SIGKILL="-KILL"
TEMPDIRS="/tmp /var/tmp"
THISCMD=`/usr/bin/basename $0`
+PWCMD="${PWCMD:-/usr/sbin/pw}"
# err msg
# Display $msg on stderr.
rm_files() {
# The argument is required
[ -n $1 ] && login=$1 || return
-
+
totalcount=0
for _dir in ${TEMPDIRS} ; do
filecount=0
continue
fi
verbose && echo -n "Removing files owned by ($login) in $_dir:"
- filecount=`find 2>/dev/null "$_dir" -user "$login" -delete -print | \
+ filecount=`find 2>/dev/null "$_dir" -user "$login" -delete -print |
wc -l | sed 's/ *//'`
verbose && echo " $filecount removed."
totalcount=$(($totalcount + $filecount))
verbose && echo -n "Removing mail spool(s) for ($login):"
if [ -f ${MAILSPOOL}/$login ]; then
- verbose && echo -n " ${MAILSPOOL}/$login" || \
+ verbose && echo -n " ${MAILSPOOL}/$login" ||
echo -n " mailspool"
rm ${MAILSPOOL}/$login
fi
- if [ -f ${MAILSPOOL}/${login}.pop ]; then
- verbose && echo -n " ${MAILSPOOL}/${login}.pop" || \
+ 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 '.'
}
verbose && echo '.'
}
+# rm_ipc login
+# Remove all IPC mechanisms which are owned by $login.
+#
+rm_ipc() {
+ 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 }' |
+ xargs -n 1 ipcrm -$i
+ done
+ verbose && echo '.'
+}
+
# rm_user login
# Remove user $login from the system. This subroutine makes use
# of the pw(8) command to remove a user from the system. The pw(8)
}
! verbose && echo -n " passwd"
verbose && echo -n " from the system:"
- pw userdel -n $login $pw_rswitch
+ ${PWCMD} userdel -n $login $pw_rswitch
verbose && echo ' Done.'
}
show_usage
exit 1
else
- echo -n "Please enter one or more user name's: "
+ echo -n "Please enter one or more usernames: "
read userlist
fi
fi
fi
# Disable any further attempts to log into this account
- pw 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