mirror of
https://github.com/uutils/rust-users.git
synced 2026-06-10 15:48:37 -07:00
Add missing impl for BSD extras
This commit is contained in:
+28
-2
@@ -455,26 +455,52 @@ pub mod os {
|
||||
#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly"))]
|
||||
pub mod bsd {
|
||||
use std::path::Path;
|
||||
use libc::{uid_t, gid_t};
|
||||
use super::super::{c_passwd, from_raw_buf};
|
||||
use libc::{uid_t, gid_t, time_t};
|
||||
use super::super::{c_passwd, from_raw_buf, User};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct UserExtras {
|
||||
pub extras: super::unix::UserExtras,
|
||||
pub change: time_t,
|
||||
pub expire: time_t,
|
||||
}
|
||||
|
||||
impl UserExtras {
|
||||
pub unsafe fn from_passwd(passwd: c_passwd) -> UserExtras {
|
||||
UserExtras {
|
||||
change: passwd.pw_change,
|
||||
expire: passwd.pw_expire,
|
||||
extras: super::unix::UserExtras::from_passwd(passwd),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl super::unix::UserExt for User {
|
||||
fn home_dir(&self) -> &Path {
|
||||
Path::new(&self.extras.extras.home_dir)
|
||||
}
|
||||
|
||||
fn with_home_dir(mut self, home_dir: &str) -> User {
|
||||
self.extras.extras.home_dir = home_dir.to_owned();
|
||||
self
|
||||
}
|
||||
|
||||
fn shell(&self) -> &Path {
|
||||
Path::new(&self.extras.extras.shell)
|
||||
}
|
||||
|
||||
fn with_shell(mut self, shell: &str) -> User {
|
||||
self.extras.extras.shell = shell.to_owned();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for UserExtras {
|
||||
fn default() -> UserExtras {
|
||||
UserExtras {
|
||||
extras: super::unix::UserExtras::default(),
|
||||
change: 0,
|
||||
expire: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user