]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Receive.pm
(no commit message)
[git.ikiwiki.info.git] / IkiWiki / Receive.pm
index 225f2b9abf33ab995f94576a8a735db9c67fb80b..f985f560b3d17b38aeef783a3b0ccbd0960d034d 100644 (file)
@@ -26,6 +26,8 @@ sub genwrapper () {
        my $ret=<<"EOF";
        {
                int u=getuid();
+               /* 3 characters per byte is certainly enough */
+               char uid_string[sizeof(u) * 3 + 1];
 EOF
        $ret.="\t\tif ( ".
                join("&&", map {
@@ -35,12 +37,19 @@ EOF
                        }
                        "u != $uid";
                } @{$config{untrusted_committers}}).
-               ") exit(0);\n";
+               ") {\n";
 
        
        $ret.=<<"EOF";
-               asprintf(&s, "CALLER_UID=%i", u);
-               newenviron[i++]=s;
+                       /* Trusted user.
+                        * Consume all stdin before exiting, as git may
+                        * otherwise be unhappy. */
+                       char buf[256];
+                       while (read(0, &buf, 256) != 0) {}
+                       exit(0);
+               }
+               snprintf(uid_string, sizeof(uid_string), "%i", u);
+               addenv("CALLER_UID", uid_string);
        }
 EOF
        return $ret;
@@ -73,7 +82,7 @@ sub test () {
                }) || error("failed adding user");
        }
 
-       check_canchange(
+       IkiWiki::check_canchange(
                cgi => $cgi,
                session => $session,
                changes => [IkiWiki::rcs_receive()]