annotate previous-work/more_control_helpers/bin/uninstall_package @ 20:c75924bd38e3
fix security hole relating to path for package user.
author |
Robert McIntyre <rlm@mit.edu> |
date |
Thu, 10 Jan 2013 04:25:17 +0000 |
parents |
d6bef198ae71 |
children |
|
rev |
line source |
rlm@1
|
1 #!/bin/sh
|
rlm@1
|
2 # Copyright (c) 2004 Matthias S. Benkmann <article AT winterdrache DOT de>
|
rlm@1
|
3 # You may do everything with this code except misrepresent its origin.
|
rlm@1
|
4 # PROVIDED `AS IS' WITH ABSOLUTELY NO WARRANTY OF ANY KIND!
|
rlm@1
|
5
|
rlm@1
|
6 if [ $# != 1 -o "$1" = '--help' ]; then
|
rlm@1
|
7 echo 1>&2 'USAGE: uninstall_package <package-name>'
|
rlm@1
|
8 exit 1
|
rlm@1
|
9 fi
|
rlm@1
|
10 echo
|
rlm@1
|
11 echo '# If package '"$1"' has setuid root binaries, then you need to be'
|
rlm@1
|
12 echo '# root for the following to work.'
|
rlm@1
|
13 echo '# Otherwise, you can do it as user '"$1"'.'
|
rlm@1
|
14 echo
|
rlm@1
|
15 echo 'forall_direntries_from "'"$1"'" -depth \( -type d -exec echo rmdir {} \; \) -or \( -not -type d -exec echo rm -f {} \; \)'
|
rlm@1
|
16 echo
|
rlm@1
|
17 echo '# After successfully deleting all files, you may want to remove the'
|
rlm@1
|
18 echo '# package user '"$1"'. But remember that if you do that you need to'
|
rlm@1
|
19 echo '# remove or change ownership of '"$(eval echo ~"$1")"'. Unless you are'
|
rlm@1
|
20 echo '# certain that you will never re-install '"$1"', it is probably better to'
|
rlm@1
|
21 echo '# just keep the package user '"$1"' and its home directory around.'
|
rlm@1
|
22 echo '# Anyway, if you want to delete the account, you can use the following'
|
rlm@1
|
23 echo '# command:'
|
rlm@1
|
24 echo
|
rlm@1
|
25 echo 'userdel "'"$1"'"'
|
rlm@1
|
26 echo
|
rlm@1
|
27 echo '# If your /etc/login.defs has USERGROUPS_ENAB set to "yes" (the default),'
|
rlm@1
|
28 echo '# then userdel will automatically delete the package user'"'"'s group if'
|
rlm@1
|
29 echo '# its name is identical to the user name. Otherwise, if you want to delete'
|
rlm@1
|
30 echo '# the package user'"'"'s group, you will need to use the `groupdel'"'"' command.'
|
rlm@1
|
31 echo
|