From 06591d413caf301b3746f048b74205b5dd87c49a Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 1 Oct 2007 13:38:00 +0000 Subject: [PATCH] Update git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5706 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/LICENSE | 36 ++- bacula/src/lib/var.h | 40 +-- bacula/src/tools/bsmtp.c | 34 ++- bacula/src/tools/smtp-orig.c | 455 +++++++++++++++++++++++++++++++++++ 4 files changed, 536 insertions(+), 29 deletions(-) create mode 100644 bacula/src/tools/smtp-orig.c diff --git a/bacula/LICENSE b/bacula/LICENSE index e039538d85..fea736568e 100644 --- a/bacula/LICENSE +++ b/bacula/LICENSE @@ -106,18 +106,42 @@ so themselves. Our intention is to respect as closely as possible Open Source practices while maintaining full respect for proprietary and copyrighted code. - -Other Licenses: -Certain parts of the Bacula software are licensed by their -copyright holder(s) under the BSD license or an IBM license. -These software files are clearly marked as such. The Bacula authors -have no copyright or other claim over that software. +GPLv2 or later license: + src/tools/bsmtp.c + Copyright (C) 1997 Ralf S. Engelschall, All Rights Reserved. + (note, bsmtp.c does not use OpenSSL) BSD License notice for inclusion with the binary: src/lib/fnmatch.c * Copyright (c) 1989, 1993, 1994 * The Regents of the University of California. All rights reserved. + src/lib/fnmatch.h + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + +Permissive licenses: + src/lib/var.c/h + ** OSSP var - Variable Expansion + ** Copyright (c) 2001-2002 Ralf S. Engelschall + ** Copyright (c) 2001-2002 The OSSP Project (http://www.ossp.org/) + ** Copyright (c) 2001-2002 Cable & Wireless Deutschland (http://www.cw.com/de/) + + src/lib/bsnprintf.c + * Copyright Patrick Powell 1995 + + src/bregex.c/h + * Copyright (c) 1991 Tatu Ylonen, Espoo, Finland + + src/lib/sha1.c/h + Copyright (C) The Internet Society (2001). All Rights Reserved. + + src/win32/compat/getopt.c + "... licensed under IBM copyrights to use the IBM-provided source code + in any way he or she deems fit ..." + src/win32/compat/sys/mtio.h (LGPL) + Copyright (C) 1996, 1997 Free Software Foundation, Inc. + Bacula can be enabled with data encryption and/or communications encryption. If this is the case, you will be including OpenSSL code that diff --git a/bacula/src/lib/var.h b/bacula/src/lib/var.h index 353f6ccfda..050c87e94e 100644 --- a/bacula/src/lib/var.h +++ b/bacula/src/lib/var.h @@ -1,26 +1,7 @@ -/* -** OSSP var - Variable Expansion -** Copyright (c) 2001-2002 Ralf S. Engelschall -** Copyright (c) 2001-2002 The OSSP Project (http://www.ossp.org/) -** Copyright (c) 2001-2002 Cable & Wireless Deutschland (http://www.cw.com/de/) -** -** This file is part of OSSP var, a variable expansion -** library which can be found at http://www.ossp.org/pkg/lib/var/. -** -** Permission to use, copy, modify, and distribute this software for -** any purpose with or without fee is hereby granted, provided that -** the above copyright notice and this permission notice appear in all -** copies. -** -** For disclaimer see below. -*/ -/* - * Modified for use with Bacula by Kern Sibbald, June 2003 - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2003-2006 Free Software Foundation Europe e.V. + Copyright (C) 2003-2007 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -44,6 +25,25 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* +** OSSP var - Variable Expansion +** Copyright (c) 2001-2002 Ralf S. Engelschall +** Copyright (c) 2001-2002 The OSSP Project (http://www.ossp.org/) +** Copyright (c) 2001-2002 Cable & Wireless Deutschland (http://www.cw.com/de/) +** +** This file is part of OSSP var, a variable expansion +** library which can be found at http://www.ossp.org/pkg/lib/var/. +** +** Permission to use, copy, modify, and distribute this software for +** any purpose with or without fee is hereby granted, provided that +** the above copyright notice and this permission notice appear in all +** copies. +** +** For disclaimer see below. +*/ +/* + * Modified for use with Bacula by Kern Sibbald, June 2003 + */ diff --git a/bacula/src/tools/bsmtp.c b/bacula/src/tools/bsmtp.c index d58d032b3c..83b0e552dc 100644 --- a/bacula/src/tools/bsmtp.c +++ b/bacula/src/tools/bsmtp.c @@ -28,14 +28,42 @@ /* Derived from a SMTPclient: + ======== Original copyrights ========== + SMTPclient -- simple SMTP client - Copyright (C) 1997 Ralf S. Engelschall, All Rights Reserved. - rse@engelschall.com - www.engelschall.com + Copyright (c) 1997 Ralf S. Engelschall, All rights reserved. + + This program is free software; it may be redistributed and/or modified + only under the terms of either the Artistic License or the GNU General + Public License, which may be found in the SMTP source distribution. + Look at the file COPYING. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + ====================================================================== + + smtpclient_main.c -- program source + + Based on smtp.c as of August 11, 1995 from + W.Z. Venema, + Eindhoven University of Technology, + Department of Mathematics and Computer Science, + Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands. + + ========= + Kern Sibbald, July 2001 + Note, the original W.Z. Venema smtp.c had no license and no + copyright. See: + http://archives.neohapsis.com/archives/postfix/2000-05/1520.html + + Version $Id$ */ diff --git a/bacula/src/tools/smtp-orig.c b/bacula/src/tools/smtp-orig.c new file mode 100644 index 0000000000..e736c0d373 --- /dev/null +++ b/bacula/src/tools/smtp-orig.c @@ -0,0 +1,455 @@ +/* +Subject: Re: send mail from chrooted Apache + From: Wietse Venema (wietseporcupine.org) + Date: Tue Jun 06 2000 - 07:43:31 CDT +Next message: Wietse Venema: "Re: -" +Previous message: Brad Knowles: "Re: performance issues" +In reply to: ISM Kolemanov, Ivan: "send mail from chrooted Apache" + ISM Kolemanov, Ivan: + > hi all, + > + > I've just prepared Apache Web Server in chroot env. + > but now I have a problem, I can't send mails from the web server + > I mean that on the web server I have some formulars, + > which my clients are using to send me mail. + > + > I guess that there is any solution for that, but up to now I didn't find it. + > If anybody knows it please respond. + > + > 10x in advance + > Ivan Kolemanov + +This is a quick-and-dirty stand-alone SMTP client from long ago. + Works OK for lines up to BUFSIZ characters, nothing to worry about + security-wise. You could probably do the same in PERL, but I wrote + this for a web server that allowed no programming languages inside + the jail. + + Wietse + */ +/*++ + /* NAME + /* smtp 1 + /* SUMMARY + /* simple smtp client + /* SYNOPSIS + /* smtp [options] recipient(s)... + /* DESCRIPTION + /* \fIsmtp\fP is a minimal smtp client that takes an email + /* message body and passes it on to an smtp daemon (default + /* the smtp daemon on the local host). Since it is + /* completely self-supporting, the smtp client is especially + /* suitable for use in restricted environments. + /* + /* Options: + /* .TP + /* -c carbon-copy + /* Specifies one Cc: address to send one copy of the message to. + /* .TP + /* -e errors-to + /* Specifies the Errors-To: address. This is where delivery + /* problems should be reported. + /* .TP + /* -f from + /* Sets the From: address. Default is "daemon", which is + /* probably wrong. + /* .TP + /* -m mailhost + /* Specifies where the mail should be posted. By default, the + /* mail is posted to the smtp daemon on \fIlocalhost\fR. + /* .TP + /* -M + /* Use MIME-style translation to quoted-printable (base 16). + /* .TP + /* -r reply-to + /* Sets the Reply-To: address. + /* .TP + /* -s subject + /* Specifies the message subject. + /* .TP + /* -v + /* Turn on verbose logging to stdout. + /* DIAGNOSTICS + /* Non-zero exit status in case of problems. Errors are reported + /* to the syslogd, with facility daemon. + /* AUTHOR(S) + /* W.Z. Venema + /* Eindhoven University of Technology + /* Department of Mathematics and Computer Science + /* Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands + /* CREATION DATE + /* Wed Dec 1 14:51:13 MET 1993 + /* LAST UPDATE + /* Fri Aug 11 12:29:23 MET DST 1995 + /*--*/ + +/* System libraries */ + +#include + #include + #include + #include + #include + #include + #include + #include + #include + +#ifdef __STDC__ + #include + #define VARARGS(func,arg,type) func(type arg, ...) + #define VASTART(ap,name,type) { va_start(ap, name) + #define VAEND(ap) va_end(ap); } + #else + #include + #define VARARGS(func,arg,type) func(va_alist) \ + va_dcl + #define VASTART(ap,name,type) { type name; \ + va_start(ap); \ + name = va_arg(ap, type) + #define VAEND(ap) va_end(ap); } + #endif /* __STDC__ */ + +extern int optind; + extern char *optarg; + +/* Local stuff */ + +static char *cc_addr = 0; + static char *err_addr = 0; + static char *from_addr = "daemon"; + static char *mailhost = "localhost"; + static char *reply_addr = 0; + static char *subject = 0; + static int mime_style = 0; + static int verbose = 0; + +static FILE *sfp; + static FILE *rfp; + +#define dprintf if (verbose) printf + #define dvprintf if (verbose) vprintf + +void toqp(); + +/* usage - explain and bail out */ + +void usage() + { + syslog(LOG_ERR, + "usage: smtp [-c cc] [-e errors-to] [-f from] [-m mailhost] [-M] [-r reply-to] [-s subject] [-v] recipents..\n"); + exit(1); + } + +/* get_response - examine message from server */ + +void get_response() + { + char buf[BUFSIZ]; + + while (fgets(buf, sizeof(buf), rfp)) { + buf[strlen(buf) - 1] = 0; + dprintf(">>>> %s\n", buf); + if (!isdigit(buf[0]) || buf[0] > '3') { + syslog(LOG_ERR, "unexpected reply: %s", buf); + exit(1); + } + if (buf[4] != '-') + break; + } + } + +/* chat - say something to server and check the response */ + +void VARARGS(chat, fmt, char *) + { + va_list ap; + + /* Format the message. */ + + VASTART(ap, fmt, char *); + vfprintf(sfp, fmt, ap); + VAEND(ap); + + VASTART(ap, fmt, char *); + dvprintf(fmt, ap); + VAEND(ap); + + /* Send message to server and parse its response. */ + + fflush(sfp); + get_response(); + } + +main(argc, argv) + int argc; + char **argv; + { + char buf[BUFSIZ]; + char my_name[BUFSIZ]; + struct sockaddr_in sin; + struct hostent *hp; + struct servent *sp; + int c; + int s; + int r; + int i; + struct passwd *pwd; + + openlog(argv[0], LOG_PID, LOG_DAEMON); + + /* Go away when something gets stuck. */ + + alarm(60); + + /* Parse JCL. */ + + while ((c = getopt(argc, argv, "c:e:f:m:Mr:s:v")) != EOF) { + switch (c) { + case 'c': /* carbon copy */ + cc_addr = optarg; + break; + case 'e': /* errors-to */ + err_addr = optarg; + break; + case 'f': /* originator */ + from_addr = optarg; + break; + case 'm': /* mailhost */ + mailhost = optarg; + break; + case 'M': /* MIME quoted printable */ + mime_style = 1; + break; + case 'r': /* reply-to */ + reply_addr = optarg; + break; + case 's': /* subject */ + subject = optarg; + break; + case 'v': /* log protocol */ + verbose = 1; + break; + default: + usage(); + /* NOTREACHED */ + } + } + if (argc == optind) + usage(); + + /* Find out my own host name for HELO; if possible, get the FQDN. */ + + if (gethostname(my_name, sizeof(my_name) - 1) < 0) { + syslog(LOG_ERR, "gethostname: %m"); + exit(1); + } + if ((hp = gethostbyname(my_name)) == 0) { + syslog(LOG_ERR, "%s: unknown host\n", my_name); + exit(1); + } + strncpy(my_name, hp->h_name, sizeof(my_name) - 1); + + /* Connect to smtp daemon on mailhost. */ + + if ((hp = gethostbyname(mailhost)) == 0) { + syslog(LOG_ERR, "%s: unknown host\n", mailhost); + exit(1); + } + if (hp->h_addrtype != AF_INET) { + syslog(LOG_ERR, "unknown address family: %d", hp->h_addrtype); + exit(1); + } + memset((char *) &sin, 0, sizeof(sin)); + memcpy((char *) &sin.sin_addr, hp->h_addr, hp->h_length); + sin.sin_family = hp->h_addrtype; + if ((sp = getservbyname("smtp", "tcp")) != 0) { + sin.sin_port = sp->s_port; + } else { + syslog(LOG_ERR, "smtp/tcp: unknown service"); + exit(1); + } + if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { + syslog(LOG_ERR, "socket: %m"); + exit(1); + } + if (connect(s, (struct sockaddr *) & sin, sizeof(sin)) < 0) { + syslog(LOG_ERR, "connect: %m"); + exit(1); + } + if ((r = dup(s)) < 0) { + syslog(LOG_ERR, "dup: %m"); + exit(1); + } + if ((sfp = fdopen(s, "w")) == 0) { + syslog(LOG_ERR, "fdopen: %m"); + exit(1); + } + if ((rfp = fdopen(r, "r")) == 0) { + syslog(LOG_ERR, "fdopen: %m"); + exit(1); + } + /* Speak SMTP. */ + + get_response(); /* banner */ + + chat("HELO %s\r\n", my_name); + + chat("MAIL FROM: <%s>\r\n", from_addr); + + for (i = optind; i < argc; i++) + chat("RCPT TO: <%s>\r\n", argv[i]); + if (cc_addr) + chat("RCPT TO: <%s>\r\n", cc_addr); + + chat("DATA\r\n"); + + /* Do message header. */ + + fprintf(sfp, "From: %s\r\n", from_addr); + + if (subject) + fprintf(sfp, "Subject: %s\r\n", subject); + + if (err_addr) + fprintf(sfp, "Errors-To: %s\r\n", err_addr); + + if (reply_addr) + fprintf(sfp, "Reply-To: %s\r\n", reply_addr); + + if ((pwd = getpwuid(getuid())) == 0) { + fprintf(sfp, "Sender: userid-%d%s\r\n", getuid(), my_name); + } else { + fprintf(sfp, "Sender: %s%s\r\n", pwd->pw_name, my_name); + } + + fprintf(sfp, "To: %s", argv[optind]); + for (i = optind + 1; i < argc; i++) + fprintf(sfp, ", %s", argv[i]); + fprintf(sfp, "\r\n"); + + if (cc_addr) + fprintf(sfp, "Cc: %s\r\n", cc_addr); + + if (mime_style) { + fprintf(sfp, "Mime-Version: 1.0\r\n"); + fprintf(sfp, "Content-Type: text/plain; charset=ISO-8859-1\r\n"); + fprintf(sfp, "Content-Transfer-Encoding: quoted-printable\r\n"); + } + fprintf(sfp, "\r\n"); + + /* Do message body. */ + + if (mime_style) { /* MIME quoted-printable */ + toqp(stdin, sfp); + } else { /* traditional... */ + while (fgets(buf, sizeof(buf), stdin)) { + buf[strlen(buf) - 1] = 0; + if (strcmp(buf, ".") == 0) { /* quote lone dots */ + fprintf(sfp, "..\r\n"); + } else { /* pass thru mode */ + fprintf(sfp, "%s\r\n", buf); + } + } + } + chat(".\r\n"); + chat("QUIT\r\n"); + exit(0); + } + + /* + * Following code was lifted from the metamail version 2.7 source code + * (codes.c) and modified to emit \r\n at line boundaries. + */ + +static char basis_hex[] = "0123456789ABCDEF"; + +/* toqp - transform to MIME-style quoted printable */ + +void toqp(infile, outfile) + FILE *infile, + *outfile; + { + int c, + ct = 0, + prevc = 255; + + while ((c = getc(infile)) != EOF) { + if ((c < 32 && (c != '\n' && c != '\t')) + || (c == '=') + || (c >= 127) + + /* + * Following line is to avoid single periods alone on lines, which + * messes up some dumb smtp implementations, sigh... + */ + || (ct == 0 && c == '.')) { + putc('=', outfile); + putc(basis_hex[c >> 4], outfile); + putc(basis_hex[c & 0xF], outfile); + ct += 3; + prevc = 'A'; /* close enough */ + } else if (c == '\n') { + if (prevc == ' ' || prevc == '\t') { + putc('=', outfile); /* soft & hard lines */ + putc(c, outfile); + } + putc(c, outfile); + ct = 0; + prevc = c; + } else { + if (c == 'F' && prevc == '\n') { + + /* + * HORRIBLE but clever hack suggested by MTR for + * sendmail-avoidance + */ + c = getc(infile); + if (c == 'r') { + c = getc(infile); + if (c == 'o') { + c = getc(infile); + if (c == 'm') { + c = getc(infile); + if (c == ' ') { + /* This is the case we are looking for */ + fputs("=46rom", outfile); + ct += 6; + } else { + fputs("From", outfile); + ct += 4; + } + } else { + fputs("Fro", outfile); + ct += 3; + } + } else { + fputs("Fr", outfile); + ct += 2; + } + } else { + putc('F', outfile); + ++ct; + } + ungetc(c, infile); + prevc = 'x'; /* close enough -- printable */ + } else { /* END horrible hack */ + putc(c, outfile); + ++ct; + prevc = c; + } + } + if (ct > 72) { + putc('=', outfile); + putc('\r', outfile); /* XXX */ + putc('\n', outfile); + ct = 0; + prevc = '\n'; + } + } + if (ct) { + putc('=', outfile); + putc('\r', outfile); /* XXX */ + putc('\n', outfile); + } + } -- 2.39.2