]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Wrapper.pm
* Don't fail syntax check if Text::Typography isn't installed.
[ikiwiki.git] / IkiWiki / Wrapper.pm
index ee547cefb9e7945ea12015a3197a2a79737e3fa7..4a98af622cad0d68819fa059f7cc2c7a1d996bf4 100644 (file)
@@ -46,17 +46,25 @@ EOF
                asprintf(&newenviron[i++], "%s=%s", "REV", s);
 EOF
        }
+       if ($config{rcs} eq "tla" && $config{notify}) {
+               $envsave.=<<"EOF"
+       if ((s=getenv("ARCH_VERSION")))
+               asprintf(&newenviron[i++], "%s=%s", "ARCH_VERSION", s);
+EOF
+       }
        
        $Data::Dumper::Indent=0; # no newlines
        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>
+#include <sys/types.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
@@ -74,6 +82,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);