httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject Re: chdir isn't thead specific
Date Wed, 06 May 1998 21:08:00 GMT


On Wed, 6 May 1998, Ben Hyde wrote:

> These are not an issue?

Right.

> These are an issue:
>   
>   modules/standard/mod_cgi.c:318:    ap_chdir_file(r->filename);
>       ap_chdir_file(r->filename);
>       if (!cld->debug)
>   	ap_error_log2stderr(r->server);
>       ap_cleanup_for_exec();
>       child_pid = ap_call_exec(r, argv0, env, 0);

The chdir file there should only have to happen in the forked child... 
except this is WIN32, and fork isn't.  I don't see how to fix this without
serializing chdir calls.  Yuck.

>   
>   modules/standard/mod_include.c:610:    ap_chdir_file(r->filename);
>     in include_cgi

Right same as above.

>   
>   modules/standard/mod_include.c:701:            ap_chdir_file(r->filename);
>     in handle_include

This one I don't understand at all.  But I think it could be fixed by just
pasting pathnames together -- use ap_make_dirstr_parent and append the
filename to be looked up.  I think it's just for #include file.  I'd
rather see it die though. 

>   modules/standard/mod_include.c:847:            ap_chdir_file(r->filename);
>   modules/standard/mod_include.c:857:            ap_chdir_file(r->filename);
>     in handle_exec
>           if (!strcmp(tag, "cmd")) {
>               ...
>               if (include_cmd(parsed_string, r) == -1) {
>   	         ...
>               }
>               /* just in case some stooge changed directories */
>               ap_chdir_file(r->filename);
>           }
>           else if (!strcmp(tag, "cgi")) {
>               ...
>               if (include_cgi(parsed_string, r) == -1) {
>                 ...
>               }
>               /* grumble groan */
>               ap_chdir_file(r->filename);
>           }
>   
>   modules/standard/mod_include.c:2082:    ap_chdir_file(r->filename);
>      in send_parsed_content
>        ...
>        ap_chdir_file(r->filename);
>        if (r->args) {
>             ...
>                      ap_escape_shell_cmd(r->pool, arg_copy) ...
>        }
>        ...

These all fall into the CGI case I think, and I think it's all overkill.

> Second, what to do...
> 
> A mutex that owns the current working directory looks necessary.
> 
> Revising all the subprocess command execution to take a
> directory would also be good.

Right, if it took a directory then on unix the chdir() could happen after
the fork() and everything is all real simple.  On NT... allow me to puke
again.

The CGI "spec" doesn't *require* the current directory to be changed in
this arcane manner.  But it's likely there are scripts that assume it. 
I'd be a lot happier if we could just say that CGIs need to do the chdir
themselves, they have the information they need in PATH_TRANSLATED I
believe. 

Dean


Mime
View raw message