From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id EHbXFVB6rV6udwAA0tVLHw (envelope-from ) for ; Sat, 02 May 2020 13:49:04 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id qAN5Jll6rV7WPQAAB5/wlQ (envelope-from ) for ; Sat, 02 May 2020 13:49:13 +0000 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:470:142::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 C1AD6940D1D for ; Sat, 2 May 2020 13:49:12 +0000 (UTC) Received: from localhost ([::1]:51108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jUsW1-0007aL-1r for larch@yhetil.org; Sat, 02 May 2020 09:49:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jUsVt-0007Xz-NP for guix-patches@gnu.org; Sat, 02 May 2020 09:49:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jUsVr-0007oe-JI for guix-patches@gnu.org; Sat, 02 May 2020 09:49:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40078) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jUsVr-0007oT-4R for guix-patches@gnu.org; Sat, 02 May 2020 09:49:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jUsVr-0005Hd-2e for guix-patches@gnu.org; Sat, 02 May 2020 09:49:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41018] [PATCH] gnu: Add AutoSSH service. Resent-From: Oleg Pykhalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 02 May 2020 13:49:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41018 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: pinoaffe Cc: 41018@debbugs.gnu.org Received: via spool by 41018-submit@debbugs.gnu.org id=B41018.158842730120201 (code B ref 41018); Sat, 02 May 2020 13:49:03 +0000 Received: (at 41018) by debbugs.gnu.org; 2 May 2020 13:48:21 +0000 Received: from localhost ([127.0.0.1]:51612 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jUsVB-0005Fl-52 for submit@debbugs.gnu.org; Sat, 02 May 2020 09:48:21 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:46439) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jUsV7-0005FV-0D for 41018@debbugs.gnu.org; Sat, 02 May 2020 09:48:19 -0400 Received: by mail-lf1-f66.google.com with SMTP id g10so5913801lfj.13 for <41018@debbugs.gnu.org>; Sat, 02 May 2020 06:48:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=lZCBNh+0ukuM+wzQMdNAwZMGwrdT1a+DHWJU7UcLiBA=; b=CzwEgSFAVBKloaEBx4jCnK9n5wIU902qju8pp8zm2VmQ8plsebe1XtQihjHo0SsBOV uYW9h718rbO21ZCi+PM6ChyC7FTy69J4tyuOmfpaM/Vqu4piekwc5lMWWbfTNuVCqxQp u18y+Q70qIsLhqjTshekz+Ec105Zm9q8EPqZbOLpEmEfwwzPJflfCafIkhnbbpJvE7fU RBOcXcT3Fb4RnymTY36AIiR/2ZK79J20nRC3TIekWTUDQFzwOn8s2jwEmM0mGOnoBiK1 cgTZkXJec7fZn44el54EetlByzU3nW3ryvD7gy7/abdpH0gLFZynxZkzn86xdUjLExIe zpNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=lZCBNh+0ukuM+wzQMdNAwZMGwrdT1a+DHWJU7UcLiBA=; b=kpRdUmfFEpHJI9HzXwh1mtmRahJC5nrTuwvLmM7qtkia+WxdcsvwTPKCL9Gj3Fi0n/ sruykaaTfbLInpxVvqqoXP9+HESlnBBGKbrx9BOakY/vuIpCZ6u8rUb7RegACLYQ+BVG ur7nPBf/p/vZCrtt/hm4FJ8OAv+LGG/eR/Q9JLZN1qSkTdGxso4Bp7jRqTdiVhvMAZjv 2MhvEqWEo1j5sGqldoD8aPaC1iK6PZ/qEd4gmoFqThX4JUB60a3+cYL/ycolMSFinJiv KXMLwSUXZUP79LN0Dbd4DJHUh5gJFsEEZ7JWOzwCoxT+0hxw80Ix4YpnLFGEagCFU4g7 9+sw== X-Gm-Message-State: AGi0PuaPI9z5dJ6r4vPSwM2pIhEANisfWfZnAHD6kW7eWRhkwmFAk6VW hCeMl4xcq5A2a8Q+7PlzMm57B090 X-Google-Smtp-Source: APiQypKmF616MZxRTDTmn8EmzATwSsLX+Yp0EnS9LHJM76+Xqpb52cVmdqj9axkPf+T5m1rVfXaOmw== X-Received: by 2002:a19:6a10:: with SMTP id u16mr1770666lfu.105.1588427290372; Sat, 02 May 2020 06:48:10 -0700 (PDT) Received: from guixsd (ppp91-122-124-75.pppoe.avangarddsl.ru. [91.122.124.75]) by smtp.gmail.com with ESMTPSA id t3sm3879013ljo.51.2020.05.02.06.48.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 May 2020 06:48:09 -0700 (PDT) From: Oleg Pykhalov References: <20200502111908.26a8e396@airmail.cc> Date: Sat, 02 May 2020 16:47:38 +0300 In-Reply-To: <20200502111908.26a8e396@airmail.cc> (pinoaffe@airmail.cc's message of "Sat, 2 May 2020 11:19:46 +0200") Message-ID: <87ees2la85.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Received-From: 209.51.188.43 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: scn0 X-Spam-Score: -2.01 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=gmail.com header.s=20161025 header.b=CzwEgSFA; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 2001:470:142::17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Scan-Result: default: False [-2.01 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.4950159474289]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2001:470:142::/48:c]; R_DKIM_REJECT(1.00)[gmail.com:s=20161025]; DWL_DNSWL_FAIL(0.00)[2001:470:142::17:server fail]; FREEMAIL_FROM(0.00)[gmail.com]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.15), country: US(-0.00), ip: 2001:470:142::17(-0.50)]; DKIM_TRACE(0.00)[gmail.com:-]; RCPT_COUNT_TWO(0.00)[2]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; MAILLIST(-0.20)[mailman]; SIGNED_PGP(-2.00)[]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_IN_DNSWL_FAIL(0.00)[2001:470:142::17:server fail]; MIME_TRACE(0.00)[0:+,1:+,2:+,3:+,4:+,5:~]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:22989, ipnet:2001:470:142::/48, country:US]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_FROM(0.00)[larch=yhetil.org]; ARC_NA(0.00)[]; FROM_NEQ_ENVFROM(0.00)[gowigust@gmail.com,guix-patches-bounces@gnu.org]; FROM_HAS_DN(0.00)[]; URIBL_BLOCKED(0.00)[airmail.cc:email]; MIME_GOOD(-0.20)[multipart/signed,multipart/mixed,text/plain,text/x-patch]; PREVIOUSLY_DELIVERED(0.00)[41018@debbugs.gnu.org]; HAS_LIST_UNSUB(-0.01)[]; RECEIVED_SPAMHAUS_PBL(0.00)[91.122.124.75:received]; RCVD_COUNT_SEVEN(0.00)[10]; FORGED_SENDER_MAILLIST(0.00)[]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : SPF not aligned (relaxed),none] X-TUID: ySbiu3NjiBvI --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, Thank you for the patch! pinoaffe writes: > * doc/guix.texi: Add documentation. > * gnu/services/ssh.scm (): New record type. > (mpd-service-type): New service type. > --- > doc/guix.texi | 75 +++++++++++++++++++++++++++++ > gnu/services/ssh.scm | 109 ++++++++++++++++++++++++++++++++++++++++++- > 2 files changed, 183 insertions(+), 1 deletion(-) > > diff --git a/doc/guix.texi b/doc/guix.texi > index c571010bc8..f88859c584 100644 > --- a/doc/guix.texi > +++ b/doc/guix.texi [=E2=80=A6] > +@lisp > +(autossh (autossh-configuration > + (user "pino") > + (ssh-options (list "-T" "-N" "-L" "8081:localhost:8081" "remot= e.net")))) > +@end lisp > +@end deffn =2D-8<---------------cut here---------------start------------->8--- (service autossh-service-type (autossh-configuration (user "pino") (ssh-options (list "-T" "-N" "-L" "8081:localhost:8081" "remote.n= et")))) =2D-8<---------------cut here---------------end--------------->8--- [=E2=80=A6] > diff --git a/gnu/services/ssh.scm b/gnu/services/ssh.scm > index d2dbb8f80d..ec0150b3a2 100644 > --- a/gnu/services/ssh.scm > +++ b/gnu/services/ssh.scm [=E2=80=A6] > +(define (autossh-service-activation config) > + (with-imported-modules '((guix build utils)) > + #~(begin > + (use-modules (guix build utils)) > + (define %user > + (getpw #$(autossh-configuration-user config))) > + (let ((directory #$(autossh-file-name config ""))) > + (mkdir-p directory) > + (chown directory (passwd:uid %user) (passwd:gid %user)))))) I cannot start the service in a testing vm because of log file is owner by root. The following fixes this. --=-=-= Content-Type: text/x-patch Content-Disposition: inline Content-Transfer-Encoding: quoted-printable diff --git a/gnu/services/ssh.scm b/gnu/services/ssh.scm index ec0150b3a2..c111437b1a 100644 =2D-- a/gnu/services/ssh.scm +++ b/gnu/services/ssh.scm @@ -715,9 +715,12 @@ object." (use-modules (guix build utils)) (define %user (getpw #$(autossh-configuration-user config))) =2D (let ((directory #$(autossh-file-name config ""))) + (let* ((directory #$(autossh-file-name config "")) + (log (string-append directory "/log"))) (mkdir-p directory) =2D (chown directory (passwd:uid %user) (passwd:gid %user)))))) + (chown directory (passwd:uid %user) (passwd:gid %user)) + (call-with-output-file log (const #t)) + (chown log (passwd:uid %user) (passwd:gid %user)))))) =20 (define autossh-service-type (service-type --=-=-= Content-Type: text/plain Also, why don't you put the log in /var/log directory? Oleg. --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAl6tefoACgkQFn+OpQAa +pzIpA/9Gl7+ROEU1v2/CnDrTMlVh2zmGsUaObBcvd6rOvtvlXv7F2v9+ej9pGg/ OfZFVaFpuveywoKj01ZBPpi8YUm4WC7xrBr53ZG1pHVejNKiaV/PGYgDepfD6AnN Ig7MeQovuBsg0SlVoiXKyMs3Uw76E5NOFJw7U9uJl8ZqDkuYk7wzsAKz8DXsD8I3 Xcff0hwGOYz4y5bGHeKaVjTEOyp7+iapuNHBzY/BaO8yf/eHaCPlmXTmC/I1zd1R mrmLqXhjEBYAgtAaSw1ot4eVF+Cu+FQZzQphmteimD3VFEfGE2BqmpCc7WwniVft rKgZTTXtysxA0UHaVfLsb3F5USndEbeNwRp9i/WDQLEcJZ62e69U56zMoAEsePjr 6qmSTuJ0WPBFp5T2nOATZ1qcjJKeFTBbcga18H8+p5FjPhnJCmXttg628s7cH11A uF2p+Uq4ZIZXGTpQEqaF0RJ2gymd9mc6lTnYL4nQkpf5flLG8c2iG6onUAIWTIE6 jXJ04EOZ7IfkAeHEfUqBimRqn2AoPh/QxiL9cGENT0rdDuO6rZoGcOe1cNn7nr0k jcqOuz+jJoLAc8U7M/xWnpSZOClaXaoOnwR6IGwissf5hZkYf12kxW2V6imP8A6a pkwXwsWAuvtkueqPU71sL1jtowsmtK7InTnRyln4wF40WZWKjBE= =9VF1 -----END PGP SIGNATURE----- --==-=-=--