]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Wrapper.pm
oops..
[ikiwiki.git] / IkiWiki / Wrapper.pm
index d723684463dda687e21be6d18341ce0c6ac0d1d5..0f64a59f4c039ab24872457cc3529c364deee172 100644 (file)
@@ -4,6 +4,7 @@ use warnings;
 use strict;
 use Cwd q{abs_path};
 use Data::Dumper;
 use strict;
 use Cwd q{abs_path};
 use Data::Dumper;
+use IkiWiki;
 
 package IkiWiki;
 
 
 package IkiWiki;
 
@@ -35,7 +36,7 @@ sub gen_wrapper () { #{{{
                asprintf(&newenviron[i++], "%s=%s", "$var", s);
 EOF
        }
                asprintf(&newenviron[i++], "%s=%s", "$var", s);
 EOF
        }
-       if ($config{svn} && $config{notify}) {
+       if ($config{rcs} eq "svn" && $config{notify}) {
                # Support running directly as hooks/post-commit by passing
                # $2 in REV in the environment.
                $envsave.=<<"EOF"
                # Support running directly as hooks/post-commit by passing
                # $2 in REV in the environment.
                $envsave.=<<"EOF"
@@ -50,12 +51,14 @@ EOF
        my $configstring=Data::Dumper->Dump([\%config], ['*config']);
        $configstring=~s/\\/\\\\/g;
        $configstring=~s/"/\\"/g;
        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";
 /* A wrapper for ikiwiki, can be safely made suid. */
 #define _GNU_SOURCE
 #include <stdio.h>
        
        open(OUT, ">$wrapper.c") || error("failed to write $wrapper.c: $!");;
        print OUT <<"EOF";
 /* A wrapper for ikiwiki, can be safely made suid. */
 #define _GNU_SOURCE
 #include <stdio.h>
+#include <sys/types.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
@@ -73,6 +76,11 @@ $envsave
        newenviron[i]=NULL;
        environ=newenviron;
 
        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);
        execl("$this", "$this", NULL);
        perror("failed to run $this");
        exit(1);