opensmtpd: support filters.
This commit is contained in:
parent
db18b6e828
commit
0dfddc5a54
@ -46,6 +46,17 @@ in {
|
|||||||
is left empty, the OpenSMTPD server will not start.
|
is left empty, the OpenSMTPD server will not start.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
procPackages = mkOption {
|
||||||
|
type = types.listOf types.path;
|
||||||
|
default = [];
|
||||||
|
description = ''
|
||||||
|
Packages to search for filters, tables, queues, and schedulers.
|
||||||
|
|
||||||
|
Add OpenSMTPD-extras here if you want to use the filters, etc. from
|
||||||
|
that package.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -72,12 +83,19 @@ in {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.opensmtpd = {
|
systemd.services.opensmtpd = let
|
||||||
|
procEnv = pkgs.buildEnv {
|
||||||
|
name = "opensmtpd-procs";
|
||||||
|
paths = [ opensmtpd ] ++ cfg.procPackages;
|
||||||
|
pathsToLink = [ "/libexec/opensmtpd" ];
|
||||||
|
};
|
||||||
|
in {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
wants = [ "network.target" ];
|
wants = [ "network.target" ];
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
preStart = "mkdir -p /var/spool";
|
preStart = "mkdir -p /var/spool";
|
||||||
serviceConfig.ExecStart = "${opensmtpd}/sbin/smtpd -d -f ${conf} ${args}";
|
serviceConfig.ExecStart = "${opensmtpd}/sbin/smtpd -d -f ${conf} ${args}";
|
||||||
|
environment.OPENSMTPD_PROC_PATH = "${procEnv}/libexec/opensmtpd";
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = [ (pkgs.runCommand "opensmtpd-sendmail" {} ''
|
environment.systemPackages = [ (pkgs.runCommand "opensmtpd-sendmail" {} ''
|
||||||
|
@ -14,6 +14,8 @@ stdenv.mkDerivation rec {
|
|||||||
sha256 = "67e9dd9682ca8c181e84e66c76245a4a8f6205834f915a2c021cdfeb22049e3a";
|
sha256 = "67e9dd9682ca8c181e84e66c76245a4a8f6205834f915a2c021cdfeb22049e3a";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
patches = [ ./proc_path.diff ];
|
||||||
|
|
||||||
configureFlags = [
|
configureFlags = [
|
||||||
"--sysconfdir=/etc"
|
"--sysconfdir=/etc"
|
||||||
"--localstatedir=/var"
|
"--localstatedir=/var"
|
||||||
|
76
pkgs/servers/mail/opensmtpd/proc_path.diff
Normal file
76
pkgs/servers/mail/opensmtpd/proc_path.diff
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
diff -Naur opensmtpd-5.7.1p1/smtpd/parse.y opensmtpd-5.7.1p1.patched/smtpd/parse.y
|
||||||
|
--- opensmtpd-5.7.1p1/smtpd/parse.y 2015-06-30 10:13:34.000000000 +0200
|
||||||
|
+++ opensmtpd-5.7.1p1.patched/smtpd/parse.y 2015-09-26 08:41:17.012472516 +0200
|
||||||
|
@@ -2519,13 +2519,19 @@
|
||||||
|
{
|
||||||
|
struct filter_conf *f;
|
||||||
|
char *path;
|
||||||
|
+ const char *proc_path;
|
||||||
|
|
||||||
|
if (dict_get(&conf->sc_filters, name)) {
|
||||||
|
yyerror("filter \"%s\" already defined", name);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (asprintf(&path, "%s/filter-%s", PATH_LIBEXEC, prog) == -1) {
|
||||||
|
+ proc_path = getenv("OPENSMTPD_PROC_PATH");
|
||||||
|
+ if (proc_path == NULL) {
|
||||||
|
+ proc_path = PATH_LIBEXEC;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (asprintf(&path, "%s/filter-%s", proc_path, prog) == -1) {
|
||||||
|
yyerror("filter \"%s\" asprintf failed", name);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
diff -Naur opensmtpd-5.7.1p1/smtpd/smtpd.c opensmtpd-5.7.1p1.patched/smtpd/smtpd.c
|
||||||
|
--- opensmtpd-5.7.1p1/smtpd/smtpd.c 2015-06-30 10:13:34.000000000 +0200
|
||||||
|
+++ opensmtpd-5.7.1p1.patched/smtpd/smtpd.c 2015-09-26 08:41:16.998472557 +0200
|
||||||
|
@@ -854,6 +854,7 @@
|
||||||
|
char path[PATH_MAX];
|
||||||
|
char name[PATH_MAX];
|
||||||
|
char *arg;
|
||||||
|
+ char *proc_path;
|
||||||
|
|
||||||
|
if (strlcpy(name, conf, sizeof(name)) >= sizeof(name)) {
|
||||||
|
log_warnx("warn: %s-proc: conf too long", key);
|
||||||
|
@@ -864,7 +865,12 @@
|
||||||
|
if (arg)
|
||||||
|
*arg++ = '\0';
|
||||||
|
|
||||||
|
- if (snprintf(path, sizeof(path), PATH_LIBEXEC "/%s-%s", key, name) >=
|
||||||
|
+ proc_path = getenv("OPENSMTPD_PROC_PATH");
|
||||||
|
+ if (proc_path == NULL) {
|
||||||
|
+ proc_path = PATH_LIBEXEC;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (snprintf(path, sizeof(path), "%s/%s-%s", proc_path, key, name) >=
|
||||||
|
(ssize_t)sizeof(path)) {
|
||||||
|
log_warn("warn: %s-proc: exec path too long", key);
|
||||||
|
return (-1);
|
||||||
|
diff -Naur opensmtpd-5.7.1p1/smtpd/table.c opensmtpd-5.7.1p1.patched/smtpd/table.c
|
||||||
|
--- opensmtpd-5.7.1p1/smtpd/table.c 2015-06-30 10:13:34.000000000 +0200
|
||||||
|
+++ opensmtpd-5.7.1p1.patched/smtpd/table.c 2015-09-26 08:41:17.005472536 +0200
|
||||||
|
@@ -201,6 +201,7 @@
|
||||||
|
struct table_backend *tb;
|
||||||
|
char buf[LINE_MAX];
|
||||||
|
char path[LINE_MAX];
|
||||||
|
+ const char *proc_path;
|
||||||
|
size_t n;
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
|
@@ -215,8 +216,14 @@
|
||||||
|
if (name && table_find(name, NULL))
|
||||||
|
fatalx("table_create: table \"%s\" already defined", name);
|
||||||
|
|
||||||
|
+ proc_path = getenv("OPENSMTPD_PROC_PATH");
|
||||||
|
+ if (proc_path == NULL) {
|
||||||
|
+ proc_path = PATH_LIBEXEC;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if ((tb = table_backend_lookup(backend)) == NULL) {
|
||||||
|
- if ((size_t)snprintf(path, sizeof(path), PATH_LIBEXEC "/table-%s",
|
||||||
|
+ if ((size_t)snprintf(path, sizeof(path), "%s/table-%s",
|
||||||
|
+ proc_path,
|
||||||
|
backend) >= sizeof(path)) {
|
||||||
|
fatalx("table_create: path too long \""
|
||||||
|
PATH_LIBEXEC "/table-%s\"", backend);
|
Loading…
Reference in New Issue
Block a user