From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Cl=C3=A9ment=20Lassieur?= Subject: [PATCH 3/4] services: openssh: Fix 'PrintLastLog' default behaviour. Date: Tue, 21 Feb 2017 00:53:54 +0100 Message-ID: <20170220235355.29115-4-clement@lassieur.org> References: <20170219185431.zgn53ndcbpedrgo7@wasp> <20170220235355.29115-1-clement@lassieur.org> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45801) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cfxng-0001ca-TS for guix-devel@gnu.org; Mon, 20 Feb 2017 18:55:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cfxnf-0005B3-NW for guix-devel@gnu.org; Mon, 20 Feb 2017 18:55:24 -0500 Received: from mail.lassieur.org ([83.152.10.219]:33728) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cfxnf-0005Ap-Eq for guix-devel@gnu.org; Mon, 20 Feb 2017 18:55:23 -0500 Received: from localhost.localdomain (unknown [88.191.118.83]) by mail.lassieur.org (Postfix) with ESMTPSA id 70E506401EF for ; Tue, 21 Feb 2017 00:55:17 +0100 (CET) In-Reply-To: <20170220235355.29115-1-clement@lassieur.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org * gnu/services/ssh.scm (openssh-config-file): Add 'pring-last-log?' option. ()[print-last-log?]: Add it. (openssh-activation): Touch /var/log/lastlog. * doc/guix.texi (Networking Services): Document 'pring-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 fdfb88046..db0bf0f9b 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -9171,6 +9171,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?}. + +@item @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 fe4598927..9e1449743 100644 --- a/gnu/services/ssh.scm +++ b/gnu/services/ssh.scm @@ -278,6 +278,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 @@ -297,6 +299,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"))) @@ -334,6 +344,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.11.1