From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id qOXuKA+jtV81DwAA0tVLHw (envelope-from ) for ; Wed, 18 Nov 2020 22:41:19 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id MBTEJA+jtV8zCAAA1q6Kng (envelope-from ) for ; Wed, 18 Nov 2020 22:41:19 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1E2E39401BF for ; Wed, 18 Nov 2020 22:41:18 +0000 (UTC) Received: from localhost ([::1]:46790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kfW8b-0002yK-S7 for larch@yhetil.org; Wed, 18 Nov 2020 17:41:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfW7O-0002WL-Gn for guix-patches@gnu.org; Wed, 18 Nov 2020 17:40:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:53685) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kfW7O-0003Z8-4q for guix-patches@gnu.org; Wed, 18 Nov 2020 17:40:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kfW7O-0001SR-1a for guix-patches@gnu.org; Wed, 18 Nov 2020 17:40:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#44435] [PATCH v2 0/1] services: Add Transmission Daemon Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 18 Nov 2020 22:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44435 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Simon South Cc: 44435@debbugs.gnu.org Received: via spool by 44435-submit@debbugs.gnu.org id=B44435.16057391565538 (code B ref 44435); Wed, 18 Nov 2020 22:40:01 +0000 Received: (at 44435) by debbugs.gnu.org; 18 Nov 2020 22:39:16 +0000 Received: from localhost ([127.0.0.1]:36996 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kfW6e-0001RF-8r for submit@debbugs.gnu.org; Wed, 18 Nov 2020 17:39:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59350) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kfW6a-0001Qz-Pb for 44435@debbugs.gnu.org; Wed, 18 Nov 2020 17:39:15 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36696) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kfW6U-0003Sf-U1; Wed, 18 Nov 2020 17:39:07 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=40080 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kfW6S-0006lJ-02; Wed, 18 Nov 2020 17:39:05 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: Date: Wed, 18 Nov 2020 23:39:01 +0100 In-Reply-To: (Simon South's message of "Sun, 8 Nov 2020 13:06:10 -0500") Message-ID: <87sg96i92y.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -1.51 X-TUID: VkQqDse4M9x7 Hi Simon, Simon South skribis: > Here's an updated version of the patch that > > - Fixes the "importing module from host" warning by removing an unnecessa= ry > import of (guix gexp) in transmission-daemon-computed-settings-file; and Good. :-) > - I've placed the code in a new "(gnu services file-sharing)" module and = the > documentation in a new "File-Sharing Services" section of the manual, o= nly > because these names seemed the most natural to me. ("Peer-to-peer" woul= d be > too broad a categorization, I think, while "BitTorrent" too narrow.) Sounds good to me. > - The module exports two procedures, "transmission-password-hash" and > "transmission-random-salt", that together are my solution to the proble= m of > assigning a value to the daemon's "rpc-password" configuration setting. > > Transmission clients seem to expect the user to supply a password in > plaintext in their "settings.json" file. At startup, the client generat= es a > random, eight-character salt value; hashes it and the password together= ; and > writes the result back to the settings file, after which the password > remains obscured. This obviously violates the functional nature of Guix= , as > we don't expect services to be rewriting their own configuration files = and > the use of a random salt value makes the process non-repeatable anyway. > > I've documented in the manual how a user can use these two procedures to > create a suitable value for "rpc-password" that remains stable across s= ystem > reconfigurations, but perhaps you know of a better (or more conventiona= l) > approach. Looks like a good idea. At worst we=E2=80=99ll have to keep it in sync with what future versions of Transmission do, but I guess it=E2=80=99s unlikely = to change often. > - I've added a custom "stop" procedure to the Shepherd service that gives= the > daemon time to shut down before eventually killing its process. This is > necessary since the daemon performs some housekeeping and sends a final > update to BitTorrent trackers before it exits, which can take several > seconds or more; without this code, restarting the service usually fail= s as > the new daemon process finds the old one is still running and attached = to > the port used for peer connections. OK. > +@node File-Sharing Services > +@subsection File-Sharing Services > + > +The @code{(gnu services file-sharing)} module provides services that > +assist with transferring files over peer-to-peer file-sharing networks. > + > +@subsubheading Transmission Daemon Service > + > +@uref{https://transmissionbt.com/, Transmission} is a flexible Great that you took the time to write good documentation with examples! > +(define (transmission-password-hash password salt) > + "Returns a string containing the result of hashing @var{password} toge= ther > +with @var{salt}, in the format recognized by Transmission clients for th= eir > +@code{rpc-password} configuration setting. > + > +@var{salt} must be an eight-character string. The > +@code{transmission-random-salt} procedure can be used to generate a suit= able > +salt value at random." > + (if (not (eq? (string-length salt) %transmission-salt-length)) > + (throw 'out-of-range > + (format #f > + "salt value must be ~d characters in length" > + %transmission-salt-length)) I=E2=80=99d recommend using (srfi srfi-34), (srfi srfi-35), (guix i18n), and (guix diagnostics) and write it like so: (raise (condition (formatted-message (G_ "salt value =E2=80=A6") =E2=80=A6))) Then you can also add this file to po/packages/POTFILE.in for translation. > + (let ((password-digest (call-with-input-string > + (string-append password salt) > + (lambda (port) > + (port-hash (hash-algorithm sha1) port))= ))) More concise: (sha1 (string->utf8 (string-append password salt))) > + (stop #~(lambda (pid) > + (kill pid SIGTERM) > + > + ;; Transmission Daemon normally needs some time to shut = down, > + ;; as it will complete some housekeeping and send a final > + ;; update to trackers before it exits. > + ;; > + ;; Wait a reasonable period for it to stop before contin= uing. > + ;; If we don't do this, restarting the service can fail = as the > + ;; new daemon process finds the old one still running and > + ;; attached to the port used for peer connections. > + (let wait-before-killing ((period #$stop-wait-period)) > + (if (zero? (car (waitpid pid WNOHANG))) > + (if (positive? period) > + (begin > + (sleep 1) > + (wait-before-killing (- period 1))) > + (begin > + (format #t > + "Wait period expired; killing \ > +transmission-daemon (pid ~a).~%" > + pid) > + (display "(If you see this message regularly= , you \ > +may need to increase the value > +of 'stop-wait-period' in the service configuration.)\n") > + kill pid SIGKILL)))) ^ Missing parens. Ideally this SIGTERM-then-SIGKILL dance would be done by shepherd itself. Future work! I=E2=80=99m not familiar with Transmission so I can=E2=80=99t really commen= t on the other things, but overall it LGTM apart from the details above. Could you send an updated patch? It would be nice to have a minimal system test to ensure at least Transmission starts and is fine with the generated config file; we can leave that to another patch though, if you prefer. Thanks! Ludo=E2=80=99.