From patchwork Mon Apr 22 03:58:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nigko Yerden X-Patchwork-Id: 63290 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 2E83827BBEA; Mon, 22 Apr 2024 05:01:32 +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=ham 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 150C627BBE2 for ; Mon, 22 Apr 2024 05:01:31 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rykre-0003hy-RX; Mon, 22 Apr 2024 00:01:15 -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 1rykrS-0003hZ-Kf for guix-patches@gnu.org; Mon, 22 Apr 2024 00:00:59 -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 1rykrH-0002ac-88 for guix-patches@gnu.org; Mon, 22 Apr 2024 00:00:54 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rykrW-0003Jo-ND for guix-patches@gnu.org; Mon, 22 Apr 2024 00:01:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70341] [PATCH v3] 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: Mon, 22 Apr 2024 04:01:02 +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.171375842712511 (code B ref 70341); Mon, 22 Apr 2024 04:01:02 +0000 Received: (at 70341) by debbugs.gnu.org; 22 Apr 2024 04:00:27 +0000 Received: from localhost ([127.0.0.1]:45335 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rykqw-0003Fj-HH for submit@debbugs.gnu.org; Mon, 22 Apr 2024 00:00:27 -0400 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]:43185) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rykqq-0003Ef-R0 for 70341@debbugs.gnu.org; Mon, 22 Apr 2024 00:00:25 -0400 Received: by mail-lj1-x244.google.com with SMTP id 38308e7fff4ca-2d872102372so37336601fa.0 for <70341@debbugs.gnu.org>; Sun, 21 Apr 2024 21:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713758398; x=1714363198; 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=g4LsYtQrFF9cYf4DGGX2LknC+LGEH/Rg9sHLzc/IhkI=; b=nKdqpJWXx75CE78qWDwubMPJPrEcGdFZrAaqFmb1T66yHg8jPW3mmjxjtXEZMn5rgO t+WJF6tEUO7q/IXHaRFIkxhjSQXV7g+UF7RMQ2vaAxXu5IISOF4sl3W/UFUjA5GLVqIX Cr6onqoEj0/97zxaiki9ta9waBlFZOS5Z92uXnMOX51ODQxzU4OK/27tcNlxmpVGhJjt T9ePS3yeqkIcsbvmZRomg4lit77PQI8iSSWfonqlvAbROVezSWJj20BR0RdYdIN9tGrl oZFL9+SEK3/lXpk69ELKYzCVHbmlQl04vIi28NbtzoaLRryU2oIGBkrrRJorCfew8fE/ y1vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713758398; x=1714363198; 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=g4LsYtQrFF9cYf4DGGX2LknC+LGEH/Rg9sHLzc/IhkI=; b=RdzhtCZOA1BkwqExhdYM6OFXrP9pnSh/H4Ig4+UQ2EzJDmahNu0t9zi4Bo9C8/siaL 6QArmGzyGGO0S67A+yPulDO7RweM1MuEVYBx6opNFqaEJGCZE5Rz/Iz+9YvFnxngueJ8 fD37+9YR4Fhw5wwGgTNg6ejHGgfsuatjQ6NyQDIkUh6Iqh7p92FFPsG6gIpxr5EhHaCX iuz/FgO4oFGLVTA+NWWYUewDM22Ev5YBGE1KqssFt0ABUs6Dxm9V/SNILJ5P9Iz+Gr6L OAmuiC02kccrUj2ik0wd7/BCPP/BKLm+8bcCtCyUoJ/7dUFlQNn1y4LCSplIrWvyUoxw sK/w== X-Gm-Message-State: AOJu0YzhpGkkXkXWoQY8cGaAttYKQxV3jdx3UvjInC3I2RMm72IcG4Hk tbB7V6t5KKuDvEEk6aGBiA3tr9JHs4MDCOBZl2DdRtYzMGUOxHQctAWhAunV X-Google-Smtp-Source: AGHT+IFVgKx8qcyYxcyWXlqNk83W9Qaz/5nIvAAfeSmzufp3w71n+2C5mB1nDX2OC1os8Z5QklRaFg== X-Received: by 2002:a05:651c:33a:b0:2d9:36af:d224 with SMTP id b26-20020a05651c033a00b002d936afd224mr3004587ljp.1.1713758397476; Sun, 21 Apr 2024 20:59:57 -0700 (PDT) Received: from localhost.localdomain ([188.244.176.248]) by smtp.gmail.com with ESMTPSA id z19-20020a2e8e93000000b002d8a12e3d90sm1339702ljk.122.2024.04.21.20.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Apr 2024 20:59:57 -0700 (PDT) From: Nigko Yerden Date: Mon, 22 Apr 2024 08:58:39 +0500 Message-ID: <3af678c4310a58373fe1e86b84f75a1d37e02295.1713758319.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 case 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: Export 'tor-configuration-transport-plugin-path', 'tor-configuration-pluggable-transport'. (): Add 'transport-plugin' and 'pluggable-transport' fields. (tor-configuration->torrc)[transport-plugin]: Add content to 'torrc' computed-file. (tor-shepherd-service)[transport-plugin]: Add file-system-mapping. Change-Id: I64e7632729287ea0ab27818bb7322fddae43de48 --- doc/guix.texi | 11 ++++++++ gnu/services/networking.scm | 54 ++++++++++++++++++++++++++----------- 2 files changed, 49 insertions(+), 16 deletions(-) base-commit: 9fa34ad616b94ad881b5ca48ef88bd84f877a0e9 diff --git a/doc/guix.texi b/doc/guix.texi index 65af136e61..eb0837860e 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} 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..6e535ea8ef 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. ;;; @@ -159,6 +160,8 @@ (define-module (gnu services networking) tor-configuration-hidden-services tor-configuration-socks-socket-type tor-configuration-control-socket-path + tor-configuration-transport-plugin-path + tor-configuration-pluggable-transport tor-onion-service-configuration tor-onion-service-configuration? tor-onion-service-configuration-name @@ -955,7 +958,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 +995,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 +1035,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 +1054,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))