diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2011-12-12 17:27:18 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2011-12-12 17:27:18 +0000 |
commit | 735415570a28d6b5cde94b2168e537ae44d95f4b (patch) | |
tree | f8d1d6e0b74e92e19de979fa2e17583e5b49352c /winsup/cygwin/fhandler_process.cc | |
parent | 7a7a9e7179155d9202cddb7d2660726f750fd195 (diff) | |
download | cygnal-735415570a28d6b5cde94b2168e537ae44d95f4b.tar.gz cygnal-735415570a28d6b5cde94b2168e537ae44d95f4b.tar.bz2 cygnal-735415570a28d6b5cde94b2168e537ae44d95f4b.zip |
* fhandler_process.cc (dos_drive_mappings::dos_drive_mappings): Fully
resolve symbolic links returned by QueryDosDeviceW. Explain why.
Diffstat (limited to 'winsup/cygwin/fhandler_process.cc')
-rw-r--r-- | winsup/cygwin/fhandler_process.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc index 54a5a8b80..bc870aeeb 100644 --- a/winsup/cygwin/fhandler_process.cc +++ b/winsup/cygwin/fhandler_process.cc @@ -585,6 +585,32 @@ struct dos_drive_mappings for (wchar_t *cur = dbuf; (*drive = *cur); cur = wcschr (cur, L'\0')+1) if (QueryDosDeviceW (drive, pbuf, NT_MAX_PATH)) { + /* The DOS drive mapping can be another symbolic link. The result + is that the mapping won't work since the section name is the + name after resolving all symbolic links. So we have to resolve + symbolic links here, too. */ + for (int syml_cnt = 0; syml_cnt < SYMLOOP_MAX; ++syml_cnt) + { + UNICODE_STRING upath; + OBJECT_ATTRIBUTES attr; + NTSTATUS status; + HANDLE h; + + RtlInitUnicodeString (&upath, pbuf); + InitializeObjectAttributes (&attr, &upath, OBJ_CASE_INSENSITIVE, + NULL, NULL); + status = NtOpenSymbolicLinkObject (&h, SYMBOLIC_LINK_QUERY, + &attr); + if (!NT_SUCCESS (status)) + break; + RtlInitEmptyUnicodeString (&upath, pbuf, + (NT_MAX_PATH - 1) * sizeof (WCHAR)); + status = NtQuerySymbolicLinkObject (h, &upath, NULL); + NtClose (h); + if (!NT_SUCCESS (status)) + break; + pbuf[upath.Length / sizeof (WCHAR)] = L'\0'; + } size_t plen = wcslen (pbuf); size_t psize = plen * sizeof (wchar_t); debug_printf ("DOS drive %ls maps to %ls", drive, pbuf); |