]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Wrapper.pm
fix broken example config file and detect this breakage
[ikiwiki.git] / IkiWiki / Wrapper.pm
index 62d284eb6fef018b268e69608c0f4282adc5f607..2e4925a1f049c4d032a853c6443b8bce433b9401 100644 (file)
@@ -19,6 +19,9 @@ sub gen_wrapper () { #{{{
                error("cannot create a wrapper that uses a setup file");
        }
        my $wrapper=possibly_foolish_untaint($config{wrapper});
+       if (! defined $wrapper || ! length $wrapper) {
+               error("wrapper filename not specified");
+       }
        delete $config{wrapper};
        
        my @envsave;
@@ -33,12 +36,12 @@ sub gen_wrapper () { #{{{
 EOF
        }
        
-       $Data::Dumper::Indent=0;
+       $Data::Dumper::Indent=0; # no newlines
        my $configstring=Data::Dumper->Dump([\%config], ['*config']);
        $configstring=~s/\\/\\\\/g;
        $configstring=~s/"/\\"/g;
        
-       open(OUT, ">ikiwiki-wrap.c") || error("failed to write ikiwiki-wrap.c: $!");;
+       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
@@ -66,10 +69,10 @@ $envsave
 }
 EOF
        close OUT;
-       if (system("gcc", "ikiwiki-wrap.c", "-o", $wrapper) != 0) {
-               error("failed to compile ikiwiki-wrap.c");
+       if (system("gcc", "$wrapper.c", "-o", $wrapper) != 0) {
+               error("failed to compile $wrapper.c");
        }
-       unlink("ikiwiki-wrap.c");
+       unlink("$wrapper.c");
        if (defined $config{wrappermode} &&
            ! chmod(oct($config{wrappermode}), $wrapper)) {
                error("chmod $wrapper: $!");