unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
To: 43921@debbugs.gnu.org
Subject: [bug#43921] [Shepherd PATCH 1/2] Use XDG_CACHE_HOME/shepherd for unprivileged users' log directory.
Date: Sun, 11 Oct 2020 11:43:57 +0200	[thread overview]
Message-ID: <20201011094358.14013-1-janneke@gnu.org> (raw)
In-Reply-To: <874kn1rtgn.fsf@gnu.org>

* modules/shepherd/support.scm (%user-cache-dir): New variable.
(user-default-log-file): Use it.
* doc/shepherd.texi (Invoking shepherd): Document it.
---
 doc/shepherd.texi            |  4 +++-
 modules/shepherd/support.scm | 11 +++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/doc/shepherd.texi b/doc/shepherd.texi
index 696477e..7c9a739 100644
--- a/doc/shepherd.texi
+++ b/doc/shepherd.texi
@@ -417,7 +417,9 @@ 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_CACHE_HOME/shepherd/shepherd.log}.  If the
+@code{XDG_CACHE_HOME} environment variable is not defined,
+@code{$HOME/.cache/shepherd/shepherd.log} is used instead.
 
 @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..fe64a05 100644
--- a/modules/shepherd/support.scm
+++ b/modules/shepherd/support.scm
@@ -4,6 +4,7 @@
 ;; Copyright (C) 2002, 2003 Wolfgang Jährling <wolfgang@pro-linux.de>
 ;; Copyright (C) 2016 Mathieu Lirzin <mthl@gnu.org>
 ;; Copyright (C) 2018 Danny Milosavljevic <dannym@scratchpost.org>
+;; Copyright (C) 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;
 ;; This file is part of the GNU Shepherd.
 ;;
@@ -265,6 +266,12 @@ There is NO WARRANTY, to the extent permitted by law.")))
       (false-if-exception (passwd:dir (getpwuid (getuid))))
       "/"))
 
+(define %user-cache-dir
+  ;; Default cache directory if shepherd is run as a normal user.
+  (string-append (or (getenv "XDG_CACHE_HOME")
+                     (string-append user-homedir "/.cache"))
+                 "/shepherd"))
+
 (define %user-config-dir
   ;; Default config directory if shepherd is run as a normal user.
   (string-append (or (getenv "XDG_CONFIG_HOME")
@@ -302,8 +309,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-cache-dir #o700)
+  (string-append %user-cache-dir "/shepherd.log"))
 
 (define default-logfile-date-format
   ;; 'strftime' format string to prefix each entry in the log.
-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com





  reply	other threads:[~2020-10-11  9:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-11  9:40 [bug#43921] [Shepherd PATCH 0/2] Add User Service example Jan Nieuwenhuizen
2020-10-11  9:43 ` Jan (janneke) Nieuwenhuizen [this message]
2020-10-11  9:43   ` [bug#43921] [Shepherd PATCH 2/2] " Jan (janneke) Nieuwenhuizen
2020-10-11 10:38     ` Jan Nieuwenhuizen
2020-10-11 12:10 ` [bug#43921] [Shepherd PATCH v2 " Jan (janneke) Nieuwenhuizen
2020-10-12  5:15 ` [bug#43921] [PATCH v3 " Jan (janneke) Nieuwenhuizen
2020-10-23 13:31   ` Ludovic Courtès
2020-10-23 16:37     ` Jan Nieuwenhuizen
2020-11-18 21:37       ` bug#43921: " Ludovic Courtès
2020-11-19  6:00         ` [bug#43921] " Jan Nieuwenhuizen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201011094358.14013-1-janneke@gnu.org \
    --to=janneke@gnu.org \
    --cc=43921@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).