git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/tor: don't do privoxy stuff by default

It's very surprising that services.tor.client.enable would set services.privoxy.enable. This violates the principle of least astonishment, because it's Privoxy that can integrate with Tor, rather than the other way around. So this patch moves the Privoxy Tor integration to the Privoxy module, and it also disables it by default. This change is documented in the release notes. Reported-by: V <v@anomalous.eu>

commite17d4b05a12fe1b567ef4d55d2f01c23ff48228d authorAlyssa Ross <hi@alyssa.is> dateTue 15 Dec 2020, 21:30 (6 years ago) parentcd75006
3 files changed+34−30
nixos/doc/manual/release-notes/rl-2103.xml+13 nixos/modules/services/networking/privoxy.nix+18−2 nixos/modules/services/security/tor.nix+3−28
nixos/doc/manual/release-notes/rl-2103.xml+13
@@ -265,6 +265,19 @@
265265 located in <literal>/run/rspamd</literal> instead of <literal>/run</literal>.
266266 </para>
267267 </listitem>
268+ <listitem>
269+ <para>
270+ Enabling the Tor client no longer silently also enables and
271+ configures Privoxy, and the
272+ <varname>services.tor.client.privoxy.enable</varname> option has
273+ been removed. To enable Privoxy, and to configure it to use
274+ Tor's faster port, use the following configuration:
275+ </para>
276+ <programlisting>
277+ <xref linkend="opt-services.privoxy.enable" /> = true;
278+ <xref linkend="opt-services.privoxy.enableTor" /> = true;
279+ </programlisting>
280+ </listitem>
268281 </itemizedlist>
269282 </section>
270283
nixos/modules/services/networking/privoxy.nix+18−2
@@ -8,15 +8,22 @@ let
88
99 cfg = config.services.privoxy;
1010
11− confFile = pkgs.writeText "privoxy.conf" ''
11+ confFile = pkgs.writeText "privoxy.conf" (''
1212 user-manual ${privoxy}/share/doc/privoxy/user-manual
1313 confdir ${privoxy}/etc/
1414 listen-address ${cfg.listenAddress}
1515 enable-edit-actions ${if (cfg.enableEditActions == true) then "1" else "0"}
1616 ${concatMapStrings (f: "actionsfile ${f}\n") cfg.actionsFiles}
1717 ${concatMapStrings (f: "filterfile ${f}\n") cfg.filterFiles}
18+ '' + optionalString cfg.enableTor ''
19+ forward-socks4a / ${config.services.tor.client.socksListenAddressFaster} .
20+ toggle 1
21+ enable-remote-toggle 0
22+ enable-edit-actions 0
23+ enable-remote-http-toggle 0
24+ '' + ''
1825 ${cfg.extraConfig}
19− '';
26+ '');
2027
2128in
2229
@@ -72,6 +79,15 @@ in
7279 '';
7380 };
7481
82+ enableTor = mkOption {
83+ type = types.bool;
84+ default = false;
85+ description = ''
86+ Whether to configure Privoxy to use Tor's faster SOCKS port,
87+ suitable for HTTP.
88+ '';
89+ };
90+
7591 extraConfig = mkOption {
7692 type = types.lines;
7793 default = "" ;
nixos/modules/services/security/tor.nix+3−28
@@ -107,6 +107,9 @@ let
107107in
108108{
109109 imports = [
110+ (mkRemovedOptionModule [ "services" "tor" "client" "privoxy" "enable" ] ''
111+ Use services.privoxy.enable and services.privoxy.enableTor instead.
112+ '')
110113 (mkRenamedOptionModule [ "services" "tor" "relay" "portSpec" ] [ "services" "tor" "relay" "port" ])
111114 (mkRemovedOptionModule [ "services" "tor" "relay" "isBridge" ] "Use services.tor.relay.role instead.")
112115 (mkRemovedOptionModule [ "services" "tor" "relay" "isExit" ] "Use services.tor.relay.role instead.")
@@ -270,23 +273,6 @@ in
270273 description = "List of suffixes to use with automapHostsOnResolve";
271274 };
272275 };
273−
274− privoxy.enable = mkOption {
275− type = types.bool;
276− default = true;
277− description = ''
278− Whether to enable and configure the system Privoxy to use Tor's
279− faster port, suitable for HTTP.
280−
281− To have anonymity, protocols need to be scrubbed of identifying
282− information, and this can be accomplished for HTTP by Privoxy.
283−
284− Privoxy can also be useful for KDE torification. A good setup would be:
285− setting SOCKS proxy to the default Tor port, providing maximum
286− circuit isolation where possible; and setting HTTP proxy to Privoxy
287− to route HTTP traffic over faster, but less isolated port.
288− '';
289− };
290276 };
291277
292278 relay = {
@@ -784,16 +770,5 @@ in
784770 };
785771
786772 environment.systemPackages = [ cfg.package ];
787−
788− services.privoxy = mkIf (cfg.client.enable && cfg.client.privoxy.enable) {
789− enable = true;
790− extraConfig = ''
791− forward-socks4a / ${cfg.client.socksListenAddressFaster} .
792− toggle 1
793− enable-remote-toggle 0
794− enable-edit-actions 0
795− enable-remote-http-toggle 0
796− '';
797− };
798773 };
799774}