guix-commits
[Top][All Lists]
Advanced

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

03/03: services: Create /var/run/utmpx upon activation.


From: Ludovic Courtès
Subject: 03/03: services: Create /var/run/utmpx upon activation.
Date: Thu, 19 Jan 2017 22:48:06 +0000 (UTC)

civodul pushed a commit to branch master
in repository guix.

commit caa7816673ba110d2192c2f4a8b985a475aa08a2
Author: Ludovic Courtès <address@hidden>
Date:   Thu Jan 19 23:42:20 2017 +0100

    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.
---
 gnu/services.scm   |    7 ++++++-
 gnu/tests/base.scm |   22 ++++++++++++++++++++--
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/gnu/services.scm b/gnu/services.scm
index 4020fd3..f72d4d5 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015, 2016 Ludovic Courtès <address@hidden>
+;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <address@hidden>
 ;;; Copyright © 2016 Chris Marusich <address@hidden>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -340,6 +340,11 @@ ACTIVATION-SCRIPT-TYPE."
                       (activate-/bin/sh
                        (string-append #$(canonical-package bash) "/bin/sh"))
 
+                      ;; Make sure the user accounting database exists.  If it
+                      ;; does not exist, 'setutxent' does not create it and
+                      ;; thus there is no accounting at all.
+                      (close-port (open-file "/var/run/utmpx" "a0"))
+
                       ;; Set up /run/current-system.  Among other things this
                       ;; sets up locales, which the activation snippets
                       ;; executed below may expect.
diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm
index 6370d69..2687a6c 100644
--- a/gnu/tests/base.scm
+++ b/gnu/tests/base.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2016 Ludovic Courtès <address@hidden>
+;;; Copyright © 2016, 2017 Ludovic Courtès <address@hidden>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -78,9 +78,11 @@ passed a gexp denoting the marionette, and it must return 
gexp that is
 inserted before the first test.  This is used to introduce an extra
 initialization step, such as entering a LUKS passphrase."
   (define test
-    (with-imported-modules '((gnu build marionette))
+    (with-imported-modules '((gnu build marionette)
+                             (guix build syscalls))
       #~(begin
           (use-modules (gnu build marionette)
+                       (guix build syscalls)
                        (srfi srfi-1)
                        (srfi srfi-26)
                        (srfi srfi-64)
@@ -176,6 +178,22 @@ info --version")
                           (apply throw args)))))
                marionette)))
 
+          ;; There should be one utmpx entry for the user logged in on tty1.
+          (test-equal "utmpx entry"
+            '(("root" "tty1" #f))
+            (marionette-eval
+             '(begin
+                (use-modules (guix build syscalls)
+                             (srfi srfi-1))
+
+                (filter-map (lambda (entry)
+                              (and (equal? (login-type USER_PROCESS)
+                                           (utmpx-login-type entry))
+                                   (list (utmpx-user entry) (utmpx-line entry)
+                                         (utmpx-host entry))))
+                            (utmpx-entries)))
+             marionette))
+
           (test-assert "host name resolution"
             (match (marionette-eval
                     '(begin



reply via email to

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