Skip to content
Snippets Groups Projects
Commit 1345882d authored by Jonathan Lebon's avatar Jonathan Lebon
Browse files

glnx_file_copy_at: Add GLNX_FILE_COPY_NOCHOWN

In some contexts, we may want to copy a root-owned file but we're not
running as root so we can't `fchown` it. (The case I'm interested in is
actually a bit more obscure than this: running in a supermin VM as root,
and wanting to copy a file we created onto a 9p mount where we don't
have perms to `fchown`).

Add a `GLNX_FILE_COPY_NOCHOWN` to handle this case.
parent 900caea6
Branches
Tags
No related merge requests found
......@@ -1000,8 +1000,11 @@ glnx_file_copy_at (int src_dfd,
if (glnx_regfile_copy_bytes (src_fd, tmp_dest.fd, (off_t) -1) < 0)
return glnx_throw_errno_prefix (error, "regfile copy");
if (fchown (tmp_dest.fd, src_stbuf->st_uid, src_stbuf->st_gid) != 0)
return glnx_throw_errno_prefix (error, "fchown");
if (!(copyflags & GLNX_FILE_COPY_NOCHOWN))
{
if (fchown (tmp_dest.fd, src_stbuf->st_uid, src_stbuf->st_gid) != 0)
return glnx_throw_errno_prefix (error, "fchown");
}
if (!(copyflags & GLNX_FILE_COPY_NOXATTRS))
{
......
......@@ -189,7 +189,8 @@ glnx_regfile_copy_bytes (int fdf, int fdt, off_t max_bytes);
typedef enum {
GLNX_FILE_COPY_OVERWRITE = (1 << 0),
GLNX_FILE_COPY_NOXATTRS = (1 << 1),
GLNX_FILE_COPY_DATASYNC = (1 << 2)
GLNX_FILE_COPY_DATASYNC = (1 << 2),
GLNX_FILE_COPY_NOCHOWN = (1 << 3)
} GLnxFileCopyFlags;
gboolean
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment