]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Wrapper.pm
* Drop real uid/gid in the suid wrapper, thus allowing commits to remote
[git.ikiwiki.info.git] / IkiWiki / Wrapper.pm
index ee547cefb9e7945ea12015a3197a2a79737e3fa7..deba58d2893e819d51968f9889c99f2807cd26e0 100644 (file)
@@ -51,6 +51,7 @@ EOF
        my $configstring=Data::Dumper->Dump([\%config], ['*config']);
        $configstring=~s/\\/\\\\/g;
        $configstring=~s/"/\\"/g;
+       $configstring=~s/\n/\\\n/g;
        
        open(OUT, ">$wrapper.c") || error("failed to write $wrapper.c: $!");;
        print OUT <<"EOF";
@@ -74,6 +75,11 @@ $envsave
        newenviron[i]=NULL;
        environ=newenviron;
 
+       if (setregid(getegid(), -1) != 0 || setreuid(geteuid(), -1) != 0) {
+               perror("failed to drop real uid/gid");
+               exit(1);
+       }
+
        execl("$this", "$this", NULL);
        perror("failed to run $this");
        exit(1);