web commit by HenrikBrixAndersen: ikiwiki-mass-rebuild fails to drop privileges and...
[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 Proposed patch:
6
7     --- ikiwiki-mass-rebuild.orig       2007-08-15 22:21:59.000000000 +0200
8     +++ ikiwiki-mass-rebuild    2007-10-25 13:04:10.000000000 +0200
9     @@ -22,13 +22,14 @@ sub processline {
10                 my ($uuid, $ugid) = (getpwnam($user))[2, 3];
11                 $)="$ugid $ugid";
12                 $(=$ugid;
13     -           $>=$uuid;
14                 $<=$uuid;
15     +           $>=$uuid;
16                 if ($< != $uuid || $> != $uuid || $( != $ugid || $) ne "$ugid $ugid") {
17                         die "failed to drop permissions to $user";
18                 }
19                 %ENV=();
20                 $ENV{HOME}=(getpwnam($user))[7];
21     +           $ENV{PATH}="/usr/bin:/usr/local/bin";
22                 exec("ikiwiki", "-setup", $setup, @ARGV);
23                 die "failed to run ikiwiki: $!";
24         }