projects
/
debian
/
amanda
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Imported Upstream version 2.6.0
[debian/amanda]
/
client-src
/
sendbackup-gnutar.c
diff --git
a/client-src/sendbackup-gnutar.c
b/client-src/sendbackup-gnutar.c
index b1bda6d060cbd4b6dbe29366ef1b2a8e0324f898..c11b55c5a65947ea1984fba7b4ab7274c3f7aa54 100644
(file)
--- a/
client-src/sendbackup-gnutar.c
+++ b/
client-src/sendbackup-gnutar.c
@@
-36,7
+36,7
@@
#include "util.h"
#include "getfsent.h" /* for amname_to_dirname lookup */
#include "version.h"
#include "util.h"
#include "getfsent.h" /* for amname_to_dirname lookup */
#include "version.h"
-#include "c
lientconf
.h"
+#include "c
onffile
.h"
#ifdef SAMBA_CLIENT
#include "findpass.h"
#ifdef SAMBA_CLIENT
#include "findpass.h"
@@
-44,7
+44,7
@@
static amregex_t re_table[] = {
/* tar prints the size in bytes */
static amregex_t re_table[] = {
/* tar prints the size in bytes */
- AM_SIZE_RE("^ *Total bytes written: [0-9][0-9]*", 1),
+ AM_SIZE_RE("^ *Total bytes written: [0-9][0-9]*", 1
, 1
),
AM_NORMAL_RE("^Elapsed time:"),
AM_NORMAL_RE("^Throughput"),
AM_NORMAL_RE("^Elapsed time:"),
AM_NORMAL_RE("^Throughput"),
@@
-141,6
+141,7
@@
start_backup(
int mesgf,
int indexf)
{
int mesgf,
int indexf)
{
+ char tmppath[PATH_MAX];
int dumpin, dumpout, compout;
char *cmd = NULL;
char *indexcmd = NULL;
int dumpin, dumpout, compout;
char *cmd = NULL;
char *indexcmd = NULL;
@@
-153,7
+154,8
@@
start_backup(
char *error_pn = NULL;
char *compopt = NULL;
char *encryptopt = skip_argument;
char *error_pn = NULL;
char *compopt = NULL;
char *encryptopt = skip_argument;
- char *quoted;
+ char *tquoted;
+ char *fquoted;
char *qdisk;
int infd, outfd;
ssize_t nb;
char *qdisk;
int infd, outfd;
ssize_t nb;
@@
-164,10
+166,9
@@
start_backup(
error_pn = stralloc2(get_pname(), "-smbclient");
qdisk = quote_string(disk);
error_pn = stralloc2(get_pname(), "-smbclient");
qdisk = quote_string(disk);
- dbprintf(("%s: start: %s:%s lev %d\n",
- get_pname(), host, qdisk, level));
+ dbprintf(_("start: %s:%s lev %d\n"), host, qdisk, level);
-
fprintf(stderr, "%s: start [%s:%s level %d]\n"
,
+
g_fprintf(stderr, _("%s: start [%s:%s level %d]\n")
,
get_pname(), host, qdisk, level);
/* apply client-side encryption here */
get_pname(), host, qdisk, level);
/* apply client-side encryption here */
@@
-175,17
+176,16
@@
start_backup(
encpid = pipespawn(options->clnt_encrypt, STDIN_PIPE,
&compout, &dataf, &mesgf,
options->clnt_encrypt, encryptopt, NULL);
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));
+ dbprintf(_("gnutar: pid %ld: %s\n"), (long)encpid, options->clnt_encrypt);
} else {
compout = dataf;
encpid = -1;
}
/* now do the client-side compression */
} else {
compout = dataf;
encpid = -1;
}
/* now do the client-side compression */
- if(options->compress == COMP
R_FAST || options->compress == COMPR
_BEST) {
+ if(options->compress == COMP
_FAST || options->compress == COMP
_BEST) {
compopt = skip_argument;
#if defined(COMPRESS_BEST_OPT) && defined(COMPRESS_FAST_OPT)
compopt = skip_argument;
#if defined(COMPRESS_BEST_OPT) && defined(COMPRESS_FAST_OPT)
- if(options->compress == COMP
R
_BEST) {
+ if(options->compress == COMP_BEST) {
compopt = COMPRESS_BEST_OPT;
} else {
compopt = COMPRESS_FAST_OPT;
compopt = COMPRESS_BEST_OPT;
} else {
compopt = COMPRESS_FAST_OPT;
@@
-194,29
+194,30
@@
start_backup(
comppid = pipespawn(COMPRESS_PATH, STDIN_PIPE,
&dumpout, &compout, &mesgf,
COMPRESS_PATH, compopt, NULL);
comppid = pipespawn(COMPRESS_PATH, STDIN_PIPE,
&dumpout, &compout, &mesgf,
COMPRESS_PATH, compopt, NULL);
- dbprintf(("%s: pid %ld: %s",
- debug_prefix_time("-gnutar"), (long)comppid, COMPRESS_PATH));
+ dbprintf(_("gnutar: pid %ld: %s"), (long)comppid, COMPRESS_PATH);
if(compopt != skip_argument) {
if(compopt != skip_argument) {
- dbprintf((" %s", compopt));
+ dbprintf(_("pid %ld: %s %s\n"),
+ (long)comppid, COMPRESS_PATH, compopt);
+ } else {
+ dbprintf(_("pid %ld: %s\n"), (long)comppid, COMPRESS_PATH);
}
}
- dbprintf(("\n"));
- } else if (options->compress == COMPR_CUST) {
+ } else if (options->compress == COMP_CUST) {
compopt = skip_argument;
comppid = pipespawn(options->clntcompprog, STDIN_PIPE,
&dumpout, &compout, &mesgf,
options->clntcompprog, compopt, NULL);
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) {
if(compopt != skip_argument) {
- dbprintf((" %s", compopt));
+ dbprintf(_("pid %ld: %s %s\n"),
+ (long)comppid, options->clntcompprog, compopt);
+ } else {
+ dbprintf(_("pid %ld: %s\n"), (long)comppid, options->clntcompprog);
}
}
- dbprintf(("\n"));
} else {
dumpout = compout;
comppid = -1;
}
} else {
dumpout = compout;
comppid = -1;
}
- gnutar_list_dir =
client_getconf_str(CLN
_GNUTAR_LIST_DIR);
+ gnutar_list_dir =
getconf_str(CNF
_GNUTAR_LIST_DIR);
if (strlen(gnutar_list_dir) == 0)
gnutar_list_dir = NULL;
if (strlen(gnutar_list_dir) == 0)
gnutar_list_dir = NULL;
@@
-228,27
+229,18
@@
start_backup(
if (gnutar_list_dir) {
char *basename = NULL;
char number[NUM_STR_SIZE];
if (gnutar_list_dir) {
char *basename = NULL;
char number[NUM_STR_SIZE];
- char *s;
- int ch;
char *inputname = NULL;
int baselevel;
char *inputname = NULL;
int baselevel;
+ char *sdisk = sanitise_filename(disk);
basename = vstralloc(gnutar_list_dir,
"/",
host,
basename = vstralloc(gnutar_list_dir,
"/",
host,
- disk,
+
s
disk,
NULL);
NULL);
- /*
- * The loop starts at the first character of the host name,
- * not the '/'.
- */
- s = basename + strlen(gnutar_list_dir) + 1;
- while((ch = *s++) != '\0') {
- if(ch == '/')
- s[-1] = '_';
- }
+ amfree(sdisk);
- snprintf(number, SIZEOF(number), "%d", level);
+
g_
snprintf(number, SIZEOF(number), "%d", level);
incrname = vstralloc(basename, "_", number, ".new", NULL);
unlink(incrname);
incrname = vstralloc(basename, "_", number, ".new", NULL);
unlink(incrname);
@@
-261,7
+253,7
@@
start_backup(
infd = -1;
while (infd == -1) {
if (--baselevel >= 0) {
infd = -1;
while (infd == -1) {
if (--baselevel >= 0) {
- snprintf(number, SIZEOF(number), "%d", baselevel);
+
g_
snprintf(number, SIZEOF(number), "%d", baselevel);
inputname = newvstralloc(inputname,
basename, "_", number, NULL);
} else {
inputname = newvstralloc(inputname,
basename, "_", number, NULL);
} else {
@@
-271,12
+263,11
@@
start_backup(
int save_errno = errno;
char *qname = quote_string(inputname);
int save_errno = errno;
char *qname = quote_string(inputname);
- dbprintf(("%s: error opening '%s': %s\n",
- debug_prefix_time("-gnutar"),
+ dbprintf(_("gnutar: error opening '%s': %s\n"),
qname,
qname,
- strerror(save_errno))
)
;
+ strerror(save_errno));
if (baselevel < 0) {
if (baselevel < 0) {
- error(
"error [opening '%s': %s]"
, qname, strerror(save_errno));
+ error(
_("error [opening '%s': %s]")
, qname, strerror(save_errno));
/*NOTREACHED*/
}
amfree(qname);
/*NOTREACHED*/
}
amfree(qname);
@@
-287,51
+278,52
@@
start_backup(
* Copy the previous listed incremental file to the new one.
*/
if ((outfd = open(incrname, O_WRONLY|O_CREAT, 0600)) == -1) {
* Copy the previous listed incremental file to the new one.
*/
if ((outfd = open(incrname, O_WRONLY|O_CREAT, 0600)) == -1) {
- error(
"error [opening '%s': %s]"
, incrname, strerror(errno));
+ error(
_("error [opening '%s': %s]")
, incrname, strerror(errno));
/*NOTREACHED*/
}
while ((nb = read(infd, &buf, SIZEOF(buf))) > 0) {
if (fullwrite(outfd, &buf, (size_t)nb) < nb) {
/*NOTREACHED*/
}
while ((nb = read(infd, &buf, SIZEOF(buf))) > 0) {
if (fullwrite(outfd, &buf, (size_t)nb) < nb) {
- error(
"error [writing to '%s': %s]"
, incrname,
+ error(
_("error [writing to '%s': %s]")
, incrname,
strerror(errno));
/*NOTREACHED*/
}
}
if (nb < 0) {
strerror(errno));
/*NOTREACHED*/
}
}
if (nb < 0) {
- error(
"error [reading from '%s': %s]"
, inputname, strerror(errno));
+ error(
_("error [reading from '%s': %s]")
, inputname, strerror(errno));
/*NOTREACHED*/
}
if (close(infd) != 0) {
/*NOTREACHED*/
}
if (close(infd) != 0) {
- error(
"error [closing '%s': %s]"
, inputname, strerror(errno));
+ error(
_("error [closing '%s': %s]")
, inputname, strerror(errno));
/*NOTREACHED*/
}
if (close(outfd) != 0) {
/*NOTREACHED*/
}
if (close(outfd) != 0) {
- error(
"error [closing '%s': %s]"
, incrname, strerror(errno));
+ error(
_("error [closing '%s': %s]")
, incrname, strerror(errno));
/*NOTREACHED*/
}
/*NOTREACHED*/
}
- dbprintf(("%s: doing level %d dump as listed-incremental",
- debug_prefix_time("-gnutar"), level));
+ tquoted = quote_string(incrname);
if(baselevel >= 0) {
if(baselevel >= 0) {
- quoted = quote_string(inputname);
- dbprintf((" from '%s'", quoted));
- amfree(quoted);
+ fquoted = quote_string(inputname);
+ dbprintf(_("doing level %d dump as listed-incremental from '%s' to '%s'\n"),
+ level, fquoted, tquoted);
+ amfree(fquoted);
+ } else {
+ dbprintf(_("doing level %d dump as listed-incremental to '%s'\n"),
+ level, tquoted);
}
}
- quoted = quote_string(incrname);
- dbprintf((" to '%s'\n", quoted));
- amfree(quoted);
+ amfree(tquoted);
amfree(inputname);
amfree(basename);
}
/* find previous dump time */
amfree(inputname);
amfree(basename);
}
/* find previous dump time */
- amandates_file =
client_getconf_str(CLN
_AMANDATES);
+ amandates_file =
getconf_str(CNF
_AMANDATES);
if(!start_amandates(amandates_file, 0)) {
if(!start_amandates(amandates_file, 0)) {
- error(
"error [opening %s: %s]"
, amandates_file, strerror(errno));
+ error(
_("error [opening %s: %s]")
, amandates_file, strerror(errno));
/*NOTREACHED*/
}
/*NOTREACHED*/
}
@@
-347,25
+339,26
@@
start_backup(
free_amandates();
gmtm = gmtime(&prev_dumptime);
free_amandates();
gmtm = gmtime(&prev_dumptime);
- snprintf(dumptimestr, SIZEOF(dumptimestr),
+
g_
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);
"%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);
- dbprintf(
("%s: doing level %d dump from date: %s\n"
,
-
debug_prefix_time("-gnutar"), level, dumptimestr)
);
+ dbprintf(
_("gnutar: doing level %d dump from date: %s\n")
,
+
level, dumptimestr
);
dirname = amname_to_dirname(amdevice);
cur_dumptime = time(0);
cur_level = level;
cur_disk = stralloc(disk);
dirname = amname_to_dirname(amdevice);
cur_dumptime = time(0);
cur_level = level;
cur_disk = stralloc(disk);
- indexcmd = vstralloc(
#ifdef GNUTAR
#ifdef GNUTAR
- GNUTAR,
+# define PROGRAM_GNUTAR GNUTAR
#else
#else
- "tar",
+# define PROGRAM_GNUTAR "tar"
#endif
#endif
+ indexcmd = vstralloc(
+ PROGRAM_GNUTAR,
" -tf", " -",
" 2>/dev/null",
" | sed", " -e",
" -tf", " -",
" 2>/dev/null",
" | sed", " -e",
@@
-390,7
+383,7
@@
start_backup(
amfree(subdir);
set_pname(error_pn);
amfree(error_pn);
amfree(subdir);
set_pname(error_pn);
amfree(error_pn);
- error(
"cannot parse disk entry %s for share/subdir"
, qdisk);
+ error(
_("cannot parse disk entry %s for share/subdir")
, qdisk);
/*NOTREACHED*/
}
if ((subdir) && (SAMBA_VERSION < 2)) {
/*NOTREACHED*/
}
if ((subdir) && (SAMBA_VERSION < 2)) {
@@
-398,7
+391,7
@@
start_backup(
amfree(subdir);
set_pname(error_pn);
amfree(error_pn);
amfree(subdir);
set_pname(error_pn);
amfree(error_pn);
- error(
"subdirectory specified for share %s but samba not v2 or better"
, qdisk);
+ error(
_("subdirectory specified for share %s but samba not v2 or better")
, qdisk);
/*NOTREACHED*/
}
if ((user_and_password = findpass(share, &domain)) == NULL) {
/*NOTREACHED*/
}
if ((user_and_password = findpass(share, &domain)) == NULL) {
@@
-408,7
+401,7
@@
start_backup(
}
set_pname(error_pn);
amfree(error_pn);
}
set_pname(error_pn);
amfree(error_pn);
- error(
"error [invalid samba host or password not found?]"
);
+ error(
_("error [invalid samba host or password not found?]")
);
/*NOTREACHED*/
}
lpass = strlen(user_and_password);
/*NOTREACHED*/
}
lpass = strlen(user_and_password);
@@
-421,7
+414,7
@@
start_backup(
}
set_pname(error_pn);
amfree(error_pn);
}
set_pname(error_pn);
amfree(error_pn);
- error(
"password field not \'user%%pass\' for %s"
, qdisk);
+ error(
_("password field not \'user%%pass\' for %s")
, qdisk);
/*NOTREACHED*/
}
*pwtext++ = '\0';
/*NOTREACHED*/
}
*pwtext++ = '\0';
@@
-435,7
+428,7
@@
start_backup(
}
set_pname(error_pn);
amfree(error_pn);
}
set_pname(error_pn);
amfree(error_pn);
- error(
"error [can't make share name of %s]"
, share);
+ error(
_("error [can't make share name of %s]")
, share);
/*NOTREACHED*/
}
/*NOTREACHED*/
}
@@
-453,11
+446,11
@@
start_backup(
strappend(taropt, "a");
}
strappend(taropt, "a");
}
- dbprintf(("%s: backup of %s", debug_prefix_time("-gnutar"), sharename));
if (subdir) {
if (subdir) {
- dbprintf(("/%s",subdir));
+ dbprintf(_("gnutar: backup of %s/%s\n"), sharename, subdir);
+ } else {
+ dbprintf(_("gnutar: backup of %s\n"), sharename);
}
}
- dbprintf(("\n"));
program->backup_name = program->restore_name = SAMBA_CLIENT;
cmd = stralloc(program->backup_name);
program->backup_name = program->restore_name = SAMBA_CLIENT;
cmd = stralloc(program->backup_name);
@@
-501,7
+494,7
@@
start_backup(
amfree(user_and_password);
set_pname(error_pn);
amfree(error_pn);
amfree(user_and_password);
set_pname(error_pn);
amfree(error_pn);
- error(
"error [password write failed: %s]"
, strerror(save_errno));
+ error(
_("error [password write failed: %s]")
, strerror(save_errno));
/*NOTREACHED*/
}
memset(user_and_password, '\0', lpass);
/*NOTREACHED*/
}
memset(user_and_password, '\0', lpass);
@@
-533,7
+526,7
@@
start_backup(
my_argv = alloc(SIZEOF(char *) * (22 + (nb_exclude*2)+(nb_include*2)));
my_argv = alloc(SIZEOF(char *) * (22 + (nb_exclude*2)+(nb_include*2)));
- cmd = vstralloc(libexecdir, "/", "runtar", versionsuffix(), NULL);
+ cmd = vstralloc(
am
libexecdir, "/", "runtar", versionsuffix(), NULL);
info_tapeheader();
start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
info_tapeheader();
start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
@@
-543,12
+536,17
@@
start_backup(
my_argv[i++] = g_options->config;
else
my_argv[i++] = "NOCONFIG";
my_argv[i++] = g_options->config;
else
my_argv[i++] = "NOCONFIG";
- my_argv[i++] = "gtar";
+#ifdef GNUTAR
+ my_argv[i++] = GNUTAR;
+#else
+ my_argv[i++] = "tar";
+#endif
my_argv[i++] = "--create";
my_argv[i++] = "--file";
my_argv[i++] = "-";
my_argv[i++] = "--directory";
my_argv[i++] = "--create";
my_argv[i++] = "--file";
my_argv[i++] = "-";
my_argv[i++] = "--directory";
- my_argv[i++] = dirname;
+ canonicalize_pathname(dirname, tmppath);
+ my_argv[i++] = tmppath;
my_argv[i++] = "--one-file-system";
if (gnutar_list_dir && incrname) {
my_argv[i++] = "--listed-incremental";
my_argv[i++] = "--one-file-system";
if (gnutar_list_dir && incrname) {
my_argv[i++] = "--listed-incremental";
@@
-590,10
+588,7
@@
start_backup(
amfree(file_include);
amfree(my_argv);
}
amfree(file_include);
amfree(my_argv);
}
- dbprintf(("%s: %s: pid %ld\n",
- debug_prefix_time("-gnutar"),
- cmd,
- (long)dumppid));
+ dbprintf(_("gnutar: %s: pid %ld\n"), cmd, (long)dumppid);
amfree(qdisk);
amfree(dirname);
amfree(qdisk);
amfree(dirname);
@@
-623,7
+618,7
@@
end_backup(
nodotnew = stralloc(incrname);
nodotnew[strlen(nodotnew)-4] = '\0';
if (rename(incrname, nodotnew)) {
nodotnew = stralloc(incrname);
nodotnew[strlen(nodotnew)-4] = '\0';
if (rename(incrname, nodotnew)) {
-
fprintf(stderr, "%s: warning [renaming %s to %s: %s]\n"
,
+
g_fprintf(stderr, _("%s: warning [renaming %s to %s: %s]\n")
,
get_pname(), incrname, nodotnew, strerror(errno));
}
amfree(nodotnew);
get_pname(), incrname, nodotnew, strerror(errno));
}
amfree(nodotnew);
@@
-631,7
+626,7
@@
end_backup(
}
if(!start_amandates(amandates_file, 1)) {
}
if(!start_amandates(amandates_file, 1)) {
-
fprintf(stderr, "%s: warning [opening %s: %s]"
, get_pname(),
+
g_fprintf(stderr, _("%s: warning [opening %s: %s]")
, get_pname(),
amandates_file, strerror(errno));
}
else {
amandates_file, strerror(errno));
}
else {