diff options
| -rw-r--r-- | Changelog | 2 | ||||
| -rwxr-xr-x | lacme | 7 | 
2 files changed, 9 insertions, 0 deletions
| @@ -28,6 +28,8 @@ lacme (0.7.1) upstream;     useful for OCSP Must-Staple.   + client: use "lacme-client/$VERSION" as User-Agent header.   + Consolidate error messages for consistency. + + Sanitize environment when spawning the lacme client, webserver and +   accountd.   - lacme: delay webserver socket shutdown to after the process has     terminated.   - documentation: suggest to generate private key material with @@ -234,6 +234,13 @@ sub drop_privileges($$$) {          die "Couldn't setuid/seteuid" unless $< == $uid and $> == $uid; # safety check      } +    # sanitize environment +    my $term = $ENV{TERM}; +    my @ent = getpwuid($>) or die "getpwuid($>): $!"; +    %ENV = ( USER => $ent[0], LOGNAME => $ent[0], HOME => $ent[7], SHELL => $ent[8] ); +    $ENV{PATH} = $> == 0 ? "/usr/sbin:/usr/bin:/sbin:/bin" : "/usr/bin:/bin"; +    $ENV{TERM} = $term if defined $term; # preserve $TERM +      chdir $dir or die "chdir($dir): $!";  } | 
