Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,18 @@ pub(crate) fn require_root() -> Result<()> {
/// A few process changes that need to be made for writing.
#[context("Preparing for write")]
pub(crate) async fn prepare_for_write() -> Result<()> {
crate::cli::require_root()?;
if ostree_ext::container_utils::is_ostree_container()? {
anyhow::bail!(
"Detected container (ostree base); this command requires a booted host system."
);
}
if ostree_ext::container_utils::running_in_container() {
anyhow::bail!("Detected container; this command requires a booted host system.");
}
if !std::path::Path::new("/run/ostree-booted").exists() {
anyhow::bail!("This command requires an ostree-booted host system");
}
crate::cli::require_root()?;
ensure_self_unshared_mount_namespace().await?;
if crate::lsm::selinux_enabled()? && !crate::lsm::selinux_ensure_install()? {
tracing::warn!("Do not have install_t capabilities");
Expand Down
12 changes: 1 addition & 11 deletions lib/src/privtests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,12 @@ pub(crate) fn impl_run_container() -> Result<()> {
assert!(!st.success());
let stderr = String::from_utf8(o.stderr)?;
assert!(
stderr.contains("This command requires full root privileges"),
stderr.contains("this command requires a booted host system"),
"stderr: {stderr}",
);
}
println!("ok upgrade/update are errors in container");

let o = Command::new("runuser")
.args(["-u", "bin", "bootc", "upgrade"])
.output()?;
assert!(!o.status.success());
let stderr = String::from_utf8(o.stderr)?;
assert!(
stderr.contains("requires root privileges"),
"stderr: {stderr}"
);

let config = cmd!(sh, "bootc install print-configuration").read()?;
let mut config: InstallConfiguration =
serde_json::from_str(&config).context("Parsing install config")?;
Expand Down