X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=www-cgi%2Fucgi.c;h=374fea5c0f1f03eef014f12f2ca649337ba23506;hb=6a3086f1860a27894942124c1ecd62502bb4b670;hp=c1239d07f90b24b14f2c139d52a713e5eaa552b1;hpb=44a77f4851d3c819f9b364018a9695f332758a71;p=userv-utils.git diff --git a/www-cgi/ucgi.c b/www-cgi/ucgi.c index c1239d0..374fea5 100644 --- a/www-cgi/ucgi.c +++ b/www-cgi/ucgi.c @@ -46,18 +46,26 @@ int main(int argc, const char **argv) { if (fputs("Content-Type: text/plain\n\n",stdout)==EOF || fflush(stdout)) syserror("write stdout"); if (dup2(1,2)<0) { perror("dup stdout to stderr"); exit(-1); } + D( printf(";;; UCGI\n"); ) } if (argc > MAX_ARGS) error("too many arguments"); pathi= getenv("PATH_INFO"); if (!pathi) error("PATH_INFO not found"); + D( if (debugmode) { + printf(";; find user name...\n" + ";; initial PATH_INFO = `%s'\n", + pathi); + } ) if (pathi[0] != '/' || pathi[1] != '~') error("PATH_INFO must start with /~"); slash2= strchr(pathi+2,'/'); if (!slash2) error("PATH_INFO must have more than one /"); usernamelen= slash2-(pathi+2); if (usernamelen > MAX_USERNAME_LEN) error("PATH_INFO username too long"); username= xmalloc(usernamelen+1); memcpy(username,pathi+2,usernamelen); username[usernamelen]= 0; + D( if (debugmode) + printf(";; user = `%s'; tail = `%s'\n", username, slash2); ) if (!isalpha(username[0])) error("username 1st character is not alphabetic"); xsetenv("PATH_INFO",slash2,1); @@ -81,6 +89,7 @@ int main(int argc, const char **argv) { arguments[nargs++]= 0; if (debugmode) { + D( fflush(stdout); ) child= fork(); if (child==-1) syserror("fork"); if (child) { rchild= waitpid(child,&status,0); @@ -90,6 +99,15 @@ int main(int argc, const char **argv) { } } + D( if (debugmode) { + int i; + + printf(";; final command line...\n"); + for (i = 0; arguments[i]; i++) + printf(";; %s\n", arguments[i]); + fflush(stdout); + } ) + execvp("userv",(char*const*)arguments); syserror("exec userv"); return -1;