From 145a6c404bca208002afc2193e3c0f27245f55d2 Mon Sep 17 00:00:00 2001 From: short <> Date: Tue, 9 Aug 2005 06:35:35 +0000 Subject: [PATCH] Permit multiple-argumented commands. - Required for xinetd(8) missing any quotation parsing. Close both the connections on any detected connection close. - Required for HTTP. - May not harm as we have no data locally buffered. --- inetdmx.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/inetdmx.c b/inetdmx.c index ebab3bf..13efc7f 100644 --- a/inetdmx.c +++ b/inetdmx.c @@ -72,7 +72,7 @@ static int opt_syslog; static int opt_stderr; static const char *opt_lock; static int opt_ignore_spawned_command_output; -static const char *opt_command; +static char *opt_command; static void fatal(const char *fmt,...) G_GNUC_PRINTF(1,2) G_GNUC_NORETURN; @@ -135,6 +135,15 @@ int rc; return string; } +static void *xmalloc(size_t size) +{ +void *r; + + if ((r=malloc(size))) + return r; + fatal("Error allocing %lu bytes",(unsigned long)size); +} + static void usage(void) { fprintf(stderr,"\ @@ -276,13 +285,6 @@ int fdi,fdo; pollfdi_name[0]=conn0_name; pollfdi_name[1]=conn1_name; for (;;) { - for (fdi=0;fdi=G_N_ELEMENTS(pollfdi)) { - lock_close(); - exit(EXIT_SUCCESS); - } if (0>=poll(pollfdi,G_N_ELEMENTS(pollfdi),-1)) fatal("poll(%s socket,%s socket): %m",pollfdi_name[0],pollfdi_name[1]); for (fdi=0;fdi=argc) fatal(" is a required argument"); - if (optind+1 may need quoting"); - opt_command=argv[optind]; + opt_command_len=0; + for (i=optind;iopt_command) + *s++=' '; + memcpy(s,argv[i],argv_i_len); + s+=argv_i_len; + } + *s++=0; + assert(s==opt_command+opt_command_len); if (!opt_syslog && !opt_stderr) opt_stderr=1; -- 1.8.3.1