finger: provide server with more arguments
Build and test / check (push) Failing after 45s
Build and test / build (push) Successful in 1m40s
Build and test / test (push) Successful in 2m6s
Build and test / docs (push) Successful in 3m58s

This commit is contained in:
2026-04-23 16:07:53 +09:00
parent 8920362d49
commit 5f8fc7944b
3 changed files with 100 additions and 9 deletions
+24 -2
View File
@@ -6,15 +6,37 @@ use std::{
use chrono::{DateTime, Duration, Timelike, Utc};
use nix::sys::stat::stat;
use serde::{Deserialize, Serialize};
use users::all_users;
use uucore::utmpx::Utmpx;
use crate::proto::finger_protocol::{FingerResponseUserEntry, FingerResponseUserSession};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum FingerRequestNetworking {
Any,
IPv4Only,
IPv6Only,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum FingerRequestInfo {
ShortHost {
restrict_gecos: bool,
},
ShortOffice {
restrict_gecos: bool,
},
Long {
prevent_files: bool,
},
}
/// Search for users whose username or full name contains the search string.
pub fn search_for_user(
search_string: &str,
dont_search_fullnames: bool,
match_fullnames: bool,
_request_info: &FingerRequestInfo,
) -> Vec<anyhow::Result<FingerResponseUserEntry>> {
(unsafe { all_users() })
.filter_map(|user| {
@@ -42,7 +64,7 @@ pub fn search_for_user(
.to_string();
let matches_username = username.contains(search_string);
let matches_fullname = !dont_search_fullnames && full_name.contains(search_string);
let matches_fullname = match_fullnames && full_name.contains(search_string);
if matches_username || matches_fullname {
match get_local_user(&username) {
Ok(Some(user_entry)) => Some(Ok(user_entry)),