Skip to content

Commit

Permalink
Do not hard-code fusermount, add option or auto-detect instead
Browse files Browse the repository at this point in the history
The hard-coding is not appropriate. According to libfuse 3.0.0 release
notes: "The fusermount and mount.fuse binaries have been renamed to
fusermount3 and mount.fuse3 to allow co-installation of libfuse 2.x
and 3.x". Some distributions seem to install a symlink, but this is
not upstream's default behavior.

In addition, fusermount might be provided from non-distro sources. So
a build-time option takes precedence over auto-detection logic.

Fixes flatpak#5104

Fixes flatpak#5694
  • Loading branch information
pabloyoyoista authored and smcv committed Feb 19, 2024
1 parent 8e63eda commit 2cb17b4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
3 changes: 1 addition & 2 deletions common/flatpak-dir.c
Expand Up @@ -2110,8 +2110,7 @@ flatpak_dir_revokefs_fuse_unmount (OstreeRepo **repo,

fusermount = g_subprocess_new (G_SUBPROCESS_FLAGS_NONE,
error,
"fusermount", "-u", "-z", mnt_dir,
NULL);
FUSERMOUNT, "-u", "-z", mnt_dir, NULL);
if (g_subprocess_wait_check (fusermount, NULL, error))
{
g_autoptr(GFile) mnt_dir_file = g_file_new_for_path (mnt_dir);
Expand Down
17 changes: 16 additions & 1 deletion meson.build
Expand Up @@ -188,14 +188,27 @@ polkit_agent_dep = dependency('polkit-agent-1', version : '>=0.98', required : g
build_system_helper = polkit_agent_dep.found()

fuse_dep = dependency('fuse3', version : '>=3.1.1', required : false)

if fuse_dep.found()
fuse_api = 31
else
fuse_dep = dependency('fuse', version : '>=2.9.2')
fuse_api = 26
endif

fusermount = get_option('system_fusermount')
if fusermount == ''
if fuse_api >= 30
fusermount_program = find_program('fusermount3', required: true)
else
fusermount_program = find_program('fusermount', required: true)
endif
if meson.version().version_compare('>=0.55')
fusermount = fusermount_program.full_path()
else
fusermount = fusermount_program.path()
endif
endif

xau_dep = dependency('xau', required : get_option('xauth'))
libostree_dep = dependency('ostree-1', version : '>=' + required_libostree)
json_glib_dep = dependency('json-glib-1.0')
Expand Down Expand Up @@ -347,6 +360,7 @@ cdata.set_quoted(
cdata.set_quoted('G_LOG_DOMAIN', 'flatpak')
cdata.set_quoted('GETTEXT_PACKAGE', 'flatpak')
cdata.set('FUSE_USE_VERSION', fuse_api)
cdata.set_quoted('FUSERMOUNT', fusermount)

if get_option('system_bubblewrap') == ''
cdata.set_quoted('HELPER', get_option('prefix') / get_option('libexecdir') / 'flatpak-bwrap')
Expand Down Expand Up @@ -433,6 +447,7 @@ summary(
'Build selinux module' : build_selinux_module,
'Build bubblewrap' : (get_option('system_bubblewrap') == ''),
'Build dbus-proxy' : (get_option('system_dbus_proxy') == ''),
'fusermount executable' : fusermount,
'Use sandboxed triggers' : get_option('sandboxed_triggers'),
'Use seccomp' : libseccomp_dep.found(),
'Privileged group' : get_option('privileged_group'),
Expand Down
6 changes: 6 additions & 0 deletions meson_options.txt
Expand Up @@ -140,6 +140,12 @@ option(
description : 'system xdg-dbus-proxy executable, or empty string to build subproject',
value : '',
)
option(
'system_fusermount',
type : 'string',
description : 'system fusermount executable, or empty string to auto-select based on fuse version',
value : '',
)
option(
'system_font_cache_dirs',
type : 'array',
Expand Down
2 changes: 1 addition & 1 deletion tests/can-use-fuse.c
Expand Up @@ -53,7 +53,7 @@ check_fuse (void)
return FALSE;
}

fusermount = g_find_program_in_path ("fusermount");
fusermount = g_find_program_in_path (FUSERMOUNT);

if (fusermount == NULL)
{
Expand Down
4 changes: 2 additions & 2 deletions tests/libtest.sh
Expand Up @@ -542,7 +542,7 @@ skip_one_without_bwrap () {
}

skip_without_fuse () {
fusermount --version >/dev/null 2>&1 || skip "no fusermount"
"${FUSERMOUNT}" --version >/dev/null 2>&1 || skip "no fusermount"

capsh --print | grep -q 'Bounding set.*[^a-z]cap_sys_admin' || \
skip "No cap_sys_admin in bounding set, can't use FUSE"
Expand Down Expand Up @@ -608,7 +608,7 @@ commit_to_path () {
cleanup () {
/bin/kill -9 $DBUS_SESSION_BUS_PID
gpg-connect-agent --homedir "${FL_GPG_HOMEDIR}" killagent /bye >&2 || true
fusermount -u $XDG_RUNTIME_DIR/doc >&2 || :
"${FUSERMOUNT}" -u $XDG_RUNTIME_DIR/doc >&2 || :
kill $(jobs -p) &> /dev/null || true
if test -n "${TEST_SKIP_CLEANUP:-}"; then
echo "# Skipping cleanup of ${TEST_DATA_DIR}"
Expand Down
1 change: 1 addition & 0 deletions tests/meson.build
Expand Up @@ -21,6 +21,7 @@ tests_environment.set(
'FLATPAK_VALIDATE_ICON',
project_build_root / 'icon-validator' / 'flatpak-validate-icon',
)
tests_environment.set('FUSERMOUNT', fusermount)
tests_environment.set('G_TEST_BUILDDIR', meson.current_build_dir())
tests_environment.set('G_TEST_SRCDIR', meson.current_source_dir())
tests_environment.prepend('GI_TYPELIB_PATH', project_build_root / 'common')
Expand Down

0 comments on commit 2cb17b4

Please sign in to comment.