Skip to content

Commit

Permalink
postprocess: Ensure dirs are 0755 regardless of umask
Browse files Browse the repository at this point in the history
`umask` is one of those really evil Unix things...it's pretty
crazy actually there's still no threadsafe way to "`mkdir` ignoring umask".

This surfaced in someone using coreos-assembler with a working
directory of mode `0750` and having that surface in the target
rootfs.

Ref: coreos/fedora-coreos-tracker#272

Closes: coreos#1902
Approved by: jlebon
  • Loading branch information
cgwalters authored and rh-atomic-bot committed Sep 11, 2019
1 parent 680cc10 commit 13377d4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/libpriv/rpmostree-postprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,18 @@ init_rootfs (int dfd,
{ "sysroot/ostree", "ostree" },
};

/* Ensure the rootfs has the right mode, we don't want to be affected
* by umask.
**/
if (fchmod (dfd, 0755) == -1)
return glnx_throw_errno_prefix (error, "fchmod(rootfs)");

for (guint i = 0; i < G_N_ELEMENTS (toplevel_dirs); i++)
{
if (!glnx_ensure_dir (dfd, toplevel_dirs[i], 0755, error))
return FALSE;
if (fchmodat (dfd, toplevel_dirs[i], 0755, 0) == -1)
return glnx_throw_errno_prefix (error, "fchmodat");
}

for (guint i = 0; i < G_N_ELEMENTS (symlinks); i++)
Expand Down

0 comments on commit 13377d4

Please sign in to comment.