diff options
| author | Sören Tempel <soeren+git@soeren-tempel.net> | 2026-05-16 13:57:23 +0200 |
|---|---|---|
| committer | Sören Tempel <soeren+git@soeren-tempel.net> | 2026-05-17 17:59:35 +0200 |
| commit | 258cabed3285ec66893cc83ae704a40d57fec9ac (patch) | |
| tree | c442e33b0fcea12c7b621160474294992d4e4107 /gnu/services | |
| parent | 28b1f28153439e47c141231549a1b809af291261 (diff) | |
services: gunicorn: Allow configuration of socket user/group/mode
Without this change, the mode is not at all configurable meaning
that—depending on the umask(1)—it may allow access to others. Further,
in many scenarios the owner/group of the Unix domain socket should
differ from the owner/group of the gunicorn process. For example,
we might want to grant the nginx group access to the socket but not
use that as the GID for the gunicorn process.
* gnu/services/web.scm (<gunicorn-app>): Add socket-user, socket-group
and socket-mode.
* gnu/services/web.scm (gunicorn-activation): Respect
gunicorn-app-socket-user, gunicorn-socket-app-group, and
gunicorn-app-socket-mode.
* doc/guix.texi (Guix Services): Document new record fields.
Change-Id: I1fe5b77deb791c38c1642753a52098d304124049
Diffstat (limited to 'gnu/services')
| -rw-r--r-- | gnu/services/web.scm | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 9acf9b0f5be..b17ccd59fc7 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm | |||
| @@ -1061,6 +1061,14 @@ renewed TLS certificates, or @code{include}d files.") | |||
| 1061 | (wsgi-app-module gunicorn-app-wsgi-app-module) | 1061 | (wsgi-app-module gunicorn-app-wsgi-app-module) |
| 1062 | (user gunicorn-app-user) | 1062 | (user gunicorn-app-user) |
| 1063 | (group gunicorn-app-group) | 1063 | (group gunicorn-app-group) |
| 1064 | (socket-user gunicorn-app-socket-user | ||
| 1065 | (default (gunicorn-app-user this-gunicorn-app)) | ||
| 1066 | (thunked)) | ||
| 1067 | (socket-group gunicorn-app-socket-group | ||
| 1068 | (default (gunicorn-app-group this-gunicorn-app)) | ||
| 1069 | (thunked)) | ||
| 1070 | (socket-mode gunicorn-app-socket-mode | ||
| 1071 | (default #o750)) | ||
| 1064 | (sockets gunicorn-app-sockets | 1072 | (sockets gunicorn-app-sockets |
| 1065 | (default (list (string-append "unix:/var/run/gunicorn/" | 1073 | (default (list (string-append "unix:/var/run/gunicorn/" |
| 1066 | (gunicorn-app-name this-gunicorn-app) | 1074 | (gunicorn-app-name this-gunicorn-app) |
| @@ -1094,16 +1102,18 @@ renewed TLS certificates, or @code{include}d files.") | |||
| 1094 | 1102 | ||
| 1095 | ;; Create socket directories and set ownership. | 1103 | ;; Create socket directories and set ownership. |
| 1096 | (for-each (match-lambda | 1104 | (for-each (match-lambda |
| 1097 | ((user group socket-directories ...) | 1105 | ((user group mode socket-directories ...) |
| 1098 | (for-each (lambda (socket-directory) | 1106 | (for-each (lambda (socket-directory) |
| 1099 | (mkdir-p socket-directory) | 1107 | (mkdir-p socket-directory) |
| 1108 | (chmod socket-directory mode) | ||
| 1100 | (chown socket-directory | 1109 | (chown socket-directory |
| 1101 | (passwd:uid (getpw user)) | 1110 | (passwd:uid (getpw user)) |
| 1102 | (group:gid (getgrnam group)))) | 1111 | (group:gid (getgrnam group)))) |
| 1103 | socket-directories))) | 1112 | socket-directories))) |
| 1104 | '#$(map (lambda (app) | 1113 | '#$(map (lambda (app) |
| 1105 | (cons* (gunicorn-app-user app) | 1114 | (cons* (gunicorn-app-socket-user app) |
| 1106 | (gunicorn-app-group app) | 1115 | (gunicorn-app-socket-group app) |
| 1116 | (gunicorn-app-socket-mode app) | ||
| 1107 | (filter-map (lambda (socket) | 1117 | (filter-map (lambda (socket) |
| 1108 | (and | 1118 | (and |
| 1109 | (unix-socket? socket) | 1119 | (unix-socket? socket) |
