guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#41018] [PATCH] gnu: Add AutoSSH service.


From: Oleg Pykhalov
Subject: [bug#41018] [PATCH] gnu: Add AutoSSH service.
Date: Sat, 02 May 2020 16:47:38 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Hi,

Thank you for the patch!

pinoaffe <address@hidden> 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.

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
Also, why don't you put the log in /var/log directory?

Oleg.

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]