Subject: Re: bug#73196: [PATCH] services: postgresql-role: Add support for password files.
From: Maxim Cournoyer <[email-masked]>
To: paul <[email-masked]>
Cc: Ludovic Courtès <[email-masked]>, [email-masked]
Date: Fri, 02 May 2025 15:33:40 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi Paul,

paul <[email-masked]> writes:

> Hi Maxim,
>
> I should have addressed all your remaining comments. I'm about to send
> a v8, hopefully this will be the correct one :) thank you a lot for
> your help

Thanks!  I've made a few cosmetic changes, e.g.:

--8<---------------cut here---------------start------------->8---
3 files changed, 18 insertions(+), 18 deletions(-)
doc/guix.texi              |  5 +++--
gnu/services/databases.scm | 17 +++++++++--------
gnu/tests/databases.scm    | 14 ++++++--------

modified   doc/guix.texi
@@ -27805,8 +27805,9 @@ Database Services
 
 @item @code{shepherd-requirement} (default: @code{'(user-processes postgres)})
 
-Set additional Shepherd services dependencies to the provisioned
-Shepherd service.
+The Shepherd services dependencies to use.  Add extra dependencies to
+@code{%default-postgresql-role-shepherd-requirement} to extend its
+value.
 
 @item @code{roles} (default: @code{'()})
 The initial PostgreSQL roles to create.
modified   gnu/services/databases.scm
@@ -417,14 +417,15 @@ (define %default-postgresql-role-shepherd-requirement
 (define-record-type* <postgresql-role-configuration>
   postgresql-role-configuration make-postgresql-role-configuration
   postgresql-role-configuration?
-  (host                  postgresql-role-configuration-host ;string
-                         (default "/var/run/postgresql"))
-  (shepherd-requirement  postgresql-role-configuration-shepherd-requirement ;list-of-symbols
-                         (default %default-postgresql-role-shepherd-requirement))
-  (log                   postgresql-role-configuration-log ;string
-                         (default "/var/log/postgresql_roles.log"))
-  (roles                 postgresql-role-configuration-roles
-                         (default '()))) ;list
+  (shepherd-requirement
+   postgresql-role-configuration-shepherd-requirement ;list-of-symbols
+   (default %default-postgresql-role-shepherd-requirement))
+  (host             postgresql-role-configuration-host ;string
+                    (default "/var/run/postgresql"))
+  (log              postgresql-role-configuration-log ;string
+                    (default "/var/log/postgresql_roles.log"))
+  (roles            postgresql-role-configuration-roles
+                    (default '()))) ;list
 
 (define (postgresql-create-roles config)
   ;; See: https://www.postgresql.org/docs/current/sql-createrole.html for the
modified   gnu/tests/databases.scm
@@ -259,21 +259,19 @@ (define (run-postgresql-test)
           (test-assert "database use fails without a password"
             (marionette-eval
              '(begin
-                (use-modules (gnu services herd)
-                             (ice-9 popen))
                 (setgid (passwd:gid (getpwnam "alice")))
                 (setuid (passwd:uid (getpw "alice")))
-                (let ((output
-                       (system* #$(file-append postgresql "/bin/psql") "-tA" "-h" "localhost" "-U" "a_database" "-c"
-                                "SELECT 1 FROM pg_database WHERE datname='a_database'")))
-                  (not (= output 0))))
+                (not (zero?
+                      (system* #$(file-append postgresql "/bin/psql")
+                               "-tA" "-h" "localhost" "-U" "a_database" "-c"
+                               (string-append "SELECT 1 FROM pg_database "
+                                              "WHERE datname='a_database'")))))
              marionette))
 
           (test-assert "database passwords are set"
             (marionette-eval
              '(begin
-                (use-modules (gnu services herd)
-                             (ice-9 popen))
+                (use-modules (ice-9 popen))
                 (setgid (passwd:gid (getpwnam "alice")))
                 (setuid (passwd:uid (getpw "alice")))
                 (setenv "PGPASSWORD"
--8<---------------cut here---------------end--------------->8---

ensured 'make check-system TESTS=postgresql' was still happy, and
pushed as commit 9d216d2ae9f.  Thank you!

-- 
Thanks,
Maxim