tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
opensmtpd: support filters.
Gabriel Ebner
10 years ago
0dfddc5a
db18b6e8
+97
-1
3 changed files
expand all
collapse all
unified
split
nixos
modules
services
mail
opensmtpd.nix
pkgs
servers
mail
opensmtpd
default.nix
proc_path.diff
+19
-1
nixos/modules/services/mail/opensmtpd.nix
···
46
46
is left empty, the OpenSMTPD server will not start.
47
47
'';
48
48
};
49
49
+
50
50
+
procPackages = mkOption {
51
51
+
type = types.listOf types.path;
52
52
+
default = [];
53
53
+
description = ''
54
54
+
Packages to search for filters, tables, queues, and schedulers.
55
55
+
56
56
+
Add OpenSMTPD-extras here if you want to use the filters, etc. from
57
57
+
that package.
58
58
+
'';
59
59
+
};
49
60
};
50
61
51
62
};
···
72
83
};
73
84
};
74
85
75
75
-
systemd.services.opensmtpd = {
86
86
+
systemd.services.opensmtpd = let
87
87
+
procEnv = pkgs.buildEnv {
88
88
+
name = "opensmtpd-procs";
89
89
+
paths = [ opensmtpd ] ++ cfg.procPackages;
90
90
+
pathsToLink = [ "/libexec/opensmtpd" ];
91
91
+
};
92
92
+
in {
76
93
wantedBy = [ "multi-user.target" ];
77
94
wants = [ "network.target" ];
78
95
after = [ "network.target" ];
79
96
preStart = "mkdir -p /var/spool";
80
97
serviceConfig.ExecStart = "${opensmtpd}/sbin/smtpd -d -f ${conf} ${args}";
98
98
+
environment.OPENSMTPD_PROC_PATH = "${procEnv}/libexec/opensmtpd";
81
99
};
82
100
83
101
environment.systemPackages = [ (pkgs.runCommand "opensmtpd-sendmail" {} ''
+2
pkgs/servers/mail/opensmtpd/default.nix
···
14
14
sha256 = "67e9dd9682ca8c181e84e66c76245a4a8f6205834f915a2c021cdfeb22049e3a";
15
15
};
16
16
17
17
+
patches = [ ./proc_path.diff ];
18
18
+
17
19
configureFlags = [
18
20
"--sysconfdir=/etc"
19
21
"--localstatedir=/var"
+76
pkgs/servers/mail/opensmtpd/proc_path.diff
···
1
1
+
diff -Naur opensmtpd-5.7.1p1/smtpd/parse.y opensmtpd-5.7.1p1.patched/smtpd/parse.y
2
2
+
--- opensmtpd-5.7.1p1/smtpd/parse.y 2015-06-30 10:13:34.000000000 +0200
3
3
+
+++ opensmtpd-5.7.1p1.patched/smtpd/parse.y 2015-09-26 08:41:17.012472516 +0200
4
4
+
@@ -2519,13 +2519,19 @@
5
5
+
{
6
6
+
struct filter_conf *f;
7
7
+
char *path;
8
8
+
+ const char *proc_path;
9
9
+
10
10
+
if (dict_get(&conf->sc_filters, name)) {
11
11
+
yyerror("filter \"%s\" already defined", name);
12
12
+
return (NULL);
13
13
+
}
14
14
+
15
15
+
- if (asprintf(&path, "%s/filter-%s", PATH_LIBEXEC, prog) == -1) {
16
16
+
+ proc_path = getenv("OPENSMTPD_PROC_PATH");
17
17
+
+ if (proc_path == NULL) {
18
18
+
+ proc_path = PATH_LIBEXEC;
19
19
+
+ }
20
20
+
+
21
21
+
+ if (asprintf(&path, "%s/filter-%s", proc_path, prog) == -1) {
22
22
+
yyerror("filter \"%s\" asprintf failed", name);
23
23
+
return (0);
24
24
+
}
25
25
+
diff -Naur opensmtpd-5.7.1p1/smtpd/smtpd.c opensmtpd-5.7.1p1.patched/smtpd/smtpd.c
26
26
+
--- opensmtpd-5.7.1p1/smtpd/smtpd.c 2015-06-30 10:13:34.000000000 +0200
27
27
+
+++ opensmtpd-5.7.1p1.patched/smtpd/smtpd.c 2015-09-26 08:41:16.998472557 +0200
28
28
+
@@ -854,6 +854,7 @@
29
29
+
char path[PATH_MAX];
30
30
+
char name[PATH_MAX];
31
31
+
char *arg;
32
32
+
+ char *proc_path;
33
33
+
34
34
+
if (strlcpy(name, conf, sizeof(name)) >= sizeof(name)) {
35
35
+
log_warnx("warn: %s-proc: conf too long", key);
36
36
+
@@ -864,7 +865,12 @@
37
37
+
if (arg)
38
38
+
*arg++ = '\0';
39
39
+
40
40
+
- if (snprintf(path, sizeof(path), PATH_LIBEXEC "/%s-%s", key, name) >=
41
41
+
+ proc_path = getenv("OPENSMTPD_PROC_PATH");
42
42
+
+ if (proc_path == NULL) {
43
43
+
+ proc_path = PATH_LIBEXEC;
44
44
+
+ }
45
45
+
+
46
46
+
+ if (snprintf(path, sizeof(path), "%s/%s-%s", proc_path, key, name) >=
47
47
+
(ssize_t)sizeof(path)) {
48
48
+
log_warn("warn: %s-proc: exec path too long", key);
49
49
+
return (-1);
50
50
+
diff -Naur opensmtpd-5.7.1p1/smtpd/table.c opensmtpd-5.7.1p1.patched/smtpd/table.c
51
51
+
--- opensmtpd-5.7.1p1/smtpd/table.c 2015-06-30 10:13:34.000000000 +0200
52
52
+
+++ opensmtpd-5.7.1p1.patched/smtpd/table.c 2015-09-26 08:41:17.005472536 +0200
53
53
+
@@ -201,6 +201,7 @@
54
54
+
struct table_backend *tb;
55
55
+
char buf[LINE_MAX];
56
56
+
char path[LINE_MAX];
57
57
+
+ const char *proc_path;
58
58
+
size_t n;
59
59
+
struct stat sb;
60
60
+
61
61
+
@@ -215,8 +216,14 @@
62
62
+
if (name && table_find(name, NULL))
63
63
+
fatalx("table_create: table \"%s\" already defined", name);
64
64
+
65
65
+
+ proc_path = getenv("OPENSMTPD_PROC_PATH");
66
66
+
+ if (proc_path == NULL) {
67
67
+
+ proc_path = PATH_LIBEXEC;
68
68
+
+ }
69
69
+
+
70
70
+
if ((tb = table_backend_lookup(backend)) == NULL) {
71
71
+
- if ((size_t)snprintf(path, sizeof(path), PATH_LIBEXEC "/table-%s",
72
72
+
+ if ((size_t)snprintf(path, sizeof(path), "%s/table-%s",
73
73
+
+ proc_path,
74
74
+
backend) >= sizeof(path)) {
75
75
+
fatalx("table_create: path too long \""
76
76
+
PATH_LIBEXEC "/table-%s\"", backend);