Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 May 2008 22:53:11 GMT
From:      Tom Smith <freebsd@thomassmith.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   misc/124052: adduser throws errors when -f input file includes comments
Message-ID:  <200805272253.m4RMrBI5035031@www.freebsd.org>
Resent-Message-ID: <200805272300.m4RN08eE060862@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         124052
>Category:       misc
>Synopsis:       adduser throws errors when -f input file includes comments
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 27 23:00:08 UTC 2008
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200805272253.m4RMrBI5035031>