Симптом (ревью 2026-11-29): samba отдавала шару `root` с `path = "/"` и
`force user = "root"` — любой, кто знает учётку владельца, получал запись
на весь корень; для ssh стоял `PermitRootLogin = "yes"`, то есть root мог
войти паролем (сам пароль запрещён `PasswordAuthentication = false`, но
разрешение на парольный вход для root в конфиге оставалось явным).
Решение владельца: «шару root убирай, я в целом ей почти не пользовался»;
«Только ключ. Пароль запрещаем».
Правка: блок шары `root` удалён целиком (шары `nixos` и `oqyude` не
тронуты); `PermitRootLogin = "prohibit-password"`, `PasswordAuthentication
= false` оставлен.
Проверено (nix eval, sapphira):
- `services.samba.settings` → attrNames `["global" "nixos" "oqyude"]`;
- `services.openssh.settings` → `{prl:"prohibit-password", pwa:false}`.
86 lines
2.5 KiB
Nix
86 lines
2.5 KiB
Nix
{
|
|
config,
|
|
inputs,
|
|
lib,
|
|
pkgs,
|
|
xlib,
|
|
...
|
|
}:
|
|
let
|
|
storage = xlib.helpers.mkServiceStorage {
|
|
name = "samba";
|
|
user = "root";
|
|
group = "root";
|
|
};
|
|
in
|
|
{
|
|
services = {
|
|
samba-wsdd = {
|
|
enable = true;
|
|
openFirewall = true;
|
|
hostname = "sapphira";
|
|
discovery = true;
|
|
};
|
|
samba = {
|
|
enable = true;
|
|
# package = pkgs.samba4Full;
|
|
nmbd = {
|
|
enable = true;
|
|
};
|
|
settings = {
|
|
global = {
|
|
"invalid users" = [ ];
|
|
"passwd program" = "/run/wrappers/bin/passwd %u";
|
|
security = "user";
|
|
};
|
|
nixos = {
|
|
"path" = "/etc/nixos";
|
|
"browseable" = "yes";
|
|
"read only" = "no";
|
|
"valid users" = "${xlib.device.username}";
|
|
"guest ok" = "no";
|
|
"writable" = "yes";
|
|
"create mask" = 755;
|
|
"directory mask" = 755;
|
|
"force user" = "${xlib.device.username}";
|
|
"force group" = "users";
|
|
};
|
|
"${xlib.device.username}" = {
|
|
"path" = "${xlib.dirs.user-home}";
|
|
"browseable" = "yes";
|
|
"read only" = "no";
|
|
"valid users" = "${xlib.device.username}";
|
|
"guest ok" = "no";
|
|
"writable" = "yes";
|
|
"create mask" = 700;
|
|
"directory mask" = 700;
|
|
"force user" = "${xlib.device.username}";
|
|
"force group" = "users";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
systemd = storage.systemd // {
|
|
# The samba file server is the unit `samba-smbd` (nixpkgs names it that
|
|
# way; there is NO unit called `samba`). `systemd.services.samba` would
|
|
# render a phantom unit with no ExecStart → systemd refuses to start it
|
|
# (ADR-0004).
|
|
#
|
|
# `unitConfig` → `[Unit]`: `ConditionPathIsMountPoint` is a unit-level
|
|
# directive and is ignored by systemd in `[Service]` (T4/R1.2).
|
|
#
|
|
# mkIf guard (2026-10-30): without it, turning the file server off
|
|
# (services.samba.enable = false) left the unit defined with ONLY
|
|
# `unitConfig` and no ExecStart — the very phantom ADR-0004 describes.
|
|
# systemd then refuses to start it ("Service has no ExecStart=… Refusing.").
|
|
# It bit us for real while proving modules/server/samba-ad.nix: the AD DC
|
|
# and the file server cannot both hold TCP/445, so the file server has to
|
|
# be switchable off. With services.samba.enable = true (every host today)
|
|
# this guard changes nothing.
|
|
services."samba-smbd" = lib.mkIf config.services.samba.enable {
|
|
unitConfig = xlib.helpers.mkStorageGuard xlib;
|
|
};
|
|
};
|
|
}
|