Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #614 from cgwalters/fetch-usrlib-too
Browse files Browse the repository at this point in the history
Support /usr/lib/ostree/auth.json
  • Loading branch information
jeckersb authored Mar 27, 2024
2 parents 8d972c1 + 2d1aa89 commit e9b16f8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
16 changes: 14 additions & 2 deletions lib/src/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,34 @@ use std::path::{Path, PathBuf};
struct ConfigPaths {
persistent: PathBuf,
runtime: PathBuf,
system: Option<PathBuf>,
}

/// Get the runtime and persistent config directories. In the system (root) case, these
/// system(root) case: /run/ostree /etc/ostree
/// user(nonroot) case: /run/user/$uid/ostree ~/.config/ostree
/// system(root) case: /run/ostree /etc/ostree /usr/lib/ostree
/// user(nonroot) case: /run/user/$uid/ostree ~/.config/ostree <none>
fn get_config_paths() -> &'static ConfigPaths {
static PATHS: OnceCell<ConfigPaths> = OnceCell::new();
PATHS.get_or_init(|| {
let mut r = if rustix::process::getuid() == rustix::process::Uid::ROOT {
ConfigPaths {
persistent: PathBuf::from("/etc"),
runtime: PathBuf::from("/run"),
system: PathBuf::from("/usr/lib").into(),
}
} else {
ConfigPaths {
persistent: glib::user_config_dir(),
runtime: glib::user_runtime_dir(),
system: None,
}
};
let path = "ostree";
r.persistent.push(path);
r.runtime.push(path);
if let Some(system) = r.system.as_mut() {
system.push(path);
}
r
})
}
Expand All @@ -49,6 +55,12 @@ impl ConfigPaths {
if let Some(f) = crate::container_utils::open_optional(&persistent)? {
return Ok(Some((persistent, f)));
}
if let Some(mut system) = self.system.clone() {
system.push(p);
if let Some(f) = crate::container_utils::open_optional(&system)? {
return Ok(Some((system, f)));
}
}
Ok(None)
}
}
Expand Down
3 changes: 2 additions & 1 deletion man/ostree-container-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ The OSTree container stack uses the same file formats as **containers-auth(5)**
not the same locations.

When running as uid 0 (root), the tooling uses `/etc/ostree/auth.json` first, then looks
in `/run/ostree/auth.json`. For any other uid, the file paths used are in `${XDG_RUNTIME_DIR}/ostree/auth.json`.
in `/run/ostree/auth.json`, and finally checks `/usr/lib/ostree/auth.json`.
For any other uid, the file paths used are in `${XDG_RUNTIME_DIR}/ostree/auth.json`.

In the future, it is likely that a path that is supported for both "system podman"
usage and ostree will be added.
Expand Down

0 comments on commit e9b16f8

Please sign in to comment.