(user: User)
| 36 | |
| 37 | impl From<User> for PasswdData { |
| 38 | fn from(user: User) -> Self { |
| 39 | // this is just a pain... |
| 40 | let cstr_lossy = |s: alloc::ffi::CString| { |
| 41 | s.into_string() |
| 42 | .unwrap_or_else(|e| e.into_cstring().to_string_lossy().into_owned()) |
| 43 | }; |
| 44 | let pathbuf_lossy = |p: std::path::PathBuf| { |
| 45 | p.into_os_string() |
| 46 | .into_string() |
| 47 | .unwrap_or_else(|s| s.to_string_lossy().into_owned()) |
| 48 | }; |
| 49 | PasswdData { |
| 50 | pw_name: user.name, |
| 51 | pw_passwd: cstr_lossy(user.passwd), |
| 52 | pw_uid: user.uid.as_raw(), |
| 53 | pw_gid: user.gid.as_raw(), |
| 54 | pw_gecos: cstr_lossy(user.gecos), |
| 55 | pw_dir: pathbuf_lossy(user.dir), |
| 56 | pw_shell: pathbuf_lossy(user.shell), |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | #[pyfunction] |
nothing calls this directly
no test coverage detected