Module: wine Branch: master Commit: 33c8a4254715c5f3b71b23fc657c6ba5eee94ce9 URL: https://source.winehq.org/git/wine.git/?a=commit;h=33c8a4254715c5f3b71b23fc6...
Author: Brendan Shanks bshanks@codeweavers.com Date: Tue Oct 6 13:36:28 2020 -0700
mountmgr: Avoid unnecessary permission prompts on macOS 10.15 and newer.
On macOS 10.15 and newer, trying to open the device node of a removable drive will trigger an "<app> would like to access files on a removable volume" permission prompt, even if the user doesn't have permissions to access the device node (which is almost always the case).
Check the value of access() (recommended by Apple for this purpose) before opening devices.
Signed-off-by: Brendan Shanks bshanks@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/mountmgr.sys/device.c | 9 +++++++++ dlls/mountmgr.sys/diskarb.c | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c index ccb0685ced..6db088f11e 100644 --- a/dlls/mountmgr.sys/device.c +++ b/dlls/mountmgr.sys/device.c @@ -26,6 +26,7 @@ #include <stdarg.h> #include <stdio.h> #include <fcntl.h> +#include <unistd.h> #include <sys/time.h> #ifdef HAVE_SYS_IOCTL_H # include <sys/ioctl.h> @@ -1026,6 +1027,14 @@ static BOOL get_volume_device_info( struct volume *volume ) if (!unix_device) return FALSE;
+#ifdef __APPLE__ + if (access( unix_device, R_OK )) + { + WARN("Unable to open %s, not accessible\n", debugstr_a(unix_device)); + return FALSE; + } +#endif + if (!(name = wine_get_dos_file_name( unix_device ))) { ERR("Failed to convert %s to NT, err %u\n", debugstr_a(unix_device), GetLastError()); diff --git a/dlls/mountmgr.sys/diskarb.c b/dlls/mountmgr.sys/diskarb.c index 12da89d768..25e0745372 100644 --- a/dlls/mountmgr.sys/diskarb.c +++ b/dlls/mountmgr.sys/diskarb.c @@ -25,6 +25,7 @@ #include <errno.h> #include <stdarg.h> #include <stdio.h> +#include <unistd.h> #ifdef HAVE_SYS_IOCTL_H # include <sys/ioctl.h> #endif @@ -150,7 +151,8 @@ static void appeared_callback( DADiskRef disk, void *context ) else if (guid_ptr) add_volume( device, device, mount_point, DEVICE_HARDDISK_VOL, guid_ptr, NULL );
- if ((fd = open( device, O_RDONLY )) >= 0) + if (!access( device, R_OK ) && + (fd = open( device, O_RDONLY )) >= 0) { dk_scsi_identify_t dsi;