jql: 8.0.0 -> 8.0.2 (#362884)
[NixPkgs.git] / pkgs / servers / mail / opensmtpd / proc_path.diff
bloba60bb603aacf1a0ee4e0c9c0dae52a5cfcb95749
1 diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c
2 index e049f07c..a1bd03a0 100644
3 --- a/usr.sbin/smtpd/smtpd.c
4 +++ b/usr.sbin/smtpd/smtpd.c
5 @@ -1157,6 +1157,7 @@ fork_proc_backend(const char *key, const char *conf, const char *procname)
6 char path[PATH_MAX];
7 char name[PATH_MAX];
8 char *arg;
9 + char *proc_path;
11 if (strlcpy(name, conf, sizeof(name)) >= sizeof(name)) {
12 log_warnx("warn: %s-proc: conf too long", key);
13 @@ -1167,7 +1168,12 @@ fork_proc_backend(const char *key, const char *conf, const char *procname)
14 if (arg)
15 *arg++ = '\0';
17 - if (snprintf(path, sizeof(path), PATH_LIBEXEC "/%s-%s", key, name) >=
18 + proc_path = getenv("OPENSMTPD_PROC_PATH");
19 + if (proc_path == NULL) {
20 + proc_path = PATH_LIBEXEC;
21 + }
23 + if (snprintf(path, sizeof(path), "%s/%s-%s", proc_path, key, name) >=
24 (ssize_t)sizeof(path)) {
25 log_warn("warn: %s-proc: exec path too long", key);
26 return (-1);
27 diff --git a/usr.sbin/smtpd/table.c b/usr.sbin/smtpd/table.c
28 index 9cfdfb99..24dfcca4 100644
29 --- a/usr.sbin/smtpd/table.c
30 +++ b/usr.sbin/smtpd/table.c
31 @@ -201,6 +201,7 @@ table_create(const char *backend, const char *name, const char *tag,
32 struct table_backend *tb;
33 char buf[LINE_MAX];
34 char path[LINE_MAX];
35 + const char *proc_path;
36 size_t n;
37 struct stat sb;
39 @@ -215,11 +216,16 @@ table_create(const char *backend, const char *name, const char *tag,
40 if (name && table_find(name, NULL))
41 fatalx("table_create: table \"%s\" already defined", name);
43 + proc_path = getenv("OPENSMTPD_PROC_PATH");
44 + if (proc_path == NULL) {
45 + proc_path = PATH_LIBEXEC;
46 + }
48 if ((tb = table_backend_lookup(backend)) == NULL) {
49 - if ((size_t)snprintf(path, sizeof(path), PATH_LIBEXEC"/table-%s",
50 - backend) >= sizeof(path)) {
51 - fatalx("table_create: path too long \""
52 - PATH_LIBEXEC"/table-%s\"", backend);
53 + if ((size_t)snprintf(path, sizeof(path), "%s/table-%s",
54 + proc_path, backend) >= sizeof(path)) {
55 + fatalx("table_create: path too long \"%s/table-%s\"",
56 + proc_path, backend);
58 if (stat(path, &sb) == 0) {
59 tb = table_backend_lookup("proc");