Skip to content

session-helper: Relax directory permission for Toolbox containers - #2916

Closed
debarshiray wants to merge 1 commit into
flatpak:masterfrom
debarshiray:wip/rishi/session-helper-monitor-dir-755
Closed

debarshiray wants to merge 1 commit into
flatpak:masterfrom
debarshiray:wip/rishi/session-helper-monitor-dir-755

Conversation

@debarshiray

Copy link
Copy Markdown
Contributor

Toolbox [1] containers, like Flatpak containers, need to keep some
configuration files synchronized with the host. eg., /etc/localtime,
/etc/resolv.conf, etc.. The easiest way to keep them updated is to bind
mount the entire /etc from the host at some location inside the
container, and then replace the container's copy of the files with
symbolic links to the bind mounted copies.

However, this doesn't work when the host's copy of a configuration file
is itself a symbolic link to a location outside /etc. eg.,
/etc/localtime, which points somewhere inside /usr/share/zoneinfo. In
that case the host needs to be actively monitored via inotify(7) and
an updated copy of the file needs to maintained in a separate
directory, which can be bind mounted into the container.

This monitoring infrastructure is already present in Flatpak and it
makes sense to leverage it for Toolbox containers too.

However, Flatpak containers have only one user, the current one logged
into the host, whereas Toolbox containers have a longer list of users
like the host itself. Therefore, if the directory getting bind mounted
(ie., $XDG_RUNTIME_DIR/.flatpak-helper/monitor) isn't world readable,
then some users inside the container won't be able to read the
configuration file. eg., this will fail:
$ sudo -u operator cat /run/host/monitor/localtime

Relaxing the directory permissions on the host shouldn't pose a
security risk. They are copies of originals that are world readable
anyway.

[1] https://github.com/debarshiray/toolbox

Toolbox [1] containers, like Flatpak containers, need to keep some
configuration files synchronized with the host. eg., /etc/localtime,
/etc/resolv.conf, etc.. The easiest way to keep them updated is to bind
mount the entire /etc from the host at some location inside the
container, and then replace the container's copy of the files with
symbolic links to the bind mounted copies.

However, this doesn't work when the host's copy of a configuration file
is itself a symbolic link to a location outside /etc. eg.,
/etc/localtime, which points somewhere inside /usr/share/zoneinfo. In
that case the host needs to be actively monitored via inotify(7) and
an updated copy of the file needs to maintained in a separate
directory, which can be bind mounted into the container.

This monitoring infrastructure is already present in Flatpak and it
makes sense to leverage it for Toolbox containers too.

However, Flatpak containers have only one user, the current one logged
into the host, whereas Toolbox containers have a longer list of users
like the host itself. Therefore, if the directory getting bind mounted
(ie., $XDG_RUNTIME_DIR/.flatpak-helper/monitor) isn't world readable,
then some users inside the container won't be able to read the
configuration file. eg., this will fail:
  $ sudo -u operator cat /run/host/monitor/localtime

Relaxing the directory permissions on the host shouldn't pose a
security risk. They are copies of originals that are world readable
anyway.

[1] https://github.com/debarshiray/toolbox
@rh-atomic-bot

Copy link
Copy Markdown

Can one of the admins verify this patch?
I understand the following commands:

  • bot, add author to whitelist
  • bot, test pull request
  • bot, test pull request once

debarshiray added a commit to containers/toolbox that referenced this pull request May 22, 2019
The permission of $XDG_RUNTIME_DIR/.flatpak-helper/monitor needs to be
relaxed [1] for this work in some corner cases. However, it already
works for the vast majority of cases when used as $USER or root inside
the toolbox container.

[1] flatpak/flatpak#2916

https://github.com/debarshiray/toolbox/issues/70
@alexlarsson

Copy link
Copy Markdown
Member

Makes sense to me. @rh-atomic-bot r+

@rh-atomic-bot

Copy link
Copy Markdown

📌 Commit 38918be has been approved by alexlarsson

@rh-atomic-bot

Copy link
Copy Markdown

⌛ Testing commit 38918be with merge bf96de9...

@rh-atomic-bot

Copy link
Copy Markdown

☀️ Test successful - status-papr
Approved by: alexlarsson
Pushing bf96de9 to master...

@debarshiray
debarshiray deleted the wip/rishi/session-helper-monitor-dir-755 branch June 25, 2019 15:11
alexlarsson pushed a commit to alexlarsson/flatpak that referenced this pull request Sep 19, 2019
Toolbox [1] containers, like Flatpak containers, need to keep some
configuration files synchronized with the host. eg., /etc/localtime,
/etc/resolv.conf, etc.. The easiest way to keep them updated is to bind
mount the entire /etc from the host at some location inside the
container, and then replace the container's copy of the files with
symbolic links to the bind mounted copies.

However, this doesn't work when the host's copy of a configuration file
is itself a symbolic link to a location outside /etc. eg.,
/etc/localtime, which points somewhere inside /usr/share/zoneinfo. In
that case the host needs to be actively monitored via inotify(7) and
an updated copy of the file needs to maintained in a separate
directory, which can be bind mounted into the container.

This monitoring infrastructure is already present in Flatpak and it
makes sense to leverage it for Toolbox containers too.

However, Flatpak containers have only one user, the current one logged
into the host, whereas Toolbox containers have a longer list of users
like the host itself. Therefore, if the directory getting bind mounted
(ie., $XDG_RUNTIME_DIR/.flatpak-helper/monitor) isn't world readable,
then some users inside the container won't be able to read the
configuration file. eg., this will fail:
  $ sudo -u operator cat /run/host/monitor/localtime

Relaxing the directory permissions on the host shouldn't pose a
security risk. They are copies of originals that are world readable
anyway.

[1] https://github.com/debarshiray/toolbox

Closes: flatpak#2916
Approved by: alexlarsson

(cherry picked from commit bf96de9)
rh-atomic-bot pushed a commit that referenced this pull request Sep 19, 2019
Toolbox [1] containers, like Flatpak containers, need to keep some
configuration files synchronized with the host. eg., /etc/localtime,
/etc/resolv.conf, etc.. The easiest way to keep them updated is to bind
mount the entire /etc from the host at some location inside the
container, and then replace the container's copy of the files with
symbolic links to the bind mounted copies.

However, this doesn't work when the host's copy of a configuration file
is itself a symbolic link to a location outside /etc. eg.,
/etc/localtime, which points somewhere inside /usr/share/zoneinfo. In
that case the host needs to be actively monitored via inotify(7) and
an updated copy of the file needs to maintained in a separate
directory, which can be bind mounted into the container.

This monitoring infrastructure is already present in Flatpak and it
makes sense to leverage it for Toolbox containers too.

However, Flatpak containers have only one user, the current one logged
into the host, whereas Toolbox containers have a longer list of users
like the host itself. Therefore, if the directory getting bind mounted
(ie., $XDG_RUNTIME_DIR/.flatpak-helper/monitor) isn't world readable,
then some users inside the container won't be able to read the
configuration file. eg., this will fail:
  $ sudo -u operator cat /run/host/monitor/localtime

Relaxing the directory permissions on the host shouldn't pose a
security risk. They are copies of originals that are world readable
anyway.

[1] https://github.com/debarshiray/toolbox

Closes: #2916
Approved by: alexlarsson

(cherry picked from commit bf96de9)

Closes: #3115
Approved by: alexlarsson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants