/*
* Amanda, The Advanced Maryland Automatic Network Disk Archiver
- * Copyright (c) 1991-1998 University of Maryland at College Park
+ * Copyright (c) 1991-1999 University of Maryland at College Park
* All Rights Reserved.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* file named AUTHORS, in the root directory of this distribution.
*/
/*
- * $Id: sendbackup-gnutar.c,v 1.56.2.15.4.4.2.11.2.1 2004/08/31 13:39:08 martinea Exp $
+ * $Id: sendbackup-gnutar.c,v 1.92 2005/12/09 03:22:52 paddy_s Exp $
*
* send backup data using GNU tar
*/
#include "findpass.h"
#endif
-#ifdef KRB4_SECURITY
-#include "sendbackup-krb4.h"
-#else /* I'd tell you what this does */
-#define NAUGHTY_BITS /* but then I'd have to kill you */
-#endif
-
-
static regex_t re_table[] = {
/* tar prints the size in bytes */
AM_SIZE_RE("^ *Total bytes written: [0-9][0-9]*", 1),
-
AM_NORMAL_RE("^Elapsed time:"),
AM_NORMAL_RE("^Throughput"),
#if SAMBA_VERSION >= 2
/* Backup attempt of nonexisting directory */
AM_ERROR_RE("ERRDOS - ERRbadpath (Directory invalid.)"),
+ AM_NORMAL_RE("^Domain="),
#endif
/* catch-all: DMP_STRANGE is returned for all other lines */
AM_STRANGE_RE(NULL)
};
+extern char *efile;
+
int cur_level;
char *cur_disk;
time_t cur_dumptime;
#ifdef GNUTAR_LISTED_INCREMENTAL_DIR
static char *incrname = NULL;
#endif
-
+/*
+ * doing similar to $ gtar | compression | encryption
+ */
static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, indexf)
char *host;
char *disk, *amdevice;
int level, dataf, mesgf, indexf;
char *dumpdate;
{
- int dumpin, dumpout;
+ int dumpin, dumpout, compout;
char *cmd = NULL;
char *indexcmd = NULL;
char *dirname = NULL;
amandates_t *amdates;
time_t prev_dumptime;
char *error_pn = NULL;
+ char *compopt = NULL;
+ char *encryptopt = skip_argument;
error_pn = stralloc2(get_pname(), "-smbclient");
+
fprintf(stderr, "%s: start [%s:%s level %d]\n",
get_pname(), host, disk, level);
-
- NAUGHTY_BITS;
-
+ /* apply client-side encryption here */
+ if ( options->encrypt == ENCRYPT_CUST ) {
+ encpid = pipespawn(options->clnt_encrypt, STDIN_PIPE,
+ &compout, &dataf, &mesgf,
+ options->clnt_encrypt, encryptopt, NULL);
+ dbprintf(("%s: pid %ld: %s\n",
+ debug_prefix_time("-gnutar"), (long)encpid, options->clnt_encrypt));
+ } else {
+ compout = dataf;
+ encpid = -1;
+ }
+ /* now do the client-side compression */
if(options->compress == COMPR_FAST || options->compress == COMPR_BEST) {
- char *compopt = skip_argument;
-
+ compopt = skip_argument;
#if defined(COMPRESS_BEST_OPT) && defined(COMPRESS_FAST_OPT)
if(options->compress == COMPR_BEST) {
compopt = COMPRESS_BEST_OPT;
}
#endif
comppid = pipespawn(COMPRESS_PATH, STDIN_PIPE,
- &dumpout, &dataf, &mesgf,
+ &dumpout, &compout, &mesgf,
COMPRESS_PATH, compopt, NULL);
dbprintf(("%s: pid %ld: %s",
debug_prefix_time("-gnutar"), (long)comppid, COMPRESS_PATH));
dbprintf((" %s", compopt));
}
dbprintf(("\n"));
+ } else if (options->compress == COMPR_CUST) {
+ compopt = skip_argument;
+ comppid = pipespawn(options->clntcompprog, STDIN_PIPE,
+ &dumpout, &compout, &mesgf,
+ options->clntcompprog, compopt, NULL);
+ dbprintf(("%s: pid %ld: %s",
+ debug_prefix_time("-gnutar-cust"), (long)comppid, options->clntcompprog));
+ if(compopt != skip_argument) {
+ dbprintf((" %s", compopt));
+ }
+ dbprintf(("\n"));
} else {
- dumpout = dataf;
+ dumpout = compout;
comppid = -1;
}
if(ch == '/' || isspace(ch)) s[-1] = '_';
}
- ap_snprintf(number, sizeof(number), "%d", level);
+ snprintf(number, sizeof(number), "%d", level);
incrname = vstralloc(basename, "_", number, ".new", NULL);
unlink(incrname);
baselevel = level;
while (in == NULL) {
if (--baselevel >= 0) {
- ap_snprintf(number, sizeof(number), "%d", baselevel);
+ snprintf(number, sizeof(number), "%d", baselevel);
inputname = newvstralloc(inputname,
basename, "_", number, NULL);
} else {
free_amandates();
gmtm = gmtime(&prev_dumptime);
- ap_snprintf(dumptimestr, sizeof(dumptimestr),
+ snprintf(dumptimestr, sizeof(dumptimestr),
"%04d-%02d-%02d %2d:%02d:%02d GMT",
gmtm->tm_year + 1900, gmtm->tm_mon+1, gmtm->tm_mday,
gmtm->tm_hour, gmtm->tm_min, gmtm->tm_sec);
parsesharename(amdevice, &share, &subdir);
if (!share) {
- amfree(share);
- amfree(subdir);
- set_pname(error_pn);
- amfree(error_pn);
- error("cannot parse disk entry '%s' for share/subdir", disk);
+ amfree(share);
+ amfree(subdir);
+ set_pname(error_pn);
+ amfree(error_pn);
+ error("cannot parse disk entry '%s' for share/subdir", disk);
}
if ((subdir) && (SAMBA_VERSION < 2)) {
- amfree(share);
- amfree(subdir);
- set_pname(error_pn);
- amfree(error_pn);
- error("subdirectory specified for share '%s' but samba not v2 or better", disk);
+ amfree(share);
+ amfree(subdir);
+ set_pname(error_pn);
+ amfree(error_pn);
+ error("subdirectory specified for share '%s' but samba not v2 or better", disk);
}
if ((user_and_password = findpass(share, &domain)) == NULL) {
if(domain) {
program->backup_name = program->restore_name = SAMBA_CLIENT;
cmd = stralloc(program->backup_name);
- write_tapeheader();
+ info_tapeheader();
start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
amfree(taropt);
tarpid = dumppid;
} else
-#endif /* } */
+#endif /*end of samba */
{
+
int nb_exclude = 0;
int nb_include = 0;
char **my_argv;
my_argv = alloc(sizeof(char *) * (17 + (nb_exclude*2)+(nb_include*2)));
cmd = vstralloc(libexecdir, "/", "runtar", versionsuffix(), NULL);
- write_tapeheader();
+ info_tapeheader();
start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
my_argv[i++] = "--incremental";
my_argv[i++] = "--newer";
my_argv[i++] = dumptimestr;
-#endif
+#endif
#ifdef ENABLE_GNUTAR_ATIME_PRESERVE
/* --atime-preserve causes gnutar to call
* utime() after reading files in order to
aclose(dumpin);
aclose(dumpout);
+ aclose(compout);
aclose(dataf);
aclose(mesgf);
if (options->createindex)
nodotnew = stralloc(incrname);
nodotnew[strlen(nodotnew)-4] = '\0';
- if (rename(incrname, nodotnew) != 0) {
- fprintf(stderr, "%s: warning [renaming %s to %s: %s]\n",
+ if (rename(incrname, nodotnew)) {
+ fprintf(stderr, "%s: warning [renaming %s to %s: %s]\n",
get_pname(), incrname, nodotnew, strerror(errno));
}
amfree(nodotnew);
#endif
if(!start_amandates(1)) {
- fprintf(stderr, "%s: warning [opening %s: %s]\n", get_pname(),
+ fprintf(stderr, "%s: warning [opening %s: %s]", get_pname(),
AMANDATES_FILE, strerror(errno));
}
else {