From nobody@FreeBSD.org  Tue May 27 22:54:49 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0FA57106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 27 May 2008 22:54:49 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 0310B8FC38
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 27 May 2008 22:54:49 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m4RMrBrl035032
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 27 May 2008 22:53:11 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m4RMrBI5035031;
	Tue, 27 May 2008 22:53:11 GMT
	(envelope-from nobody)
Message-Id: <200805272253.m4RMrBI5035031@www.freebsd.org>
Date: Tue, 27 May 2008 22:53:11 GMT
From: Tom Smith <freebsd@thomassmith.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: adduser throws errors when -f input file includes comments
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         124052
>Category:       bin
>Synopsis:       [patch] adduser(8) throws errors when -f input file includes comments
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 27 23:00:08 UTC 2008
>Closed-Date:    Fri Nov 02 22:22:36 UTC 2012
>Last-Modified:  Fri Nov 02 22:22:36 UTC 2012
>Originator:     Tom Smith
>Release:        6.1-RELEASE
>Organization:
>Environment:
FreeBSD host.my.com 6.1-RELEASE FreeBSD 6.1-RELEASE #0: Sun May  7 04:32:43 UTC 2006     root@opus.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
man adduser indicates that, when using the -f option to input a list of users to add, any line in the file starting with a # represents a comment. However, the adduser script interprets such lines as actual users to add and throws a variety of errors depending on the content of the commented line.
>How-To-Repeat:
Create an adduser input file with a comment in it:

# A comment
mname::::::My Name::sh:

And execute adduser passing the file name in for the -f argument:

adduser -w random -f myfile

Observe errors having to do with adduser trying to interpret the commented line.
>Fix:
In the adduser shell script, input_from_file() function, the case statement is incorrect. It checks if the line is commented, but then ends the case statement and goes on to get variables from the line and attempt the add the user with the resulting information. The fix is to extend the case statement so that it only tries to interpret the line and add the user if the line does not begin with a #. Patch file attached.

Patch attached with submission follows:

--- adduser.bak Mon May 26 22:31:12 2008
+++ /usr/sbin/adduser   Mon May 26 22:40:09 2008
@@ -592,19 +592,20 @@
                case "$fileline" in
                \#*|'')
                        ;;
-               esac
-
-               get_user || continue
-               get_gecos
-               get_uid
-               get_logingroup
-               get_class
-               get_shell
-               get_homedir
-               get_password
-               get_expire_dates
+               *)
+                       get_user || continue
+                       get_gecos
+                       get_uid
+                       get_logingroup
+                       get_class
+                       get_shell
+                       get_homedir
+                       get_password
+                       get_expire_dates
 
-               add_user
+                       add_user
+                       ;;
+               esac
        done
 }


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: jh 
State-Changed-When: Tue Feb 9 17:08:28 UTC 2010 
State-Changed-Why:  
This has been fixed by r168651. The fix has not been MFCd to stable/6. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=124052 
State-Changed-From-To: patched->closed 
State-Changed-By: eadler 
State-Changed-When: Fri Nov 2 22:22:35 UTC 2012 
State-Changed-Why:  
MFCed/fixed by now or it will never be MFCed 

http://www.freebsd.org/cgi/query-pr.cgi?pr=124052 
>Unformatted:
