# samba2-20000418.diff # Todd Pfaff, pfaff@mcmaster.ca # Apr 18 2000 # # This patch is for amanda-2.4.1p1 to incorporate the samba-2.0.x changes # that are in amanda-2.4.2 (specifically the 2.4.2-19990920 snapshot). # This patch includes changes for: # # - configure changes for SAMBA_VERSION # - SAMBA_DEBUG_LEVEL # - 'du' or 'dir' switch based on samba version # - '-q' quiet option to smbclient # - all the DMP_* regex lines # # This patch has been tested with amanda-2.4.1p1 and samba-2.0.6. # # This patch combines all or part of some previously posted patches # for amanda-2.4.1p1 and samba-2.x, including: # - samba2.diff by Todd Pfaff Oct 4 1999 # - this version had some improperly wrapped lines in configure # - samba-2.0.6-patch by John Hynes Nov 29 1999 # - samba2-20000122.diff by Todd Pfaff Jan 22 2000 # - only the two DMP_NORMAL regular expressions from this patch # are incorporated here # - samba2-20000414.diff by Todd Pfaff Apr 14 2000 # - this version fixed the wrapped lines in the Oct 4 1999 version diff -r -u amanda-2.4.1p1-orig/client-src/sendbackup-gnutar.c amanda-2.4.1p1/client-src/sendbackup-gnutar.c --- amanda-2.4.1p1-orig/client-src/sendbackup-gnutar.c Fri Sep 11 16:33:50 1998 +++ amanda-2.4.1p1/client-src/sendbackup-gnutar.c Tue Apr 18 14:33:34 2000 @@ -63,8 +63,8 @@ { DMP_NORMAL, ": Cannot add file .*: No such file or directory$", 1}, { DMP_NORMAL, ": Error exit delayed from previous errors", 1}, #endif - - /* samba 1.9.17 has introduced these output messages */ + + /* samba may produce these output messages */ { DMP_NORMAL, "^doing parameter", 1}, { DMP_NORMAL, "^pm_process\\(\\)", 1}, { DMP_NORMAL, "^adding IPC", 1}, @@ -90,15 +90,24 @@ { DMP_NORMAL, "^nread=", 1}, { DMP_NORMAL, "^\\([0-9][0-9]* kb/s\\)", 1}, { DMP_NORMAL, "^\\([0-9][0-9]*\\.[0-9][0-9]* kb/s\\)", 1}, + { DMP_NORMAL, "^[ ]*[0-9][0-9]* \\([ ]*[0-9][0-9]*\\.[0-9][0-9]* kb/s\\)", 1}, + { DMP_NORMAL, "^[ ]*directory ", 1}, { DMP_NORMAL, "^tar: dumped [0-9][0-9]* tar files", 1}, { DMP_NORMAL, "^load_client_codepage", 1}, + { DMP_NORMAL, "^session request to ", 1}, + { DMP_NORMAL, "^added interface", 1}, + { DMP_NORMAL, "^tar: dumped [0-9][0-9]* files and directories", 1}, #ifdef IGNORE_SMBCLIENT_ERRORS /* This will cause amanda to ignore real errors, but that may be - * unavoidable when you're backing up system disks. Add this at - * your own risk! */ + * unavoidable when you're backing up system disks. It seems to be + * a safe thing to do if you know what you're doing. */ { DMP_NORMAL, "^ERRDOS - ERRbadshare opening remote file", 1}, { DMP_NORMAL, "^ERRDOS - ERRbadfile opening remote file", 1}, + { DMP_NORMAL, "^ERRDOS - ERRnoaccess opening remote file", 1}, + { DMP_NORMAL, "^ERRSRV - ERRaccess setting attributes on file", 1}, { DMP_NORMAL, "^ERRDOS - ERRnoaccess setting attributes on file", 1}, + { DMP_NORMAL, "^ERRDOS - ERRnoaccess listing", 1}, + { DMP_NORMAL, "^ERRDOS - [0-9][0-9]* opening remote file", 1}, #endif /* catch-all: DMP_STRANGE is returned for all other lines */ @@ -298,6 +307,15 @@ } error("[can't make share name of %s]", disk); } +#if SAMBA_VERSION >= 2 + if (level==0) { + if (no_record) + taropt = "-Tqc"; + else + taropt = "-Tqca"; + } else + taropt = "-Tqcg"; +#else if (level==0) { if (no_record) taropt = "-Tc"; @@ -305,6 +323,7 @@ taropt = "-Tca"; } else taropt = "-Tcg"; +#endif dbprintf(("backup from %s, user %s, pass %s\n", sharename, SAMBA_USER, "XXXXX")); diff -r -u amanda-2.4.1p1-orig/client-src/sendsize.c amanda-2.4.1p1/client-src/sendsize.c --- amanda-2.4.1p1-orig/client-src/sendsize.c Tue Nov 17 20:07:20 1998 +++ amanda-2.4.1p1/client-src/sendsize.c Tue Apr 18 14:33:34 2000 @@ -571,7 +571,13 @@ {"Total bytes written: [0-9][0-9]*", 1}, /* Gnutar client */ #ifdef SAMBA_CLIENT - {"Total bytes listed: [0-9][0-9]*", 1}, /* Samba client */ +#if SAMBA_VERSION >= 2 +#define SAMBA_DEBUG_LEVEL "0" + {"Total number of bytes: [0-9][0-9]*", 1}, /* Samba du */ +#else +#define SAMBA_DEBUG_LEVEL "3" + {"Total bytes listed: [0-9][0-9]*", 1}, /* Samba dir */ +#endif #endif #ifdef HAVE_DUMP_ESTIMATE @@ -918,18 +924,26 @@ } nullfd = open("/dev/null", O_RDWR); pipe(pipefd); +#if SAMBA_VERSION >= 2 + if (level == 0) + tarkeys = "archive 0;recurse;du"; + else + tarkeys = "archive 1;recurse;du"; +#else if (level == 0) tarkeys = "archive 0;recurse;dir"; else tarkeys = "archive 1;recurse;dir"; +#endif - dbprintf(("%s: running \"%s \'%s\' %s -d 3 -U %s -E%s%s -c \'%s\'\"\n", - get_pname(), SAMBA_CLIENT, sharename, "XXXXX", SAMBA_USER, - domain ? " -W " : "", domain ? domain : "", - tarkeys)); + dbprintf(("%s: running \"%s \'%s\' %s -d %s -U %s -E%s%s -c \'%s\'\"\n", + get_pname(), SAMBA_CLIENT, sharename, "XXXXX", + SAMBA_DEBUG_LEVEL, SAMBA_USER, domain ? " -W " : "", + domain ? domain : "", tarkeys)); switch(dumppid = fork()) { case -1: + dbprintf(("fork for %s failed: %s\n", SAMBA_CLIENT, strerror(errno))); memset(pass, '\0', strlen(pass)); amfree(pass); if(domain) { @@ -948,7 +962,7 @@ aclose(pipefd[0]); execle(SAMBA_CLIENT, "smbclient", sharename, pass, - "-d", "3", + "-d", SAMBA_DEBUG_LEVEL, "-U", SAMBA_USER, "-E", domain ? "-W" : "-c", @@ -958,6 +972,7 @@ (char *)0, safe_env()); /* should not get here */ + dbprintf(("execle of %s failed: %s\n", SAMBA_CLIENT, strerror(errno))); memset(pass, '\0', strlen(pass)); amfree(pass); if(domain) { diff -r -u amanda-2.4.1p1-orig/config/config.h.in amanda-2.4.1p1/config/config.h.in --- amanda-2.4.1p1-orig/config/config.h.in Sat Oct 31 09:06:10 1998 +++ amanda-2.4.1p1/config/config.h.in Tue Apr 18 14:33:34 2000 @@ -612,6 +612,9 @@ /* Define the location of smbclient for backing up Samba PC clients. */ #undef SAMBA_CLIENT +/* Not the actual samba version, just a number that should be increased whenever we start to rely on a new samba feature. */ +#undef SAMBA_VERSION + /* Define the location of smbclient for backing up Samba PC clients. */ #undef SAMBA_USER diff -r -u amanda-2.4.1p1-orig/configure amanda-2.4.1p1/configure --- amanda-2.4.1p1-orig/configure Sat Nov 21 12:12:59 1998 +++ amanda-2.4.1p1/configure Tue Apr 18 14:33:34 2000 @@ -1682,79 +1682,30 @@ # Check whether --with-smbclient or --without-smbclient was given. if test "${with_smbclient+set}" = set; then withval="$with_smbclient" - - case "$withval" in - y | ye | yes) - for ac_prog in smbclient -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1694: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_SAMBA_CLIENT'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case "$SAMBA_CLIENT" in - /*) - ac_cv_path_SAMBA_CLIENT="$SAMBA_CLIENT" # Let the user override the test with a path. - ;; - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $LOCSYSPATH$ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_path_SAMBA_CLIENT="$ac_dir/$ac_word" - break - fi - done - IFS="$ac_save_ifs" - ;; -esac -fi -SAMBA_CLIENT="$ac_cv_path_SAMBA_CLIENT" -if test -n "$SAMBA_CLIENT"; then - echo "$ac_t""$SAMBA_CLIENT" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi -test -n "$SAMBA_CLIENT" && break -done + case "$withval" in + /*) SAMBA_CLIENT="$withval";; + y|ye|yes) :;; + n|no) SAMBA_CLIENT=;; + *) { echo "configure: error: *** You must supply a full pathname to --with-smbclient" 1>&2; exit 1; };; + esac - if test -z "$SAMBA_CLIENT"; then - { echo "configure: error: *** please specify --with-smbclient=/some/dir/smbclient" 1>&2; exit 1; } - fi - ;; - n | no) unset SAMBA_CLIENT - ;; - *) SAMBA_CLIENT="$withval" - ;; - esac - fi -if test "$SAMBA_CLIENT"; then - LIBSRCS_CLIENT="$LIBSRCS_CLIENT findpass.c" - LIBOBJS_CLIENT="$LIBOBJS_CLIENT findpass.o" - cat >> confdefs.h <&2; exit 1; } - ;; - *) SAMBA_USER="$withval" - ;; - esac - + + case "$withval" in + "" | y | ye | yes | n | no) + { echo "configure: error: *** You must supply a user to the --with-samba-user option." 1>&2; exit 1; } + ;; + *) SAMBA_USER="$withval" + ;; + esac + else : ${SAMBA_USER="backup"} @@ -3079,6 +3030,76 @@ ;; esac fi + +for ac_prog in smbclient +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:3506: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_SAMBA_CLIENT'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$SAMBA_CLIENT" in + /*) + ac_cv_path_SAMBA_CLIENT="$SAMBA_CLIENT" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_SAMBA_CLIENT="$SAMBA_CLIENT" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$LOCSYSPATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_SAMBA_CLIENT="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + ;; +esac +fi +SAMBA_CLIENT="$ac_cv_path_SAMBA_CLIENT" +if test -n "$SAMBA_CLIENT"; then + echo "$ac_t""$SAMBA_CLIENT" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$SAMBA_CLIENT" && break +done + +if test ! -z "$SAMBA_CLIENT"; then + case "`\"$SAMBA_CLIENT\" '\\\\not.a.host.name\\notashare' -U nosuchuser -N -Tx + /dev/null 2>&1`" in + *"Unknown host"*) + smbversion=1 + ;; + *"Connection to not.a.host.name failed"*) + smbversion=2 + ;; + *) + echo "configure: warning: *** $SAMBA_CLIENT does not seem to be smbclient, so it will not be used." 1>&2 + SAMBA_CLIENT= + ;; + esac + if test -n "$SAMBA_CLIENT"; then + LIBSRCS_CLIENT="$LIBSRCS_CLIENT findpass.c" + LIBOBJS_CLIENT="$LIBOBJS_CLIENT findpass.o" + cat >> confdefs.h <> confdefs.h <