5 unlink ("/etc/alternatives/sudo") if ( -l "/etc/alternatives/sudo");
7 # make sure we have a sudoers file
8 if ( ! -f "/etc/sudoers") {
10 print "No /etc/sudoers found... creating one for you.\n";
12 open (SUDOERS, "> /etc/sudoers");
13 print SUDOERS "# /etc/sudoers\n",
15 "# This file MUST be edited with the 'visudo' command as root.\n",
17 "# See the man page for details on how to write a sudoers file.\n",
18 "#\n\n# Host alias specification\n\n",
19 "# User alias specification\n\n",
20 "# Cmnd alias specification\n\n",
21 "# User privilege specification\nroot\tALL=(ALL) ALL\n";
26 # make sure sudoers has the correct permissions and owner/group
27 system ('chown root:root /etc/sudoers');
28 system ('chmod 440 /etc/sudoers');
30 # must do a remove first to un-do the "bad" links created by previous version
31 system ('update-rc.d -f sudo remove >/dev/null 2>&1');
33 system ('update-rc.d sudo start 75 S . >/dev/null');
35 # make sure we have a sudo group
37 exit 0 if getgrnam("sudo"); # we're finished if there is a group sudo
39 $gid = 27; # start searcg with gid 27
41 while (getgrgid($gid)) {
47 print "On Debian we normally use gid 27 for 'sudo'.\n";
48 $gname = getgrgid(27);
49 print "However, on your system gid 27 is group '$gname'.\n\n";
50 print "Would you like me to stop configuring sudo so that you can change this? [n] ";
52 if ($ans =~ m/^[yY].*/) {
53 print "'dpkg --pending --configure' will restart the configuration.\n\n\n";
58 print "Creating group 'sudo' with gid = $gid\n";
59 system("groupadd -g $gid sudo");