walld: add enable toggle in config

This commit is contained in:
2026-07-30 21:24:28 +09:00
parent 58f711cbef
commit ed72963e6c
4 changed files with 57 additions and 15 deletions
+6
View File
@@ -190,6 +190,12 @@ in {
# };
# };
};
walld = {
enable = lib.mkEnableOption "the walld service" // {
default = true;
};
};
};
};
default = { };
+3
View File
@@ -138,6 +138,7 @@ async fn main() -> anyhow::Result<()> {
whod_status_store.clone(),
config.rwhod.enable,
config.fingerd.enable,
config.walld.enable,
finger_ignore_list,
client_server_token,
));
@@ -201,6 +202,7 @@ async fn client_server(
whod_status_store: RwhodStatusStore,
rwhod_enabled: bool,
fingerd_enabled: bool,
walld_enabled: bool,
finger_ignore_list: Option<IgnoreList>,
startup_token: CancellationToken,
) -> anyhow::Result<()> {
@@ -214,6 +216,7 @@ async fn client_server(
whod_status_store,
rwhod_enabled,
fingerd_enabled,
walld_enabled,
finger_ignore_list,
);
+9
View File
@@ -21,6 +21,9 @@ pub struct Config {
/// Configuration for the fingerd server.
pub fingerd: FingerdConfig,
/// Configuration for the walld server.
pub walld: WalldConfig,
/// Path to the Unix domain socket for client-server communication.
///
/// If left as `None`, the server expects to be served a file descriptor to the socket named 'client'.
@@ -115,3 +118,9 @@ pub struct FingerdConfig {
/// Path to the ignore list for users that should be hidden from fingerd.
pub ignore_list_path: Option<PathBuf>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct WalldConfig {
/// Enable or disable the walld server functionality.
pub enable: bool,
}
+39 -15
View File
@@ -51,6 +51,7 @@ pub struct VarlinkRoowhoo2ClientServer {
whod_status_store: RwhodStatusStore,
rwhod_enabled: bool,
fingerd_enabled: bool,
walld_enabled: bool,
finger_ignore_list: Option<IgnoreList>,
polkit: Option<PolkitAuthority>,
}
@@ -60,6 +61,7 @@ impl VarlinkRoowhoo2ClientServer {
whod_status_store: RwhodStatusStore,
rwhod_enabled: bool,
fingerd_enabled: bool,
walld_enabled: bool,
finger_ignore_list: Option<IgnoreList>,
polkit: Option<PolkitAuthority>,
) -> Self {
@@ -67,6 +69,7 @@ impl VarlinkRoowhoo2ClientServer {
whod_status_store,
rwhod_enabled,
fingerd_enabled,
walld_enabled,
finger_ignore_list,
polkit,
}
@@ -280,7 +283,14 @@ impl zlink::Service<UnixStream> for VarlinkRoowhoo2ClientServer {
nobanner,
timeout_secs,
}) => {
// TODO: add walld toggle to config
if !self.walld_enabled {
return (
MethodReply::Error(VarlinkReplyError::Walld(
VarlinkWalldClientError::Disabled,
)),
Default::default(),
);
}
// TODO: ensure the outer duration is more than the inner duration.
let result = match timeout(
@@ -329,7 +339,15 @@ impl zlink::Service<UnixStream> for VarlinkRoowhoo2ClientServer {
target_tty,
message,
}) => {
// TODO: add walld toggle to config
if !self.walld_enabled {
return (
MethodReply::Error(VarlinkReplyError::Walld(
VarlinkWalldClientError::Disabled,
)),
Default::default(),
);
}
let result = match timeout(
Duration::from_secs(2),
handle_write_request(
@@ -378,21 +396,26 @@ pub async fn varlink_client_server_task(
whod_status_store: RwhodStatusStore,
rwhod_enabled: bool,
fingerd_enabled: bool,
walld_enabled: bool,
finger_ignore_list: Option<IgnoreList>,
) -> anyhow::Result<()> {
let polkit = match timeout(Duration::from_secs(5), PolkitAuthority::connect()).await {
Ok(Ok(polkit)) => Some(polkit),
Ok(Err(e)) => {
tracing::warn!(
"Failed to connect to polkit; Wall/Write requests will be denied: {e:#}"
);
None
}
Err(_) => {
tracing::warn!(
"Timed out connecting to polkit after 5 seconds; Wall/Write requests will be denied"
);
None
let polkit = if !walld_enabled {
None
} else {
match timeout(Duration::from_secs(5), PolkitAuthority::connect()).await {
Ok(Ok(polkit)) => Some(polkit),
Ok(Err(e)) => {
tracing::warn!(
"Failed to connect to polkit; Wall/Write requests will be denied: {e:#}"
);
None
}
Err(_) => {
tracing::warn!(
"Timed out connecting to polkit after 5 seconds; Wall/Write requests will be denied"
);
None
}
}
};
@@ -400,6 +423,7 @@ pub async fn varlink_client_server_task(
whod_status_store,
rwhod_enabled,
fingerd_enabled,
walld_enabled,
finger_ignore_list,
polkit,
);