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";
32 HOME => (getpwnam($user))[7],
34 exec("ikiwiki", "-setup", $setup, @ARGV);
35 die "failed to run ikiwiki: $!";
39 print STDERR "Processing $setup as user $user failed with code $?\n";
48 open ($list, "<$file") || die "$file: $!";
53 next if /^#/ || ! length;
55 if (/^([^\s]+)\s+([^\s]+)$/) {
58 if (defined $forceuser && $forceuser ne $user) {
59 print STDERR "warning: in $file line $., attempt to set user to $user, but user forced to $forceuser. Skipping\n";
61 processline($user, $setup);
63 elsif (/^([^\s]+)$/) {
65 my $home=(getpwnam($user))[7];
66 if (defined $home && -d $home) {
67 my $dotfile="$home/.ikiwiki/wikilist";
69 processlist($dotfile, $user);
77 my $wikilist="/etc/ikiwiki/wikilist";
80 processlist($wikilist);