Skip to content

Commit fc1f279

Browse files
nixos/calibre-server: fix service argument escaping (#498278)
2 parents c6ea892 + 3f7f374 commit fc1f279

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

nixos/modules/services/misc/calibre-server.nix

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
config,
33
lib,
44
pkgs,
5+
utils,
56
...
67
}:
78
let
@@ -11,20 +12,17 @@ let
1112
documentationLink = "https://manual.calibre-ebook.com";
1213
generatedDocumentationLink = documentationLink + "/generated/en/calibre-server.html";
1314

14-
execFlags = (
15-
lib.concatStringsSep " " (
16-
lib.mapAttrsToList (k: v: "${k} ${toString v}") (
17-
lib.filterAttrs (name: value: value != null) {
18-
"--listen-on" = cfg.host;
19-
"--port" = cfg.port;
20-
"--auth-mode" = cfg.auth.mode;
21-
"--userdb" = cfg.auth.userDb;
22-
}
23-
)
24-
++ [ (lib.optionalString (cfg.auth.enable == true) "--enable-auth") ]
25-
++ cfg.extraFlags
15+
execFlags =
16+
lib.mapAttrsToList (k: v: "--${k}=${toString v}") (
17+
lib.filterAttrs (name: value: value != null) {
18+
listen-on = cfg.host;
19+
port = cfg.port;
20+
auth-mode = cfg.auth.mode;
21+
userdb = cfg.auth.userDb;
22+
}
2623
)
27-
);
24+
++ lib.optional cfg.auth.enable "--enable-auth"
25+
++ cfg.extraFlags;
2826
in
2927

3028
{
@@ -150,7 +148,9 @@ in
150148
serviceConfig = {
151149
User = cfg.user;
152150
Restart = "always";
153-
ExecStart = "${cfg.package}/bin/calibre-server ${lib.concatStringsSep " " cfg.libraries} ${execFlags}";
151+
ExecStart = utils.escapeSystemdExecArgs (
152+
[ "${cfg.package}/bin/calibre-server" ] ++ execFlags ++ [ "--" ] ++ cfg.libraries
153+
);
154154
};
155155

156156
};

0 commit comments

Comments
 (0)