Skip to content

Commit

Permalink
core,scripts: Move creation of /var/tmp into core
Browse files Browse the repository at this point in the history
In prep for cleaning up how we manage mounts.  If we're looking
at a real existing `/var`, then it must have the directory.  The
only case where we don't is in pkglayering, so move the special
case there.

Prep for coreos#1329
  • Loading branch information
cgwalters committed Apr 10, 2018
1 parent eb62896 commit 4023f94
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
5 changes: 5 additions & 0 deletions src/libpriv/rpmostree-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3829,6 +3829,11 @@ rpmostree_context_assemble (RpmOstreeContext *self,

rpmostree_output_progress_end ();

/* Some packages expect to be able to make temporary files here
* for obvious reasons, but we otherwise make `/var` read-only.
*/
if (!glnx_shutil_mkdir_p_at (tmprootfs_dfd, "var/tmp", 0755, cancellable, error))
return FALSE;
if (!rpmostree_rootfs_prepare_links (tmprootfs_dfd, cancellable, error))
return FALSE;

Expand Down
26 changes: 0 additions & 26 deletions src/libpriv/rpmostree-scripts.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ run_script_in_bwrap_container (int rootfs_fd,
const char *postscript_path_container = glnx_strjoina ("/usr", postscript_name);
const char *postscript_path_host = postscript_path_container + 1;
g_autoptr(RpmOstreeBwrap) bwrap = NULL;
gboolean created_var_tmp = FALSE;
gboolean created_var_lib_rpmstate = FALSE;
glnx_autofd int stdout_fd = -1;
glnx_autofd int stderr_fd = -1;
Expand All @@ -308,29 +307,6 @@ run_script_in_bwrap_container (int rootfs_fd,
goto out;
}

/* We need to make the mount point in the case where we're doing
* package layering, since the host `/var` tree is empty. We
* *could* point at the real `/var`...but that seems
* unnecessary/dangerous to me. Daemons that need to perform data
* migrations should do them as part of their systemd units and not
* in %post.
*
* Another alternative would be to make a tmpfs with the compat
* symlinks.
*/
if (mkdirat (rootfs_fd, "var/tmp", 0755) < 0)
{
if (errno == EEXIST)
;
else
{
glnx_set_error_from_errno (error);
goto out;
}
}
else
created_var_tmp = TRUE;

/* And similarly for /var/lib/rpm-state */
if (var_lib_rpm_statedir)
{
Expand Down Expand Up @@ -455,8 +431,6 @@ run_script_in_bwrap_container (int rootfs_fd,
out:
glnx_tmpfile_clear (&buffered_output);
(void) unlinkat (rootfs_fd, postscript_path_host, 0);
if (created_var_tmp)
(void) unlinkat (rootfs_fd, "var/tmp", AT_REMOVEDIR);
if (created_var_lib_rpmstate)
(void) unlinkat (rootfs_fd, "var/lib/rpm-state", AT_REMOVEDIR);
return ret;
Expand Down

0 comments on commit 4023f94

Please sign in to comment.