From: Kern Sibbald Date: Mon, 20 Mar 2006 07:13:12 +0000 (+0000) Subject: Integrate addition of line count limitation to bsmtp -l from X-Git-Tag: Release-2.0.0~996 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e0f74676180e3db4345fca6078b4f9c9aba77061;p=bacula%2Fbacula Integrate addition of line count limitation to bsmtp -l from Sebastian Stark git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2839 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kes-1.39 b/bacula/kes-1.39 index ee005f41c6..5d0d8922e5 100644 --- a/bacula/kes-1.39 +++ b/bacula/kes-1.39 @@ -2,6 +2,9 @@ Kern Sibbald General: +20Mar06 +- Integrate addition of line count limitation to bsmtp -l from + Sebastian Stark 17Mar06 - Implement regex test program in tools directory. - Attempt to fix time problem with bsmtp with foreign langs. diff --git a/bacula/src/tools/bsmtp.c b/bacula/src/tools/bsmtp.c index cb994bdf20..5c22b0c830 100644 --- a/bacula/src/tools/bsmtp.c +++ b/bacula/src/tools/bsmtp.c @@ -125,6 +125,8 @@ _("\n" " -f set the From: field\n" " -h use mailhost:port as the SMTP server\n" " -s set the Subject: field\n" +" -r set the Reply-To: field\n" +" -l set the maximum number of lines that should be sent (default: unlimited)\n" " -? print this message.\n" "\n"), MY_NAME); @@ -142,6 +144,7 @@ int main (int argc, char *argv[]) struct sockaddr_in sin; struct hostent *hp; int s, r, i, ch; + unsigned long maxlines, lines; struct passwd *pwd; char *cp, *p; time_t now = time(NULL); @@ -152,8 +155,9 @@ int main (int argc, char *argv[]) textdomain("bacula"); my_name_is(argc, argv, "bsmtp"); + maxlines = 0; - while ((ch = getopt(argc, argv, "c:d:f:h:r:s:?")) != -1) { + while ((ch = getopt(argc, argv, "c:d:f:h:r:s:l:?")) != -1) { switch (ch) { case 'c': Dmsg1(20, "cc=%s\n", optarg); @@ -191,6 +195,11 @@ int main (int argc, char *argv[]) reply_addr = optarg; break; + case 'l': + Dmsg1(20, "maxlines=%s\n", optarg); + maxlines = (unsigned long) atol(optarg); + break; + case '?': default: usage(); @@ -359,7 +368,12 @@ hp: /* * Send message body */ + lines = 0; while (fgets(buf, sizeof(buf), stdin)) { + if (maxlines > 0 && ++lines > maxlines) { + Dmsg1(20, "skip line because of maxlines limit: %lu\n", maxlines); + continue; + } buf[strlen(buf)-1] = 0; if (strcmp(buf, ".") == 0) { /* quote lone dots */ fprintf(sfp, "..\r\n"); @@ -368,6 +382,11 @@ hp: } } + if (lines > maxlines) { + Dmsg1(10, "hit maxlines limit: %lu\n", maxlines); + fprintf(sfp, "\r\n[maximum of %lu lines exceeded, skipped %lu lines of output]\r\n", maxlines, lines-maxlines); + } + /* * Send SMTP quit command */ diff --git a/bacula/src/version.h b/bacula/src/version.h index 5756349191..69c4634952 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "1.39.6" -#define BDATE "17 March 2006" -#define LSMDATE "17Mar06" +#define BDATE "20 March 2006" +#define LSMDATE "20Mar06" /* Debug flags */ #undef DEBUG