guix-commits
[Top][All Lists]
Advanced

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

[shepherd] 01/02: support: Move unprivileged shepherd log file to XDG_DA


From: Ludovic Courtès
Subject: [shepherd] 01/02: support: Move unprivileged shepherd log file to XDG_DATA_DIR.
Date: Wed, 18 Nov 2020 16:34:01 -0500 (EST)

civodul pushed a commit to branch master
in repository shepherd.

commit c6382a6898f2851d78b675f209787c5ff9ad4320
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Wed Nov 18 22:21:24 2020 +0100

    support: Move unprivileged shepherd log file to XDG_DATA_DIR.
    
    * modules/shepherd/support.scm (%user-log-dir): New variable.
    (user-default-log-file): Use it.
    * tests/basic.sh: Adjust accordingly.
    * doc/shepherd.texi (Invoking shepherd): Likewise.
    
    Co-authored-by: Efraim Flashner <efraim@flashner.co.il>
---
 doc/shepherd.texi            |  2 +-
 modules/shepherd/support.scm | 10 ++++++++--
 tests/basic.sh               |  4 ++++
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/doc/shepherd.texi b/doc/shepherd.texi
index 696477e..47c4324 100644
--- a/doc/shepherd.texi
+++ b/doc/shepherd.texi
@@ -417,7 +417,7 @@ permissions are not as expected.
 Log output into @var{file}.
 
 For unprivileged users, the default log file is
-@file{$XDG_CONFIG_HOME/shepherd/shepherd.log}.
+@file{$XDG_DATA_DIR/.local/share/shepherd/shepherd.log}.
 
 @cindex syslog
 When running as root, the default behavior is to connect to
diff --git a/modules/shepherd/support.scm b/modules/shepherd/support.scm
index cdb7b35..db52571 100644
--- a/modules/shepherd/support.scm
+++ b/modules/shepherd/support.scm
@@ -271,6 +271,12 @@ There is NO WARRANTY, to the extent permitted by law.")))
                      (string-append user-homedir "/.config"))
                  "/shepherd"))
 
+(define %user-log-dir
+  ;; Default log directory if shepherd is run as a normal user.
+  (string-append (or (getenv "XDG_DATA_DIR")
+                     (string-append user-homedir "/.local/share"))
+                 "/shepherd"))
+
 (define %user-runtime-dir
   ;; Default runtime directory if shepherd is run as a normal user.
   (string-append (or (getenv "XDG_RUNTIME_DIR")
@@ -302,8 +308,8 @@ TARGET should be a string representing a filepath + name."
 ;; Logging.
 (define (user-default-log-file)
   "Return the file name of the user's default log file."
-  (mkdir-p %user-config-dir #o700)
-  (string-append %user-config-dir "/shepherd.log"))
+  (mkdir-p %user-log-dir #o700)
+  (string-append %user-log-dir "/shepherd.log"))
 
 (define default-logfile-date-format
   ;; 'strftime' format string to prefix each entry in the log.
diff --git a/tests/basic.sh b/tests/basic.sh
index a6148fc..5079aa1 100644
--- a/tests/basic.sh
+++ b/tests/basic.sh
@@ -24,6 +24,7 @@ herd --version
 socket="t-socket-$$"
 conf="t-conf-$$"
 confdir="t-confdir-$$"
+datadir="t-datadir-$$"
 log="t-log-$$"
 stamp="t-stamp-$$"
 pid="t-pid-$$"
@@ -259,7 +260,9 @@ test -f "$log"
 
 # Set XDG_CONFIG_HOME for configuration files.
 export XDG_CONFIG_HOME=$confdir
+export XDG_DATA_DIR=$datadir
 mkdir -p $confdir/shepherd
+mkdir -p $datadir/shepherd
 mv $conf $confdir/shepherd/init.scm
 rm -f "$pid" "$socket"
 shepherd -I -s "$socket" --pid="$pid" &
@@ -281,3 +284,4 @@ $herd stop root
 ! kill -0 $shepherd_pid
 
 rm -rf $confdir
+rm -rf $datadir



reply via email to

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