diff --git a/src/main.rs b/src/main.rs index 6a1bc08..19e4949 100644 --- a/src/main.rs +++ b/src/main.rs @@ -174,6 +174,13 @@ const SYSTEM_MOUNTS: &[MountInfo] = &[ flags: (libc::MS_NOSUID | libc::MS_NODEV) as usize, fsdata: "", }, + MountInfo { + source: "tmpfs", + target: "/var/lib/sudo", + fs_type: "tmpfs", + flags: (libc::MS_NOSUID | libc::MS_NODEV) as usize, + fsdata: "", + }, MountInfo { source: "tmpfs", target: "/var/lib/apt", @@ -329,6 +336,9 @@ fn generate_sudoers() -> io::Result<()> { if let Ok(user) = env::var("virtme_user") { content += &format!("{} ALL = (ALL) NOPASSWD: ALL\n", user); } + if !Path::new("/etc/sudoers").exists() { + utils::create_file("/etc/sudoers", 0o0440, "").unwrap_or_else(|_| {}); + } utils::create_file(fname, 0o0440, &content).ok(); utils::do_mount(fname, "/etc/sudoers", "", libc::MS_BIND as usize, ""); Ok(())