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
@@ -819,6 +819,7 @@ ostree_repo_open (OstreeRepo *self,
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
gboolean is_archive;
|
||||
struct stat stbuf;
|
||||
gs_free char *version = NULL;
|
||||
gs_free char *mode = NULL;
|
||||
gs_free char *parent_repo_path = NULL;
|
||||
@@ -836,6 +837,22 @@ ostree_repo_open (OstreeRepo *self,
|
||||
|
||||
self->writable = faccessat (AT_FDCWD, gs_file_get_path_cached (self->objects_dir), W_OK, 0) == 0;
|
||||
|
||||
if (fstat (self->objects_dir_fd, &stbuf) != 0)
|
||||
{
|
||||
ot_util_set_error_from_errno (error, errno);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (stbuf.st_uid != getuid () || stbuf.st_gid != getgid ())
|
||||
{
|
||||
self->target_owner_uid = stbuf.st_uid;
|
||||
self->target_owner_gid = stbuf.st_gid;
|
||||
}
|
||||
else
|
||||
{
|
||||
self->target_owner_uid = self->target_owner_gid = -1;
|
||||
}
|
||||
|
||||
self->config = g_key_file_new ();
|
||||
if (!g_key_file_load_from_file (self->config, gs_file_get_path_cached (self->config_file), 0, error))
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user