diff options
author | Colin Walters <walters@verbum.org> | 2017-06-07 14:21:59 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-06-12 14:24:22 +0000 |
commit | 8edb5161dbf9a94734baeb0332b367fe66aafbe4 (patch) | |
tree | 87f19bcd2b79bb6143be4869af2a2c6bfa89cdfc /src/libostree/ostree-repo-checkout.c | |
parent | 18ae8e5267f35394faa41cdeadd5125962ba9417 (diff) | |
download | ostree-8edb5161dbf9a94734baeb0332b367fe66aafbe4.tar.gz |
lib/checkout: Ignore world-writable dirs for bare-user-only checkout
See https://github.com/ostreedev/ostree/pull/909 for more information on the
rationale. Basically there's no reason for flatpak (which uses `bare-user-only`)
to have world-writable dirs. Particularly with the presence of the system
helper.
An approach I considered instead was to parse and validate directory metadata
objects at commit time. We still may do that in addition; for file objects we *had*
to do it that way because the actual files would be laid down suid. But directories
live only as inert `.dirmeta` objects until we do a checkout (i.e. `mkdir()`), so
we can solve the problem at checkout time.
Closes: #914
Approved by: alexlarsson
Diffstat (limited to 'src/libostree/ostree-repo-checkout.c')
-rw-r--r-- | src/libostree/ostree-repo-checkout.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libostree/ostree-repo-checkout.c b/src/libostree/ostree-repo-checkout.c index bb7c1771..2b259464 100644 --- a/src/libostree/ostree-repo-checkout.c +++ b/src/libostree/ostree-repo-checkout.c @@ -749,8 +749,18 @@ checkout_tree_at_recurse (OstreeRepo *self, */ if (!did_exist) { - if (TEMP_FAILURE_RETRY (fchmod (destination_dfd, mode)) < 0) - return glnx_throw_errno (error); + guint32 canonical_mode; + /* Silently ignore world-writable directories (plus sticky, suid bits, + * etc.) when doing a checkout for bare-user-only repos. This is related + * to the logic in ostree-repo-commit.c for files. + * See also: https://github.com/ostreedev/ostree/pull/909 i.e. 0c4b3a2b6da950fd78e63f9afec602f6188f1ab0 + */ + if (self->mode == OSTREE_REPO_MODE_BARE_USER_ONLY) + canonical_mode = (mode & 0775) | S_IFDIR; + else + canonical_mode = mode; + if (TEMP_FAILURE_RETRY (fchmod (destination_dfd, canonical_mode)) < 0) + return glnx_throw_errno_prefix (error, "fchmod"); } if (!did_exist && options->mode != OSTREE_REPO_CHECKOUT_MODE_USER) |