From patchwork Sun Oct 11 09:20:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 24554 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 46D7227BBEA; Sun, 11 Oct 2020 10:22:10 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 81A0427BBEB for ; Sun, 11 Oct 2020 10:22:08 +0100 (BST) Received: from localhost ([::1]:54606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRXYN-0005pv-Jz for patchwork@mira.cbaines.net; Sun, 11 Oct 2020 05:22:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRXYI-0005pE-V4 for guix-patches@gnu.org; Sun, 11 Oct 2020 05:22:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55817) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kRXYI-0005HX-M6 for guix-patches@gnu.org; Sun, 11 Oct 2020 05:22:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kRXYI-00068b-HD for guix-patches@gnu.org; Sun, 11 Oct 2020 05:22:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#43920] [SHEPHERD PATCH] shepherd: Move log file to XDG_CACHE_DIR. Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 11 Oct 2020 09:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 43920 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 43920@debbugs.gnu.org Cc: Efraim Flashner X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.160240809223552 (code B ref -1); Sun, 11 Oct 2020 09:22:02 +0000 Received: (at submit) by debbugs.gnu.org; 11 Oct 2020 09:21:32 +0000 Received: from localhost ([127.0.0.1]:39130 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kRXXo-00067o-78 for submit@debbugs.gnu.org; Sun, 11 Oct 2020 05:21:32 -0400 Received: from lists.gnu.org ([209.51.188.17]:43280) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kRXXl-00067g-HZ for submit@debbugs.gnu.org; Sun, 11 Oct 2020 05:21:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48952) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRXXl-0005lQ-Bv for guix-patches@gnu.org; Sun, 11 Oct 2020 05:21:29 -0400 Received: from flashner.co.il ([178.62.234.194]:45238) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRXXj-0005Ct-Ic for guix-patches@gnu.org; Sun, 11 Oct 2020 05:21:29 -0400 Received: from localhost (unknown [141.226.15.20]) by flashner.co.il (Postfix) with ESMTPSA id 4B378401E5; Sun, 11 Oct 2020 09:20:54 +0000 (UTC) From: Efraim Flashner Date: Sun, 11 Oct 2020 12:20:17 +0300 Message-Id: <20201011092017.31901-1-efraim@flashner.co.il> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Received-SPF: pass client-ip=178.62.234.194; envelope-from=efraim@flashner.co.il; helo=flashner.co.il X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/11 05:20:54 X-ACL-Warn: Detected OS = ??? X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * modules/shepherd/support.scm (%user-log-dir): New variable. (user-default-log-file): Use it. * doc/shepherd.texi: (Invoking shepherd): Adjust listed default log file. * tests/basic.sh: Adjust for separate log directory. --- 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..0c3901e 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_CACHE_DIR/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..008b280 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_CACHE_DIR") + (string-append user-homedir "/.cache")) + "/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..145c0d3 100644 --- a/tests/basic.sh +++ b/tests/basic.sh @@ -24,6 +24,7 @@ herd --version socket="t-socket-$$" conf="t-conf-$$" confdir="t-confdir-$$" +cachedir="t-cachedir-$$" 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_CACHE_DIR=$cachedir mkdir -p $confdir/shepherd +mkdir -p $cachedir/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 $cachedir