Page MenuHomeFreeBSD

D40745.id123714.diff
No OneTemporary

D40745.id123714.diff

diff --git a/usr.sbin/adduser/rmuser.sh b/usr.sbin/adduser/rmuser.sh
--- a/usr.sbin/adduser/rmuser.sh
+++ b/usr.sbin/adduser/rmuser.sh
@@ -34,14 +34,14 @@
MAILSPOOL="/var/mail"
SIGKILL="-KILL"
TEMPDIRS="/tmp /var/tmp"
-THISCMD=`/usr/bin/basename $0`
+THISCMD=$(/usr/bin/basename "$0")
PWCMD="${PWCMD:-/usr/sbin/pw}"
# err msg
# Display $msg on stderr.
#
err() {
- echo 1>&2 ${THISCMD}: $*
+ echo 1>&2 "${THISCMD}": "$*"
}
# verbose
@@ -57,18 +57,18 @@
#
rm_files() {
# The argument is required
- [ -n $1 ] && login=$1 || return
+ [ -n "$1" ] && login=$1 || return
totalcount=0
for _dir in ${TEMPDIRS} ; do
filecount=0
- if [ ! -d $_dir ]; then
+ if [ ! -d "$_dir" ]; then
err "$_dir is not a valid directory."
continue
fi
verbose && echo -n "Removing files owned by ($login) in $_dir:"
- filecount=`find 2>/dev/null "$_dir" -user "$login" -delete -print |
- wc -l | sed 's/ *//'`
+ filecount=$(find 2>/dev/null "$_dir" -user "$login" -delete -print |
+ wc -l | sed 's/ *//')
verbose && echo " $filecount removed."
totalcount=$(($totalcount + $filecount))
done
@@ -81,18 +81,18 @@
#
rm_mail() {
# The argument is required
- [ -n $1 ] && login=$1 || return
+ [ -n "$1" ] && login=$1 || return
verbose && echo -n "Removing mail spool(s) for ($login):"
- if [ -f ${MAILSPOOL}/$login ]; then
+ if [ -f "${MAILSPOOL}/$login" ]; then
verbose && echo -n " ${MAILSPOOL}/$login" ||
echo -n " mailspool"
- rm ${MAILSPOOL}/$login
+ rm "${MAILSPOOL}/$login"
fi
- if [ -f ${MAILSPOOL}/.${login}.pop ]; then
+ if [ -f "${MAILSPOOL}/.${login}.pop" ]; then
verbose && echo -n " ${MAILSPOOL}/.${login}.pop" ||
echo -n " pop3"
- rm ${MAILSPOOL}/.${login}.pop
+ rm "${MAILSPOOL}/.${login}.pop"
fi
verbose && echo '.'
}
@@ -102,13 +102,13 @@
#
kill_procs() {
# The argument is required
- [ -n $1 ] && login=$1 || return
+ [ -n "$1" ] && login=$1 || return
verbose && echo -n "Terminating all processes owned by ($login):"
killcount=0
- proclist=`ps 2>/dev/null -U $login | grep -v '^\ *PID' | awk '{print $1}'`
+ proclist=$(ps 2>/dev/null -U "$login" | grep -v '^\ *PID' | awk '{print $1}')
for _pid in $proclist ; do
- kill 2>/dev/null ${SIGKILL} $_pid
+ kill 2>/dev/null ${SIGKILL} "$_pid"
killcount=$(($killcount + 1))
done
verbose && echo " ${SIGKILL} signal sent to $killcount processes."
@@ -120,13 +120,13 @@
#
rm_at_jobs() {
# The argument is required
- [ -n $1 ] && login=$1 || return
+ [ -n "$1" ] && login=$1 || return
- atjoblist=`find 2>/dev/null ${ATJOBDIR} -maxdepth 1 -user $login -print`
+ atjoblist=$(find 2>/dev/null ${ATJOBDIR} -maxdepth 1 -user "$login" -print)
jobcount=0
verbose && echo -n "Removing at(1) jobs owned by ($login):"
for _atjob in $atjoblist ; do
- rm -f $_atjob
+ rm -f "$_atjob"
jobcount=$(($jobcount + 1))
done
verbose && echo " $jobcount removed."
@@ -138,12 +138,12 @@
#
rm_crontab() {
# The argument is required
- [ -n $1 ] && login=$1 || return
+ [ -n "$1" ] && login=$1 || return
verbose && echo -n "Removing crontab for ($login):"
- if [ -f ${CRONJOBDIR}/$login ]; then
+ if [ -f "${CRONJOBDIR}/$login" ]; then
verbose && echo -n " ${CRONJOBDIR}/$login" || echo -n " crontab"
- rm -f ${CRONJOBDIR}/$login
+ rm -f "${CRONJOBDIR}/$login"
fi
verbose && echo '.'
}
@@ -155,7 +155,7 @@
verbose && echo -n "Removing IPC mechanisms"
for i in s m q; do
ipcs -$i |
- awk -v i=$i -v login=$1 '$1 == i && $5 == login { print $2 }' |
+ awk -v i=$i -v login="$1" '$1 == i && $5 == login { print $2 }' |
xargs -n 1 ipcrm -$i
done
verbose && echo '.'
@@ -166,13 +166,13 @@
# of the pw(8) command to remove a user from the system. The pw(8)
# command will remove the specified user from the user database
# and group file and remove any crontabs. His home
-# directory will be removed if it is owned by him and contains no
+# directory will be removed if it is owned by him and contains no
# files or subdirectories owned by other users. Mail spool files will
# also be removed.
#
rm_user() {
# The argument is required
- [ -n $1 ] && login=$1 || return
+ [ -n "$1" ] && login=$1 || return
verbose && echo -n "Removing user ($login)"
[ -n "$pw_rswitch" ] && {
@@ -181,7 +181,7 @@
}
! verbose && echo -n " passwd"
verbose && echo -n " from the system:"
- ${PWCMD} userdel -n $login $pw_rswitch
+ ${PWCMD} userdel -n "$login" $pw_rswitch
verbose && echo ' Done.'
}
@@ -230,18 +230,18 @@
yflag=
vflag=
-procowner=`/usr/bin/id -u`
+procowner=$(/usr/bin/id -u)
if [ "$procowner" != "0" ]; then
err 'you must be root (0) to use this utility.'
exit 1
fi
-args=`getopt 2>/dev/null yvf: $*`
+args=$(getopt 2>/dev/null yvf: "$*")
if [ "$?" != "0" ]; then
show_usage
exit 1
fi
-set -- $args
+set -- "$args"
for _switch ; do
case $_switch in
-y)
@@ -269,13 +269,13 @@
# from a file, the file must be owned by and writable only by root.
#
if [ $fflag ]; then
- _insecure=`find $ffile ! -user 0 -or -perm +0022`
+ _insecure=$(find "$ffile" ! -user 0 -or -perm +0022)
if [ -n "$_insecure" ]; then
err "file ($ffile) must be owned by and writeable only by root."
exit 1
fi
if [ -r "$ffile" ]; then
- userlist=`cat $ffile | while read _user _junk ; do
+ userlist=$(cat "$ffile" | while read _user _junk ; do
case $_user in
\#*|'')
;;
@@ -283,10 +283,10 @@
echo -n "$userlist $_user"
;;
esac
- done`
+ done)
fi
else
- while [ $1 ] ; do
+ while [ "$1" ] ; do
userlist="$userlist $1"
shift
done
@@ -315,12 +315,12 @@
# Make sure the name exists in the passwd database and that it
# does not have a uid of 0
#
- userrec=`pw 2>/dev/null usershow -n $_user`
+ userrec=$(pw 2>/dev/null usershow -n "$_user")
if [ "$?" != "0" ]; then
err "user ($_user) does not exist in the password database."
continue
fi
- _uid=`echo $userrec | awk -F: '{print $3}'`
+ _uid=$(echo "$userrec" | awk -F: '{print $3}')
if [ "$_uid" = "0" ]; then
err "user ($_user) has uid 0. You may not remove this user."
continue
@@ -332,12 +332,12 @@
if [ -z "$yflag" ]; then
echo "Matching password entry:"
echo
- echo $userrec
+ echo "$userrec"
echo
if ! prompt_yesno "Is this the entry you wish to remove? " ; then
continue
fi
- _homedir=`echo $userrec | awk -F: '{print $9}'`
+ _homedir=$(echo "$userrec" | awk -F: '{print $9}')
if prompt_yesno "Remove user's home directory ($_homedir)? "; then
pw_rswitch="-r"
fi
@@ -346,18 +346,18 @@
fi
# Disable any further attempts to log into this account
- ${PWCMD} 2>/dev/null lock $_user
+ ${PWCMD} 2>/dev/null lock "$_user"
# Remove crontab, mail spool, etc. Then obliterate the user from
# the passwd and group database.
#
! verbose && echo -n "Removing user ($_user):"
- rm_crontab $_user
- rm_at_jobs $_user
- rm_ipc $_user
- kill_procs $_user
- rm_files $_user
- rm_mail $_user
- rm_user $_user
+ rm_crontab "$_user"
+ rm_at_jobs "$_user"
+ rm_ipc "$_user"
+ kill_procs "$_user"
+ rm_files "$_user"
+ rm_mail "$_user"
+ rm_user "$_user"
! verbose && echo "."
done

File Metadata

Mime Type
text/plain
Expires
Thu, Mar 5, 5:05 PM (7 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29292475
Default Alt Text
D40745.id123714.diff (6 KB)

Event Timeline