diff --git a/Cargo.toml b/Cargo.toml index 1f84299..9a57d4d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,6 @@ edition = "2024" [dependencies] ldap3 = { version = "0.12", default-features = false, features = ["sync", "tls-rustls-ring"] } -nix = { version = "0.29", features = ["fs"] } serde = { version = "1", features = ["derive"] } toml = "1.1" diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..b3abc00 --- /dev/null +++ b/config.toml @@ -0,0 +1,7 @@ +# Belongs in /etc/loading-program/ +ldap_uri = "ldaps://1337.berkeley.edu" +bind_dn = "CN=ldapbind,OU=Services,OU=Lab,DC=1337,DC=berkeley,DC=edu" +bind_password_file = "/etc/loading-program/ldapbind.secret" +base_dn = "OU=Users,OU=Lab,DC=1337,DC=berkeley,DC=edu" +group_dn = "CN=lab-committee,OU=Groups,OU=Lab,DC=1337,DC=berkeley,DC=edu" +homes_dir = "/mnt/stockroom/homes" diff --git a/src/main.rs b/src/main.rs index 555f739..841770f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,6 @@ use std::process::exit; use std::time::Duration; use ldap3::{ldap_escape, LdapConn, LdapConnSettings, Scope, SearchEntry}; -use nix::sys::statfs::statfs; use serde::Deserialize; const CEPH_SUPER_MAGIC: i64 = 0x00C3_6400; @@ -37,19 +36,12 @@ struct Config { homes_dir: PathBuf, #[serde(default = "default_skel")] skel_dir: PathBuf, - /// Refuse to run unless homes_dir is on CephFS - #[serde(default = "default_true")] - require_cephfs: bool, } fn default_skel() -> PathBuf { PathBuf::from("/etc/skel") } -fn default_true() -> bool { - true -} - struct Member { sam: String, dir_name: String, @@ -132,13 +124,6 @@ fn fetch_members(cfg: &Config) -> Result, Box> { Ok(members) } -fn is_cephfs(path: &Path) -> bool { - match statfs(path) { - Ok(s) => s.filesystem_type().0 as i64 == CEPH_SUPER_MAGIC, - Err(_) => false, - } -} - /// Recursively copy `src` into the existing directory `dst`, chowning every /// entry (without following symlinks) to uid:gid. fn copy_skel(src: &Path, dst: &Path, uid: u32, gid: u32) -> io::Result<()> { @@ -207,14 +192,6 @@ fn run() -> Result> { let cfg: Config = toml::from_str(&fs::read_to_string(&config_path)?)?; - if cfg.require_cephfs && !is_cephfs(&cfg.homes_dir) { - return Err(format!( - "{} is not on CephFS; refusing to create directories", - cfg.homes_dir.display() - ) - .into()); - } - let members = fetch_members(&cfg)?; println!("{} eligible member(s) found", members.len());