Re: Re: Current working directory and multi-threaded environments
| From: | Sascha Schumann | Date: | Thu, 16 Mar 2000 17:37:42 +0000 |
| Subject: | Re: Re: Current working directory and multi-threaded environments | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-16896@lists.php.net to get a copy of this message | ||
On Thu, Mar 16, 2000 at 07:21:33PM +0200, Andi Gutmans wrote:
> On Thu, 16 Mar 2000, Sascha Schumann wrote:
>
> > On Thu, Mar 16, 2000 at 06:57:22PM +0200, Andi Gutmans wrote:
> > > Guys,
> > >
> > > I just commited a file php_virtual_chdir.c to our CVS. It has a main() in
> > > it so you can compile it and run it.
> > > I want to base the new virtual current working directory on this code,
> > > which seems to work pretty well and normalizes the names of the
> > > directories. Look at the main and see that it deals very nicely with all
> > > sorts of scenarios.
> > > There are two main issues with this code:
> > > a) It doesn't *really* check if the directory exists.
> > > b) strtok() isn't thread-safe in all machine's. I think we have the
> > > necessary #define's to strtok_r for most platforms though. In any case, we
> > > can either use something small we write ourselves.
> >
> > Why not use strtok_r directly?
>
> I prefer to use the PHP #define's. I don't think Windows has an strtok_r.
Hm, even win32/registry.c uses strtok_r. If Windows supports POSIX,
then it should have strtok_r.
http://www.opengroup.org/onlinepubs/007908799/xsh/strtok.html
> > f) does not handle COMMAND.COM special cases (i.e. "..."). This has been
> > a nasty security problem for many programs handling paths on Win16/32,
> > so we should try to cover this.
>
> Don't know this issue. Can you please expand on it? Does chdir() in
> Win16/32 do something special? Should we emulate that something special?
AFAIC "\.{2,}" is treated like "..". Perhaps some Windows guru can
verify (or falsify) that.
Additionally, "\foo\bar" is not an absolute path name on Windows.
It's still relative to the current drive.
> > g) what about other O/S?
>
> Like what? This covers UNIX and Windows. Does PHP support other machines?
There is an OS/2 port. I'm currently abstracting your code a little bit
and will post an improved version in some minutes.
- Sascha