Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 70 | magnus | 1 | Description: Changes related to the arguments sent to spamc, namely thst |
| 2 | we don't pass -d (SAspamcHost), -p (SAspamcPort), or -U (SAspamcSockPath) |
||
| 3 | if those options aren't set, as well as the new parameter -u (SAspamcUser). |
||
| 4 | Author: Magnus Holmgren <holmgren@debian.org> |
||
| 5 | Bug-Debian: http://bugs.debian.org/506571 |
||
| 6 | |||
| 7 | --- sa-exim-4.2.1.orig/sa-exim.c |
||
| 8 | +++ sa-exim-4.2.1/sa-exim.c |
||
| 9 | @@ -515,6 +513,7 @@ int local_scan(volatile int fd, uschar * |
||
| 10 | int pid; |
||
| 11 | int writefd[2]; |
||
| 12 | int readfd[2]; |
||
| 13 | + char *spamc_argv[10]; |
||
| 14 | int i; |
||
| 15 | /* These are the only values that we want working after the longjmp |
||
| 16 | * The automatic ones can be clobbered, but we don't really care */ |
||
| 17 | @@ -550,8 +549,9 @@ int local_scan(volatile int fd, uschar * |
||
| 18 | static char *SAspamcpath=SPAMC_LOCATION; |
||
| 19 | static char *SAsafemesgidchars=SAFEMESGIDCHARS |
||
| 20 | static char *SAspamcSockPath=NULL; |
||
| 21 | - static char *SAspamcPort="783"; |
||
| 22 | - static char *SAspamcHost="127.0.0.1"; |
||
| 23 | + static char *SAspamcPort=NULL; |
||
| 24 | + static char *SAspamcHost=NULL; |
||
| 25 | + static char *SAspamcUser=NULL; |
||
| 26 | static char *SAEximRunCond="0"; |
||
| 27 | static char *SAEximRejCond="1"; |
||
| 28 | static int SAmaxbody=250*1024; |
||
| 29 | @@ -712,6 +721,7 @@ int local_scan(volatile int fd, uschar * |
||
| 30 | M_CHECKFORSTR(SAspamcSockPath); |
||
| 31 | M_CHECKFORSTR(SAspamcPort); |
||
| 32 | M_CHECKFORSTR(SAspamcHost); |
||
| 33 | + M_CHECKFORSTR(SAspamcUser); |
||
| 34 | M_CHECKFORSTR(SAEximRunCond); |
||
| 35 | M_CHECKFORSTR(SAEximRejCond); |
||
| 36 | M_CHECKFORVAR(SAmaxbody, "%d"); |
||
| 37 | @@ -914,6 +924,22 @@ int local_scan(volatile int fd, uschar * |
||
| 38 | ret=dup2(readfd[1],2); |
||
| 39 | CHECKERR(ret,"dup2 stderr",__LINE__); |
||
| 40 | |||
| 41 | + i = 0; |
||
| 42 | + spamc_argv[i++] = "spamc"; |
||
| 43 | + if (SAspamcUser && SAspamcUser[0]) |
||
| 44 | + { |
||
| 45 | + expand=expand_string(SAspamcUser); |
||
| 46 | + if (expand == NULL) |
||
| 47 | + { |
||
| 48 | + log_write(0, LOG_MAIN | LOG_PANIC, "SA: SAspamcUser expansion failure on %s, will run as Exim user instead.", SAspamcUser); |
||
| 49 | + } |
||
| 50 | + else if (expand[0] != '\0') |
||
| 51 | + { |
||
| 52 | + spamc_argv[i++] = "-u"; |
||
| 53 | + spamc_argv[i++] = expand; |
||
| 54 | + } |
||
| 55 | + } |
||
| 56 | + |
||
| 57 | /* |
||
| 58 | * I could implement the spamc protocol and talk to spamd directly |
||
| 59 | * instead of forking spamc, but considering the overhead spent |
||
| 60 | @@ -924,17 +950,30 @@ int local_scan(volatile int fd, uschar * |
||
| 61 | /* Ok, we cheat, spamc cares about how big the whole message is and |
||
| 62 | * we only know about the body size, so I'll give an extra 16K |
||
| 63 | * to account for any headers that can accompany the message */ |
||
| 64 | + |
||
| 65 | + spamc_argv[i++] = "-s"; |
||
| 66 | + spamc_argv[i++] = string_sprintf("%d", SAmaxbody+16384); |
||
| 67 | + |
||
| 68 | if(SAspamcSockPath) |
||
| 69 | { |
||
| 70 | - ret=execl(SAspamcpath, "spamc", "-s", string_sprintf("%d", SAmaxbody+16384), "-U", SAspamcSockPath, NULL); |
||
| 71 | - CHECKERR(ret,string_sprintf("exec %s", SAspamcpath),__LINE__); |
||
| 72 | + spamc_argv[i++] = "-U"; |
||
| 73 | + spamc_argv[i++] = SAspamcSockPath; |
||
| 74 | } |
||
| 75 | else |
||
| 76 | { |
||
| 77 | - ret=execl(SAspamcpath, "spamc", "-s", string_sprintf("%d", SAmaxbody+16384), "-d", SAspamcHost, "-p", SAspamcPort, NULL); |
||
| 78 | - CHECKERR(ret,string_sprintf("exec %s", SAspamcpath),__LINE__); |
||
| 79 | + if (SAspamcHost) { |
||
| 80 | + spamc_argv[i++] = "-d"; |
||
| 81 | + spamc_argv[i++] = SAspamcHost; |
||
| 82 | + } |
||
| 83 | + if (SAspamcPort) { |
||
| 84 | + spamc_argv[i++] = "-p"; |
||
| 85 | + spamc_argv[i++] = SAspamcPort; |
||
| 86 | + } |
||
| 87 | } |
||
| 88 | - |
||
| 89 | + spamc_argv[i++] = NULL; |
||
| 90 | + |
||
| 91 | + ret=execv(SAspamcpath, spamc_argv); |
||
| 92 | + CHECKERR(ret,string_sprintf("exec %s", SAspamcpath),__LINE__); |
||
| 93 | } |
||
| 94 | |||
| 95 | if (SAEximDebug > 8) |
||
| 96 | --- sa-exim-4.2.1.orig/sa-exim.conf |
||
| 97 | +++ sa-exim-4.2.1/sa-exim.conf |
||
| 98 | @@ -49,11 +49,17 @@ SAspamcpath: /usr/bin/spamc |
||
| 99 | # you set it, it will override the two TCP connect options below |
||
| 100 | #SAspamcSockPath: /var/run/spamd.sock |
||
| 101 | |||
| 102 | -# SAspamcHost / SAspamcPort: TCP socket where your spamd is listening |
||
| 103 | -# Shown below are the defaults: |
||
| 104 | -SAspamcHost: 127.0.0.1 |
||
| 105 | -SAspamcPort: 783 |
||
| 106 | - |
||
| 107 | +# SAspamcHost / SAspamcPort: TCP socket where your spamd is listening. |
||
| 108 | +# Default is to let spamc use any settings in spamc.conf. |
||
| 109 | +#SAspamcHost: 127.0.0.1 |
||
| 110 | +#SAspamcPort: 783 |
||
| 111 | + |
||
| 112 | +# SAspamcUser: The username passed to spamc. Some tricks are needed to |
||
| 113 | +# decide on one user when there are many recipients. This string is of |
||
| 114 | +# course expanded. If unset or empty, spamc will use the user Exim |
||
| 115 | +# runs as. We suggest that you decide what username to use in the ACLs |
||
| 116 | +# and set an ACL variable. |
||
| 117 | +#SAspamcUser: $acl_m2 |
||
| 118 | |||
| 119 | # Exim configuration string to run before running SA against the message |
||
| 120 | # This decides whether SA gets run against the message or not. This |