nixos/tor: expose control socket

This commit is contained in:
Jaka Hudoklin 2017-04-16 15:18:44 +02:00 committed by Jan Malakhovski
parent 273fd896bc
commit cb9c1c63c9

View File

@ -5,6 +5,7 @@ with lib;
let
cfg = config.services.tor;
torDirectory = "/var/lib/tor";
torRunDirectory = "/run/tor";
opt = name: value: optionalString (value != null) "${name} ${value}";
optint = name: value: optionalString (value != null && value != 0) "${name} ${toString value}";
@ -38,6 +39,7 @@ let
''}
${optint "ControlPort" cfg.controlPort}
${optionalString cfg.controlSocket.enable "ControlSocket ${torRunDirectory}/control GroupWritable RelaxDirModeCheck"}
''
# Client connection config
+ optionalString cfg.client.enable ''
@ -140,6 +142,17 @@ in
'';
};
controlSocket = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
Wheter to enable Tor control socket. Control socket is created
in <literal>${torRunDirectory}/control</literal>
'';
};
};
client = {
enable = mkOption {
type = types.bool;
@ -692,7 +705,7 @@ in
# Translated from the upstream contrib/dist/tor.service.in
preStart = ''
install -o tor -g tor -d ${torDirectory}/onion
install -o tor -g tor -d ${torDirectory}/onion ${torRunDirectory}
${pkgs.tor}/bin/tor -f ${torRcFile} --verify-config
'';
@ -716,7 +729,7 @@ in
DevicePolicy = "closed";
InaccessibleDirectories = "/home";
ReadOnlyDirectories = "/";
ReadWriteDirectories = torDirectory;
ReadWriteDirectories = [torDirectory torRunDirectory];
NoNewPrivileges = "yes";
};
};