Bug#1500: adduser makes a .bash_profile in the invoking user's directory
I reported that adduser creates a .bash_profile file in the invoking
user's current directory. On examining the code, it seems that if
/etc/skel contains a .login or a .profile it will write those too.
Below is a patch that I believe will fix the problem. It also adds a
new feature: after creating a new user, adduser will run
/usr/local/sbin/adduser.local if it exists, passing as arguments the
new username, its uid and its gid.
Ian.
--- /usr/sbin/adduser Mon Jul 10 02:10:53 1995
+++ adduser Thu Sep 28 14:59:59 1995
@@ -671,14 +671,14 @@
$this_file = $home_dir . "/" . $file;
if (-f $this_file) {
open (FILE, "$this_file") || die "open: $!";
- open (NEWFILE, ">$file.new") || die "open: $!";
+ open (NEWFILE, ">$this_file.new") || die "open: $!";
while ($line = <FILE>) {
$line =~ s/umask 0([267])\1/umask 00$1/;
print NEWFILE $line;
}
close FILE;
close NEWFILE;
- rename ("$file.new", "$file") || die "rename: $!";
+ rename ("$this_file.new", "$this_file") || die "rename: $!";
}
}
}
@@ -719,6 +719,11 @@
}
print "done.\n";
&clean_up();
+ if (-f "/usr/local/sbin/adduser.local") {
+ exec("/usr/local/sbin/adduser.local",
+ $new_name, $new_uid, $new_gid);
+ die "exec adduser.local: $!";
+ }
exit 0;
}
Reply to: