chiark / gitweb /
prefork: add a magic number to prefork-interp
[chiark-utils.git] / cprogs / prefork.c
index 437923f88c3dbeb2ae0e49f4552eaf0e57015adc..909d0658ebf7f407f317f32164299b8306ff7101 100644 (file)
@@ -19,7 +19,7 @@ void vmsgcore(int estatus, int errnoval, const char *fmt, va_list al) {
   if (logging) {
     const char *fmt_use = fmt;
     char *fmt_free = 0;
-    if (errnoval) {
+    if (errnoval!=-1) {
       r = asprintf(&fmt_free, "%s: %%m", fmt);
       if (r) {
        fmt_free = 0;
@@ -148,7 +148,8 @@ void find_socket_path(void) {
     int i;
 
     ident_addstring(0,interp);
-    ident_addstring(0,script);
+    if (script)
+      ident_addstring(0,script);
     sha256_digest(&identsc,sizeof(bbuf),bbuf);
 
     for (i=0; i<identlen; i += 2)
@@ -205,6 +206,7 @@ void process_opts(const char *const **argv_io) {
   const char *smashedopt;
 
   sha256_init(&identsc);
+  ident_addinit();
 
   if ((*argv_io)[0] &&
       (smashedopt = (*argv_io)[1]) &&
@@ -233,6 +235,9 @@ void process_opts(const char *const **argv_io) {
 
     shbang_opts(&split_argv, cmdinfos);
     /* sets interp */
+
+    if (!**argv_io)
+      badusage("no script argument (expected after combined #! options)");
   } else {
     shbang_opts(argv_io, cmdinfos);
   }