diff options
author | Jonathan Lebon <jlebon@redhat.com> | 2017-06-02 10:09:23 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-06-02 17:46:16 +0000 |
commit | a32c6d2c70c82b583e8ee7c2a2f4e00b0d888fe5 (patch) | |
tree | 042550cc67e2f8b5447ed1ce9207c33dd7272391 /src/libostree/ostree-repo-checkout.c | |
parent | 3ec2b5773ea1553a70c362c25574978b7bbc932a (diff) | |
download | ostree-a32c6d2c70c82b583e8ee7c2a2f4e00b0d888fe5.tar.gz |
checkout: also chmod in the user checkout case
When falling back to copying, we previously would only chmod checked out
files in the non-user-checkout mode. Fix this by always doing chmod.
The file_mode was being prepared but never actually applied.
Add a basic test in the archive-z2 --> usermode checkout case in which
we're guaranteed to always fall back to copy mode.
Closes: #633
Closes: #903
Approved by: cgwalters
Diffstat (limited to 'src/libostree/ostree-repo-checkout.c')
-rw-r--r-- | src/libostree/ostree-repo-checkout.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/libostree/ostree-repo-checkout.c b/src/libostree/ostree-repo-checkout.c index 8dbe49e3..bb7c1771 100644 --- a/src/libostree/ostree-repo-checkout.c +++ b/src/libostree/ostree-repo-checkout.c @@ -140,10 +140,7 @@ write_regular_file_content (OstreeRepo *self, { if (TEMP_FAILURE_RETRY (fchown (outfd, g_file_info_get_attribute_uint32 (file_info, "unix::uid"), g_file_info_get_attribute_uint32 (file_info, "unix::gid"))) < 0) - return glnx_throw_errno (error); - - if (TEMP_FAILURE_RETRY (fchmod (outfd, g_file_info_get_attribute_uint32 (file_info, "unix::mode"))) < 0) - return glnx_throw_errno (error); + return glnx_throw_errno_prefix (error, "fchown"); if (xattrs) { @@ -152,10 +149,19 @@ write_regular_file_content (OstreeRepo *self, } } + guint32 file_mode = g_file_info_get_attribute_uint32 (file_info, "unix::mode"); + + /* Don't make setuid files on checkout when we're doing --user */ + if (mode == OSTREE_REPO_CHECKOUT_MODE_USER) + file_mode &= ~(S_ISUID|S_ISGID); + + if (TEMP_FAILURE_RETRY (fchmod (outfd, file_mode)) < 0) + return glnx_throw_errno_prefix (error, "fchmod"); + if (fsync_is_enabled (self, options)) { if (fsync (outfd) == -1) - return glnx_throw_errno (error); + return glnx_throw_errno_prefix (error, "fsync"); } if (outstream) @@ -249,14 +255,8 @@ create_file_copy_from_input_at (OstreeRepo *repo, else if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR) { g_auto(OtTmpfile) tmpf = { 0, }; - guint32 file_mode; GLnxLinkTmpfileReplaceMode replace_mode; - file_mode = g_file_info_get_attribute_uint32 (file_info, "unix::mode"); - /* Don't make setuid files on checkout when we're doing --user */ - if (options->mode == OSTREE_REPO_CHECKOUT_MODE_USER) - file_mode &= ~(S_ISUID|S_ISGID); - if (!ot_open_tmpfile_linkable_at (destination_dfd, ".", O_WRONLY | O_CLOEXEC, &tmpf, error)) return FALSE; |