Skip to content

Commit

Permalink
feat(cfg/auth): Auth.add_to_chroot()
Browse files Browse the repository at this point in the history
  • Loading branch information
madonuko committed Jul 18, 2024
1 parent 0a68a40 commit 144d6f9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cfg/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl Auth {
shadow
}

pub fn add_user(&self) -> Result<(), std::io::Error> {
pub fn add_user(&self) -> std::io::Result<()> {
let mut cmd = std::process::Command::new("useradd");
cmd.arg(&self.username);
if let Some(shell) = &self.shell {
Expand All @@ -69,4 +69,10 @@ impl Auth {
}
cmd.output().map(|_| ())
}

#[tracing::instrument]
pub fn add_to_chroot(&self, chroot: &std::path::Path) -> std::io::Result<()> {
tracing::debug!("Adding user to chroot");
tiffin::Container::new(chroot.to_owned()).run(|| self.add_user()).and_then(|r| r)
}
}

0 comments on commit 144d6f9

Please sign in to comment.