gio: don't use O_PATH file descriptors with OpenURI portal

This change relates to https://github.com/flatpak/xdg-desktop-portal/issues/167

The OpenURI portal requires the caller to pass a file descriptor as
proof of access for local files.  Old versions required this file
descriptor to use the O_PATH mode.  However, this does not prove access
since you can create O_PATH descriptors for files that you can't read.

Since xdg-desktop-portal 1.0.1, regular file descriptors are also
accepted with O_PATH descriptors restricted to flatpaks for the
transition.
This commit is contained in:
James Henstridge 2019-01-15 15:59:46 +08:00
parent 5751189fb8
commit e244a78fbc

View File

@ -31,9 +31,6 @@
#include "gunixfdlist.h"
#endif
#ifndef O_PATH
#define O_PATH 0
#endif
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#else
@ -107,7 +104,7 @@ g_openuri_portal_open_uri (const char *uri,
path = g_file_get_path (file);
fd = g_open (path, O_PATH | O_CLOEXEC);
fd = g_open (path, O_RDONLY | O_CLOEXEC);
errsv = errno;
if (fd == -1)
{
@ -318,7 +315,7 @@ g_openuri_portal_open_uri_async (const char *uri,
g_object_set_data (G_OBJECT (task), "open-file", GINT_TO_POINTER (TRUE));
path = g_file_get_path (file);
fd = g_open (path, O_PATH | O_CLOEXEC);
fd = g_open (path, O_RDONLY | O_CLOEXEC);
errsv = errno;
if (fd == -1)
{