From: ian Date: Thu, 11 Sep 1997 18:20:14 +0000 (+0000) Subject: Fix builtins. X-Git-Tag: release-0-55~4 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=userv.git;a=commitdiff_plain;h=26444956110f28281bef77dfc28be75e25ae85a2 Fix builtins. --- diff --git a/client.c b/client.c index 7a810b5..02d77a9 100644 --- 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 19713af..6612545 100644 --- a/debug.c +++ b/debug.c @@ -176,6 +176,8 @@ void debug_dumprequest(pid_t mypid) { for (i=0; i0) { putchar(' '); nspaces--; } putchar(c); + lnl= 0; + break; } } - assert(*--string == '\n'); + assert(lnl); serv_checkstdoutexit(); }