public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: cwdstuff: check if /dev exists Date: Tue, 25 May 2021 20:05:52 +0000 (GMT) [thread overview] Message-ID: <20210525200553.0303B3858018@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=4c09dc4f9c1c3d6c6510b8976d4da99c82ae9a26 commit 4c09dc4f9c1c3d6c6510b8976d4da99c82ae9a26 Author: Corinna Vinschen <corinna@vinschen.de> Date: Tue May 25 21:46:13 2021 +0200 Cygwin: cwdstuff: check if /dev exists /dev has been handled as virtual dir in cwdstuff, thus not allowing to start native apps from /dev as CWD, even if /dev actually exists on disk. Unfortunately this also affects Cygwin executables started from a debugger. When chdir'ing to /dev, check if /dev exists on disk. If so, treat it as any other existing path. Signed-off-by: Corinna Vinschen <corinna@vinschen.de> Diff: --- winsup/cygwin/path.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 39ba17514..53cdc282d 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -4886,6 +4886,7 @@ cwdstuff::set (path_conv *nat_cwd, const char *posix_cwd) { NTSTATUS status; UNICODE_STRING upath; + OBJECT_ATTRIBUTES attr; PEB &peb = *NtCurrentTeb ()->Peb; bool virtual_path = false; bool unc_path = false; @@ -4927,7 +4928,23 @@ cwdstuff::set (path_conv *nat_cwd, const char *posix_cwd) { upath = *nat_cwd->get_nt_native_path (); if (nat_cwd->isspecial ()) - virtual_path = true; + { + virtual_path = true; + /* But allow starting of native apps from /dev if /dev actually + exists on disk. */ + if (isdev_dev (nat_cwd->dev)) + { + FILE_BASIC_INFORMATION fbi; + + InitializeObjectAttributes (&attr, &upath, + OBJ_CASE_INSENSITIVE | OBJ_INHERIT, + NULL, NULL); + status = NtQueryAttributesFile (&attr, &fbi); + if (status != STATUS_OBJECT_NAME_NOT_FOUND + && status != STATUS_OBJECT_PATH_NOT_FOUND) + virtual_path = false; + } + } } /* Memorize old DismountCount before opening the dir. This value is @@ -4944,7 +4961,6 @@ cwdstuff::set (path_conv *nat_cwd, const char *posix_cwd) if (!virtual_path) { IO_STATUS_BLOCK io; - OBJECT_ATTRIBUTES attr; if (!nat_cwd) {
reply other threads:[~2021-05-25 20:05 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210525200553.0303B3858018@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).