2020-11-24 20:58:05 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.samba-wsdd;
|
|
|
|
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
services.samba-wsdd = {
|
|
|
|
enable = mkEnableOption ''
|
|
|
|
Enable Web Services Dynamic Discovery host daemon. This enables (Samba) hosts, like your local NAS device,
|
|
|
|
to be found by Web Service Discovery Clients like Windows.
|
|
|
|
<note>
|
|
|
|
<para>If you use the firewall consider adding the following:</para>
|
|
|
|
<programlisting>
|
|
|
|
networking.firewall.allowedTCPPorts = [ 5357 ];
|
|
|
|
networking.firewall.allowedUDPPorts = [ 3702 ];
|
|
|
|
</programlisting>
|
|
|
|
</note>
|
|
|
|
'';
|
|
|
|
interface = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
example = "eth0";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Interface or address to use.";
|
2020-11-24 20:58:05 +00:00
|
|
|
};
|
|
|
|
hoplimit = mkOption {
|
|
|
|
type = types.nullOr types.int;
|
|
|
|
default = null;
|
|
|
|
example = 2;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Hop limit for multicast packets (default = 1).";
|
2020-11-24 20:58:05 +00:00
|
|
|
};
|
|
|
|
workgroup = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
example = "HOME";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Set workgroup name (default WORKGROUP).";
|
2020-11-24 20:58:05 +00:00
|
|
|
};
|
|
|
|
hostname = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
example = "FILESERVER";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Override (NetBIOS) hostname to be used (default hostname).";
|
2020-11-24 20:58:05 +00:00
|
|
|
};
|
|
|
|
domain = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Set domain name (disables workgroup).";
|
2020-11-24 20:58:05 +00:00
|
|
|
};
|
|
|
|
discovery = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Enable discovery operation mode.";
|
2020-11-24 20:58:05 +00:00
|
|
|
};
|
|
|
|
listen = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/run/wsdd/wsdd.sock";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Listen on path or localhost port in discovery mode.";
|
2020-11-24 20:58:05 +00:00
|
|
|
};
|
|
|
|
extraOptions = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ "--shortlog" ];
|
|
|
|
example = [ "--verbose" "--no-http" "--ipv4only" "--no-host" ];
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Additional wsdd options.";
|
2020-11-24 20:58:05 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.wsdd ];
|
|
|
|
|
|
|
|
systemd.services.samba-wsdd = {
|
|
|
|
description = "Web Services Dynamic Discovery host daemon";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
DynamicUser = true;
|
|
|
|
Type = "simple";
|
|
|
|
ExecStart = ''
|
|
|
|
${pkgs.wsdd}/bin/wsdd ${optionalString (cfg.interface != null) "--interface '${cfg.interface}'"} \
|
|
|
|
${optionalString (cfg.hoplimit != null) "--hoplimit '${toString cfg.hoplimit}'"} \
|
|
|
|
${optionalString (cfg.workgroup != null) "--workgroup '${cfg.workgroup}'"} \
|
|
|
|
${optionalString (cfg.hostname != null) "--hostname '${cfg.hostname}'"} \
|
|
|
|
${optionalString (cfg.domain != null) "--domain '${cfg.domain}'"} \
|
|
|
|
${optionalString cfg.discovery "--discovery --listen '${cfg.listen}'"} \
|
|
|
|
${escapeShellArgs cfg.extraOptions}
|
|
|
|
'';
|
|
|
|
# Runtime directory and mode
|
|
|
|
RuntimeDirectory = "wsdd";
|
|
|
|
RuntimeDirectoryMode = "0750";
|
|
|
|
# Access write directories
|
|
|
|
UMask = "0027";
|
|
|
|
# Capabilities
|
|
|
|
CapabilityBoundingSet = "";
|
|
|
|
# Security
|
|
|
|
NoNewPrivileges = true;
|
|
|
|
# Sandboxing
|
|
|
|
ProtectSystem = "strict";
|
|
|
|
ProtectHome = true;
|
|
|
|
PrivateTmp = true;
|
|
|
|
PrivateDevices = true;
|
|
|
|
PrivateUsers = false;
|
|
|
|
ProtectHostname = true;
|
|
|
|
ProtectClock = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
|
|
ProtectKernelModules = true;
|
|
|
|
ProtectKernelLogs = true;
|
|
|
|
ProtectControlGroups = true;
|
2020-12-25 13:55:36 +00:00
|
|
|
RestrictAddressFamilies = [ "AF_UNIX" "AF_INET" "AF_INET6" "AF_NETLINK" ];
|
2020-11-24 20:58:05 +00:00
|
|
|
RestrictNamespaces = true;
|
|
|
|
LockPersonality = true;
|
|
|
|
MemoryDenyWriteExecute = true;
|
|
|
|
RestrictRealtime = true;
|
|
|
|
RestrictSUIDSGID = true;
|
|
|
|
PrivateMounts = true;
|
|
|
|
# System Call Filtering
|
|
|
|
SystemCallArchitectures = "native";
|
2021-05-20 23:08:51 +00:00
|
|
|
SystemCallFilter = "~@cpu-emulation @debug @mount @obsolete @privileged @resources";
|
2020-11-24 20:58:05 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|