chiark / gitweb /
Fix builtins.
authorian <ian>
Thu, 11 Sep 1997 18:20:14 +0000 (18:20 +0000)
committerian <ian>
Thu, 11 Sep 1997 18:20:14 +0000 (18:20 +0000)
client.c
debug.c
servexec.c

index 7a810b534aa98d42da10dad7135d4b5810a825a2..02d77a9340057e8da024a92aa777c39e6c0fe44e 100644 (file)
--- a/client.c
+++ b/client.c
@@ -133,14 +133,14 @@ struct fdsetupstate {
 };
 
 enum signalsexitspecials { se_number=-100, se_numbernocore, se_highbit, se_stdout };
-enum overridetypes { ot_none, ot_string, ot_file };
+enum overridetypes { ot_none, ot_string, ot_file, ot_builtin };
 
 struct constkeyvaluepair { const char *key, *value; };
 
 static const char *serviceuser;
 static uid_t serviceuid, myuid;
 static struct fdsetupstate *fdsetup;
-static int fdsetupsize, builtin;
+static int fdsetupsize;
 static struct constkeyvaluepair *defvararray;
 static int defvaravail, defvarused;
 static unsigned long timeout;
@@ -472,10 +472,6 @@ static void of_hidecwd(const struct optioninfo *oip, const char *value, char *ke
   hidecwd=1;
 }
 
-static void of_builtin(const struct optioninfo *oip, const char *value, char *key) {
-  builtin=1;
-}
-
 static void of_help(const struct optioninfo *oip, const char *value, char *key) {
   usage();
   exit(0);
@@ -500,6 +496,10 @@ static void of_copyright(const struct optioninfo *oip, const char *value, char *
   exit(0);
 }
 
+static void of_builtin(const struct optioninfo *oip, const char *value, char *key) {
+  overridetype= ot_builtin;
+}
+
 static void of_override(const struct optioninfo *oip, const char *value, char *key) {
   overridetype= ot_string;
   overridevalue= value;
@@ -759,13 +759,13 @@ int main(int argc, char *const *argv) {
       }
     }
   }
-  if (builtin) {
+  if (overridetype == ot_builtin) {
     serviceuser= "-";
   } else {
     if (!*argpp) usageerror("no service user given after options");
     serviceuser= *argpp++;
   }
-  if (!*argpp) usageerror(builtin ?
+  if (!*argpp) usageerror(overridetype == ot_builtin ?
                          "no service name given after options and service user" :
                          "no builtin service given after options");
   
@@ -848,13 +848,22 @@ int main(int argc, char *const *argv) {
     ovused= -1;
     ovbuf= 0;
     break;
+  case ot_builtin:
+    l= strlen(argv[0]);
+    if (l >= MAX_OVERRIDE_LEN-20)
+      miscerror("builtin service string is too long (%d, max is %d)",
+               l,MAX_OVERRIDE_LEN-21);
+    l+= 20;
+    ovbuf= xmalloc(l);
+    snprintf(ovbuf,l,"execute-builtin %s\n",argv[0]);
+    ovused= strlen(ovbuf);
+    break;
   case ot_string:
     l= strlen(overridevalue);
     if (l >= MAX_OVERRIDE_LEN)
       miscerror("override string is too long (%d, max is %d)",l,MAX_OVERRIDE_LEN-1);
     ovbuf= xmalloc(l+2);
-    strcpy(ovbuf,overridevalue);
-    strcat(ovbuf,"\n");
+    snprintf(ovbuf,l+2,"%s\n",overridevalue);
     ovused= l+1;
     break;
   case ot_file:
diff --git a/debug.c b/debug.c
index 19713af4bcdf028b34ecfd488e63bfeb53de0fb2..6612545a1bff4e3c0a8c0d9e088d2ff0355cbaa0 100644 (file)
--- a/debug.c
+++ b/debug.c
@@ -176,6 +176,8 @@ void debug_dumprequest(pid_t mypid) {
   for (i=0; i<request_mbuf.nvars; i++)
     printf(" `%s'=`%s'",defvararray[i].key,defvararray[i].value);
   printf("\n");
+  if (overridedata) printf("override data: `%s'\n",overridedata);
+  else printf("not overridden\n");
   if (getenv("USERVD_SLEEP")) sleep(atoi(getenv("USERVD_SLEEP")));
 }
 
index abd36089ad5296b8c1692a2a413418d6f5c88618..71412a7266f7fd5804b37992dfa1d94a0b389f7b 100644 (file)
@@ -68,7 +68,7 @@ void bisexec_version(const char *const *argv) {
         "production version"
 #endif
         " - protocol magic number %08lx\n"
-        "protocol checksum:",
+        "protocol checksum: ",
         BASE_MAGIC);
   for (i=0, p=protocolchecksumversion; i<sizeof(protocolchecksumversion); i++, p++)
     printf("%02x",*p);
@@ -76,7 +76,7 @@ void bisexec_version(const char *const *argv) {
         "rendezvous socket: `" RENDEZVOUSPATH "'\n"
         "system config dir: `" SYSTEMCONFIGDIR "'\n"
         "pipe filename format: `%s' (max length %d)\n"
-        "maximums:    fd %-10d                general string %d"
+        "maximums:    fd %-10d                general string %d\n"
         "             gids %-10d              override length %d\n\n"
         "             args or variables %-10d error message %d\n"
         "             nested inclusion %-10d  errno string reserve %d\n",
@@ -89,20 +89,25 @@ void bisexec_version(const char *const *argv) {
 }
 
 static void NONRETURNING dumpconfig(const char *string) {
-  int nspaces, c;
+  int nspaces, c, lnl;
   
-  assert(*string);
   nspaces= 0;
+  lnl= 1;
   while ((c= *string++)) {
     switch (c) {
     case ' ': nspaces++; break;
-    case '\n': nspaces= 0; putchar('\n'); break;
+    case '\n':
+      if (!lnl) putchar('\n');
+      nspaces= 0; lnl= 1;
+      break;
     default:
       while (nspaces>0) { putchar(' '); nspaces--; }
       putchar(c);
+      lnl= 0;
+      break;
     }
   }
-  assert(*--string == '\n');
+  assert(lnl);
   serv_checkstdoutexit();
 }