unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Oleg Pykhalov <go.wigust@gmail.com>
To: pinoaffe <pinoaffe@airmail.cc>
Cc: 41018@debbugs.gnu.org
Subject: [bug#41018] [PATCH] gnu: Add AutoSSH service.
Date: Sat, 02 May 2020 16:47:38 +0300	[thread overview]
Message-ID: <87ees2la85.fsf@gmail.com> (raw)
In-Reply-To: <20200502111908.26a8e396@airmail.cc> (pinoaffe@airmail.cc's message of "Sat, 2 May 2020 11:19:46 +0200")


[-- Attachment #1.1: Type: text/plain, Size: 1784 bytes --]

Hi,

Thank you for the patch!

pinoaffe <pinoaffe@airmail.cc> writes:

> * doc/guix.texi: Add documentation.
> * gnu/services/ssh.scm (<autossh-configuration>): 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

[…]

> +@lisp
> +(autossh (autossh-configuration
> +          (user "pino")
> +          (ssh-options (list "-T" "-N" "-L" "8081:localhost:8081" "remote.net"))))
> +@end lisp
> +@end deffn

--8<---------------cut here---------------start------------->8---
(service autossh-service-type
         (autossh-configuration
          (user "pino")
          (ssh-options (list "-T" "-N" "-L" "8081:localhost:8081" "remote.net"))))
--8<---------------cut here---------------end--------------->8---

[…]

> 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

[…]

> +(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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: Type: text/x-patch, Size: 828 bytes --]

diff --git a/gnu/services/ssh.scm b/gnu/services/ssh.scm
index ec0150b3a2..c111437b1a 100644
--- 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)))
-        (let ((directory #$(autossh-file-name config "")))
+        (let* ((directory #$(autossh-file-name config ""))
+               (log (string-append directory "/log")))
           (mkdir-p directory)
-          (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))))))
 
 (define autossh-service-type
   (service-type

[-- Attachment #1.3: Type: text/plain, Size: 63 bytes --]


Also, why don't you put the log in /var/log directory?

Oleg.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2020-05-02 13:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-02  9:19 [bug#41018] [PATCH] gnu: Add AutoSSH service pinoaffe
2020-05-02 13:47 ` Oleg Pykhalov [this message]
2020-05-03 15:13 ` pinoaffe
2020-05-03 15:52   ` Oleg Pykhalov
2020-05-04 15:56 ` [bug#41018] [PATCH v2] " pinoaffe
2020-05-04 22:49   ` Oleg Pykhalov
2020-05-05  7:31 ` [bug#41018] [PATCH v2 try 2] " pinoaffe
2020-05-05 12:33   ` Oleg Pykhalov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ees2la85.fsf@gmail.com \
    --to=go.wigust@gmail.com \
    --cc=41018@debbugs.gnu.org \
    --cc=pinoaffe@airmail.cc \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).