mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-03 13:11:31 +00:00
init: write 1.1.1.1 to resolv.conf if /etc exists
This commit is contained in:
@ -13,8 +13,9 @@ use std::net::Ipv4Addr;
|
|||||||
use std::os::fd::AsRawFd;
|
use std::os::fd::AsRawFd;
|
||||||
use std::os::linux::fs::MetadataExt;
|
use std::os::linux::fs::MetadataExt;
|
||||||
use std::os::unix::fs::{chroot, PermissionsExt};
|
use std::os::unix::fs::{chroot, PermissionsExt};
|
||||||
use std::path::Path;
|
use std::path::{Path, PathBuf};
|
||||||
use std::ptr::addr_of_mut;
|
use std::ptr::addr_of_mut;
|
||||||
|
use std::str::FromStr;
|
||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use sys_mount::{FilesystemType, Mount, MountFlags};
|
use sys_mount::{FilesystemType, Mount, MountFlags};
|
||||||
@ -324,6 +325,14 @@ impl ContainerInit {
|
|||||||
} else {
|
} else {
|
||||||
warn!("unable to find link named {}", network.link);
|
warn!("unable to find link named {}", network.link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let etc = PathBuf::from_str("/etc")?;
|
||||||
|
if !etc.exists() {
|
||||||
|
fs::create_dir(etc)?;
|
||||||
|
}
|
||||||
|
let resolv = PathBuf::from_str("/etc/resolv.conf")?;
|
||||||
|
fs::write(resolv, "nameserver 1.1.1.1\n")?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user