Re: AW: [cgiwrap-users] CGIWrap Error: Script dir not found
Brought to you by:
nneul
From: Daniel L. <ml-...@lo...> - 2002-08-04 14:02:06
|
hi, > So you find a way to do it? To add the domain? > hmm could you then mail me your cgiwrap.c. Since I'm not really used to > C. Same applies to me. I never did more than "Hello World" in C, thus my code is more than ugly. The following patch checks whether a request has been made to http://domain.tld/cgi-bin/ which would result in the local path /home/user/cgi-bin/, or whether the request was of the kind http://domain.tld/foobar.cgi, which would result in /home/user/public_html/<subdomain>/foobar.cgi. This is achieved by extracting the script path from PATH_TRANSLATED. /* We need our own cgiBaseDir */ if(strcmp("cgi-bin", StripPathComponents(1,GetPathComponents(2, getenv("PATH_INFO")))) == 0) { cgiBaseDir = (char *) SafeMalloc(strlen(user->pw_dir) + 1, "Our customized cgiBaseDir"); cgiBaseDir = user->pw_dir; } else { cgiBaseDir = (char *) SafeMalloc(strlen(GetPathComponents(4, getenv("PATH_TRANSLATED"))) + 2, "Our customized cgiBaseDir"); sprintf(cgiBaseDir, "/%s", GetPathComponents(4, getenv("PATH_TRANSLATED"))); } This code replaces (approx. line 120): cgiBaseDir = GetBaseDirectory(user); Please don't laugh. Terrible code, I know :) I'm not even sure whether I'm malloc'ing enough memory to it. p.s.: Always CC to the list -daniel |