Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Dec 2003 15:17:02 -0600 (CST)
From:      "SIUE non-NIS acct." <unix@snow.cs.siue.edu>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/60635: Enhanced adduser script allowing different homedir create permissions.
Message-ID:  <200312272117.hBRLH20x099462@snow.cs.siue.edu>
Resent-Message-ID: <200312272130.hBRLUGZW073930@freefall.freebsd.org>

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

>Number:         60635
>Category:       bin
>Synopsis:       Enhanced adduser script allowing different homedir create permissions.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sat Dec 27 13:30:16 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     William Michael Grim
>Release:        FreeBSD 5.1-RELEASE i386
>Organization:
Unix Network Administrator, CS Dept., SIUE
>Environment:
System: FreeBSD snow.cs.siue.edu 5.1-RELEASE FreeBSD 5.1-RELEASE #1: Fri Oct 10 12:06:11 CDT 2003 root@snow.cs.siue.edu:/usr/obj/usr/src/sys/SNOW i386


	Dual Xeon 1.8GHz
	FreeBSD 5.1-RELEASE
>Description:
	Before, when using adduser, I became frustrated with the fact that
	home directories were created with mode 0755 when I wanted 0751.  I
	kept forgetting to set permissions and decided to fix adduser to do
	this for me.  I figured it could help others as well.
>How-To-Repeat:
	Run the current adduser utility and then view the permissions to the
	newly created home directory.  Currently, they're 0755.
>Fix:

	You could either let users write their own script in addition to
	adduser so that it changes the permissions after adding a user, or
	this patch could be applied, letting a user choose home directory
	permissions on-the-fly (in case they're forgetful like me).

	Patches for adduser.sh and adduser.8 are included here.

--- adduser.sh.diff begins here ---
--- adduser.sh	Sat Dec 27 00:43:54 2003
+++ /usr/src/usr.sbin/adduser/adduser.sh	Sun Mar 23 17:06:44 2003
@@ -82,7 +82,6 @@
 	echo "  -L		login class of the user"
 	echo "  -N		do not read configuration file"
 	echo "  -d		home directory"
-	echo "  -o		home directory permissions (octal)"
 	echo "  -f		file from which input will be received"
 	echo "  -g		default login group"
 	echo "  -h		display this usage message"
@@ -152,7 +151,6 @@
 	echo "defaultgroups=$ugroups"	>> ${ADDUSERCONF}
 	echo "passwdtype=$passwdtype" 	>> ${ADDUSERCONF}
 	echo "homeprefix=$homeprefix" 	>> ${ADDUSERCONF}
-	echo "mode=$mode"		>> ${ADDUSERCONF}
 	echo "defaultshell=$ushell"	>> ${ADDUSERCONF}
 	echo "udotdir=$udotdir"		>> ${ADDUSERCONF}
 	echo "msgfile=$msgfile"		>> ${ADDUSERCONF}
@@ -271,9 +269,6 @@
 			info "Sent welcome message to ($username)."
 		}
 	fi
-
-	chmod $mode "$uhome";
-	info "Set permissions of ($uhome) to $mode.";
 }
 
 # get_user
@@ -387,21 +382,6 @@
 	fi
 }
 
-# get_mode
-#	Reads an octal number (permissions) in an interactive session or batch
-#	session.  Sets the user's new home directory to these permissions.
-#
-get_mode() {
-	_input=
-
-	echo -n "Home directory permissions [$mode]: "
-	read _input
-
-	if [ -n "$_input" ]; then
-		mode=$_input
-	fi
-}
-
 # get_uid
 #	Reads a numeric userid in an interactive or batch session. Automatically
 #	allocates one if it is not specified.
@@ -625,7 +605,6 @@
 	get_class
 	get_shell
 	get_homedir
-	get_mode
 
 	while : ; do
 		echo -n "Use password-based authentication? [$_usepass]: "
@@ -736,7 +715,6 @@
 	printf "%-10s : %s\n" "Class" "$uclass"
 	printf "%-10s : %s %s\n" "Groups" "${ulogingroup:-$username}" "$ugroups"
 	printf "%-10s : %s\n" "Home" "$uhome"
-	printf "%-10s : %s\n" "Home Perms" "$mode"
 	printf "%-10s : %s\n" "Shell" "$ushell"
 	printf "%-10s : %s\n" "Locked" "$_disable"
 	while : ; do
@@ -802,7 +780,6 @@
 defaultLgroup=
 defaultgoups=
 defaultshell="${DEFAULTSHELL}"
-mode=0751
 
 # Make sure the user running this program is root. This isn't a security
 # measure as much as it is a usefull method of reminding the user to
@@ -874,10 +851,6 @@
 	-d)
 		homeprefix="$2"
 		shift; shift
-		;;
-	-o)
-		mode="$2"
-		shift; shift;
 		;;
 	-m)
 		case "$2" in
--- adduser.sh.diff ends here ---

--- adduser.8.diff begins here ---
--- adduser.8	Sat Dec 27 00:43:54 2003
+++ /usr/src/usr.sbin/adduser/adduser.8	Thu Mar 20 10:36:03 2003
@@ -45,7 +45,6 @@
 .Op Fl s Ar shell
 .Op Fl u Ar uid_start
 .Op Fl w Ar type
-.Op Fl o Ar mode
 .Sh DESCRIPTION
 The
 .Nm
@@ -114,11 +113,6 @@
 You may choose an empty password, disable the password, use a
 randomly generated password or specify your own plaintext password,
 which will be encrypted before being stored in the user database.
-.It mode
-You may only use absolute or symbolic modes for home directory
-permissions; see
-.Xr chmod 1
-for more information.
 .El
 .Sh UNIQUE GROUPS
 Perhaps you are missing what
@@ -282,10 +276,6 @@
 .Va randompass
 variable.
 .El
-.It Fl o Ar mode
-Set the default permissions of a new home directory using modes
-specified in
-.Xr chmod 1 .
 .El
 .Sh FORMAT
 When the
--- adduser.8.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



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