(address . guix-patches@gnu.org)
* 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