9 if (! getpwnam("$user")) {
10 print STDERR "warning: user $user does not exist\n";
14 print STDERR "warning: $setup does not exist, skipping\n";
17 print "Processing $setup as user $user ...\n";
18 # su is not used because it passes arguments through the shell,
19 # which is not safe for untrusted setup file names.
20 defined(my $pid = fork) or die "Can’t fork: $!";
22 my ($uuid, $ugid) = (getpwnam($user))[2, 3];
27 if ($< != $uuid || $> != $uuid || $( != $ugid || $) ne "$ugid $ugid") {
28 die "failed to drop permissions to $user";
31 $ENV{HOME}=(getpwnam($user))[7];
32 exec("ikiwiki", "-setup", $setup, @ARGV);
33 die "failed to run ikiwiki: $!";
37 print STDERR "Processing $setup as user $user failed with code $?\n";
46 open ($list, "<$file") || die "$file: $!";
51 next if /^#/ || ! length;
53 if (/^([^\s]+)\s+([^\s]+)$/) {
56 if (defined $forceuser && $forceuser ne $user) {
57 print STDERR "warning: in $file line $., attempt to set user to $user, but user forced to $forceuser. Skipping\n";
59 processline($user, $setup);
61 elsif (/^([^\s]+)$/) {
63 my $home=(getpwnam($user))[7];
64 if (defined $home && -d $home) {
65 my $dotfile="$home/.ikiwiki/wikilist";
67 processlist($dotfile, $user);
75 my $wikilist="/etc/ikiwiki/wikilist";
78 processlist($wikilist);