2 # Add a user to the system wide wikilist.
3 # This script can safely be made suid.
8 my $remove=(@ARGV && $ARGV[0] eq '-r');
10 my $username=getpwuid($REAL_USER_ID);
11 if (! defined $username || ! length $username) {
12 die "unable to determine user name for UID $REAL_USER_ID\n";
15 my $wikilist="/etc/ikiwiki/wikilist";
17 die "$wikilist does not exist\n";
23 open (my $list, "<$wikilist") || die "read $wikilist: $!";
26 if (/^\s*([^\s]+)\s*$/) {
28 if ($user eq $username) {
42 if (! $seen && ! $remove) {
43 push @lines, $username;
47 close $list || die "ikiwiki-update-wikilist: error reading $list: $!\n";
48 open ($list, ">$wikilist") || die "ikiwiki-update-wikilist: error writing $wikilist: $!\n";
53 print "ikiwiki-update-wikilist: removed user $username from $wikilist\n";
56 print "ikiwiki-update-wikilist: added user $username to $wikilist\n";
58 close $list || die "ikiwiki-update-wikilist: error writing $wikilist: $!\n";
61 print "ikiwiki-update-wikilist: no changes need to be made\n";