[PATCH v2 3/4] services: postgresql: Ensure correct ownership of directory trees.

  • Open
  • quality assurance status badge
Details
One participant
  • Brice Waegeneire
Owner
unassigned
Submitted by
Brice Waegeneire
Severity
normal
Merged with
B
B
Brice Waegeneire wrote on 21 Dec 2021 20:36
(address . guix-patches@gnu.org)
20211221193646.16849-3-brice@waegenei.re
* gnu/services/databases.scm (postgresql-activation): Replace 'chown'
calls by 'lchown-recursive'.
---
gnu/services/databases.scm | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

Toggle diff (59 lines)
diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index 39225a4bd6..58d93a8e35 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -8,6 +8,7 @@
;;; Copyright © 2019 Robert Vollmert <rob@vllmrt.net>
;;; Copyright © 2020 Marius Bakke <marius@gnu.org>
;;; Copyright © 2021 David Larsson <david.larsson@selfhosted.xyz>
+;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -214,8 +215,11 @@ (define postgresql-activation
(($ <postgresql-configuration> postgresql port locale config-file
log-directory data-directory
extension-packages)
- #~(begin
+ (with-imported-modules (source-module-closure
+ '((gnu build activation)))
+ #~(begin
(use-modules (guix build utils)
+ (gnu build activation)
(ice-9 match))
(let ((user (getpwnam "postgres"))
@@ -230,19 +234,19 @@ (define postgresql-activation
'()))))
;; Create db state directory.
(mkdir-p #$data-directory)
- (chown #$data-directory (passwd:uid user) (passwd:gid user))
+ (lchown-recursive #$data-directory (passwd:uid user) (passwd:gid user))
;; Create the socket directory.
(let ((socket-directory
#$(postgresql-config-file-socket-directory config-file)))
(when (string? socket-directory)
(mkdir-p socket-directory)
- (chown socket-directory (passwd:uid user) (passwd:gid user))))
+ (lchown-recursive socket-directory (passwd:uid user) (passwd:gid user))))
;; Create the log directory.
(when (string? #$log-directory)
(mkdir-p #$log-directory)
- (chown #$log-directory (passwd:uid user) (passwd:gid user)))
+ (lchown-recursive #$log-directory (passwd:uid user) (passwd:gid user)))
;; Drop privileges and init state directory in a new
;; process. Wait for it to finish before proceeding.
@@ -262,7 +266,7 @@ (define postgresql-activation
initdb-args)))
(lambda ()
(primitive-exit 1))))
- (pid (waitpid pid))))))))
+ (pid (waitpid pid)))))))))
(define postgresql-shepherd-service
(match-lambda
--
2.34.0
B
B
Brice Waegeneire wrote on 21 Dec 2021 21:10
control message for bug #52714
(address . control@debbugs.gnu.org)
E1mzlTO-00082G-Rt@debbugs.gnu.org
merge 52714 52454
quit
B
B
Brice Waegeneire wrote on 21 Dec 2021 21:10
control message for bug #52713
(address . control@debbugs.gnu.org)
E1mzlTW-00083L-0S@debbugs.gnu.org
merge 52713 52454
quit
B
B
Brice Waegeneire wrote on 21 Dec 2021 21:11
control message for bug #52712
(address . control@debbugs.gnu.org)
E1mzlTe-00083g-5l@debbugs.gnu.org
merge 52712 52454
quit
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 52714@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 52714
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch