X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=recover-src%2Fextract_list.c;h=9f7217b58654ba19417951fdf589490420bdb5ce;hb=cd0b924f27312d57bd42f6c4fae2b795139e2d0b;hp=baac50775b4705014b229ac80b813ffb2a5f6e05;hpb=b116e9366c7b2ea2c2eb53b0a13df4090e176235;p=debian%2Famanda diff --git a/recover-src/extract_list.c b/recover-src/extract_list.c index baac507..9f7217b 100644 --- a/recover-src/extract_list.c +++ b/recover-src/extract_list.c @@ -45,6 +45,7 @@ #include "event.h" #include "client_util.h" #include "security.h" +#include "pipespawn.h" typedef struct EXTRACT_LIST_ITEM { char *path; @@ -96,6 +97,9 @@ static char *dump_device_name = NULL; static char *errstr; static char *amidxtaped_line = NULL; extern char *localhost; +static char header_buf[32768]; +static int header_size = 0; + /* global pid storage for interrupt handler */ pid_t extract_restore_child_pid = -1; @@ -1953,7 +1957,8 @@ extract_files_child( GSList *scriptlist; script_t *script; - merge_properties(dump_dle->application_property, proplist); + merge_properties(dump_dle, NULL, dump_dle->application_property, + proplist, 0); application_property_add_to_argv(argv_ptr, dump_dle, NULL, tapesrv_features); for (scriptlist = dump_dle->scriptlist; scriptlist != NULL; @@ -2106,6 +2111,7 @@ writer_intermediary( ctl_data.bsu = NULL; ctl_data.bytes_read = 0; + header_size = 0; security_stream_read(amidxtaped_streams[DATAFD].fd, read_amidxtaped_data, &ctl_data); @@ -2289,7 +2295,7 @@ extract_files(void) all_level = g_slist_append(all_level, level); } if (dump_dle) { - g_slist_free_full(dump_dle->levellist); + slist_free_full(dump_dle->levellist, g_free); dump_dle->levellist = all_level; run_client_scripts(EXECUTE_ON_PRE_RECOVER, &g_options, dump_dle, stderr); @@ -2337,7 +2343,7 @@ extract_files(void) dump_dle->levellist = g_slist_append(dump_dle->levellist, level); run_client_scripts(EXECUTE_ON_INTER_LEVEL_RECOVER, &g_options, dump_dle, stderr); - g_slist_free_full(dump_dle->levellist); + slist_free_full(dump_dle->levellist, g_free); dump_dle->levellist = NULL; } @@ -2373,7 +2379,7 @@ extract_files(void) if (dump_dle) { run_client_scripts(EXECUTE_ON_POST_LEVEL_RECOVER, &g_options, dump_dle, stderr); - g_slist_free_full(dump_dle->levellist); + slist_free_full(dump_dle->levellist, g_free); dump_dle->levellist = NULL; } } @@ -2381,7 +2387,7 @@ extract_files(void) dump_dle->levellist = all_level; run_client_scripts(EXECUTE_ON_POST_RECOVER, &g_options, dump_dle, stderr); - g_slist_free_full(dump_dle->levellist); + slist_free_full(dump_dle->levellist, g_free); all_level = NULL; dump_dle->levellist = NULL; } @@ -2687,10 +2693,24 @@ read_amidxtaped_data( GPtrArray *errarray; g_option_t g_options; data_path_t data_path_set = DATA_PATH_AMANDA; + int to_move; + + to_move = MIN(32768-header_size, size); + memcpy(header_buf+header_size, buf, to_move); + header_size += to_move; + g_debug("read header %zd => %d", size, header_size); + if (header_size < 32768) { + security_stream_read(amidxtaped_streams[DATAFD].fd, + read_amidxtaped_data, cookie); + return; + } else if (header_size > 32768) { + error("header_size is %d\n", header_size); + } + assert (to_move == size); /* parse the file header */ fh_init(&ctl_data->file); - parse_file_header(buf, &ctl_data->file, (size_t)size); + parse_file_header(header_buf, &ctl_data->file, (size_t)header_size); /* call backup_support_option */ g_options.config = get_config_name(); @@ -2825,6 +2845,43 @@ start_processing_data( /*NOTREACHED*/ } + /* decrypt */ + if (ctl_data->file.encrypted) { + char *argv[3]; + int crypt_out; + int errfd = fileno(stderr); + + g_debug("image is encrypted %s %s", ctl_data->file.clnt_encrypt, ctl_data->file.clnt_decrypt_opt); + argv[0] = ctl_data->file.clnt_encrypt; + argv[1] = ctl_data->file.clnt_decrypt_opt; + argv[2] = NULL; + pipespawnv(ctl_data->file.clnt_encrypt, STDOUT_PIPE, 0, &ctl_data->child_pipe[0], &crypt_out, &errfd, argv); + ctl_data->child_pipe[0] = crypt_out; + } + + /* decompress */ + if (ctl_data->file.compressed) { + char *argv[3]; + int comp_out; + int errfd = fileno(stderr); + char *comp_prog; + char *comp_arg; + + g_debug("image is compressed %s", ctl_data->file.clntcompprog); + if (strlen(ctl_data->file.clntcompprog) > 0) { + comp_prog = ctl_data->file.clntcompprog; + comp_arg = "-d"; + } else { + comp_prog = UNCOMPRESS_PATH; + comp_arg = UNCOMPRESS_OPT; + } + argv[0] = comp_prog; + argv[1] = comp_arg; + argv[2] = NULL; + pipespawnv(comp_prog, STDOUT_PIPE, 0, &ctl_data->child_pipe[0], &comp_out, &errfd, argv); + ctl_data->child_pipe[0] = comp_out; + } + /* okay, ready to extract. fork a child to do the actual work */ if ((ctl_data->pid = fork()) == 0) { /* this is the child process */