Skip to content

Commit

Permalink
Give access to removable devices and other temporary mounts
Browse files Browse the repository at this point in the history
Currently, when udisks is configured to use /run/media instead of
/media, on most operating systems, the /run/media directory is created
by udisks itself when the first mount is handled [1]. This causes
problems when creating the toolbox container, if nothing has been
mounted after the current boot, because a missing directory cannot be
bind mounted.

Fedora Silverblue is a significant exception to the above, where
rpm-ostree takes care of creating /run/media with systemd-tmpfiles [2]
during boot.

The correct long-term solution is to get udisks to create /run/media
during boot with systemd-tmpfiles by installing a snippet in
tmpfiles.d [3, 4]. Until that happens, and is widely deployed, the
toolbox needs to provide the snippet itself to make things work on
the majority of operating systems.

Note that, in case udisks is configured to use /media instead of
/run/media, then this will create an unused /run/media directory. This
is probably fine because /run/media is the default setting for udisks.
Moreover, an unused directory is way better than not being able to
access mount points from a toolbox container or having 'podman create'
fail due to a missing directory.

Based on 4a2a15f and as suggested by
Daniel J Walsh.

[1] UDisks commit aa02e5fc53efdeaf
    storaged-project/udisks@aa02e5fc53efdeaf
[2] rpm-ostree commit 958dfa435e4e4a3e
    coreos/rpm-ostree@958dfa435e4e4a3e
[3] https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html
[4] storaged-project/udisks#641

https://github.com/debarshiray/toolbox/issues/3
  • Loading branch information
debarshiray committed Mar 13, 2019
1 parent a1865ba commit 0c848ab
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
subdir('tmpfiles.d')
4 changes: 4 additions & 0 deletions data/tmpfiles.d/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
install_data(
'toolbox.conf',
install_dir: tmpfilesdir,
)
1 change: 1 addition & 0 deletions data/tmpfiles.d/toolbox.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d /run/media 0755 root root
4 changes: 4 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ project(

go_md2man = find_program('go-md2man')

systemd_dep = dependency('systemd')
tmpfilesdir = systemd_dep.get_pkgconfig_variable('tmpfilesdir')

install_data(
'toolbox',
install_dir: get_option('bindir'),
)

subdir('data')
subdir('doc')
3 changes: 3 additions & 0 deletions toolbox
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,9 @@ create()
--volume "$dbus_system_bus_path":"$dbus_system_bus_path" \
--volume /dev/dri:/dev/dri \
--volume /dev/fuse:/dev/fuse \
--volume /media:/media:rslave \
--volume /mnt:/mnt:rslave \
--volume /run/media:/run/media:rslave \
$toolbox_image \
/bin/sh >/dev/null 2>&3
ret_val=$?
Expand Down

0 comments on commit 0c848ab

Please sign in to comment.