]> git.sur5r.net Git - bacula/bacula/commitdiff
make bconsole and bstmp
authorKern Sibbald <kern@sibbald.com>
Mon, 10 Nov 2003 18:05:36 +0000 (18:05 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 10 Nov 2003 18:05:36 +0000 (18:05 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@804 91ce42f0-d328-0410-95d8-f526ca767f89

16 files changed:
bacula/Makefile.in
bacula/autoconf/configure.in
bacula/configure
bacula/scripts/.cvsignore
bacula/scripts/Makefile.in
bacula/scripts/bconsole.in [new file with mode: 0755]
bacula/src/console/.cvsignore
bacula/src/console/Makefile.in
bacula/src/console/bconsole.conf.in [new file with mode: 0644]
bacula/src/console/console.c
bacula/src/dird/bacula-dir.conf.in
bacula/src/dird/catreq.c
bacula/src/filed/win32/Makefile.in
bacula/src/tools/Makefile.in
bacula/src/tools/bsmtp.c [new file with mode: 0644]
bacula/src/version.h

index 65b008f80c610d44caf9587d89658527b7ca0a67..0fb34b60f16763c4d6b35c9f0fa4a4dac6d0dbb1 100755 (executable)
@@ -113,7 +113,7 @@ Makefiles:
        $(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
@@ -142,7 +142,7 @@ distclean:
        @(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
index 54c3256ba0d6a957e42b79f8009997fc8e703e93..664b8f0a34ac220675351bc08e3c5322d0f7c6d0 100644 (file)
@@ -273,7 +273,7 @@ AC_ARG_ENABLE(static-cons,
 
 STATIC_CONS=
 if test x$support_static_cons = xyes; then
-   STATIC_CONS="static-console"
+   STATIC_CONS="static-bconsole"
 fi
 AC_SUBST(STATIC_CONS)
 
@@ -1488,7 +1488,7 @@ AC_OUTPUT([autoconf/Make.common \
           scripts/btraceback \
           scripts/startit \
           scripts/stopit \
-          scripts/console \
+          scripts/bconsole \
           scripts/gconsole \
           scripts/bacula \
           scripts/fd \
@@ -1501,7 +1501,7 @@ AC_OUTPUT([autoconf/Make.common \
           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 \
@@ -1542,7 +1542,7 @@ AC_OUTPUT([autoconf/Make.common \
 
 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
@@ -1616,16 +1616,16 @@ Configuration on `date`:
   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}
 
index 518ca00084c2c8c0cf03a2b9da6c445e8666a3a3..5e93cb11a1c13c670763b232f3a52878a79992d5 100755 (executable)
@@ -4800,7 +4800,7 @@ fi;
 
 STATIC_CONS=
 if test x$support_static_cons = xyes; then
-   STATIC_CONS="static-console"
+   STATIC_CONS="static-bconsole"
 fi
 
 
@@ -17576,7 +17576,7 @@ if test "x${subsysdir}" = "x${sbindir}" ; then
    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
@@ -18116,7 +18116,7 @@ do
   "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" ;;
@@ -18129,7 +18129,7 @@ do
   "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" ;;
@@ -18931,7 +18931,7 @@ fi
 
 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
@@ -19005,16 +19005,16 @@ Configuration on `date`:
   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}
 
index 804abf5efc27675c994a0f2a9ac61cbd7f6acc05..f3a2819fdda4879bbefb69812fcbf5de740219f6 100644 (file)
@@ -3,6 +3,6 @@ logrotate
 bacula.desktop
 bacula.desktop.gnome1  
 bacula.desktop.gnome2
-console
+bconsole
 gconsole
 mtx-changer
index eec6bf4fb23f46e74001a8ae34294aa4563f75b0..9690a97d09becf668613aec79a93bdf6ae3a0037 100755 (executable)
@@ -34,7 +34,7 @@ installdirs:
 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
@@ -45,7 +45,7 @@ install: installdirs
 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)
@@ -57,12 +57,12 @@ Makefile: Makefile.in
        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
@@ -70,7 +70,7 @@ clean:
 # 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
 
 # ------------------------------------------------------------------------
diff --git a/bacula/scripts/bconsole.in b/bacula/scripts/bconsole.in
new file mode 100755 (executable)
index 0000000..2aa66b0
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+if [ $# = 1 ] ; then
+   echo "doing bconsole $1.conf"
+   @sbindir@/bconsole -c $1.conf
+else
+   @sbindir@/bconsole -c @sysconfdir@/bconsole.conf
+fi
index a149a3fd4ef9a4600180ecd24bf0d6d0463e8a78..b476bc173203a5968a082100f9292cc3df65756c 100644 (file)
@@ -1,8 +1,8 @@
-test-console.conf
+test-bconsole.conf
 Makefile
 btraceback
 btraceback.gdb
-console
-console.conf
+bconsole
+bconsole.conf
 startit
 stopit
index 9f9d3d73642867822d84d044819d720bcea67c39..83958a8410e941b31090d14a5b095811950696d8 100644 (file)
@@ -43,11 +43,11 @@ all: Makefile console @STATIC_CONS@
        @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 $@
diff --git a/bacula/src/console/bconsole.conf.in b/bacula/src/console/bconsole.conf.in
new file mode 100644 (file)
index 0000000..010797b
--- /dev/null
@@ -0,0 +1,10 @@
+#
+# Bacula User Agent (or Console) Configuration File
+#
+
+Director {
+  Name = @hostname@-dir
+  DIRport = @dir_port@
+  address = @hostname@
+  Password = "@dir_password@"
+}
index e424a4300f480319197d00b0b210d78439706bc3..686ce2e2a05afc1fc1b03604024c55457013a643 100644 (file)
@@ -72,13 +72,13 @@ static int timecmd(FILE *input, BSOCK *UA_sock);
 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"
@@ -252,7 +252,7 @@ int main(int argc, char *argv[])
    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";
@@ -379,6 +379,18 @@ try_again:
 
    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) {
index 9c00dfbdb4b009ef4497becd9f4e286264b1a771..3a7679972b4046cb061f32ea9a63b3524d138fc2 100644 (file)
@@ -177,8 +177,8 @@ Catalog {
 #  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
index 44bb5980195a8af424f16214bd4155216ecb413f..db060bedefa87ce2ca1eec035a435a210ac022d5 100644 (file)
@@ -231,6 +231,7 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
          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);
 
    /*
index d952aa817f23cb0f89c77daac2f3b7d55fd22fa4..7d8e42062e1e2913e840fd94a612f7828763a117 100755 (executable)
@@ -61,7 +61,7 @@ Makefile: $(srcdir)/Makefile.in $(topdir)/config.status
 
 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
@@ -71,16 +71,16 @@ install:
        @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:
@@ -90,17 +90,17 @@ 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
index eae2bf9480d54a731637af36ce240aa39b37c698..9f735b05f2bfad27ce4939104c7f937747dd6e67 100644 (file)
@@ -36,12 +36,12 @@ EXTRAOBJS = @OBJLIST@
 .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)
@@ -61,7 +61,7 @@ Makefile: $(srcdir)/Makefile.in $(topdir)/config.status
          && 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
@@ -71,12 +71,12 @@ distclean: realclean
        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)
 
 
diff --git a/bacula/src/tools/bsmtp.c b/bacula/src/tools/bsmtp.c
new file mode 100644 (file)
index 0000000..f851582
--- /dev/null
@@ -0,0 +1,342 @@
+/*
+   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);
+}
index 898808ce965afcbe50159490bdbaffeef7445ea7..e81d5e77d6449bd9f3aee40eabc092317a98d6b0 100644 (file)
@@ -2,8 +2,8 @@
 #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