]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/ikiwiki-mass-rebuild_fails_to_drop_privileges_and_execute_ikiwiki.mdwn
web commit by http://svend.myopenid.com/: Submit bug.
[ikiwiki.git] / doc / bugs / ikiwiki-mass-rebuild_fails_to_drop_privileges_and_execute_ikiwiki.mdwn
1 The ikiwiki-mass-rebuild utility fails to drop privileges and fails to execute ikiwiki on FreeBSD.
2
3 The solution is to set the effective UID after setting the real UID, and to set $PATH in the environment before calling exec().
4
5 > Why does the PATH need to be reset? --[[Joey]]
6
7 > > It doesn't - it needs to be set. The line with `%ENV=();` clears the environment, thus no `$PATH` is set. --[[HenrikBrixAndersen]]
8
9 > > > I guess it shouldn't clear it then. Both [[done]] --[[Joey]]
10
11 Proposed patch:
12
13     --- ikiwiki-mass-rebuild.orig       2007-08-15 22:21:59.000000000 +0200
14     +++ ikiwiki-mass-rebuild    2007-10-25 13:04:10.000000000 +0200
15     @@ -22,13 +22,14 @@ sub processline {
16                 my ($uuid, $ugid) = (getpwnam($user))[2, 3];
17                 $)="$ugid $ugid";
18                 $(=$ugid;
19     -           $>=$uuid;
20                 $<=$uuid;
21     +           $>=$uuid;
22                 if ($< != $uuid || $> != $uuid || $( != $ugid || $) ne "$ugid $ugid") {
23                         die "failed to drop permissions to $user";
24                 }
25                 %ENV=();
26                 $ENV{HOME}=(getpwnam($user))[7];
27     +           $ENV{PATH}="/usr/bin:/usr/local/bin";
28                 exec("ikiwiki", "-setup", $setup, @ARGV);
29                 die "failed to run ikiwiki: $!";
30         }