repo: When writing to a non-root owned repo, chown() objects to match
Some package systems need to be run as root, so the process linking to libostree may also be root. However, it's reasonable to have the target repository be owned by a uid other than root. This patch makes it Just Work by chowning the file content to match. Note this only operates on archive-z2 repositories, because you can't usefully serve bare repositories via HTTP. https://bugzilla.gnome.org/show_bug.cgi?id=738954
This commit is contained in:
1 parent
a4d904ee38
commit
5fb8bb955e
3 files changed
+36
No files matched your search
@@ -72,6 +72,22 @@ commit_loose_object_trusted (OstreeRepo *self,
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
|
||||
/* We may be writing as root to a non-root-owned repository; if so,
|
||||
* automatically inherit the non-root ownership.
|
||||
*/
|
||||
if (self->mode == OSTREE_REPO_MODE_ARCHIVE_Z2
|
||||
&& self->target_owner_uid != -1)
|
||||
{
|
||||
if (G_UNLIKELY (fchownat (self->tmp_dir_fd, temp_filename,
|
||||
self->target_owner_uid,
|
||||
self->target_owner_gid,
|
||||
AT_SYMLINK_NOFOLLOW) == -1))
|
||||
{
|
||||
ot_util_set_error_from_errno (error, errno);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/* Special handling for symlinks in bare repositories */
|
||||
if (is_symlink && self->mode == OSTREE_REPO_MODE_BARE)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user