mirror of
https://github.com/ostreedev/ostree.git
synced 2024-12-22 17:35:55 +03:00
generator: Exit if there's no /run/ostree
Currently if run in a container image under systemd, we will incorrectly synthesize a `var.mount` unit even if `ostree-prepare-root` hasn't run. The comment here said why we didn't do that before, but that's for the really legacy embedded-only "ostree-prepare-root-static" path, and even then I'm pretty sure it was wrong because the generator here only runs in the *real* root, and we should have `/run/ostree` at that point.
This commit is contained in:
parent
d1d8f4ab40
commit
b9ce0e8980
@ -251,18 +251,18 @@ _ostree_impl_system_generator (const char *normal_dir, const char *early_dir, co
|
|||||||
if (unlinkat (AT_FDCWD, INITRAMFS_MOUNT_VAR, 0) == 0)
|
if (unlinkat (AT_FDCWD, INITRAMFS_MOUNT_VAR, 0) == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
// If we're not booted via ostree, do nothing
|
||||||
|
if (!glnx_fstatat_allow_noent (AT_FDCWD, OTCORE_RUN_OSTREE, NULL, 0, error))
|
||||||
|
return FALSE;
|
||||||
|
if (errno == ENOENT)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
g_autofree char *cmdline = read_proc_cmdline ();
|
g_autofree char *cmdline = read_proc_cmdline ();
|
||||||
if (!cmdline)
|
if (!cmdline)
|
||||||
return glnx_throw (error, "Failed to read /proc/cmdline");
|
return glnx_throw (error, "Failed to read /proc/cmdline");
|
||||||
|
|
||||||
/* If we're installed on a system which isn't using OSTree for boot (e.g.
|
|
||||||
* package installed as a dependency for flatpak or whatever), silently
|
|
||||||
* exit so that we don't error, but at the same time work where switchroot
|
|
||||||
* is PID 1 (and so hasn't created /run/ostree-booted).
|
|
||||||
*/
|
|
||||||
g_autofree char *ostree_cmdline = otcore_find_proc_cmdline_key (cmdline, "ostree");
|
g_autofree char *ostree_cmdline = otcore_find_proc_cmdline_key (cmdline, "ostree");
|
||||||
if (!ostree_cmdline)
|
// SAFETY: If we have /run/ostree, then we must have the ostree= karg
|
||||||
return TRUE;
|
g_assert (ostree_cmdline);
|
||||||
|
|
||||||
if (!require_internal_units (normal_dir, early_dir, late_dir, error))
|
if (!require_internal_units (normal_dir, early_dir, late_dir, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Loading…
Reference in New Issue
Block a user