5 sub supplemental_groups
{
9 while (my @fields=getgrent()) {
10 if (grep { $_ eq $user } split(' ', $fields[3])) {
11 push @list, $fields[2];
19 my %a=map { $_ => 1 } split(' ', shift());
20 my %b=map { $_ => 1 } split(' ', shift());
22 foreach my $i (keys %b) {
23 if (! exists $a{$i}) {
27 foreach my $i (keys %a) {
28 if (! exists $b{$i}) {
39 if (! getpwnam("$user")) {
40 print STDERR
"warning: user $user does not exist\n";
44 print STDERR
"warning: $setup does not exist, skipping\n";
47 print "Processing $setup as user $user ...\n";
48 # su is not used because it passes arguments through the shell,
49 # which is not safe for untrusted setup file names.
50 defined(my $pid = fork) or die "Can’t fork: $!";
52 my ($uuid, $ugid) = (getpwnam($user))[2, 3];
53 my $grouplist=join(" ", $ugid, sort {$a <=> $b} $ugid, supplemental_groups
($user));
54 if (! samelists
(($)=$grouplist), $grouplist)) {
55 die "failed to set egid $grouplist (got back $))";
60 if ($< != $uuid || $> != $uuid || $( != $ugid) {
61 die "failed to drop permissions to $user";
65 HOME
=> (getpwnam($user))[7],
67 exec("ikiwiki", "-setup", $setup, @ARGV);
68 die "failed to run ikiwiki: $!";
72 print STDERR
"Processing $setup as user $user failed with code $?\n";
81 open ($list, "<$file") || die "$file: $!";
86 next if /^#/ || ! length;
88 if (/^([^\s]+)\s+([^\s]+)$/) {
91 if (defined $forceuser && $forceuser ne $user) {
92 print STDERR
"warning: in $file line $., attempt to set user to $user, but user forced to $forceuser. Skipping\n";
94 processline
($user, $setup);
96 elsif (/^([^\s]+)$/) {
98 my $home=(getpwnam($user))[7];
99 if (defined $home && -d
$home) {
100 my $dotfile="$home/.ikiwiki/wikilist";
102 processlist
($dotfile, $user);
110 my $wikilist="/etc/ikiwiki/wikilist";
113 processlist
($wikilist);