fix: removed nix dependency and cephfs check, it's handled by systemd
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
@@ -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"
|
||||
-23
@@ -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<Vec<Member>, Box<dyn Error>> {
|
||||
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<bool, Box<dyn Error>> {
|
||||
|
||||
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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user