Browse Source

dvdnav: Improve user information about insufficient permissions

The mentioned security setting is relevant for accessing
external media like RAW block devices (/dev/xxx), which is one of
the main use cases for this module (modern Macs do not have internal
optical drives anymore).

Probe for this case explicitly to inform the user how to get
access.

This is only relevant starting with macOS Catalina.
pull/106/head
David Fuhrmann 6 years ago
parent
commit
18e5f17fb8
  1. 2
      modules/access/Makefile.am
  2. 70
      modules/access/disc_helper.h
  3. 12
      modules/access/dvdnav.c
  4. 1
      po/POTFILES.in

2
modules/access/Makefile.am

@ -242,7 +242,7 @@ endif
EXTRA_LTLIBRARIES += libvcd_plugin.la
access_LTLIBRARIES += $(LTLIBvcd)
libdvdnav_plugin_la_SOURCES = access/dvdnav.c demux/mpeg/ps.h demux/mpeg/pes.h
libdvdnav_plugin_la_SOURCES = access/disc_helper.h access/dvdnav.c demux/mpeg/ps.h demux/mpeg/pes.h
libdvdnav_plugin_la_CFLAGS = $(AM_CFLAGS) $(DVDNAV_CFLAGS)
libdvdnav_plugin_la_LIBADD = $(DVDNAV_LIBS)
libdvdnav_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(accessdir)'

70
modules/access/disc_helper.h

@ -0,0 +1,70 @@
/*****************************************************************************
* disc_helper.h: disc helper functions
*****************************************************************************
* Copyright (C) 2020 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <errno.h>
#include <sys/stat.h>
#include <unistd.h>
#include <vlc_dialog.h>
#include <vlc_fs.h>
inline static int DiscProbeMacOSPermission( vlc_object_t *p_this, const char *psz_file )
{
#ifdef __APPLE__
/* Check is only relevant starting macOS Catalina */
if( __builtin_available( macOS 10.15, * ) )
{
/* Continue. The check above cannot be negated. */
}
else
{
return VLC_SUCCESS;
}
msg_Dbg( p_this, "Checking access permission for path %s", psz_file );
struct stat stat_buf;
if( vlc_stat( psz_file, &stat_buf ) != 0 )
return VLC_SUCCESS; // Continue with probing to be on the safe side
if( !S_ISBLK( stat_buf.st_mode ) && !S_ISCHR( stat_buf.st_mode ) )
return VLC_SUCCESS;
/* Check that device access in fact fails with EPERM error */
int retVal = access( psz_file, R_OK );
if( retVal == -1 && errno == EPERM )
{
msg_Err( p_this, "Path %s cannot be opened due to unsufficient permissions", psz_file );
vlc_dialog_display_error( p_this, _("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."));
return VLC_EGENERIC;
}
return VLC_SUCCESS;
#else
VLC_UNUSED( p_this );
VLC_UNUSED( psz_file );
return VLC_SUCCESS;
#endif
}

12
modules/access/dvdnav.c

@ -65,6 +65,8 @@ dvdnav_status_t dvdnav_jump_to_sector_by_time(dvdnav_t *, uint64_t, int32_t);
#include "../demux/mpeg/ps.h"
#include "../demux/timestamps_filter.h"
#include "disc_helper.h"
/*****************************************************************************
* Module descriptor
*****************************************************************************/
@ -414,6 +416,9 @@ static int AccessDemuxOpen ( vlc_object_t *p_this )
if( !forced && ProbeDVD( psz_file ) != VLC_SUCCESS )
goto bailout;
if( forced && DiscProbeMacOSPermission( p_this, psz_file ) != VLC_SUCCESS )
goto bailout;
/* Open dvdnav */
psz_path = ToLocale( psz_file );
#if DVDNAV_VERSION >= 60100
@ -425,13 +430,6 @@ static int AccessDemuxOpen ( vlc_object_t *p_this )
#endif
{
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."));
#endif
goto bailout;
}

1
po/POTFILES.in

@ -159,6 +159,7 @@ modules/access/concat.c
modules/access/dc1394.c
modules/access/dcp/dcp.cpp
modules/access/decklink.cpp
modules/access/disc_helper.h
modules/access/dshow/dshow.cpp
modules/access/dsm/access.c
modules/access/dsm/sd.c

Loading…
Cancel
Save