aboutsummaryrefslogtreecommitdiff
path: root/doc/bugs/ikiwiki-mass-rebuild_fails_to_drop_privileges_and_execute_ikiwiki.mdwn
blob: 2eaca76323c67e184c5ebb5dd76a6a8e8ec259e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
The ikiwiki-mass-rebuild utility fails to drop privileges and fails to execute ikiwiki on FreeBSD.

The solution is to set the effective UID after setting the real UID, and to set $PATH in the environment before calling exec().

> Why does the PATH need to be reset? --[[Joey]]

> > It doesn't - it needs to be set. The line with `%ENV=();` clears the environment, thus no `$PATH` is set. --[[HenrikBrixAndersen]]

> > > I guess it shouldn't clear it then. Both [[done]] --[[Joey]]

Proposed patch:

    --- ikiwiki-mass-rebuild.orig	2007-08-15 22:21:59.000000000 +0200
    +++ ikiwiki-mass-rebuild	2007-10-25 13:04:10.000000000 +0200
    @@ -22,13 +22,14 @@ sub processline {
     		my ($uuid, $ugid) = (getpwnam($user))[2, 3];
     		$)="$ugid $ugid";
     		$(=$ugid;
    -		$>=$uuid;
     		$<=$uuid;
    +		$>=$uuid;
     		if ($< != $uuid || $> != $uuid || $( != $ugid || $) ne "$ugid $ugid") {
     			die "failed to drop permissions to $user";
     		}
     		%ENV=();
     		$ENV{HOME}=(getpwnam($user))[7];
    +		$ENV{PATH}="/usr/bin:/usr/local/bin";
     		exec("ikiwiki", "-setup", $setup, @ARGV);
     		die "failed to run ikiwiki: $!";
     	}