5 sub supplemental_groups
{
9 while (my @fields=getgrent()) {
10 if (grep { $_ eq $user } split(' ', $fields[3])) {
11 push @list, $fields[2];
22 if (! getpwnam("$user")) {
23 print STDERR
"warning: user $user does not exist\n";
27 print STDERR
"warning: $setup does not exist, skipping\n";
30 print "Processing $setup as user $user ...\n";
31 # su is not used because it passes arguments through the shell,
32 # which is not safe for untrusted setup file names.
33 defined(my $pid = fork) or die "Can’t fork: $!";
35 my ($uuid, $ugid) = (getpwnam($user))[2, 3];
36 my $grouplist=join(" ", $ugid, $ugid, supplemental_groups
($user));
39 die "failed to set egid $grouplist: $!";
44 if ($< != $uuid || $> != $uuid || $( != $ugid) {
45 die "failed to drop permissions to $user";
49 HOME
=> (getpwnam($user))[7],
51 exec("ikiwiki", "-setup", $setup, @ARGV);
52 die "failed to run ikiwiki: $!";
56 print STDERR
"Processing $setup as user $user failed with code $?\n";
65 open ($list, "<$file") || die "$file: $!";
70 next if /^#/ || ! length;
72 if (/^([^\s]+)\s+([^\s]+)$/) {
75 if (defined $forceuser && $forceuser ne $user) {
76 print STDERR
"warning: in $file line $., attempt to set user to $user, but user forced to $forceuser. Skipping\n";
78 processline
($user, $setup);
80 elsif (/^([^\s]+)$/) {
82 my $home=(getpwnam($user))[7];
83 if (defined $home && -d
$home) {
84 my $dotfile="$home/.ikiwiki/wikilist";
86 processlist
($dotfile, $user);
94 my $wikilist="/etc/ikiwiki/wikilist";
97 processlist
($wikilist);