[Midnightbsd-cvs] src [11415] U trunk/usr.sbin/adduser: add default home permissions
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Fri Jul 6 22:30:25 EDT 2018
Revision: 11415
http://svnweb.midnightbsd.org/src/?rev=11415
Author: laffer1
Date: 2018-07-06 22:30:24 -0400 (Fri, 06 Jul 2018)
Log Message:
-----------
add default home permissions
Modified Paths:
--------------
trunk/usr.sbin/adduser/Makefile
trunk/usr.sbin/adduser/adduser.8
trunk/usr.sbin/adduser/adduser.conf.5
trunk/usr.sbin/adduser/adduser.sh
Property Changed:
----------------
trunk/usr.sbin/adduser/adduser.8
trunk/usr.sbin/adduser/adduser.conf.5
trunk/usr.sbin/adduser/adduser.sh
Modified: trunk/usr.sbin/adduser/Makefile
===================================================================
--- trunk/usr.sbin/adduser/Makefile 2018-07-07 02:28:37 UTC (rev 11414)
+++ trunk/usr.sbin/adduser/Makefile 2018-07-07 02:30:24 UTC (rev 11415)
@@ -1,5 +1,5 @@
# $MidnightBSD$
-# $FreeBSD: src/usr.sbin/adduser/Makefile,v 1.19 2004/03/30 21:50:42 trhodes Exp $
+# $FreeBSD: stable/10/usr.sbin/adduser/Makefile 127644 2004-03-30 21:50:42Z trhodes $
SCRIPTS=adduser.sh rmuser.sh
MAN= adduser.conf.5 adduser.8 rmuser.8
Modified: trunk/usr.sbin/adduser/adduser.8
===================================================================
--- trunk/usr.sbin/adduser/adduser.8 2018-07-07 02:28:37 UTC (rev 11414)
+++ trunk/usr.sbin/adduser/adduser.8 2018-07-07 02:30:24 UTC (rev 11415)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1995-1996 Wolfram Schneider <wosch at FreeBSD.org>. Berlin.
.\" All rights reserved.
.\" Copyright (c) 2002-2004 Michael Telahun Makonnen <mtm at FreeBSD.org>
@@ -24,10 +25,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
-.\" $FreeBSD: src/usr.sbin/adduser/adduser.8,v 1.59.2.1 2007/10/28 21:06:34 mtm Exp $
+.\" $FreeBSD: stable/10/usr.sbin/adduser/adduser.8 240530 2012-09-15 16:24:03Z issyl0 $
.\"
-.Dd June 7, 2006
+.Dd September 15, 2012
.Dt ADDUSER 8
.Os
.Sh NAME
@@ -38,6 +38,7 @@
.Op Fl CDENShq
.Op Fl G Ar groups
.Op Fl L Ar login_class
+.Op Fl M Ar mode
.Op Fl d Ar partition
.Op Fl f Ar file
.Op Fl g Ar login_group
@@ -239,6 +240,9 @@
file can reference the internal variables of the
.Nm
script.
+.It Fl M Ar mode
+Create the home directory with permissions set to
+.Ar mode .
.It Fl N
Do not read the default configuration file.
.It Fl q
@@ -392,7 +396,7 @@
empty, its contents will be used
as a password.
This field will be ignored if the
-.Fl p
+.Fl w
option is used with a
.Cm no
or
Property changes on: trunk/usr.sbin/adduser/adduser.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/adduser/adduser.conf.5
===================================================================
--- trunk/usr.sbin/adduser/adduser.conf.5 2018-07-07 02:28:37 UTC (rev 11414)
+++ trunk/usr.sbin/adduser/adduser.conf.5 2018-07-07 02:30:24 UTC (rev 11415)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\"
.\" Copyright (c) 2004 Tom Rhodes
.\" All rights reserved.
@@ -23,8 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
-.\" $FreeBSD: src/usr.sbin/adduser/adduser.conf.5,v 1.6 2007/04/12 08:39:13 ceri Exp $
+.\" $FreeBSD: stable/10/usr.sbin/adduser/adduser.conf.5 233648 2012-03-29 05:02:12Z eadler $
.\"
.Dd April 12, 2007
.Dt ADDUSER.CONF 5
@@ -35,7 +35,7 @@
.Xr adduser 8
configuration file
.Sh DESCRIPTION
-The
+The
.Pa /etc/adduser.conf
file is automatically generated by the
.Xr adduser 8
@@ -209,6 +209,9 @@
.Nm
manual page first appeared in
.Fx 5.3 .
+.Sh AUTHORS
+This manual page was written by
+.An Tom Rhodes Aq trhodes at FreeBSD.org .
.Sh BUGS
The internal variables documented here may change without notice.
Do not rely on them.
@@ -217,6 +220,3 @@
with the
.Fl C
option instead.
-.Sh AUTHORS
-This manual page was written by
-.An Tom Rhodes Aq trhodes at FreeBSD.org .
Property changes on: trunk/usr.sbin/adduser/adduser.conf.5
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/adduser/adduser.sh
===================================================================
--- trunk/usr.sbin/adduser/adduser.sh 2018-07-07 02:28:37 UTC (rev 11414)
+++ trunk/usr.sbin/adduser/adduser.sh 2018-07-07 02:30:24 UTC (rev 11415)
@@ -24,25 +24,25 @@
#
# Email: Mike Makonnen <mtm at FreeBSD.Org>
#
-# $MidnightBSD: src/usr.sbin/adduser/adduser.sh,v 1.3 2008/04/28 04:13:27 laffer1 Exp $
-# $FreeBSD: src/usr.sbin/adduser/adduser.sh,v 1.30.2.1 2007/10/28 21:06:34 mtm Exp $
+# $FreeBSD: stable/10/usr.sbin/adduser/adduser.sh 232146 2012-02-25 07:58:59Z deischen $
+# $MidnightBSD$
#
# err msg
-# Display $msg on stderr, unless we're being quiet.
-#
+# Display $msg on stderr, unless we're being quiet.
+#
err() {
if [ -z "$quietflag" ]; then
- echo 1>&2 ${THISCMD}: ERROR: $*
+ echo 1>&2 ${THISCMD}: ERROR: $*
fi
}
# info msg
-# Display $msg on stdout, unless we're being quiet.
-#
+# Display $msg on stdout, unless we're being quiet.
+#
info() {
if [ -z "$quietflag" ]; then
- echo ${THISCMD}: INFO: $*
+ echo ${THISCMD}: INFO: $*
fi
}
@@ -51,7 +51,7 @@
# is not, output the value of the next higher uid that is available.
# If a uid is not specified, output the first available uid, as indicated
# by pw(8).
-#
+#
get_nextuid () {
_uid=$1
_nextuid=
@@ -82,6 +82,7 @@
echo " -E disable this account after creation"
echo " -G additional groups to add accounts to"
echo " -L login class of the user"
+ echo " -M file permission for home directory"
echo " -N do not read configuration file"
echo " -S a nonexistent shell is not an error"
echo " -d home directory"
@@ -163,8 +164,7 @@
# the path is invalid or it is not executable it
# will emit an informational message saying so.
#
-shell_exists()
-{
+shell_exists() {
_sh="$1"
_shellchk="${GREPCMD} '^$_sh$' ${ETCSHELLS} > /dev/null 2>&1"
@@ -191,6 +191,7 @@
echo "# NOTE: only *some* variables are saved." >> ${ADDUSERCONF}
echo "# Last Modified on `${DATECMD}`." >> ${ADDUSERCONF}
echo '' >> ${ADDUSERCONF}
+ echo "defaultHomePerm=$uhomeperm" >> ${ADDUSERCONF}
echo "defaultLgroup=$ulogingroup" >> ${ADDUSERCONF}
echo "defaultclass=$uclass" >> ${ADDUSERCONF}
echo "defaultgroups=$ugroups" >> ${ADDUSERCONF}
@@ -248,7 +249,12 @@
if [ "$uhome" = "$NOHOME" ]; then
_home='-d "$uhome"'
else
- _home='-m -d "$uhome"'
+ # Use home directory permissions if specified
+ if [ -n "$uhomeperm" ]; then
+ _home='-m -d "$uhome" -M "$uhomeperm"'
+ else
+ _home='-m -d "$uhome"'
+ fi
fi
elif [ -n "$Dflag" -a -n "$uhome" ]; then
_home='-d "$uhome"'
@@ -450,6 +456,29 @@
fi
}
+# get_homeperm
+# Reads the account's home directory permissions.
+#
+get_homeperm() {
+ uhomeperm=$defaultHomePerm
+ _input=
+ _prompt=
+
+ if [ -n "$uhomeperm" ]; then
+ _prompt="Home directory permissions [${uhomeperm}]: "
+ else
+ _prompt="Home directory permissions (Leave empty for default): "
+ fi
+ if [ -z "$fflag" ]; then
+ echo -n "$_prompt"
+ read _input
+ fi
+
+ if [ -n "$_input" ]; then
+ uhomeperm="$_input"
+ fi
+}
+
# get_uid
# Reads a numeric userid in an interactive or batch session. Automatically
# allocates one if it is not specified.
@@ -460,6 +489,7 @@
_prompt=
if [ -n "$uuid" ]; then
+ uuid=`get_nextuid $uuid`
_prompt="Uid [$uuid]: "
else
_prompt="Uid (Leave empty for default): "
@@ -602,6 +632,7 @@
get_class
get_shell
get_homedir
+ get_homeperm
get_password
get_expire_dates
ugroups="$defaultgroups"
@@ -617,7 +648,6 @@
# the user database.
#
input_interactive() {
-
_disable=
_pass=
_passconfirm=
@@ -671,6 +701,7 @@
get_class
get_shell
get_homedir
+ get_homeperm
while : ; do
echo -n "Use password-based authentication? [$_usepass]: "
@@ -781,6 +812,7 @@
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 Mode" "$uhomeperm"
printf "%-10s : %s\n" "Shell" "$ushell"
printf "%-10s : %s\n" "Locked" "$_disable"
while : ; do
@@ -825,6 +857,7 @@
ulogingroup=
uclass=
uhome=
+uhomeperm=
upass=
ushell=
udotdir=/usr/share/skel
@@ -851,9 +884,10 @@
defaultLgroup=
defaultgroups=
defaultshell="${DEFAULTSHELL}"
+defaultHomePerm=
# 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
+# measure as much as it is a useful method of reminding the user to
# 'su -' before he/she wastes time entering data that won't be saved.
#
procowner=${procowner:-`/usr/bin/id -u`}
@@ -862,7 +896,7 @@
exit 1
fi
-# Overide from our conf file
+# Override from our conf file
# Quickly go through the commandline line to see if we should read
# from our configuration file. The actual parsing of the commandline
# arguments happens after we read in our configuration file (commandline
@@ -882,7 +916,7 @@
fi
fi
-# Proccess command-line options
+# Process command-line options
#
for _switch ; do
case $_switch in
@@ -939,6 +973,10 @@
esac
shift; shift
;;
+ -M)
+ defaultHomePerm=$2
+ shift; shift
+ ;;
-N)
readconfig=
shift
Property changes on: trunk/usr.sbin/adduser/adduser.sh
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
More information about the Midnightbsd-cvs
mailing list