diff mbox series

[bug#57363,v2] shepherd: Set #o640 permissions for log file of service in container.

Message ID 20220829191547.2685-1-arunisaac@systemreboot.net
State Accepted
Headers show
Series [bug#57363,v2] shepherd: Set #o640 permissions for log file of service in container. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Arun Isaac Aug. 29, 2022, 7:15 p.m. UTC
* gnu/build/shepherd.scm (make-forkexec-constructor/container): Set #o640
permissions for log file.
---
 gnu/build/shepherd.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Ludovic Courtès Sept. 2, 2022, 9:21 a.m. UTC | #1
Hi,

Arun Isaac <arunisaac@systemreboot.net> skribis:

> * gnu/build/shepherd.scm (make-forkexec-constructor/container): Set #o640
> permissions for log file.

LGTM!

However, note that ‘make-forkexec-constructor/container’ is now
deprecated in favor of (guix least-authority); apparently PageKite and
Jami are the only real users left.

Thanks,
Ludo’.
Arun Isaac Sept. 2, 2022, 11:20 a.m. UTC | #2
>> * gnu/build/shepherd.scm (make-forkexec-constructor/container): Set #o640
>> permissions for log file.
>
> LGTM!

Thanks, pushed!

> However, note that ‘make-forkexec-constructor/container’ is now
> deprecated in favor of (guix least-authority); apparently PageKite and
> Jami are the only real users left.

Ah, I didn't know. I've been making extensive use of
make-forkexec-constructor/container in guix-forge and all my
services. Time to switch!
diff mbox series

Patch

diff --git a/gnu/build/shepherd.scm b/gnu/build/shepherd.scm
index f4caefce3c..9d9bfcfbc0 100644
--- a/gnu/build/shepherd.scm
+++ b/gnu/build/shepherd.scm
@@ -2,6 +2,7 @@ 
 ;;; Copyright © 2017, 2018, 2019, 2020, 2022 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2020 Mathieu Othacehe <othacehe@gnu.org>
 ;;; Copyright © 2022 Leo Nikkilä <hello@lnikki.la>
+;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -186,7 +187,7 @@  (define mounts
     (when log-file
       ;; Create LOG-FILE so we can map it in the container.
       (unless (file-exists? log-file)
-        (call-with-output-file log-file (const #t))
+        (close (open log-file (logior O_CREAT O_APPEND O_CLOEXEC) #o640))
         (when user
           (let ((pw (getpwnam user)))
             (chown log-file (passwd:uid pw) (passwd:gid pw))))))