From bcceff4ab079acfa2404e0ac0214e620c76a4fdd Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 18 Dec 2020 15:48:13 +0100 Subject: [PATCH] module-access: update with checks for fuse like upstream xdp --- src/modules/module-access.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/modules/module-access.c b/src/modules/module-access.c index 8ec144e1a..786e52dd8 100644 --- a/src/modules/module-access.c +++ b/src/modules/module-access.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -95,11 +96,21 @@ static int check_flatpak(struct pw_impl_client *client, int pid) sprintf(root_path, "/proc/%u/root", pid); root_fd = openat (AT_FDCWD, root_path, O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC | O_NOCTTY); if (root_fd == -1) { + res = -errno; + if (res == -EACCES) { + struct statfs buf; + /* Access to the root dir isn't allowed. This can happen if the root is on a fuse + * filesystem, such as in a toolbox container. We will never have a fuse rootfs + * in the flatpak case, so in that case its safe to ignore this and + * continue to detect other types of apps. */ + if (statfs(root_path, &buf) == 0 && + buf.f_type == 0x65735546) /* FUSE_SUPER_MAGIC */ + return 0; + } /* Not able to open the root dir shouldn't happen. Probably the app died and * we're failing due to /proc/$pid not existing. In that case fail instead * of treating this as privileged. */ - res = -errno; - pw_log_error("failed to open \"%s\": %m", root_path); + pw_log_error("failed to open \"%s\": %s", root_path, spa_strerror(res)); return res; } info_fd = openat (root_fd, ".flatpak-info", O_RDONLY | O_CLOEXEC | O_NOCTTY);