summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-01-19 23:42:20 +0100
committerLudovic Courtès <ludo@gnu.org>2017-01-19 23:45:11 +0100
commitcaa7816673ba110d2192c2f4a8b985a475aa08a2 (patch)
treebd0ca671c45e34091a687610b0b2f65f48c3c7d9 /gnu
parent150309726f221c9b982e594466d35f5b895391d5 (diff)
services: Create /var/run/utmpx upon activation.
This fixes a bug whereby /var/run/utmpx would never be created, and thus accounting information would be missing. * gnu/services.scm (activation-script): Create /var/run/utmpx. * gnu/tests/base.scm (run-basic-test)["utmpx entry"]: New test.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/services.scm7
-rw-r--r--gnu/tests/base.scm22
2 files changed, 26 insertions, 3 deletions
diff --git a/gnu/services.scm b/gnu/services.scm
index 4020fd37e04..f72d4d57850 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -1,5 +1,5 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2015, 2016 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
3;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com> 3;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
4;;; 4;;;
5;;; This file is part of GNU Guix. 5;;; This file is part of GNU Guix.
@@ -340,6 +340,11 @@ ACTIVATION-SCRIPT-TYPE."
340 (activate-/bin/sh 340 (activate-/bin/sh
341 (string-append #$(canonical-package bash) "/bin/sh")) 341 (string-append #$(canonical-package bash) "/bin/sh"))
342 342
343 ;; Make sure the user accounting database exists. If it
344 ;; does not exist, 'setutxent' does not create it and
345 ;; thus there is no accounting at all.
346 (close-port (open-file "/var/run/utmpx" "a0"))
347
343 ;; Set up /run/current-system. Among other things this 348 ;; Set up /run/current-system. Among other things this
344 ;; sets up locales, which the activation snippets 349 ;; sets up locales, which the activation snippets
345 ;; executed below may expect. 350 ;; executed below may expect.
diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm
index 6370d6951bf..2687a6cdb80 100644
--- a/gnu/tests/base.scm
+++ b/gnu/tests/base.scm
@@ -1,5 +1,5 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2016, 2017 Ludovic Courtès <ludo@gnu.org>
3;;; 3;;;
4;;; This file is part of GNU Guix. 4;;; This file is part of GNU Guix.
5;;; 5;;;
@@ -78,9 +78,11 @@ passed a gexp denoting the marionette, and it must return gexp that is
78inserted before the first test. This is used to introduce an extra 78inserted before the first test. This is used to introduce an extra
79initialization step, such as entering a LUKS passphrase." 79initialization step, such as entering a LUKS passphrase."
80 (define test 80 (define test
81 (with-imported-modules '((gnu build marionette)) 81 (with-imported-modules '((gnu build marionette)
82 (guix build syscalls))
82 #~(begin 83 #~(begin
83 (use-modules (gnu build marionette) 84 (use-modules (gnu build marionette)
85 (guix build syscalls)
84 (srfi srfi-1) 86 (srfi srfi-1)
85 (srfi srfi-26) 87 (srfi srfi-26)
86 (srfi srfi-64) 88 (srfi srfi-64)
@@ -176,6 +178,22 @@ info --version")
176 (apply throw args))))) 178 (apply throw args)))))
177 marionette))) 179 marionette)))
178 180
181 ;; There should be one utmpx entry for the user logged in on tty1.
182 (test-equal "utmpx entry"
183 '(("root" "tty1" #f))
184 (marionette-eval
185 '(begin
186 (use-modules (guix build syscalls)
187 (srfi srfi-1))
188
189 (filter-map (lambda (entry)
190 (and (equal? (login-type USER_PROCESS)
191 (utmpx-login-type entry))
192 (list (utmpx-user entry) (utmpx-line entry)
193 (utmpx-host entry))))
194 (utmpx-entries)))
195 marionette))
196
179 (test-assert "host name resolution" 197 (test-assert "host name resolution"
180 (match (marionette-eval 198 (match (marionette-eval
181 '(begin 199 '(begin