]> git.gag.com Git - debian/sudo/blob - debian/postinst
Imported Debian patch 1.6.9p15-1
[debian/sudo] / debian / postinst
1 #!/usr/bin/perl
2
3 # remove old link
4
5 unlink ("/etc/alternatives/sudo") if ( -l "/etc/alternatives/sudo");
6
7 # make sure we have a sudoers file
8 if ( ! -f "/etc/sudoers") {
9
10         print "No /etc/sudoers found... creating one for you.\n";
11
12         open (SUDOERS, "> /etc/sudoers");
13         print SUDOERS "# /etc/sudoers\n",
14           "#\n",
15           "# This file MUST be edited with the 'visudo' command as root.\n",
16           "#\n",
17           "# See the man page for details on how to write a sudoers file.\n",
18           "#\n\nDefaults\tenv_reset\n\n",
19           "# Uncomment to allow members of group sudo to not need a password\n",
20           "# %sudo ALL=NOPASSWD: ALL\n\n",
21           "# Host alias specification\n\n",
22           "# User alias specification\n\n",
23           "# Cmnd alias specification\n\n",
24           "# User privilege specification\nroot\tALL=(ALL) ALL\n";
25         close SUDOERS;
26
27 }
28
29 # make sure sudoers has the correct permissions and owner/group
30 system ('chown root:root /etc/sudoers');
31 system ('chmod 440 /etc/sudoers');
32
33 # must do a remove first to un-do the "bad" links created by previous version
34 system ('update-rc.d -f sudo remove >/dev/null 2>&1');
35
36 system ('update-rc.d sudo start 75 S . >/dev/null');
37
38 # make sure we have a sudo group
39
40 exit 0 if getgrnam("sudo"); # we're finished if there is a group sudo
41
42 $gid = 27;                 # start searcg with gid 27
43 setgrent;
44 while (getgrgid($gid)) {
45         ++$gid;
46 }
47 endgrent;
48
49 if ($gid != 27) {
50         print "On Debian we normally use gid 27 for 'sudo'.\n";
51         $gname = getgrgid(27);
52         print "However, on your system gid 27 is group '$gname'.\n\n";
53         print "Would you like me to stop configuring sudo so that you can change this? [n] "; 
54         $ans = <STDIN>;
55         if ($ans =~ m/^[yY].*/) {
56                 print "'dpkg --pending --configure' will restart the configuration.\n\n\n";
57                 exit 1;
58         }
59 }
60
61 print "Creating group 'sudo' with gid = $gid\n";
62 system("groupadd -g $gid sudo");
63
64 print "";