fn spawn_dhcpd() -> Result<rexpect::session::PtyReplSession> {
    // apparmor prevents reading of ./tests/dhcpd.conf for dhcpd
    // on Ubuntu, so we make sure it is disabled:
    let o = process::Command::new("sudo")
        .args(&["service", "apparmor", "teardown"])
        .output();
    if o.is_err() {
        match o.unwrap_err().kind() {
            ErrorKind::NotFound => println!("AppArmor not found"),
            _ => panic!("failed to disable apparmor"),
        }
    }
    let _o = process::Command::new("sudo")
        .args(&["killall", "dhcpd"])
        .output()
        .expect("failed to shut down dhcpd");

    // Spawn a bash session for dhcpd, otherwise it seems we
    // can't kill the process since we do not run as root
    let mut b = spawn_bash(Some(45_000))?;
    b.send_line("sudo dhcpd -f -d tap0 --no-pid -cf ./tests/dhcpd.conf")?;
    Ok(b)
}
/// Spawns a DHCP server on our host
///
/// It uses our dhcpd config and listens on the tap0 interface
/// (that we set up in our run.py script).
Spawns a DHCP server on our host
It uses our dhcpd config and listens on the tap0 interface
(that we set up in our run.py script).
Spawns a DHCP server on our host It uses our dhcpd config and listens on the tap0 interface ( that we set up in our run . py script ) .
fn spawn_dhcpd() -> Result<rexpect::session::PtyReplSession> {
    // apparmor prevents reading of ./tests/dhcpd.conf for dhcpd
    // on Ubuntu, so we make sure it is disabled:
    let o = process::Command::new("sudo")
        .args(&["service", "apparmor", "teardown"])
        .output();
    if o.is_err() {
        match o.unwrap_err().kind() {
            ErrorKind::NotFound => println!("AppArmor not found"),
            _ => panic!("failed to disable apparmor"),
        }
    }
    let _o = process::Command::new("sudo")
        .args(&["killall", "dhcpd"])
        .output()
        .expect("failed to shut down dhcpd");
    // Spawn a bash session for dhcpd, otherwise it seems we
    // can't kill the process since we do not run as root
    let mut b = spawn_bash(Some(45_000))?;
    b.send_line("sudo dhcpd -f -d tap0 --no-pid -cf ./tests/dhcpd.conf")?;
    Ok(b)
}
fn spawn_dhcpd ( ) -> Result < rexpect :: session :: PtyReplSession > { // apparmor prevents reading of ./tests/dhcpd.conf for dhcpd // on Ubuntu, so we make sure it is disabled: let o = process :: Command :: new ( " " ) . args ( & [ " " , " " , " " ] ) . output ( ) ; if o . is_err ( ) { match o . unwrap_err ( ) . kind ( ) { ErrorKind :: NotFound => println ! ( " " ) , _ => panic ! ( " " ) , } } let _o = process :: Command :: new ( " " ) . args ( & [ " " , " " ] ) . output ( ) . expect ( " " ) ; // Spawn a bash session for dhcpd, otherwise it seems we // can't kill the process since we do not run as root let mut b = spawn_bash ( Some ( 45_000 ) ) ? ; b . send_line ( " " ) ? ; Ok ( b ) }
Spawns a DHCP server on our host
It uses our dhcpd config and listens on the tap0 interface
(that we set up in our run.py script).
Spawns a DHCP server on our host It uses our dhcpd config and listens on the tap0 interface ( that we set up in our run . py script ) .