Merge tag 'upstream/1.8.5p2'
[debian/sudo] / debian / sudo.postinst
1 #!/bin/sh
2
3 set -e
4
5 # remove old link
6
7 if [ -L /etc/alternatives/sudo ]; then
8         rm /etc/alternatives/sudo
9 fi
10
11 # complain if no sudoers file is present
12 if [ ! -f /etc/sudoers ];then
13         echo "WARNING:  /etc/sudoers not present!";
14 fi
15
16 # handle state directory transition from /var/run/sudo to /var/lib/sudo,
17 # moving any existing content over to avoid re-lecturing existing users
18 if [ -d "/var/run/sudo" ];then
19     mkdir -p /var/lib/sudo
20     (cd /var/run/sudo ; tar cf - .) | (cd /var/lib/sudo ; tar xf -)
21     rm -rf /var/run/sudo
22 fi
23
24 # make sure sudoers has the correct permissions and owner/group
25 chown root:root /etc/sudoers
26 chmod 440 /etc/sudoers
27
28 update-rc.d -f sudo remove >/dev/null 2>&1
29
30 update-rc.d sudo start 75 2 3 4 5 . >/dev/null
31
32 # if we've gotten this far .. remove the saved, unchanged old sudoers file
33 rm -f /etc/sudoers.pre-conffile
34
35 # make sure we have a sudo group
36
37 [ -n "`getent group sudo`" ] && exit 0   # we're finished if there is a group sudo:
38
39 # start search with gid 27
40 gid="27"
41 while [ -n "`getent group $gid | cut -d: -f3`" ];do
42         gid=`expr $gid + 1`
43 done
44
45
46 if [ "$gid" -ne "27" ];then
47         echo "On Debian we normally use gid 27 for 'sudo'."
48         gname="`getent group 27 | cut -d: -f1`"
49         echo "However, on your system gid 27 is group '$gname'."
50         echo ""
51         echo "Would you like me to stop configuring sudo so that you can change this?"; 
52         while true;do
53                 echo -n "(Enter 'yes' to stop, enter to continue): "
54                 read ans
55                 [ "$ans" = "" ] && break
56                 if [ "$ans" = "yes" -o "$ans" = "YES" ];then
57                         echo "'dpkg --pending --configure' will restart the configuration."
58                         exit 1;
59                 fi
60                 echo "Please enter exactly 'yes' to stop, or press the enter key to continue without stopping"
61         done
62 fi
63
64 echo "Creating group 'sudo' with gid = $gid";
65 groupadd -g $gid sudo
66
67 echo ""
68
69 #DEBHELPER#