summaryrefslogtreecommitdiff
path: root/whrd/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'whrd/src/lib.rs')
-rw-r--r--[-rwxr-xr-x]whrd/src/lib.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/whrd/src/lib.rs b/whrd/src/lib.rs
index fb45f74..50c9ef8 100755..100644
--- a/whrd/src/lib.rs
+++ b/whrd/src/lib.rs
@@ -1,5 +1,6 @@
use std::io::Cursor;
-use std::path::PathBuf;
+
+#[cfg(unix)]
use coreutils_core::os::utmpx::*;
use crate::error::{WhereResult, EncodeDecodeResult, EncodeDecodeError};
@@ -34,6 +35,7 @@ pub struct SessionCollection {
}
impl SessionCollection {
+ #[cfg(unix)]
pub fn fetch() -> Self {
let inner: Vec<Session> = UtmpxSet::system()
.into_iter()
@@ -174,6 +176,7 @@ impl Session {
}
}
+#[cfg(unix)]
impl From<Utmpx> for Session {
fn from(utmpx: Utmpx) -> Self {
// BStr doesn't have a known size at compile time, so we can't use it instead of String
@@ -198,8 +201,8 @@ impl From<Utmpx> for Session {
// active when they are not.
let mut path = PathBuf::from("/dev");
path.push(utmpx.device_name().to_string());
- let active = utmpx.entry_type() == UtmpxKind::UserProcess && path.exists();
- let login_time = utmpx.timeval().tv_sec;
+ let active = utmpx.entry_type() == UtmpxKind::UserProcess && utmpx.is_active();
+ let login_time = utmpx.timeval().tv_sec as i64;
Self {
host: None,