From patchwork Sat Apr 20 14:43:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nigko Yerden X-Patchwork-Id: 63177 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 DFD8827BBE2; Sat, 20 Apr 2024 15:46:11 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 89CF327BBE9 for ; Sat, 20 Apr 2024 15:46:09 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ryByP-00049A-J5; Sat, 20 Apr 2024 10:45:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ryByN-00048z-MA for guix-patches@gnu.org; Sat, 20 Apr 2024 10:45:48 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ryByN-0000RA-D8 for guix-patches@gnu.org; Sat, 20 Apr 2024 10:45:47 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ryByb-0007DF-T5 for guix-patches@gnu.org; Sat, 20 Apr 2024 10:46:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70341] [PATCH v2] services: tor: Add support for pluggable transports. References: <11e72216f4be8b6559ecc04646fd722daa5dd09d.1712846897.git.nigko.yerden@gmail.com> In-Reply-To: <11e72216f4be8b6559ecc04646fd722daa5dd09d.1712846897.git.nigko.yerden@gmail.com> Resent-From: Nigko Yerden Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 20 Apr 2024 14:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70341 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70341@debbugs.gnu.org Cc: Nigko Yerden Received: via spool by 70341-submit@debbugs.gnu.org id=B70341.171362431327336 (code B ref 70341); Sat, 20 Apr 2024 14:46:01 +0000 Received: (at 70341) by debbugs.gnu.org; 20 Apr 2024 14:45:13 +0000 Received: from localhost ([127.0.0.1]:36649 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ryBxo-00076q-Vn for submit@debbugs.gnu.org; Sat, 20 Apr 2024 10:45:13 -0400 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]:56431) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ryBxl-00076g-Cb for 70341@debbugs.gnu.org; Sat, 20 Apr 2024 10:45:10 -0400 Received: by mail-lf1-x144.google.com with SMTP id 2adb3069b0e04-516d4d80d00so3809759e87.0 for <70341@debbugs.gnu.org>; Sat, 20 Apr 2024 07:44:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713624288; x=1714229088; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hzMggZRHPhx9LlQJHpLbUh6ZYrpKzlOeJlfRlaBIXjU=; b=Nz3/pywO933DMoQXL0H7FNK6E8SH6KBj7DZxfMbeExIw2B3/Eoe4DmXIqGJRSuprBu DttOKsg+CBWcdUjJBOatv8HdfPTerp4VqLT6MV6OzWNKE5T8UkfTlPyXG/zkhE2sZvBK eqFiY9Kt9NLBkzD1jSUW7afKNSrkDT9MUHwjx/YoE3OfWG9V5iWqwVoNhOs0MKVq0B2/ y+aF1ZXIaGyPlgS0FffaLyWjj67EAJ79FFvbcN0TGh7H8be4OcuLu89Jw9FJm04ichvN U+a/BgMsOFDKtEjUAvd4lvskZzZZ5ptV5zrAKTieQkuTjho8NEgA56bf+Ll7pBlgtUZd aaNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713624288; x=1714229088; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hzMggZRHPhx9LlQJHpLbUh6ZYrpKzlOeJlfRlaBIXjU=; b=obGuMo8o5+uHh1xV5gBXwROui7oALvEI0FRAzgt+9ZcpXVMJhhlsCkbz/Oq/9HhCOD bpYlrOpaDhp4+BDyxXfb/SWXvaWci86bKbdzR/qGYhsOvxnLBn92V+26GHgHMdIyzcnH c5Oi9cP1YgI46WWO1uivxLxpK9TI0P1JzzqO+8A0Vfz5KC+8qxTPFfiKvRTu3P71+gVM YFRfIFbJWpK0+Z0oujpmRtkLhzO6OP1x9vxv11DIjRg0SHICvyztnX9o3Ej3t+Ur+SDd W94nTDsm90O9/HZFx1Rns+87wj0wyFynwlAI1nZrjXNinrgesxMuxu9VbkMDbtxbmxHt U/9w== X-Gm-Message-State: AOJu0Yx4eayndDMEkpBMHudjle8nH5wlF3CBV1qzg8Ma8au/pdzlgxZS wcBADkLZt1lMUT20QWYoOF0X0mjnoFvdR/MpZYvINTri9koywQQ5J0IGKbDd X-Google-Smtp-Source: AGHT+IE5FVaIBqgD4IatsdJ2kvzqhyWxUOA9alkB0PvDlcdQwE03YxRh1rQSLJ+CjJtNspY9nnvpFA== X-Received: by 2002:a05:6512:3b96:b0:51a:c9a2:58e with SMTP id g22-20020a0565123b9600b0051ac9a2058emr3481491lfv.29.1713624287770; Sat, 20 Apr 2024 07:44:47 -0700 (PDT) Received: from localhost.localdomain ([188.68.139.217]) by smtp.gmail.com with ESMTPSA id h7-20020a056512220700b0051ac9a1cbdbsm625736lfu.50.2024.04.20.07.44.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Apr 2024 07:44:47 -0700 (PDT) From: Nigko Yerden Date: Sat, 20 Apr 2024 19:43:03 +0500 Message-ID: <714e3316b5a14168c495253ae585c9e73361b11a.1713624182.git.nigko.yerden@gmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Pluggable transports are programs that disguise Tor traffic, which can be useful in cases when Tor is censored. Pluggable transports cannot be configured by #:config-file file exclusively because Tor process is run via 'least-authority-wrapper' and cannot have access to transport plugin, which is a separate executable (Bug:#70302, Bug:#70332). * doc/guix.texi (Networking Services): Document 'transport-plugin' and 'pluggable-transport' options for 'tor-configuration'. * gnu/services/networking.scm (): Add 'transport-plugin' and 'pluggable-transport' fields. (tor-configuration->torrc)[transport-plugin]: Add content to 'torrc' computed-file. (tor-shepherd-service)[transport-plugin-path]: Add file-system-mapping. Change-Id: I64e7632729287ea0ab27818bb7322fddae43de48 --- doc/guix.texi | 11 ++++++++ gnu/services/networking.scm | 52 +++++++++++++++++++++++++------------ 2 files changed, 47 insertions(+), 16 deletions(-) base-commit: 0f68306268773f0eaa4327e1f6fdcb39442e4a34 diff --git a/doc/guix.texi b/doc/guix.texi index 65af136e61..9fbe928484 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -127,6 +127,7 @@ Copyright @copyright{} 2024 Herman Rimm@* Copyright @copyright{} 2024 Matthew Trzcinski@* Copyright @copyright{} 2024 Richard Sent@* +Copyright @copyright{} 2024 Nigko Yerden@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -21849,6 +21850,16 @@ Networking Services @file{/var/run/tor/control-sock}, which will be made writable by members of the @code{tor} group. +@item @code{transport-plugin} (default: @code{#f}) +This must be either @code{#f}, in which case the pluggable transports are +not used by Tor, or a ``file-like'' object pointing to the pluggable transport +plugin executable. In the latter case the @code{#:config-file} file +should contain line(s) configuring one or more bridges. + +@item @code{pluggable-transport} (default: @code{"obfs4"}) +A string that specifies the type of the pluggable transport in +case @code{#:transport-plugin} is not @code{#f}. + @end table @end deftp diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 8e64e529ab..e47f7ca61a 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -22,6 +22,7 @@ ;;; Copyright © 2023 Declan Tsien ;;; Copyright © 2023 Bruno Victal ;;; Copyright © 2023 muradm +;;; Copyright © 2024 Nigko Yerden ;;; ;;; This file is part of GNU Guix. ;;; @@ -955,7 +956,11 @@ (define-record-type* (socks-socket-type tor-configuration-socks-socket-type ; 'tcp or 'unix (default 'tcp)) (control-socket? tor-configuration-control-socket-path - (default #f))) + (default #f)) + (transport-plugin tor-configuration-transport-plugin-path + (default #f)) + (pluggable-transport tor-configuration-pluggable-transport + (default "obfs4"))) (define %tor-accounts ;; User account and groups for Tor. @@ -988,7 +993,8 @@ (define-configuration/no-serialization tor-onion-service-configuration (define (tor-configuration->torrc config) "Return a 'torrc' file for CONFIG." (match-record config - (tor config-file hidden-services socks-socket-type control-socket?) + (tor config-file hidden-services socks-socket-type control-socket? + transport-plugin pluggable-transport) (computed-file "torrc" (with-imported-modules '((guix build utils)) @@ -1027,6 +1033,13 @@ (define (tor-configuration->torrc config) (cons name mapping))) hidden-services)) + (when #$transport-plugin + (format port "\ +UseBridges 1 +ClientTransportPlugin ~a exec ~a~%" + #$pluggable-transport + #$transport-plugin)) + (display "\ ### End of automatically generated lines.\n\n" port) @@ -1039,23 +1052,30 @@ (define (tor-configuration->torrc config) (define (tor-shepherd-service config) "Return a running Tor." (let* ((torrc (tor-configuration->torrc config)) + (transport-plugin-path (tor-configuration-transport-plugin-path config)) (tor (least-authority-wrapper (file-append (tor-configuration-tor config) "/bin/tor") #:name "tor" - #:mappings (list (file-system-mapping - (source "/var/lib/tor") - (target source) - (writable? #t)) - (file-system-mapping - (source "/dev/log") ;for syslog - (target source)) - (file-system-mapping - (source "/var/run/tor") - (target source) - (writable? #t)) - (file-system-mapping - (source torrc) - (target source))) + #:mappings (append + (list (file-system-mapping + (source "/var/lib/tor") + (target source) + (writable? #t)) + (file-system-mapping + (source "/dev/log") ;for syslog + (target source)) + (file-system-mapping + (source "/var/run/tor") + (target source) + (writable? #t)) + (file-system-mapping + (source torrc) + (target source))) + (if transport-plugin-path + (list (file-system-mapping + (source transport-plugin-path) + (target source))) + '())) #:namespaces (delq 'net %namespaces)))) (list (shepherd-service (provision '(tor))