Skip to content

Commit

Permalink
composeutil: Test for ability to open new /dev/null
Browse files Browse the repository at this point in the history
If `nodev` is set, we should fail fast.  See also
containers/storage#208
  • Loading branch information
cgwalters committed Oct 9, 2018
1 parent 51e90ea commit 0f25110
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/app/rpmostree-composeutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ rpmostree_composeutil_legacy_prep_dev (int rootfs_dfd,
return glnx_throw_errno (error);
}

{ GLNX_AUTO_PREFIX_ERROR ("Testing /dev/null in target root (is nodev set?)", error);
glnx_autofd int devnull_fd = -1;
if (!glnx_openat_rdonly (dest_fd, "null", TRUE, &devnull_fd, error))
return FALSE;
char buf[1];
ssize_t s = read (devnull_fd, buf, sizeof (buf));
if (s < 0)
return glnx_throw_errno_prefix (error, "read");
}

return TRUE;
}

Expand Down

0 comments on commit 0f25110

Please sign in to comment.