This is the mail archive of the
cygwin-developers
mailing list for the Cygwin project.
Re: 1.7.5: Occasional failure of CreatePipe or signal handing due to thread-unsafe code in cwdstuff::set
On Aug 12 07:17, Andy Koppe wrote:
> On 11 August 2010 21:33, Christopher Faylor wrote:
> >On Wed, Aug 11, 2010 at 07:14:31PM +0200, Corinna Vinschen wrote:
> >>> If we can't make it fail then I still think that the file should be
> >>> created "up" the directory path, as close as you can get to Cygwin's
> >>> notion of cwd.
> >>
> >>So, "set it to the longest possible path prefix of Cygwin's cwd which is
> >>still accepted by SetCurrentDirectory".
> >
> > Yes, but I still think it should be an error.
>
> I agree, that would be ideal, and the fake drive letter is a very
> clever idea. It needs to be fast though, as it will affect every
> chdir() call where SetCurrentDirectory fails.
>
> Regarding the alternative, I think cutting the path to fit MAX_PATH is
> worse than either simply ignoring the failure (and hence leaving it in
> the previous directory) or changing to a known and documented
> directory. Cutting the path to length may be straightforward in code,
> but it would be very awkward to work out manually. Also, repeated
> SetCurrentDirectory calls with shorter and shorter paths would be
> needed if the failure is due to missing privileges rather than an
> overlong PATH.
>
> As for going to a known location, the Cygwin root seems the best of a
> bad bunch so far. GetWindowsDirectory()\Temp might be another
> possibility, but I don't know whether that's guaranteed to exist.
> Simply ignoring the SetCurrentDirectory() failure suddenly seems quite
> tempting. At least it's fast.
I had an overnight idea which I'll test today. Basically, Cygwin still
has the code to access the PEB directly. So, what I intend to try is this:
bool invalid_path = false;
if incoming path is a virtual Cygwin dir
invalid_path = true;
else
invalid_path = !SetCurrentDirectoryW (incoming path);
if (invalid_path)
{
InterlockedExchange (PEB CWD handle, NULL);
NtClose (exchanged handle);
PEB CWD pathname = "---invalid path---";
}
If that works as expected, this looks like an easy solution to me to
disallow further path-relative WIn32 commands, if the CWD can't be
handled by the Win32 API.
I'll report back what I find.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat