$(SHELL) config.status
(cd scripts; \
chmod 755 startmysql stopmysql bacula fd startit stopit btraceback; \
- chmod 755 mtx-changer console gconsole)
+ chmod 755 mtx-changer bconsole gconsole)
chmod 755 src/cats/make_mysql_tables src/cats/drop_mysql_tables
chmod 755 src/cats/make_sqlite_tables src/cats/drop_sqlite_tables
chmod 755 src/cats/make_bdb_tables src/cats/drop_bdb_tables
@(cd $(srcdir); $(RMF) Makefile autoconf/Make.common)
@(cd platforms; echo "==>Entering directory `pwd`"; ${MAKE} $@ || exit 1)
@$(RMF) bacula fd Makefile startmysql stopmysql startit stopit btraceback
- @$(RMF) console gconsole
+ @$(RMF) bconsole gconsole
@$(RMF) *~ 1 2 3 core core.* config.guess console.log console.sum
@$(RMF) working/*
@$(RMF) -r examples/devices/CVS autoconf/CVS autoconf/gnome-macros/CVS
STATIC_CONS=
if test x$support_static_cons = xyes; then
- STATIC_CONS="static-console"
+ STATIC_CONS="static-bconsole"
fi
AC_SUBST(STATIC_CONS)
scripts/btraceback \
scripts/startit \
scripts/stopit \
- scripts/console \
+ scripts/bconsole \
scripts/gconsole \
scripts/bacula \
scripts/fd \
src/Makefile \
src/host.h \
src/console/Makefile \
- src/console/console.conf \
+ src/console/bconsole.conf \
src/gnome-console/Makefile \
src/gnome-console/gnome-console.conf \
src/gnome2-console/Makefile \
cd scripts
chmod 755 startmysql stopmysql bacula startit stopit btraceback mtx-changer
-chmod 755 console gconsole mtx-changer
+chmod 755 bconsole gconsole mtx-changer
cd ..
chmod 755 src/cats/make_mysql_tables src/cats/drop_mysql_tables
chmod 755 src/cats/make_test_tables src/cats/drop_test_tables
Traceback Email: ${dump_email}
SMTP Host Address: ${smtp_host}
- Director Port: ${dir_port}
+ Director Port: ${dir_port}
File daemon Port: ${fd_port}
Storage daemon Port: ${sd_port}
- Director User: ${dir_user}
- Director Group: ${dir_group}
- Storage Daemon User: ${dir_user}
- Storage DaemonGroup: ${dir_group}
- File Daemon User: ${dir_user}
- File Daemon Group: ${dir_group}
+ Director User: ${dir_user}
+ Director Group: ${dir_group}
+ Storage Daemon User: ${dir_user}
+ Storage DaemonGroup: ${dir_group}
+ File Daemon User: ${dir_user}
+ File Daemon Group: ${dir_group}
SQL binaries Directory ${SQL_BINDIR}
STATIC_CONS=
if test x$support_static_cons = xyes; then
- STATIC_CONS="static-console"
+ STATIC_CONS="static-bconsole"
fi
exit 1
fi
- ac_config_files="$ac_config_files autoconf/Make.common Makefile rescue/Makefile rescue/linux/Makefile rescue/freebsd/Makefile rescue/solaris/Makefile scripts/startmysql scripts/stopmysql scripts/btraceback scripts/startit scripts/stopit scripts/console scripts/gconsole scripts/bacula scripts/fd scripts/Makefile scripts/logrotate scripts/bacula.desktop.gnome1 scripts/bacula.desktop.gnome2 scripts/mtx-changer doc/Makefile src/Makefile src/host.h src/console/Makefile src/console/console.conf src/gnome-console/Makefile src/gnome-console/gnome-console.conf src/gnome2-console/Makefile src/gnome2-console/gnome-console.conf src/tconsole/Makefile src/dird/Makefile src/dird/bacula-dir.conf src/lib/Makefile src/stored/Makefile src/stored/bacula-sd.conf src/filed/Makefile src/filed/bacula-fd.conf src/filed/win32/Makefile src/cats/Makefile src/cats/make_catalog_backup src/cats/delete_catalog_backup src/cats/alter_mysql_tables src/cats/make_mysql_tables src/cats/drop_mysql_tables src/cats/create_mysql_database src/cats/grant_mysql_privileges src/cats/alter_sqlite_tables src/cats/make_sqlite_tables src/cats/drop_sqlite_tables src/cats/create_sqlite_database src/cats/sqlite src/cats/mysql src/cats/create_bdb_database src/cats/make_bdb_tables src/cats/drop_bdb_tables src/cats/make_bacula_tables src/cats/drop_bacula_tables src/findlib/Makefile src/tools/Makefile $PFILES"
+ ac_config_files="$ac_config_files autoconf/Make.common Makefile rescue/Makefile rescue/linux/Makefile rescue/freebsd/Makefile rescue/solaris/Makefile scripts/startmysql scripts/stopmysql scripts/btraceback scripts/startit scripts/stopit scripts/bconsole scripts/gconsole scripts/bacula scripts/fd scripts/Makefile scripts/logrotate scripts/bacula.desktop.gnome1 scripts/bacula.desktop.gnome2 scripts/mtx-changer doc/Makefile src/Makefile src/host.h src/console/Makefile src/console/bconsole.conf src/gnome-console/Makefile src/gnome-console/gnome-console.conf src/gnome2-console/Makefile src/gnome2-console/gnome-console.conf src/tconsole/Makefile src/dird/Makefile src/dird/bacula-dir.conf src/lib/Makefile src/stored/Makefile src/stored/bacula-sd.conf src/filed/Makefile src/filed/bacula-fd.conf src/filed/win32/Makefile src/cats/Makefile src/cats/make_catalog_backup src/cats/delete_catalog_backup src/cats/alter_mysql_tables src/cats/make_mysql_tables src/cats/drop_mysql_tables src/cats/create_mysql_database src/cats/grant_mysql_privileges src/cats/alter_sqlite_tables src/cats/make_sqlite_tables src/cats/drop_sqlite_tables src/cats/create_sqlite_database src/cats/sqlite src/cats/mysql src/cats/create_bdb_database src/cats/make_bdb_tables src/cats/drop_bdb_tables src/cats/make_bacula_tables src/cats/drop_bacula_tables src/findlib/Makefile src/tools/Makefile $PFILES"
ac_config_commands="$ac_config_commands default"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
"scripts/btraceback" ) CONFIG_FILES="$CONFIG_FILES scripts/btraceback" ;;
"scripts/startit" ) CONFIG_FILES="$CONFIG_FILES scripts/startit" ;;
"scripts/stopit" ) CONFIG_FILES="$CONFIG_FILES scripts/stopit" ;;
- "scripts/console" ) CONFIG_FILES="$CONFIG_FILES scripts/console" ;;
+ "scripts/bconsole" ) CONFIG_FILES="$CONFIG_FILES scripts/bconsole" ;;
"scripts/gconsole" ) CONFIG_FILES="$CONFIG_FILES scripts/gconsole" ;;
"scripts/bacula" ) CONFIG_FILES="$CONFIG_FILES scripts/bacula" ;;
"scripts/fd" ) CONFIG_FILES="$CONFIG_FILES scripts/fd" ;;
"src/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
"src/host.h" ) CONFIG_FILES="$CONFIG_FILES src/host.h" ;;
"src/console/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/console/Makefile" ;;
- "src/console/console.conf" ) CONFIG_FILES="$CONFIG_FILES src/console/console.conf" ;;
+ "src/console/bconsole.conf" ) CONFIG_FILES="$CONFIG_FILES src/console/bconsole.conf" ;;
"src/gnome-console/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/gnome-console/Makefile" ;;
"src/gnome-console/gnome-console.conf" ) CONFIG_FILES="$CONFIG_FILES src/gnome-console/gnome-console.conf" ;;
"src/gnome2-console/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/gnome2-console/Makefile" ;;
cd scripts
chmod 755 startmysql stopmysql bacula startit stopit btraceback mtx-changer
-chmod 755 console gconsole mtx-changer
+chmod 755 bconsole gconsole mtx-changer
cd ..
chmod 755 src/cats/make_mysql_tables src/cats/drop_mysql_tables
chmod 755 src/cats/make_test_tables src/cats/drop_test_tables
Traceback Email: ${dump_email}
SMTP Host Address: ${smtp_host}
- Director Port: ${dir_port}
+ Director Port: ${dir_port}
File daemon Port: ${fd_port}
Storage daemon Port: ${sd_port}
- Director User: ${dir_user}
- Director Group: ${dir_group}
- Storage Daemon User: ${dir_user}
- Storage DaemonGroup: ${dir_group}
- File Daemon User: ${dir_user}
- File Daemon Group: ${dir_group}
+ Director User: ${dir_user}
+ Director Group: ${dir_group}
+ Storage Daemon User: ${dir_user}
+ Storage DaemonGroup: ${dir_group}
+ File Daemon User: ${dir_user}
+ File Daemon Group: ${dir_group}
SQL binaries Directory ${SQL_BINDIR}
bacula.desktop
bacula.desktop.gnome1
bacula.desktop.gnome2
-console
+bconsole
gconsole
mtx-changer
install: installdirs
$(INSTALL_SCRIPT) startmysql $(DESTDIR)$(scriptdir)/startmysql
$(INSTALL_SCRIPT) stopmysql $(DESTDIR)$(scriptdir)/stopmysql
- $(INSTALL_SCRIPT) console $(DESTDIR)$(scriptdir)/console
+ $(INSTALL_SCRIPT) bconsole $(DESTDIR)$(scriptdir)/bconsole
$(INSTALL_SCRIPT) gconsole $(DESTDIR)$(scriptdir)/gconsole
$(INSTALL_SCRIPT) bacula $(DESTDIR)$(scriptdir)/bacula
$(INSTALL_SCRIPT) fd $(DESTDIR)$(scriptdir)/fd
uninstall:
(cd $(DESTDIR)$(scriptdir); $(RMF) startmysql)
(cd $(DESTDIR)$(scriptdir); $(RMF) stopmysql)
- (cd $(DESTDIR)$(scriptdir); $(RMF) console)
+ (cd $(DESTDIR)$(scriptdir); $(RMF) bconsole)
(cd $(DESTDIR)$(scriptdir); $(RMF) gconsole)
(cd $(DESTDIR)$(scriptdir); $(RMF) bacula)
(cd $(DESTDIR)$(scriptdir); $(RMF) fd)
cd $(topdir) \
&& CONFIG_FILES=$(thisdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
chmod 755 startmysql stopmysql bacula fd startit stopit btraceback
- chmod 755 mtx-changer console gconsole
+ chmod 755 mtx-changer bconsole gconsole
Makefiles:
$(SHELL) config.status
chmod 755 startmysql stopmysql bacula fd startit stopit btraceback
- chmod 755 mtx-changer console gconsole
+ chmod 755 mtx-changer bconsole gconsole
clean:
@$(RMF) *~ 1 2 3
# clean for distribution
distclean: clean
@$(RMF) startmysql stopmysql bacula fd startit stopit btraceback
- @$(RMF) console gconsole logrotate bacula.desktop
+ @$(RMF) bconsole gconsole logrotate bacula.desktop
@$(RMF) bacula.desktop.gnome1 bacula.desktop.gnome2 mtx-changer
# ------------------------------------------------------------------------
--- /dev/null
+#!/bin/sh
+if [ $# = 1 ] ; then
+ echo "doing bconsole $1.conf"
+ @sbindir@/bconsole -c $1.conf
+else
+ @sbindir@/bconsole -c @sysconfdir@/bconsole.conf
+fi
-test-console.conf
+test-bconsole.conf
Makefile
btraceback
btraceback.gdb
-console
-console.conf
+bconsole
+bconsole.conf
startit
stopit
@echo " "
-console: $(CONSOBJS) ../lib/libbac.a ../cats/libsql.a
+bconsole: $(CONSOBJS) ../lib/libbac.a ../cats/libsql.a
$(CXX) $(LDFLAGS) $(CONS_LDFLAGS) -L../lib -L../cats -o $@ $(CONSOBJS) \
$(LIBS) $(DLIB) $(CONS_LIBS) -lbac -lsql -lm
-static-console: $(CONSOBJS) ../lib/libbac.a ../cats/libsql.a
+static-bconsole: $(CONSOBJS) ../lib/libbac.a ../cats/libsql.a
$(CXX) -static $(LDFLAGS) $(CONS_LDFLAGS) -L../lib -L../cats -o $@ $(CONSOBJS) \
$(LIBS) $(DLIB) $(CONS_LIBS) -lbac -lsql -lm
strip $@
--- /dev/null
+#
+# Bacula User Agent (or Console) Configuration File
+#
+
+Director {
+ Name = @hostname@-dir
+ DIRport = @dir_port@
+ address = @hostname@
+ Password = "@dir_password@"
+}
static int sleepcmd(FILE *input, BSOCK *UA_sock);
-#define CONFIG_FILE "./console.conf" /* default configuration file */
+#define CONFIG_FILE "./bconsole.conf" /* default configuration file */
static void usage()
{
fprintf(stderr, _(
"\nVersion: " VERSION " (" BDATE ") %s %s %s\n\n"
-"Usage: console [-s] [-c config_file] [-d debug_level] [config_file]\n"
+"Usage: bconsole [-s] [-c config_file] [-d debug_level] [config_file]\n"
" -c <file> set configuration file to file\n"
" -dnn set debug level to nn\n"
" -s no signals\n"
JCR jcr;
init_stack_dump();
- my_name_is(argc, argv, "console");
+ my_name_is(argc, argv, "bconsole");
textdomain("bacula-console");
init_msg(NULL, NULL);
working_directory = "/tmp";
sendit(_("Enter a period to cancel a command.\n"));
+ char *env = getenv("HOME");
+ if (env) {
+ FILE *fd;
+ pm_strcpy(&UA_sock->msg, env);
+ pm_strcat(&UA_sock->msg, "/.bconsolerc");
+ fd = fopen(UA_sock->msg, "r");
+ if (fd) {
+ read_and_process_input(fd, UA_sock);
+ fclose(fd);
+ }
+ }
+
read_and_process_input(stdin, UA_sock);
if (UA_sock) {
# and to the console
Messages {
Name = Standard
- mailcommand = "@sbindir@/smtp -h @smtp_host@ -f \"\(Bacula\) %r\" -s \"Bacula: %t %e of %c %l\" %r"
- operatorcommand = "@sbindir@/smtp -h @smtp_host@ -f \"\(Bacula\) %r\" -s \"Bacula: Intervention needed for %j\" %r"
+ mailcommand = "@sbindir@/bsmtp -h @bsmtp_host@ -f \"\(Bacula\) %r\" -s \"Bacula: %t %e of %c %l\" %r"
+ operatorcommand = "@sbindir@/bsmtp -h @bsmtp_host@ -f \"\(Bacula\) %r\" -s \"Bacula: Intervention needed for %j\" %r"
mail = @job_email@ = all, !skipped
operator = @job_email@ = mount
console = all, !skipped, !saved
bnet_fsend(bs, "1992 Update Media error\n");
Dmsg0(190, "send error\n");
}
+ has_volume_expired(jcr, &mr); /* if expired, change Media record */
db_unlock(jcr->db);
/*
clean:
rm -f *.exe *.o *.res *.a 1 2 3
- rm -f bin/bacula-fd.exe bin/smtp.exe bin/testfind.exe
+ rm -f bin/bacula-fd.exe bin/bsmtp.exe bin/testfind.exe
distclean: clean
@rm -f Makefile
@mkdir -p $(DESTDIR)$(sbindir) $(DESTDIR)/tmp $(DESTDIR)$(sbindir)/../working
@echo "Installing system binary files ..."
@strip ../bacula-fd.exe
- @strip ../../tools/smtp.exe
+ @strip ../../tools/bsmtp.exe
@strip ../../tools/testfind.exe
- @strip ../../console/console.exe
+ @strip ../../console/bconsole.exe
@cp -f ../bacula-fd.exe bin/
- @cp -f ../../tools/smtp.exe bin/
+ @cp -f ../../tools/bsmtp.exe bin/
@cp -f ../../tools/testfind.exe bin/
- @cp -f ../../console/console.exe bin/
+ @cp -f ../../console/bconsole.exe bin/
@cp -f bin/* $(DESTDIR)$(sbindir)
@cp -f ../bacula-fd.conf $(DESTDIR)$(sysconfdir)/bacula-fd.conf.new
- @cp -f ../../console/console.conf $(DESTDIR)$(sysconfdir)/console.conf.new
+ @cp -f ../../console/bconsole.conf $(DESTDIR)$(sysconfdir)/bconsole.conf.new
# Make a Win32 binary release
binary-release:
@echo "Copying system binary files ..."
@cp bin/* wr/$(sbindir)
@strip ../bacula-fd.exe
- @strip ../../tools/smtp.exe
+ @strip ../../tools/bsmtp.exe
@strip ../../tools/testfind.exe
- @strip ../../console/console.exe
+ @strip ../../console/bconsole.exe
@echo "Copying executables ..."
@cp -f ../bacula-fd.exe wr/$(sbindir)/bacula-fd.exe
- @cp -f ../../tools/smtp.exe wr/$(sbindir)/smtp.exe
+ @cp -f ../../tools/bsmtp.exe wr/$(sbindir)/bsmtp.exe
@cp -f ../../tools/testfind.exe wr/$(sbindir)/testfind.exe
- @cp -f ../../console/console.exe wr/$(sbindir)/console.exe
+ @cp -f ../../console/bconsole.exe wr/$(sbindir)/bconsole.exe
@echo "Copying bacula-fd.conf..."
@cp -f ../bacula-fd.conf wr/$(sysconfdir)/bacula-fd.conf.new
- @cp -f ../../console/console.conf wr/$(sysconfdir)/console.conf.new
+ @cp -f ../../console/bconsole.conf wr/$(sysconfdir)/bconsole.conf.new
# the two dummy files are necessary to insure that WinZip
# actually creates the directories.
@echo "dummy" >wr/tmp/dummy.txt
.c.o:
$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $<
#-------------------------------------------------------------------------
-all: Makefile smtp dbcheck testfind testls
+all: Makefile bsmtp dbcheck testfind testls
@echo "==== Make of tools is good ===="
@echo " "
-smtp: smtp.o ../lib/libbac.a
- $(CXX) $(LDFLAGS) -L../lib -o $@ smtp.o -lbac -lm $(LIBS) $(DLIB)
+bsmtp: bsmtp.o ../lib/libbac.a
+ $(CXX) $(LDFLAGS) -L../lib -o $@ bsmtp.o -lbac -lm $(LIBS) $(DLIB)
dbcheck: dbcheck.o ../lib/libbac.a ../cats/libsql.a
$(CXX) $(LDFLAGS) -L../lib -L../cats -o $@ dbcheck.o -lsql -lbac -lm $(LIBS) $(DB_LIBS)
&& CONFIG_FILES=$(thisdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
clean:
- @$(RMF) smtp core core.* a.out *.o *.bak *~ *.intpro *.extpro 1 2 3
+ @$(RMF) bsmtp core core.* a.out *.o *.bak *~ *.intpro *.extpro 1 2 3
@$(RMF) testfind dbcheck testls
realclean: clean
if test $(srcdir) = .; then $(MAKE) realclean; fi
(cd $(srcdir); $(RMF) Makefile; $(RMF) -r CVS)
-install: smtp
- $(INSTALL_PROGRAM) smtp $(DESTDIR)$(sbindir)/smtp
+install: bsmtp
+ $(INSTALL_PROGRAM) bsmtp $(DESTDIR)$(sbindir)/bsmtp
$(INSTALL_PROGRAM) dbcheck $(DESTDIR)$(sbindir)/dbcheck
uninstall:
- (cd $(DESTDIR)$(sbindir); $(RMF) smtp)
+ (cd $(DESTDIR)$(sbindir); $(RMF) bsmtp)
(cd $(DESTDIR)$(sbindir); $(RMF) dbcheck)
--- /dev/null
+/*
+ Copyright (C) 2000-2003 Kern Sibbald and John Walker
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License, or (at your option) any later version.
+
+ 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.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ */
+
+/*
+ Derived from a SMTPclient:
+
+ SMTPclient -- simple SMTP client
+
+ Copyright (C) 1997 Ralf S. Engelschall, All Rights Reserved.
+ rse@engelschall.com
+ www.engelschall.com
+
+ Kern Sibbald, July 2001
+
+ Version $Id$
+
+ */
+
+#include "bacula.h"
+#include "jcr.h"
+
+#ifndef MAXSTRING
+#define MAXSTRING 254
+#endif
+
+static FILE *sfp;
+static FILE *rfp;
+
+static char *from_addr = NULL;
+static char *cc_addr = NULL;
+static char *subject = NULL;
+static char *err_addr = NULL;
+static char *mailhost = NULL;
+static char *reply_addr = NULL;
+static int mailport = 25;
+static char my_hostname[MAXSTRING];
+
+
+/*
+ * examine message from server
+ */
+static void get_response(void)
+{
+ char buf[MAXSTRING];
+
+ Dmsg0(50, "Calling fgets on read socket rfp.\n");
+ while (fgets(buf, sizeof(buf), rfp)) {
+ buf[strlen(buf)-1] = 0;
+ Dmsg2(10, "%s --> %s\n", mailhost, buf);
+ if (!isdigit((int)buf[0]) || buf[0] > '3') {
+ Dmsg1(10, "Fatal malformed reply: %s\n", buf);
+ exit(1);
+ }
+ if (buf[4] != '-') {
+ break;
+ }
+ }
+ return;
+}
+
+/*
+ * say something to server and check the response
+ */
+static void chat(char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(sfp, fmt, ap);
+ if (debug_level >= 10) {
+ fprintf(stdout, "%s --> ", my_hostname);
+ vfprintf(stdout, fmt, ap);
+ }
+ va_end(ap);
+
+ fflush(sfp);
+ if (debug_level >= 10) {
+ fflush(stdout);
+ }
+ get_response();
+}
+
+
+static void usage()
+{
+ fprintf(stderr,
+"\n"
+"Usage: smtp [-f from] [-h mailhost] [-s subject] [-c copy] [recepient ...]\n"
+" -c set the Cc: field\n"
+" -dnn set debug level to nn\n"
+" -f set the From: field\n"
+" -h use mailhost:port as the SMTP server\n"
+" -s set the Subject: field\n"
+" -? print this message.\n"
+"\n");
+
+ exit(1);
+}
+
+
+/*********************************************************************
+ *
+ * Program to send email
+ */
+int main (int argc, char *argv[])
+{
+ char buf[MAXSTRING];
+ struct sockaddr_in sin;
+ struct hostent *hp;
+ int s, r, i, ch;
+ struct passwd *pwd;
+ char *cp, *p;
+
+ my_name_is(argc, argv, "smtp");
+
+ while ((ch = getopt(argc, argv, "c:d:f:h:r:s:?")) != -1) {
+ switch (ch) {
+ case 'c':
+ Dmsg1(20, "cc=%s\n", optarg);
+ cc_addr = optarg;
+ break;
+
+ case 'd': /* set debug level */
+ debug_level = atoi(optarg);
+ if (debug_level <= 0) {
+ debug_level = 1;
+ }
+ Dmsg1(20, "Debug level = %d\n", debug_level);
+ break;
+
+ case 'f': /* from */
+ from_addr = optarg;
+ break;
+
+ case 'h': /* smtp host */
+ Dmsg1(20, "host=%s\n", optarg);
+ p = strchr(optarg, ':');
+ if (p) {
+ *p++ = 0;
+ mailport = atoi(p);
+ }
+ mailhost = optarg;
+ break;
+
+ case 's': /* subject */
+ Dmsg1(20, "subject=%s\n", optarg);
+ subject = optarg;
+ break;
+
+ case 'r': /* reply address */
+ reply_addr = optarg;
+ break;
+
+ case '?':
+ default:
+ usage();
+
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (argc < 1) {
+ Dmsg0(0, "Fatal error: no recipient given.\n");
+ usage();
+ exit(1);
+ }
+
+ /*
+ * Determine SMTP server
+ */
+ if (mailhost == NULL) {
+ if ((cp = getenv("SMTPSERVER")) != NULL) {
+ mailhost = cp;
+ } else {
+ mailhost = "localhost";
+ }
+ }
+
+ /*
+ * Find out my own host name for HELO;
+ * if possible, get the fully qualified domain name
+ */
+ if (gethostname(my_hostname, sizeof(my_hostname) - 1) < 0) {
+ Dmsg1(0, "Fatal gethostname error: ERR=%s\n", strerror(errno));
+ exit(1);
+ }
+ if ((hp = gethostbyname(my_hostname)) == NULL) {
+ Dmsg2(0, "Fatal gethostbyname for myself failed \"%s\": ERR=%s\n", my_hostname,
+ strerror(errno));
+ exit(1);
+ }
+ strcpy(my_hostname, hp->h_name);
+ Dmsg1(20, "My hostname is: %s\n", my_hostname);
+
+ /*
+ * Determine from address.
+ */
+ if (from_addr == NULL) {
+ if ((pwd = getpwuid(getuid())) == 0) {
+ sprintf(buf, "userid-%d@%s", (int)getuid(), my_hostname);
+ } else {
+ sprintf(buf, "%s@%s", pwd->pw_name, my_hostname);
+ }
+ from_addr = bstrdup(buf);
+ }
+ Dmsg1(20, "From addr=%s\n", from_addr);
+
+ /*
+ * Connect to smtp daemon on mailhost.
+ */
+hp:
+ if ((hp = gethostbyname(mailhost)) == NULL) {
+ Dmsg2(0, "Error unknown mail host \"%s\": ERR=%s\n", mailhost,
+ strerror(errno));
+ if (strcasecmp(mailhost, "localhost") != 0) {
+ Dmsg0(0, "Retrying connection using \"localhost\".\n");
+ mailhost = "localhost";
+ goto hp;
+ }
+ exit(1);
+ }
+
+ if (hp->h_addrtype != AF_INET) {
+ Dmsg1(0, "Fatal error: Unknown address family for smtp host: %d\n", 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;
+ sin.sin_port = htons(mailport);
+ if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+ Dmsg1(0, "Fatal socket error: ERR=%s\n", strerror(errno));
+ exit(1);
+ }
+ if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
+ Dmsg1(0, "Fatal connect error: ERR=%s\n", strerror(errno));
+ exit(1);
+ }
+ Dmsg0(20, "Connected\n");
+ if ((r = dup(s)) < 0) {
+ Dmsg1(0, "Fatal dup error: ERR=%s\n", strerror(errno));
+ exit(1);
+ }
+ if ((sfp = fdopen(s, "w")) == 0) {
+ Dmsg1(0, "Fatal fdopen error: ERR=%s\n", strerror(errno));
+ exit(1);
+ }
+ if ((rfp = fdopen(r, "r")) == 0) {
+ Dmsg1(0, "Fatal fdopen error: ERR=%s\n", strerror(errno));
+ exit(1);
+ }
+
+ /*
+ * Send SMTP headers
+ */
+ get_response(); /* banner */
+ chat("helo %s\r\n", my_hostname);
+ chat("mail from: <%s>\r\n", from_addr);
+
+ for (i = 0; i < argc; i++) {
+ Dmsg1(20, "rcpt to: %s\n", argv[i]);
+ chat("rcpt to: <%s>\r\n", argv[i]);
+ }
+
+ if (cc_addr) {
+ chat("rcpt to: <%s>\r\n", cc_addr);
+ }
+ Dmsg0(20, "Data\n");
+ chat("data\r\n");
+
+ /*
+ * Send message header
+ */
+ fprintf(sfp, "From: %s\r\n", from_addr);
+ if (subject) {
+ fprintf(sfp, "Subject: %s\r\n", subject);
+ }
+ if (reply_addr) {
+ fprintf(sfp, "Reply-To: %s\r\n", reply_addr);
+ }
+ if (err_addr) {
+ fprintf(sfp, "Errors-To: %s\r\n", err_addr);
+ }
+ if ((pwd = getpwuid(getuid())) == 0) {
+ fprintf(sfp, "Sender: userid-%d@%s\r\n", (int)getuid(), my_hostname);
+ } else {
+ fprintf(sfp, "Sender: %s@%s\r\n", pwd->pw_name, my_hostname);
+ }
+
+ fprintf(sfp, "To: %s", argv[0]);
+ for (i = 1; i < argc; i++) {
+ fprintf(sfp, ",%s", argv[i]);
+ }
+
+ fprintf(sfp, "\r\n");
+ if (cc_addr) {
+ fprintf(sfp, "Cc: %s\r\n", cc_addr);
+ }
+
+ fprintf(sfp, "\r\n");
+
+ /*
+ * Send message body
+ */
+ while (fgets(buf, sizeof(buf), stdin)) {
+ buf[strlen(buf)-1] = 0;
+ if (strcmp(buf, ".") == 0) { /* quote lone dots */
+ fprintf(sfp, "..\r\n");
+ } else { /* pass body through unchanged */
+ fprintf(sfp, "%s\r\n", buf);
+ }
+ }
+
+ /*
+ * Send SMTP quit command
+ */
+ chat(".\r\n");
+ chat("quit\r\n");
+
+ /*
+ * Go away gracefully ...
+ */
+ exit(0);
+}
#undef VERSION
#define VERSION "1.33"
#define VSTRING "1"
-#define BDATE "09 Nov 2003"
-#define LSMDATE "09Nov03"
+#define BDATE "10 Nov 2003"
+#define LSMDATE "10Nov03"
/* Debug flags */
#undef DEBUG