* file named AUTHORS, in the root directory of this distribution.
*/
/*
- * $Id: extract_list.c,v 1.117.2.2 2006/12/22 15:10:26 martinea Exp $
+ * $Id: extract_list.c,v 1.117 2006/08/24 01:57:15 paddy_s Exp $
*
* implements the "extract" command in amrecover
*/
#include "findpass.h"
#endif
#include "util.h"
-#include "clientconf.h"
+#include "conffile.h"
#include "protocol.h"
#include "event.h"
#include "security.h"
long timeout_s)
{
ssize_t size = 0;
- fd_set readset;
+ SELECT_ARG_TYPE readset;
struct timeval timeout;
char *dataptr;
ssize_t spaceleft;
{
DIR_ITEM *ditem, lditem;
char *path_on_disk = NULL;
- char *path_on_disk_slash = NULL;
char *cmd = NULL;
char *err = NULL;
int i;
amfree(clean_disk_path);
}
- path_on_disk_slash = stralloc2(path_on_disk, "/");
-
dbprintf(("add_file: Converted path=\"%s\" to path_on_disk=\"%s\"\n",
regex, path_on_disk));
quoted = quote_string(ditem->path);
dbprintf(("add_file: Pondering ditem->path=%s\n", quoted));
amfree(quoted);
- if (match(path_on_disk, ditem->path)
- || match(path_on_disk_slash, ditem->path))
+ if (match(path_on_disk, ditem->path))
{
found_one = 1;
j = (ssize_t)strlen(ditem->path);
amfree(cmd);
amfree(ditem_path);
amfree(path_on_disk);
- amfree(path_on_disk_slash);
exit(1);
}
amfree(cmd);
if ((i = get_reply_line()) == -1) {
amfree(ditem_path);
amfree(path_on_disk);
- amfree(path_on_disk_slash);
exit(1);
}
if(i==0) { /* assume something wrong */
amfree(ditem_path);
amfree(path_on_disk);
- amfree(path_on_disk_slash);
l = reply_line();
printf("%s\n", l);
return;
if (i == -1) {
amfree(ditem_path);
amfree(path_on_disk);
- amfree(path_on_disk_slash);
exit(1);
}
if(err) {
puts(l);
continue;
}
-#define sc "201-"
- if(strncmp(l, sc, sizeof(sc)-1) != 0) {
+
+ s = l;
+ if(strncmp_const_skip(l, "201-", s, ch) != 0) {
err = "bad reply: not 201-";
continue;
}
-
- s = l + sizeof(sc)-1;
ch = *s++;
-#undef sc
+
skip_whitespace(s, ch);
if(ch == '\0') {
err = "bad reply: missing date field";
s[-1] = (char)ch;
if(am_has_feature(indexsrv_features, fe_amindexd_fileno_in_ORLD)) {
+ OFF_T_FMT_TYPE fileno_ = (OFF_T_FMT_TYPE)0;
skip_whitespace(s, ch);
- if(ch == '\0' || sscanf(s - 1, OFF_T_FMT,
- (OFF_T_FMT_TYPE *)&lditem.fileno) != 1) {
+ if(ch == '\0' ||
+ sscanf(s - 1, OFF_T_FMT, &fileno_) != 1) {
err = "bad reply: cannot parse fileno field";
continue;
}
+ lditem.fileno = (off_t)fileno_;
skip_integer(s, ch);
}
amfree(cmd);
amfree(ditem_path);
amfree(path_on_disk);
- amfree(path_on_disk_slash);
amfree(lditem.path);
amfree(lditem.date);
{
DIR_ITEM *ditem, lditem;
char *path_on_disk = NULL;
- char *path_on_disk_slash = NULL;
char *cmd = NULL;
char *err = NULL;
int i;
amfree(clean_disk_path);
}
- path_on_disk_slash = stralloc2(path_on_disk, "/");
-
dbprintf(("delete_file: Converted path=\"%s\" to path_on_disk=\"%s\"\n",
regex, path_on_disk));
found_one = 0;
quoted = quote_string(ditem->path);
dbprintf(("delete_file: Pondering ditem->path=%s\n", quoted));
amfree(quoted);
- if (match(path_on_disk, ditem->path)
- || match(path_on_disk_slash, ditem->path))
+ if (match(path_on_disk, ditem->path))
{
found_one = 1;
j = (ssize_t)strlen(ditem->path);
amfree(cmd);
amfree(ditem_path);
amfree(path_on_disk);
- amfree(path_on_disk_slash);
exit(1);
}
amfree(cmd);
if ((i = get_reply_line()) == -1) {
amfree(ditem_path);
amfree(path_on_disk);
- amfree(path_on_disk_slash);
exit(1);
}
if(i==0) /* assume something wrong */
{
amfree(ditem_path);
amfree(path_on_disk);
- amfree(path_on_disk_slash);
l = reply_line();
printf("%s\n", l);
return;
if (i == -1) {
amfree(ditem_path);
amfree(path_on_disk);
- amfree(path_on_disk_slash);
exit(1);
}
if(err) {
puts(l);
continue;
}
-#define sc "201-"
- if(strncmp(l, sc, sizeof(sc)-1) != 0) {
+
+ s = l;
+ if(strncmp_const_skip(l, "201-", s, ch) != 0) {
err = "bad reply: not 201-";
continue;
}
- s = l + sizeof(sc)-1;
ch = *s++;
-#undef sc
+
skip_whitespace(s, ch);
if(ch == '\0') {
err = "bad reply: missing date field";
*tape_undo = '\0';
if(am_has_feature(indexsrv_features, fe_amindexd_fileno_in_ORLD)) {
+ OFF_T_FMT_TYPE fileno_ = (OFF_T_FMT_TYPE)0;
skip_whitespace(s, ch);
- if(ch == '\0' || sscanf(s - 1, OFF_T_FMT,
- (OFF_T_FMT_TYPE *)&fileno) != 1) {
+ if(ch == '\0' ||
+ sscanf(s - 1, OFF_T_FMT, &fileno_) != 1) {
err = "bad reply: cannot parse fileno field";
continue;
}
+ fileno = (off_t)fileno_;
skip_integer(s, ch);
}
amfree(cmd);
amfree(ditem_path);
amfree(path_on_disk);
- amfree(path_on_disk_slash);
if(! found_one) {
printf("File %s doesn't exist in directory\n", path);
"auth=", authopt, ";",
"\n", NULL);
protocol_sendreq(tape_server_name, amidxtaped_secdrv,
- amidxtaped_client_get_security_conf, req, STARTUP_TIMEOUT,
+ generic_client_get_security_conf, req, STARTUP_TIMEOUT,
amidxtaped_response, &response_error);
amfree(req);
protocol_run();
tt = newstralloc2(tt, "FEATURES=", our_features_string);
send_to_tape_server(amidxtaped_streams[CTLFD].fd, tt);
get_amidxtaped_line();
- if(strncmp(amidxtaped_line,"FEATURES=",9) == 0) {
+ if(strncmp_const(amidxtaped_line,"FEATURES=") == 0) {
tapesrv_features = am_string_to_feature(amidxtaped_line+9);
} else {
fprintf(stderr, "amrecover - expecting FEATURES line from amidxtaped\n");
IS_GNUTAR,
IS_TAR,
IS_SAMBA,
- IS_SAMBA_TAR
+ IS_SAMBA_TAR,
+ IS_BACKUP_API
};
static void
}
if (file.program != NULL) {
+ if (strcmp(file.program, "BACKUP") == 0)
+ dumptype = IS_BACKUP_API;
#ifdef GNUTAR
if (strcmp(file.program, GNUTAR) == 0)
dumptype = IS_GNUTAR;
}
#endif
break;
+ case IS_BACKUP_API:
+ extra_params = 5;
+ break;
}
-
restore_args = (char **)alloc((size_t)((extra_params + files_off_tape + 1)
* sizeof(char *)));
switch(dumptype) {
restore_args[j++] = stralloc("-"); /* data on stdin */
}
#endif
+ break;
+ case IS_BACKUP_API:
+ restore_args[j++] = stralloc(file.dumper);
+ restore_args[j++] = stralloc("restore");
+ restore_args[j++] = stralloc("--config");
+ restore_args[j++] = stralloc(config);
+ restore_args[j++] = stralloc("--disk");
+ restore_args[j++] = stralloc(file.disk);
+ break;
}
for (i = 0, fn = elist->files; i < files_off_tape; i++, fn = fn->next)
{
switch (dumptype) {
+ case IS_BACKUP_API:
case IS_TAR:
case IS_GNUTAR:
case IS_SAMBA_TAR:
{
restore_args[j++] = stralloc(fn->path);
}
+ break;
}
}
#if defined(XFSDUMP)
file.program);
cmd = stralloc("restore");
}
+ break;
+ case IS_BACKUP_API:
+ cmd = vstralloc(DUMPER_DIR, "/", file.dumper, NULL);
+ break;
}
if (cmd) {
dbprintf(("Exec'ing %s with arguments:\n", cmd));
send_to_tape_server(amidxtaped_streams[CTLFD].fd, "ERROR");
break;
}
- } else if(strncmp(amidxtaped_line, "MESSAGE ", 8) == 0) {
+ } else if(strncmp_const(amidxtaped_line, "MESSAGE ") == 0) {
printf("%s\n",&amidxtaped_line[8]);
} else {
fprintf(stderr, "Strange message from tape server: %s",
/* connect to the tape handler daemon on the tape drive server */
if ((extract_files_setup(elist->tape, elist->fileno)) == -1)
{
- fprintf(stderr, "amrecover - can't talk to tape server\n");
+ fprintf(stderr, "amrecover - can't talk to tape server: %s\n",errstr);
return;
}
assert(sech != NULL);
memset(ports, -1, SIZEOF(ports));
- security_close_connection(sech, dump_hostname);
if (pkt == NULL) {
errstr = newvstralloc(errstr, "[request failed: ",
security_geterror(sech), "]", NULL);
*response_error = 1;
return;
}
+ security_close_connection(sech, dump_hostname);
if (pkt->type == P_NAK) {
#if defined(PACKET_DEBUG)
/*
while((p = strchr(tok, ';')) != NULL) {
*p++ = '\0';
-#define sc "features="
- if(strncmp(tok, sc, sizeof(sc)-1) == 0) {
- tok += sizeof(sc) - 1;
-#undef sc
+ if(strncmp_const(tok, "features=") == 0) {
+ tok += sizeof("features=") - 1;
am_release_feature_set(their_features);
if((their_features = am_string_to_feature(tok)) == NULL) {
errstr = newvstralloc(errstr,
return(NULL);
if(strcmp(string, "auth")==0) {
- return(client_getconf_str(CLN_AUTH));
+ return(getconf_str(CNF_AUTH));
}
if(strcmp(string, "ssh_keys")==0) {
- return(client_getconf_str(CLN_SSH_KEYS));
+ return(getconf_str(CNF_SSH_KEYS));
}
return(NULL);
}