Alexandre Julliard : ntdll: Only reset the Unix current directory on removable devices.

Alexandre Julliard julliard at winehq.org
Fri Dec 18 12:52:54 CST 2020


Module: wine
Branch: master
Commit: cdaa72c728df3c80499c8a4f59e731f353347db0
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=cdaa72c728df3c80499c8a4f59e731f353347db0

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Dec 18 15:20:45 2020 +0100

ntdll: Only reset the Unix current directory on removable devices.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49545
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/unix/env.c    |  1 -
 dlls/ntdll/unix/server.c | 11 ++++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c
index f6775fc37a4..e9a40495c9d 100644
--- a/dlls/ntdll/unix/env.c
+++ b/dlls/ntdll/unix/env.c
@@ -1348,7 +1348,6 @@ void CDECL get_initial_directory( UNICODE_STRING *dir )
         MESSAGE("Warning: could not find DOS drive for current working directory '%s', "
                 "starting in the Windows directory.\n", cwd ? cwd : "" );
     free( cwd );
-    chdir( "/" ); /* avoid locking removable devices */
 }
 
 
diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c
index 7236f0acb83..87dd4b10b83 100644
--- a/dlls/ntdll/unix/server.c
+++ b/dlls/ntdll/unix/server.c
@@ -1466,7 +1466,16 @@ void server_init_process_done(void)
     IMAGE_NT_HEADERS *nt = get_exe_nt_header();
     void *entry = (char *)peb->ImageBaseAddress + nt->OptionalHeader.AddressOfEntryPoint;
     NTSTATUS status;
-    int suspend;
+    int suspend, needs_close, unixdir;
+
+    if (peb->ProcessParameters->CurrentDirectory.Handle &&
+        !server_get_unix_fd( peb->ProcessParameters->CurrentDirectory.Handle,
+                             FILE_TRAVERSE, &unixdir, &needs_close, NULL, NULL ))
+    {
+        fchdir( unixdir );
+        if (needs_close) close( unixdir );
+    }
+    else chdir( "/" ); /* avoid locking removable devices */
 
 #ifdef __APPLE__
     send_server_task_port();




More information about the wine-cvs mailing list