Commit 94669901 authored by Heinz N. Gies's avatar Heinz N. Gies

Use brand for login

parent e6d0b18e
Pipeline #12368801 passed with stage
in 2 minutes and 43 seconds
......@@ -48,7 +48,7 @@ impl Step {
).collect()
}
#[cfg(not(target_os = "freebsd"))]
pub fn run(&self, jail: &Jail, conf: &Config) -> Result<Output, std::io::Error> {
pub fn output(&self, jail: &Jail, conf: &Config) -> Result<Output, std::io::Error> {
let command = self.cmd(jail, conf);
let args = self.args(jail, conf);
debug!("[BRAND] Running command";
......@@ -59,7 +59,7 @@ impl Step {
Command::new("echo").args(args).output()
}
#[cfg(target_os = "freebsd")]
pub fn run(&self, jail: &Jail, conf: &Config) -> Result<Output, std::io::Error> {
pub fn output(&self, jail: &Jail, conf: &Config) -> Result<Output, std::io::Error> {
let command = self.cmd(jail, conf);
let args = self.args(jail, conf);
debug!("[BRAND] Running command";
......@@ -69,6 +69,29 @@ impl Step {
"brand" => jail.config.brand.as_str());
Command::new(command).args(args).output()
}
#[cfg(not(target_os = "freebsd"))]
pub fn spawn(&self, jail: &Jail, conf: &Config) -> Result<std::process::Child, std::io::Error> {
let command = self.cmd(jail, conf);
let args = self.args(jail, conf);
debug!("[BRAND] Running command";
"command" => command.clone(),
"args" => args.clone().join(" "),
"scope" => "brand",
"brand" => jail.config.brand.as_str());
Command::new("echo").args(args).spawn()
}
#[cfg(target_os = "freebsd")]
pub fn spawn(&self, jail: &Jail, conf: &Config) -> Result<std::process::Child, std::io::Error> {
let command = self.cmd(jail, conf);
let args = self.args(jail, conf);
debug!("[BRAND] Running command";
"command" => command.clone(),
"args" => args.clone().join(" "),
"scope" => "brand",
"brand" => jail.config.brand.as_str());
Command::new(command).args(args).spawn()
}
pub fn to_string(&self, jail: &Jail, conf: &Config) -> String {
let mut cmd = self.cmd(jail, conf);
cmd.push(' ');
......
......@@ -62,7 +62,7 @@ impl<'a> Jail<'a> {
self.set_rctl()?;
let brand = self.brand(config)?;
brand.init.run(self, config).expect("brand init failed");
brand.init.output(self, config).expect("brand init failed");
// self.mount_devfs()?;
// if self.config.brand == "lx-jail" {
// self.mount_lxfs()?;
......@@ -98,7 +98,7 @@ impl<'a> Jail<'a> {
debug!("Dleting jail"; "vm" => self.idx.uuid.hyphenated().to_string());
let brand = self.brand(config)?;
brand.halt.run(self, config).expect("brand halt failed");;
brand.halt.output(self, config).expect("brand halt failed");;
let output = Command::new(JAIL)
.args(&["-r", self.idx.uuid.hyphenated().to_string().as_str()])
......@@ -224,7 +224,7 @@ impl<'a> Jail<'a> {
exec_start.push_str("/sbin/ifconfig lo0 127.0.0.1 up; ");
};
brand.init.run(self, config).expect("brand init failed");
brand.init.output(self, config).expect("brand init failed");
// inner jail configuration
exec_start.push_str(brand.boot.to_string(self, config).as_str());
......
......@@ -54,8 +54,6 @@ use std::fs::File;
use aud::{Failure, Adventure, Saga};
use std::process::Command;
mod brand;
mod zfs;
mod images;
......@@ -76,12 +74,6 @@ use config::Config;
mod errors;
use errors::GenericError;
#[cfg(target_os = "freebsd")]
static JEXEC: &'static str = "jexec";
#[cfg(not(target_os = "freebsd"))]
static JEXEC: &'static str = "echo";
/// Custom Drain logic
struct RuntimeLevelFilter<D> {
drain: D,
......@@ -316,10 +308,9 @@ fn console(conf: &Config, matches: &clap::ArgMatches) -> Result<i32, Box<Error>>
println!("The vm is not running");
Err(GenericError::bx("VM is not running"))
}
Ok(Jail { inner: Some(jid), .. }) => {
let mut child = Command::new(JEXEC)
.args(&[jid.id.to_string().as_str(), "/bin/csh"])
.spawn()
Ok(jail) => {
let brand = jail.brand(conf)?;
let mut child = brand.login.spawn(&jail, conf)
.expect("failed to execute jexec");
let ecode = child.wait().expect("failed to wait on child");
if ecode.success() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment