guix-devel
[Top][All Lists]
Advanced

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

[PATCH 3/3] services: openssh: Fix 'PrintLastLog' default behaviour.


From: Clément Lassieur
Subject: [PATCH 3/3] services: openssh: Fix 'PrintLastLog' default behaviour.
Date: Thu, 2 Mar 2017 22:06:29 +0100

* gnu/services/ssh.scm (openssh-config-file): Add 'print-last-log?' option.
(<openssh-configuration>)[print-last-log?]: Add it.
(openssh-activation): Touch /var/log/lastlog.
* doc/guix.texi (Networking Services): Document 'print-last-log?'.

Before that, the service did not work as expected because /var/log/lastlog did
not exist.
---
 doc/guix.texi        |  4 ++++
 gnu/services/ssh.scm | 13 +++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 0d57cde2c..f45da4562 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -9178,6 +9178,10 @@ Because PAM challenge response authentication usually 
serves an
 equivalent role to password authentication, you should disable either
 @code{challenge-response-authentication?} or
 @code{password-authentication?}.
+
address@hidden @code{print-last-log?} (default: @code{#t})
+Specifies whether @command{sshd} should print the date and time of the
+last user login when a user logs in interactively.
 @end table
 @end deftp
 
diff --git a/gnu/services/ssh.scm b/gnu/services/ssh.scm
index d0eb043c1..5645bcfa0 100644
--- a/gnu/services/ssh.scm
+++ b/gnu/services/ssh.scm
@@ -277,6 +277,8 @@ The other options should be self-descriptive."
   (challenge-response-authentication? 
openssh-challenge-response-authentication?
                                       (default #f)) ;Boolean
   (use-pam?              openssh-configuration-use-pam?
+                         (default #t)) ;Boolean
+  (print-last-log?       openssh-configuration-print-last-log?
                          (default #t))) ;Boolean
 
 (define %openssh-accounts
@@ -296,6 +298,14 @@ The other options should be self-descriptive."
       (mkdir-p "/etc/ssh")
       (mkdir-p (dirname #$(openssh-configuration-pid-file config)))
 
+      (define (touch file-name)
+        (call-with-output-file file-name (const #t)))
+
+      (let ((lastlog "/var/log/lastlog"))
+        (when #$(openssh-configuration-print-last-log? config)
+          (unless (file-exists? lastlog)
+            (touch lastlog))))
+
       ;; Generate missing host keys.
       (system* (string-append #$openssh "/bin/ssh-keygen") "-A")))
 
@@ -333,6 +343,9 @@ The other options should be self-descriptive."
          (format port "UsePAM ~a\n"
                  #$(if (openssh-configuration-use-pam? config)
                        "yes" "no"))
+         (format port "PrintLastLog ~a\n"
+                 #$(if (openssh-configuration-print-last-log? config)
+                       "yes" "no"))
          #t))))
 
 (define (openssh-shepherd-service config)
-- 
2.12.0




reply via email to

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