proc_path.diff (2739B)
1 diff -Naur opensmtpd-5.7.1p1/smtpd/parse.y opensmtpd-5.7.1p1.patched/smtpd/parse.y 2 --- opensmtpd-5.7.1p1/smtpd/parse.y 2015-06-30 10:13:34.000000000 +0200 3 +++ opensmtpd-5.7.1p1.patched/smtpd/parse.y 2015-09-26 08:41:17.012472516 +0200 4 @@ -2519,13 +2519,19 @@ 5 { 6 struct filter_conf *f; 7 char *path; 8 + const char *proc_path; 9 10 if (dict_get(&conf->sc_filters, name)) { 11 yyerror("filter \"%s\" already defined", name); 12 return (NULL); 13 } 14 15 - if (asprintf(&path, "%s/filter-%s", PATH_LIBEXEC, prog) == -1) { 16 + proc_path = getenv("OPENSMTPD_PROC_PATH"); 17 + if (proc_path == NULL) { 18 + proc_path = PATH_LIBEXEC; 19 + } 20 + 21 + if (asprintf(&path, "%s/filter-%s", proc_path, prog) == -1) { 22 yyerror("filter \"%s\" asprintf failed", name); 23 return (0); 24 } 25 diff -Naur opensmtpd-5.7.1p1/smtpd/smtpd.c opensmtpd-5.7.1p1.patched/smtpd/smtpd.c 26 --- opensmtpd-5.7.1p1/smtpd/smtpd.c 2015-06-30 10:13:34.000000000 +0200 27 +++ opensmtpd-5.7.1p1.patched/smtpd/smtpd.c 2015-09-26 08:41:16.998472557 +0200 28 @@ -854,6 +854,7 @@ 29 char path[PATH_MAX]; 30 char name[PATH_MAX]; 31 char *arg; 32 + char *proc_path; 33 34 if (strlcpy(name, conf, sizeof(name)) >= sizeof(name)) { 35 log_warnx("warn: %s-proc: conf too long", key); 36 @@ -864,7 +865,12 @@ 37 if (arg) 38 *arg++ = '\0'; 39 40 - if (snprintf(path, sizeof(path), PATH_LIBEXEC "/%s-%s", key, name) >= 41 + proc_path = getenv("OPENSMTPD_PROC_PATH"); 42 + if (proc_path == NULL) { 43 + proc_path = PATH_LIBEXEC; 44 + } 45 + 46 + if (snprintf(path, sizeof(path), "%s/%s-%s", proc_path, key, name) >= 47 (ssize_t)sizeof(path)) { 48 log_warn("warn: %s-proc: exec path too long", key); 49 return (-1); 50 diff -Naur opensmtpd-5.7.1p1/smtpd/table.c opensmtpd-5.7.1p1.patched/smtpd/table.c 51 --- opensmtpd-5.7.1p1/smtpd/table.c 2015-06-30 10:13:34.000000000 +0200 52 +++ opensmtpd-5.7.1p1.patched/smtpd/table.c 2015-09-26 08:41:17.005472536 +0200 53 @@ -201,6 +201,7 @@ 54 struct table_backend *tb; 55 char buf[LINE_MAX]; 56 char path[LINE_MAX]; 57 + const char *proc_path; 58 size_t n; 59 struct stat sb; 60 61 @@ -215,8 +216,14 @@ 62 if (name && table_find(name, NULL)) 63 fatalx("table_create: table \"%s\" already defined", name); 64 65 + proc_path = getenv("OPENSMTPD_PROC_PATH"); 66 + if (proc_path == NULL) { 67 + proc_path = PATH_LIBEXEC; 68 + } 69 + 70 if ((tb = table_backend_lookup(backend)) == NULL) { 71 - if ((size_t)snprintf(path, sizeof(path), PATH_LIBEXEC "/table-%s", 72 + if ((size_t)snprintf(path, sizeof(path), "%s/table-%s", 73 + proc_path, 74 backend) >= sizeof(path)) { 75 fatalx("table_create: path too long \"" 76 PATH_LIBEXEC "/table-%s\"", backend);