From patchwork Mon Feb 15 23:04:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christine Lemmer-Webber X-Patchwork-Id: 27081 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 8F92827BC47; Mon, 15 Feb 2021 23:05:09 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id AEFD127BC45 for ; Mon, 15 Feb 2021 23:05:08 +0000 (GMT) Received: from localhost ([::1]:54136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBmvT-0005uI-RH for patchwork@mira.cbaines.net; Mon, 15 Feb 2021 18:05:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBmvO-0005u6-9U for guix-patches@gnu.org; Mon, 15 Feb 2021 18:05:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:55581) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBmvO-00019z-2A for guix-patches@gnu.org; Mon, 15 Feb 2021 18:05:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lBmvN-000090-Ru for guix-patches@gnu.org; Mon, 15 Feb 2021 18:05:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#46549] services: tor: Add control-socket? option. Resent-From: Christopher Lemmer Webber Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 15 Feb 2021 23:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 46549 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 46549@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.1613430261491 (code B ref -1); Mon, 15 Feb 2021 23:05:01 +0000 Received: (at submit) by debbugs.gnu.org; 15 Feb 2021 23:04:21 +0000 Received: from localhost ([127.0.0.1]:38894 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lBmui-00007q-02 for submit@debbugs.gnu.org; Mon, 15 Feb 2021 18:04:21 -0500 Received: from lists.gnu.org ([209.51.188.17]:55728) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lBmud-00007f-9f for submit@debbugs.gnu.org; Mon, 15 Feb 2021 18:04:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBmud-0005mm-4I for guix-patches@gnu.org; Mon, 15 Feb 2021 18:04:15 -0500 Received: from dustycloud.org ([50.116.34.160]:59736) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBmuU-0000xr-Cx for guix-patches@gnu.org; Mon, 15 Feb 2021 18:04:14 -0500 Received: from twig (localhost [127.0.0.1]) by dustycloud.org (Postfix) with ESMTPS id 6EDD726614 for ; Mon, 15 Feb 2021 18:04:04 -0500 (EST) User-agent: mu4e 1.4.13; emacs 27.1 From: Christopher Lemmer Webber Message-ID: <87czx1orvf.fsf@dustycloud.org> Date: Mon, 15 Feb 2021 18:04:04 -0500 MIME-Version: 1.0 Received-SPF: pass client-ip=50.116.34.160; envelope-from=cwebber@dustycloud.org; helo=dustycloud.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches This allows users to have an easy way to enable control sockets for Tor. Turning it on does so via a unix domain socket. Intentionally I did not add the localhost+port path because I feel unsure about the safety of that, and nobodey has yet demonstrated a need. I suppose another nice option might be to let the user specify a specific path, but we didn't allow that for the socks-sock, so I was too lazy to allow it here either. From b85d5d49678ae11fd5a855acddbc78be123d863c Mon Sep 17 00:00:00 2001 From: Christopher Lemmer Webber Date: Mon, 15 Feb 2021 17:57:04 -0500 Subject: [PATCH] services: tor: Add control-socket? option. * doc/guix.texi (Networking Services): Document new `control-socket?' option for `tor-configuration`. * gnu/services/networking.scm (): (tor-configuration->torrc): --- doc/guix.texi | 9 ++++++++- gnu/services/networking.scm | 13 +++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 535c98a453..81cc24e0e3 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -45,7 +45,7 @@ Copyright @copyright{} 2017 Federico Beffa@* Copyright @copyright{} 2017, 2018 Carlo Zancanaro@* Copyright @copyright{} 2017 Thomas Danckaert@* Copyright @copyright{} 2017 humanitiesNerd@* -Copyright @copyright{} 2017 Christopher Allan Webber@* +Copyright @copyright{} 2017, 2021 Christopher Lemmer Webber@* Copyright @copyright{} 2017, 2018, 2019, 2020 Marius Bakke@* Copyright @copyright{} 2017, 2019, 2020 Hartmut Goebel@* Copyright @copyright{} 2017, 2019, 2020, 2021 Maxim Cournoyer@* @@ -16578,6 +16578,13 @@ If you want to customize the SOCKS socket in more detail, leave @end table @end deftp +@item @code{control-socket?} (default: @code{#f}) +Whether or not to provide a ``control socket'' by which Tor can be +controlled to, for instance, dynamically instantiate tor onion services. +If @code{#t}, Tor will listen for control commands on the UNIX domain socket +@file{/var/run/tor/control-sock}, which will be made writable by members of the +@code{tor} group. + @cindex hidden service @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping} Define a new Tor @dfn{hidden service} called @var{name} and implementing diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index a4d4ac0646..231a9f66c7 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -15,6 +15,7 @@ ;;; Copyright © 2019 Alex Griffin ;;; Copyright © 2020 Brice Waegeneire ;;; Copyright © 2021 Oleg Pykhalov +;;; Copyright © 2021 Christopher Lemmer Webber ;;; ;;; This file is part of GNU Guix. ;;; @@ -744,7 +745,9 @@ demand."))) (hidden-services tor-configuration-hidden-services (default '())) (socks-socket-type tor-configuration-socks-socket-type ; 'tcp or 'unix - (default 'tcp))) + (default 'tcp)) + (control-socket? tor-control-socket-path + (default #f))) (define %tor-accounts ;; User account and groups for Tor. @@ -766,7 +769,8 @@ demand."))) (define (tor-configuration->torrc config) "Return a 'torrc' file for CONFIG." (match config - (($ tor config-file services socks-socket-type) + (($ tor config-file services + socks-socket-type control-socket?) (computed-file "torrc" (with-imported-modules '((guix build utils)) @@ -786,6 +790,11 @@ Log notice syslog\n" port) (display "\ SocksPort unix:/var/run/tor/socks-sock UnixSocksGroupWritable 1\n" port)) + (when #$control-socket? + (display "\ +ControlSocket unix:/var/run/tor/control-sock GroupWritable RelaxDirModeCheck +ControlSocketsGroupWritable 1\n" + port)) (for-each (match-lambda ((service (ports hosts) ...) -- 2.30.0