Subject: Re: bug#76022: udisks is configured to use /media instead of /run

From: Maxim Cournoyer <[email-masked]>
Date: Mon, 03 Feb 2025 22:00:53 +0900

Hi Leo,

Leo Famulari <[email-masked]> writes:

> On Mon, Feb 03, 2025 at 12:16:57PM +0900, Maxim Cournoyer wrote:
>> Since commit 35263cd8627b296c3badc21de355b4fe613d7cd4 ("gnu: udisks:
>> Mount things under /media."), udisks mounts removable devices under the
>> /media directory instead of using the /run directory, which would
>> otherwise be the default [0].
>>
>> [0]  https://wiki.archlinux.org/title/Udisks#Mount_to_/media
>
> I don't know what's correct here, but I get the same behaviour on Debian:
> udiskctl mounts things under /media.

There's no 'correct' here, it depends what you want, but if you trust
the upstream developing udisks choices and every distribution except
Debian, that would be to use /run/media by default:

--8<---------------cut here---------------start------------->8---
# configure.ac
fhs_media=no
AC_ARG_ENABLE(fhs-media,
              [AS_HELP_STRING([--enable-fhs-media],
                              [Mount devices in /media instead of /run/media [default=no]])],
              AS_IF([test "x$enable_fhs_media" == "xyes"], [fhs_media=yes]),
              fhs_media=no)
AM_CONDITIONAL(HAVE_FHS_MEDIA, test "x$fhs_media" = "xyes")
if test "x$fhs_media" = "xyes"; then
  AC_DEFINE([HAVE_FHS_MEDIA], 1, [Define to 1 to use /media for mounting])
fi
--8<---------------cut here---------------end--------------->8---

As yo can see, the --enable-fhs-media is opt-in, which we (currently)
and Debian use.  Fedora and others (Arch, Gentoo, OpenSUSE, Nix, etc.)
use the default, /run/media.

The main advantage I see to use /run/media is what I mentioned
up-thread: assuming /run is a tmpfs, which it should (and will be, when
patch #73494 is merged), then the mount points are not persisted across
reboots (they should have been removed by udisks, but a user
error/script could create them), which is a good thing for removable
media as you don't want to erroneously copy something there while the
drives are not connected.

Another change which was not apparent immediately: /run/media/$USER is
per user.  A drive mounted for one user will not be accessile to another
user.  That was motivated for security in multi-users scenarios [0, 1].

[0]  https://cgit.freedesktop.org/udisks/commit/?id=9541a638ffd
[1]  https://bugs.freedesktop.org/show_bug.cgi?id=51709#c2

-- 
Thanks,
Maxim