};
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;
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);
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;
}
}
}
- 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");
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:
"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);
"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",
}
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();
}