From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Cl=C3=A9ment=20Lassieur?= Subject: [PATCH 3/3] services: openssh: Fix 'PrintLastLog' default behaviour. Date: Thu, 2 Mar 2017 22:06:29 +0100 Message-ID: <20170302210629.6274-3-clement@lassieur.org> References: <87efyfxufb.fsf@lassieur.org> <20170302210629.6274-1-clement@lassieur.org> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjXw2-00013e-Fh for guix-devel@gnu.org; Thu, 02 Mar 2017 16:06:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjXvz-0006fu-Ms for guix-devel@gnu.org; Thu, 02 Mar 2017 16:06:50 -0500 Received: from mail.lassieur.org ([83.152.10.219]:36818) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cjXvz-0006ex-Cq for guix-devel@gnu.org; Thu, 02 Mar 2017 16:06:47 -0500 Received: from localhost.localdomain (unknown [88.191.118.83]) by mail.lassieur.org (Postfix) with ESMTPSA id 450AF640207 for ; Thu, 2 Mar 2017 22:06:44 +0100 (CET) In-Reply-To: <20170302210629.6274-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 'print-last-log?' option. ()[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?}. + +@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 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