[vlc-devel] [PATCH 1/2] dvdnav: Limit user information about insufficient permissions

david.fuhrmann at gmail.com david.fuhrmann at gmail.com
Fri May 1 12:58:21 CEST 2020


From: David Fuhrmann <dfuhrmann at videolan.org>

The mentioned security setting is only relevant for accessing
RAW block devices (/dev/xxx), which is one of the main use cases
for this module (accessing an optical drive).
It is not relevant for file or folder access.

Therefore limit the dialog to only show it in this case.
dvdnav does not provide a way to get the underlying error back
to this module, therefore the path is probed again to ensure
that the actual failure was EPERM.
---
 modules/access/dvdnav.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/modules/access/dvdnav.c b/modules/access/dvdnav.c
index f082f1021b..558103eae3 100644
--- a/modules/access/dvdnav.c
+++ b/modules/access/dvdnav.c
@@ -377,10 +377,23 @@ static int AccessDemuxOpen ( vlc_object_t *p_this )
         msg_Warn( p_demux, "cannot open DVD (%s)", psz_file);
 
 #ifdef __APPLE__
-        vlc_dialog_display_error( p_demux, _("Problem accessing a system resource"),
-            _("Potentially, macOS blocks access to your disc. "
-              "Please open \"System Preferences\" -> \"Security & Privacy\" "
-              "and allow VLC to access your external media in \"Files and Folders\" section."));
+        /* This is only relevant when accessing RAW block devices */
+        if( forced && !strncasecmp( psz_file, "/dev/", 5) )
+        {
+            int fd = vlc_open( psz_file, O_RDONLY | O_NONBLOCK );
+            bool permissionError = ( fd == -1 && errno == EPERM );
+            if( fd != -1 )
+                vlc_close( fd );
+
+            if( permissionError )
+            {
+                msg_Err( p_demux, "Path %s cannot be opened due to unsufficient permissions", psz_file );
+                vlc_dialog_display_error( p_demux, _("Problem accessing a system resource"),
+                                         _("Potentially, macOS blocks access to your disc. "
+                                           "Please open \"System Preferences\" -> \"Security & Privacy\" "
+                                           "and allow VLC to access your external media in \"Files and Folders\" section."));
+            }
+        }
 #endif
         goto bailout;
     }
-- 
2.21.1 (Apple Git-122.3)



More information about the vlc-devel mailing list