2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 University of Maryland at College Park
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of U.M. not be used in advertising or
11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. U.M. makes no representations about the
13 * suitability of this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
16 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Author: James da Silva, Systems Design and Analysis Group
24 * Computer Science Department
25 * University of Maryland at College Park
28 * $Id: diskfile.c,v 1.95 2006/07/26 15:17:37 martinea Exp $
39 static am_host_t *hostlist;
40 static netif_t *all_netifs;
43 static char *upcase(char *st);
44 static int parse_diskline(disklist_t *, const char *, FILE *, int *, char **);
45 static void disk_parserror(const char *, int, const char *, ...)
60 lst->head = lst->tail = NULL;
63 /* if we already have config errors, then don't bother */
64 if (config_errors(NULL) >= CFGERR_ERRORS) {
65 return config_errors(NULL);
68 if ((diskf = fopen(filename, "r")) == NULL) {
69 config_add_error(CFGERR_ERRORS,
70 vstrallocf(_("Could not open '%s': %s"), filename, strerror(errno)));
75 while ((line = agets(diskf)) != NULL) {
77 if (line[0] != '\0') {
78 if (parse_diskline(lst, filename, diskf, &line_num, &line) < 0) {
88 return config_errors(NULL);
97 for (p = hostlist; p != NULL; p = p->next) {
98 if(strcasecmp(p->hostname, hostname) == 0) return p;
105 const char *hostname,
106 const char *diskname)
111 host = lookup_host(hostname);
115 for (disk = host->disks; disk != NULL; disk = disk->hostnext) {
116 if (strcmp(disk->name, diskname) == 0)
124 * put disk on end of queue
132 if(list->tail == NULL) list->head = disk;
133 else list->tail->next = disk;
134 disk->prev = list->tail;
142 * put disk on head of queue
150 if(list->head == NULL) list->tail = disk;
151 else list->head->prev = disk;
152 disk->next = list->head;
160 * insert in sorted order
167 int (*cmp)(disk_t *a, disk_t *b))
175 if(cmp(disk, ptr) < 0) break;
182 if(prev == NULL) list->head = disk;
183 else prev->next = disk;
184 if(ptr == NULL) list->tail = disk;
185 else ptr->prev = disk;
197 disk = alloc(SIZEOF(disk_t));
198 bzero(disk, SIZEOF(disk_t));
200 disk->tape_splitsize = (off_t)0;
201 disk->split_diskbuffer = NULL;
202 disk->fallback_splitsize = (off_t)0;
203 disk->hostname = stralloc(hostname);
204 disk->name = stralloc(diskname);
205 disk->device = stralloc(diskname);
208 disk->compress = COMP_NONE;
209 disk->encrypt = ENCRYPT_NONE;
213 disk->exclude_list = NULL;
214 disk->exclude_file = NULL;
215 disk->include_list = NULL;
216 disk->include_file = NULL;
217 disk->application = NULL;
218 disk->pp_scriptlist = NULL;
220 host = lookup_host(hostname);
222 host = alloc(SIZEOF(am_host_t));
223 host->next = hostlist;
226 host->hostname = stralloc(hostname);
228 host->inprogress = 0;
233 host->features = NULL;
234 host->pre_script = 0;
235 host->post_script = 0;
237 enqueue_disk(list, disk);
240 disk->hostnext = host->disks;
248 * check if disk is present in list. Return true if so, false otherwise.
259 while ((t != NULL) && (t != disk)) {
274 int (*cmp)(disk_t *a, disk_t *b))
279 tmp = in; /* just in case in == out */
281 out->head = (disk_t *)0;
282 out->tail = (disk_t *)0;
284 while((disk = dequeue_disk(tmp)))
285 insert_disk(out, disk, cmp);
290 * remove disk from front of queue
299 if(list->head == NULL) return NULL;
302 list->head = disk->next;
304 if(list->head == NULL) list->tail = NULL;
305 else list->head->prev = NULL;
307 disk->prev = disk->next = NULL; /* for debugging */
316 if(disk->prev == NULL) list->head = disk->next;
317 else disk->prev->next = disk->next;
319 if(disk->next == NULL) list->tail = disk->prev;
320 else disk->next->prev = disk->prev;
322 disk->prev = disk->next = NULL;
330 am_host_t *host, *hostnext;
332 while (dl->head != NULL) {
333 dp = dequeue_disk(dl);
335 amfree(dp->hostname);
337 free_sl(dp->exclude_file);
338 free_sl(dp->exclude_list);
339 free_sl(dp->include_file);
340 free_sl(dp->include_list);
344 for(host=hostlist; host != NULL; host = hostnext) {
345 amfree(host->hostname);
346 am_release_feature_set(host->features);
347 host->features = NULL;
348 hostnext = host->next;
361 if(islower((int)*s)) *s = (char)toupper((int)*s);
368 /* return 0 on success */
369 /* return -1 on error */
373 const char *filename,
376 /*@keep@*/ char ** line_p)
381 netif_t *netif = NULL;
382 interface_t *cfg_if = NULL;
383 char *hostname = NULL;
384 char *diskname, *diskdevice;
388 char *line = *line_p;
389 int line_num = *line_num_p;
396 assert(filename != NULL);
397 assert(line_num > 0);
398 assert(line != NULL);
402 skip_whitespace(s, ch);
403 if(ch == '\0' || ch == '#')
407 skip_non_whitespace(s, ch);
409 host = lookup_host(fp);
411 hostname = stralloc(fp);
413 hostname = stralloc(host->hostname);
414 if (strcmp(host->hostname, fp) != 0) {
415 disk_parserror(filename, line_num, "Same host with different case: \"%s\" and \"%s\".", host->hostname, fp);
420 shost = sanitise_filename(hostname);
421 for (p = hostlist; p != NULL; p = p->next) {
422 char *shostp = sanitise_filename(p->hostname);
423 if (strcmp(hostname, p->hostname) &&
424 !strcmp(shost, shostp)) {
425 disk_parserror(filename, line_num, "Two hosts are mapping to the same name: \"%s\" and \"%s\"", p->hostname, hostname);
428 else if (strcasecmp(hostname, p->hostname) &&
429 match_host(hostname, p->hostname) &&
430 match_host(p->hostname, hostname)) {
431 disk_parserror(filename, line_num, _("Duplicate host name: \"%s\" and \"%s\""), p->hostname, hostname);
438 skip_whitespace(s, ch);
439 if(ch == '\0' || ch == '#') {
440 disk_parserror(filename, line_num, _("disk device name expected"));
446 skip_quoted_string(s, ch);
448 diskname = unquote_string(fp);
449 if (strlen(diskname) == 0) {
450 disk_parserror(filename, line_num, _("invalid empty diskname"));
454 skip_whitespace(s, ch);
455 if(ch == '\0' || ch == '#') {
456 disk_parserror(filename, line_num, _("disk dumptype expected"));
462 skip_quoted_string(s, ch);
469 dumptype = unquote_string(fp);
470 if (strlen(dumptype) == 0) {
471 disk_parserror(filename, line_num, _("invalid empty diskdevice"));
475 if ((dtype = lookup_dumptype(dumptype)) == NULL) {
476 diskdevice = dumptype;
477 skip_whitespace(s, ch);
478 if(ch == '\0' || ch == '#') {
479 disk_parserror(filename, line_num,
480 _("disk dumptype '%s' not found"), dumptype);
488 skip_quoted_string(s, ch);
491 dumptype = unquote_string(fp);
496 /* check for duplicate disk */
499 if ((disk = lookup_disk(hostname, diskname)) != NULL) {
505 a1 = clean_regex(diskname);
506 a2 = clean_regex(disk->name);
508 if (match_disk(a1, disk->name) && match_disk(a2, diskname)) {
511 disk = disk->hostnext;
516 while (dup == 0 && disk != NULL);
519 disk_parserror(filename, line_num,
520 _("duplicate disk record, previous on line %d"),
525 disk = alloc(SIZEOF(disk_t));
526 disk->line = line_num;
527 disk->hostname = stralloc(hostname);
528 disk->name = diskname;
529 disk->device = diskdevice;
532 disk->inprogress = 0;
533 disk->application = NULL;
534 disk->pp_scriptlist = NULL;
538 sdisk = sanitise_filename(diskname);
539 for (dp = host->disks; dp != NULL; dp = dp->hostnext) {
540 char *sdiskp = sanitise_filename(dp->name);
541 if (strcmp(diskname, dp->name) != 0 &&
542 strcmp(sdisk, sdiskp) == 0) {
543 disk_parserror(filename, line_num,
544 _("Two disks are mapping to the same name: \"%s\" and \"%s\"; you must use different diskname"),
556 skip_whitespace(s, ch);
557 if (ch != '\0' && ch != '#') {
558 disk_parserror(filename, line_num,
559 _("expected line break after `{\', ignoring rest of line"));
562 if (strchr(s-1, '}') &&
563 (strchr(s-1, '#') == NULL ||
564 strchr(s-1, '}') < strchr(s-1, '#'))) {
565 disk_parserror(filename, line_num,_("'}' on same line than '{'"));
568 amfree(disk->device);
577 dtype = read_dumptype(vstralloc("custom(", hostname,
578 ":", disk->name, ")",
579 ".", anonymous_value(), NULL),
580 diskf, (char*)filename, line_num_p);
581 if (dtype == NULL || dup) {
582 disk_parserror(filename, line_num,
583 _("read of custom dumptype failed"));
586 amfree(disk->device);
597 *line_p = line = agets(diskf);
598 line_num = *line_num_p; /* no incr, read_dumptype did it already */
601 *line_p = line = stralloc("");
605 if((dtype = lookup_dumptype(dumptype)) == NULL) {
606 char *qdt = quote_string(dumptype);
608 disk_parserror(filename, line_num, _("undefined dumptype `%s'"), qdt);
613 amfree(disk->device);
625 /* disk_parserror already called, above */
626 g_assert(config_errors(NULL) != CFGERR_OK);
633 disk->dtype_name = dumptype_name(dtype);
634 disk->program = dumptype_get_program(dtype);
635 disk->exclude_list = duplicate_sl(dumptype_get_exclude(dtype).sl_list);
636 disk->exclude_file = duplicate_sl(dumptype_get_exclude(dtype).sl_file);
637 disk->exclude_optional = dumptype_get_exclude(dtype).optional;
638 disk->include_list = duplicate_sl(dumptype_get_include(dtype).sl_list);
639 disk->include_file = duplicate_sl(dumptype_get_include(dtype).sl_file);
640 disk->include_optional = dumptype_get_include(dtype).optional;
641 disk->priority = dumptype_get_priority(dtype);
642 disk->dumpcycle = dumptype_get_dumpcycle(dtype);
643 /* disk->frequency = dumptype_get_frequency(dtype);*/
644 disk->security_driver = dumptype_get_security_driver(dtype);
645 disk->maxdumps = dumptype_get_maxdumps(dtype);
646 disk->tape_splitsize = dumptype_get_tape_splitsize(dtype);
647 disk->split_diskbuffer = dumptype_get_split_diskbuffer(dtype);
648 disk->fallback_splitsize = dumptype_get_fallback_splitsize(dtype);
649 disk->maxpromoteday = dumptype_get_maxpromoteday(dtype);
650 disk->bumppercent = dumptype_get_bumppercent(dtype);
651 disk->bumpsize = dumptype_get_bumpsize(dtype);
652 disk->bumpdays = dumptype_get_bumpdays(dtype);
653 disk->bumpmult = dumptype_get_bumpmult(dtype);
654 disk->starttime = dumptype_get_starttime(dtype);
655 disk->application = dumptype_get_application(dtype);
656 disk->pp_scriptlist = dumptype_get_pp_scriptlist(dtype);
658 if (disk->starttime > 0) {
661 stm = localtime(&st);
662 disk->start_t -= stm->tm_sec + 60 * stm->tm_min + 3600 * stm->tm_hour;
663 disk->start_t += disk->starttime / 100 * 3600 +
664 disk->starttime % 100 * 60;
665 if ((disk->start_t - st) < -43200)
666 disk->start_t += 86400;
668 disk->strategy = dumptype_get_strategy(dtype);
669 disk->ignore = dumptype_get_ignore(dtype);
670 disk->estimate = dumptype_get_estimate(dtype);
671 disk->compress = dumptype_get_compress(dtype);
672 disk->srvcompprog = dumptype_get_srvcompprog(dtype);
673 disk->clntcompprog = dumptype_get_clntcompprog(dtype);
674 disk->encrypt = dumptype_get_encrypt(dtype);
675 disk->srv_decrypt_opt = dumptype_get_srv_decrypt_opt(dtype);
676 disk->clnt_decrypt_opt = dumptype_get_clnt_decrypt_opt(dtype);
677 disk->srv_encrypt = dumptype_get_srv_encrypt(dtype);
678 disk->clnt_encrypt = dumptype_get_clnt_encrypt(dtype);
679 disk->amandad_path = dumptype_get_amandad_path(dtype);
680 disk->client_username = dumptype_get_client_username(dtype);
681 disk->ssh_keys = dumptype_get_ssh_keys(dtype);
682 disk->comprate[0] = dumptype_get_comprate(dtype)[0];
683 disk->comprate[1] = dumptype_get_comprate(dtype)[1];
686 * Boolean parameters with no value (Appears here as value 2) defaults
687 * to TRUE for backward compatibility and for logical consistency.
689 disk->record = dumptype_get_record(dtype) != 0;
690 disk->skip_incr = dumptype_get_skip_incr(dtype) != 0;
691 disk->skip_full = dumptype_get_skip_full(dtype) != 0;
692 disk->to_holdingdisk = dumptype_get_to_holdingdisk(dtype);
693 disk->kencrypt = dumptype_get_kencrypt(dtype) != 0;
694 disk->index = dumptype_get_index(dtype) != 0;
698 skip_whitespace(s, ch);
700 if(ch && ch != '#') { /* get optional spindle number */
704 skip_non_whitespace(s, ch);
707 if (*fp1 == '-') fp1++;
708 for(;*fp1!='\0';fp1++) {
709 if(!isdigit((int)*fp1)) {
714 disk_parserror(filename, line_num, _("non-integer spindle `%s'"), fp);
720 disk->spindle = atoi(fp);
724 skip_whitespace(s, ch);
726 if(ch && ch != '#') { /* get optional network interface */
727 skip_non_whitespace(s, ch);
729 if((cfg_if = lookup_interface(upcase(fp))) == NULL) {
730 disk_parserror(filename, line_num,
731 _("undefined network interface `%s'"), fp);
738 cfg_if = lookup_interface("default");
741 /* see if we already have a netif_t for this interface */
742 for (netif = all_netifs; netif != NULL; netif = netif->next) {
743 if (netif->config == cfg_if)
747 /* nope; make up a new one */
749 netif = alloc(sizeof(*netif));
750 netif->next = all_netifs;
752 netif->config = cfg_if;
756 skip_whitespace(s, ch);
757 if(ch && ch != '#') { /* now we have garbage, ignore it */
758 disk_parserror(filename, line_num, _("end of line expected"));
761 if (disk->program && disk->application &&
762 strcmp(disk->program,"APPLICATION")) {
763 disk_parserror(filename, line_num,
764 _("Both program and application set"));
767 if (disk->program && strcmp(disk->program,"APPLICATION")==0 &&
768 !disk->application) {
769 disk_parserror(filename, line_num,
770 _("program set to APPLICATION but no application set"));
773 if(dumptype_get_ignore(dtype) || dumptype_get_strategy(dtype) == DS_SKIP) {
777 /* success, add disk to lists */
779 if(host == NULL) { /* new host */
780 host = alloc(SIZEOF(am_host_t));
781 host->next = hostlist;
784 host->hostname = hostname;
787 host->inprogress = 0;
788 host->maxdumps = 1; /* will be overwritten */
792 host->features = NULL;
793 host->pre_script = 0;
794 host->post_script = 0;
801 enqueue_disk(lst, disk);
804 disk->hostnext = host->disks;
806 host->maxdumps = disk->maxdumps;
812 printf_arglist_function2(void disk_parserror, const char *, filename,
813 int, line_num, const char *, format)
819 /* format the error message and hand it off to conffile */
821 arglist_start(argp, format);
822 msg = g_strdup_vprintf(format, argp);
823 errstr = g_strdup_printf("\"%s\", line %d: %s", filename, line_num, msg);
827 config_add_error(CFGERR_ERRORS, errstr);
835 int npr, /* we print first npr disks on queue, plus last two */
843 g_fprintf(f, _("%s QUEUE: empty\n"), st);
846 g_fprintf(f, _("%s QUEUE:\n"), st);
847 for(pos = 0, d = q.head, p = NULL; d != NULL; p = d, d = d->next, pos++) {
848 qname = quote_string(d->name);
849 if(pos < npr) g_fprintf(f, "%3d: %-10s %-4s\n",
850 pos, d->host->hostname, qname);
854 if(pos > npr+2) g_fprintf(f, " ...\n");
857 g_fprintf(f, "%3d: %-10s %-4s\n", pos-2, d->host->hostname, d->name);
860 g_fprintf(f, "%3d: %-10s %-4s\n", pos-1, d->host->hostname, d->name);
867 am_feature_t * their_features,
870 char *auth_opt = NULL;
871 char *kencrypt_opt = "";
872 char *compress_opt = "";
873 char *encrypt_opt = stralloc("");
874 char *decrypt_opt = stralloc("");
875 char *record_opt = "";
876 char *index_opt = "";
877 char *exclude_file = NULL;
878 char *exclude_list = NULL;
879 char *include_file = NULL;
880 char *include_list = NULL;
893 assert(dp->host != NULL);
895 qdpname = quote_string(dp->name);
896 if(am_has_feature(dp->host->features, fe_options_auth)) {
897 auth_opt = vstralloc("auth=", dp->security_driver, ";", NULL);
898 } else if(strcasecmp(dp->security_driver, "bsd") == 0) {
899 if(am_has_feature(dp->host->features, fe_options_bsd_auth))
900 auth_opt = stralloc("bsd-auth;");
903 _("WARNING: %s:%s does not support auth or bsd-auth\n"),
904 dp->host->hostname, qdpname);
906 } else if(strcasecmp(dp->security_driver, "krb4") == 0) {
907 if(am_has_feature(dp->host->features, fe_options_krb4_auth))
908 auth_opt = stralloc("krb4-auth;");
911 _("WARNING: %s:%s does not support auth or krb4-auth\n"),
912 dp->host->hostname, qdpname);
915 if(am_has_feature(dp->host->features, fe_options_kencrypt)) {
916 kencrypt_opt = "kencrypt;";
920 _("WARNING: %s:%s does not support kencrypt\n"),
921 dp->host->hostname, qdpname);
926 switch(dp->compress) {
928 if(am_has_feature(their_features, fe_options_compress_fast)) {
929 compress_opt = "compress-fast;";
933 _("WARNING: %s:%s does not support fast compression\n"),
934 dp->host->hostname, qdpname);
938 if(am_has_feature(their_features, fe_options_compress_best)) {
939 compress_opt = "compress-best;";
943 _("WARNING: %s:%s does not support best compression\n"),
944 dp->host->hostname, qdpname);
948 if(am_has_feature(their_features, fe_options_compress_cust)) {
949 compress_opt = vstralloc("comp-cust=", dp->clntcompprog, ";", NULL);
950 if (BSTRNCMP(compress_opt, "comp-cust=;") == 0){
953 _("ERROR: %s:%s client custom compression with no compression program specified\n"),
954 dp->host->hostname, qdpname);
961 _("WARNING: %s:%s does not support client custom compression\n"),
962 dp->host->hostname, qdpname);
965 case COMP_SERVER_FAST:
966 if(am_has_feature(their_features, fe_options_srvcomp_fast)) {
967 compress_opt = "srvcomp-fast;";
970 case COMP_SERVER_BEST:
971 if(am_has_feature(their_features, fe_options_srvcomp_best)) {
972 compress_opt = "srvcomp-best;";
975 case COMP_SERVER_CUST:
976 if(am_has_feature(their_features, fe_options_srvcomp_cust)) {
977 compress_opt = vstralloc("srvcomp-cust=", dp->srvcompprog, ";", NULL);
978 if (BSTRNCMP(compress_opt, "srvcomp-cust=;") == 0){
981 _("ERROR: %s:%s server custom compression with no compression program specified\n"),
982 dp->host->hostname, qdpname);
989 _("WARNING: %s:%s does not support server custom compression\n"),
990 dp->host->hostname, qdpname);
995 switch(dp->encrypt) {
997 if(am_has_feature(their_features, fe_options_encrypt_cust)) {
998 encrypt_opt = newvstralloc(encrypt_opt, "encrypt-cust=",
999 dp->clnt_encrypt, ";", NULL);
1000 if (BSTRNCMP(encrypt_opt, "encrypt-cust=;") == 0) {
1003 _("ERROR: %s:%s encrypt client with no encryption program specified\n"),
1004 dp->host->hostname, qdpname);
1008 if ( dp->compress == COMP_SERVER_FAST ||
1009 dp->compress == COMP_SERVER_BEST ||
1010 dp->compress == COMP_SERVER_CUST ) {
1013 _("ERROR: %s:Client encryption with server compression is "
1014 "not supported. See amanda.conf(5) for detail.\n"),
1015 dp->host->hostname);
1019 if(dp->clnt_decrypt_opt) {
1020 if(am_has_feature(their_features, fe_options_client_decrypt_option)) {
1021 decrypt_opt = newvstralloc(decrypt_opt, "client-decrypt-option=",
1022 dp->clnt_decrypt_opt, ";", NULL);
1026 _("WARNING: %s:%s does not support client decrypt option\n"),
1027 dp->host->hostname, qdpname);
1033 _("WARNING: %s:%s does not support client data encryption\n"),
1034 dp->host->hostname, qdpname);
1037 case ENCRYPT_SERV_CUST:
1038 if(am_has_feature(their_features, fe_options_encrypt_serv_cust)) {
1039 encrypt_opt = newvstralloc(encrypt_opt, "encrypt-serv-cust=",
1040 dp->srv_encrypt, ";", NULL);
1041 if (BSTRNCMP(encrypt_opt, "encrypt-serv-cust=;") == 0){
1044 _("ERROR: %s:%s No encryption program specified in dumptypes\n"),
1045 dp->host->hostname, qdpname);
1046 g_fprintf(fdout, _("Change the dumptype in the disklist or mention "
1047 "the ecnryption program to use in the dumptypes file\n"));
1052 if(dp->srv_decrypt_opt) {
1053 if(am_has_feature(their_features, fe_options_server_decrypt_option)) {
1054 decrypt_opt = newvstralloc(decrypt_opt, "server-decrypt-option=",
1055 dp->srv_decrypt_opt, ";", NULL);
1059 _("WARNING: %s:%s client version does not support server data decryption\n"),
1060 dp->host->hostname, qdpname);
1066 _("WARNING: %s:%s client version does not support server data encryption\n"),
1067 dp->host->hostname, qdpname);
1073 if(am_has_feature(their_features, fe_options_no_record)) {
1074 record_opt = "no-record;";
1077 g_fprintf(fdout, _("WARNING: %s:%s does not support no record\n"),
1078 dp->host->hostname, qdpname);
1083 if(am_has_feature(their_features, fe_options_index)) {
1084 index_opt = "index;";
1087 g_fprintf(fdout, _("WARNING: %s:%s does not support index\n"),
1088 dp->host->hostname, qdpname);
1092 if(dp->kencrypt) kencrypt_opt = "kencrypt;";
1095 exclude_file = stralloc("");
1096 nb_exclude_file = 0;
1097 if(dp->exclude_file != NULL && dp->exclude_file->nb_element > 0) {
1098 nb_exclude_file = dp->exclude_file->nb_element;
1099 if(am_has_feature(their_features, fe_options_exclude_file)) {
1100 if(am_has_feature(their_features, fe_options_multiple_exclude) ||
1101 dp->exclude_file->nb_element == 1) {
1102 for(excl = dp->exclude_file->first; excl != NULL;
1103 excl = excl->next) {
1104 qname = quote_string(excl->name);
1105 exc = newvstralloc( exc, "exclude-file=", qname, ";", NULL);
1106 strappend(exclude_file, exc);
1110 qname = quote_string(dp->exclude_file->last->name);
1111 exc = newvstralloc(exc, "exclude-file=", qname, ";", NULL);
1112 strappend(exclude_file, exc);
1115 _("WARNING: %s:%s does not support multiple exclude\n"),
1116 dp->host->hostname, qdpname);
1121 g_fprintf(fdout, _("WARNING: %s:%s does not support exclude file\n"),
1122 dp->host->hostname, qdpname);
1125 exclude_list = stralloc("");
1126 if(dp->exclude_list != NULL && dp->exclude_list->nb_element > 0) {
1127 if(am_has_feature(their_features, fe_options_exclude_list)) {
1128 if(am_has_feature(their_features, fe_options_multiple_exclude) ||
1129 (dp->exclude_list->nb_element == 1 && nb_exclude_file == 0)) {
1130 for(excl = dp->exclude_list->first; excl != NULL;
1131 excl = excl->next) {
1132 qname = quote_string(excl->name);
1133 exc = newvstralloc( exc, "exclude-list=", qname, ";", NULL);
1134 strappend(exclude_list, exc);
1138 qname = quote_string(dp->exclude_list->last->name);
1139 exc = newvstralloc(exc, "exclude-list=", qname, ";", NULL);
1140 strappend(exclude_list, exc);
1143 _("WARNING: %s:%s does not support multiple exclude\n"),
1144 dp->host->hostname, qdpname);
1149 g_fprintf(fdout, _("WARNING: %s:%s does not support exclude list\n"),
1150 dp->host->hostname, qdpname);
1154 include_file = stralloc("");
1155 nb_include_file = 0;
1156 if(dp->include_file != NULL && dp->include_file->nb_element > 0) {
1157 nb_include_file = dp->include_file->nb_element;
1158 if(am_has_feature(their_features, fe_options_include_file)) {
1159 if(am_has_feature(their_features, fe_options_multiple_include) ||
1160 dp->include_file->nb_element == 1) {
1161 for(excl = dp->include_file->first; excl != NULL;
1162 excl = excl->next) {
1163 qname = quote_string(excl->name);
1164 exc = newvstralloc(exc, "include-file=", qname, ";", NULL);
1165 strappend(include_file, exc);
1169 qname = quote_string(dp->include_file->last->name);
1170 exc = newvstralloc(exc, "include-file=", qname, ";", NULL);
1171 strappend(include_file, exc);
1174 _("WARNING: %s:%s does not support multiple include\n"),
1175 dp->host->hostname, qdpname);
1180 g_fprintf(fdout, _("WARNING: %s:%s does not support include file\n"),
1181 dp->host->hostname, qdpname);
1184 include_list = stralloc("");
1185 if(dp->include_list != NULL && dp->include_list->nb_element > 0) {
1186 if(am_has_feature(their_features, fe_options_include_list)) {
1187 if(am_has_feature(their_features, fe_options_multiple_include) ||
1188 (dp->include_list->nb_element == 1 && nb_include_file == 0)) {
1189 for(excl = dp->include_list->first; excl != NULL;
1190 excl = excl->next) {
1191 qname = quote_string(excl->name);
1192 exc = newvstralloc(exc, "include-list=", qname, ";", NULL);
1193 strappend(include_list, exc);
1197 qname = quote_string(dp->include_list->last->name);
1198 exc = newvstralloc(exc, "include-list=", qname, ";", NULL);
1199 strappend(include_list, exc);
1202 _("WARNING: %s:%s does not support multiple include\n"),
1203 dp->host->hostname, qdpname);
1208 g_fprintf(fdout, _("WARNING: %s:%s does not support include list\n"),
1209 dp->host->hostname, qdpname);
1213 if(dp->exclude_optional) {
1214 if(am_has_feature(their_features, fe_options_optional_exclude)) {
1215 excl_opt = "exclude-optional;";
1219 _("WARNING: %s:%s does not support optional exclude\n"),
1220 dp->host->hostname, qdpname);
1223 if(dp->include_optional) {
1224 if(am_has_feature(their_features, fe_options_optional_include)) {
1225 incl_opt = "include-optional;";
1229 _("WARNING: %s:%s does not support optional include\n"),
1230 dp->host->hostname, qdpname);
1234 result = vstralloc(";",
1251 amfree(exclude_list);
1252 amfree(exclude_file);
1253 amfree(include_file);
1254 amfree(include_list);
1256 amfree(decrypt_opt);
1257 amfree(encrypt_opt);
1259 /* result contains at least 'auth=...' */
1272 am_feature_t * their_features,
1276 char *auth_opt = stralloc("");
1277 char *kencrypt_opt = stralloc("");
1278 char *compress_opt = stralloc("");
1279 char *encrypt_opt = stralloc("");
1280 char *decrypt_opt = stralloc("");
1281 char *record_opt = stralloc("");
1282 char *index_opt = stralloc("");
1283 char *exclude = stralloc("");
1284 char *exclude_file = NULL;
1285 char *exclude_list = NULL;
1286 char *include = stralloc("");
1287 char *include_file = NULL;
1288 char *include_list = NULL;
1289 char *excl_opt = "";
1290 char *incl_opt = "";
1293 char *result = NULL;
1295 int nb_exclude_file;
1296 int nb_include_file;
1302 assert(dp->host != NULL);
1304 qdpname = quote_string(dp->name);
1305 if(am_has_feature(dp->host->features, fe_options_auth)) {
1306 auth_opt = vstralloc(" <auth>", dp->security_driver, "</auth>\n", NULL);
1309 _("WARNING: %s:%s does not support auth\n"),
1310 dp->host->hostname, qdpname);
1313 switch(dp->compress) {
1315 if(am_has_feature(their_features, fe_options_compress_fast)) {
1316 compress_opt = " <compress>FAST</compress>\n";
1320 _("WARNING: %s:%s does not support fast compression\n"),
1321 dp->host->hostname, qdpname);
1325 if(am_has_feature(their_features, fe_options_compress_best)) {
1326 compress_opt = " <compress>BEST</compress>\n";
1330 _("WARNING: %s:%s does not support best compression\n"),
1331 dp->host->hostname, qdpname);
1335 if(am_has_feature(their_features, fe_options_compress_cust)) {
1336 if (dp->clntcompprog == NULL) {
1339 _("ERROR: %s:%s client custom compression with no compression program specified\n"),
1340 dp->host->hostname, qdpname);
1345 compress_opt = vstralloc(" <compress>CUSTOM"
1346 "<custom-compress-program>",
1348 "</custom-compress-program>\n"
1349 " </compress>\n", NULL);
1354 _("WARNING: %s:%s does not support client custom compression\n"),
1355 dp->host->hostname, qdpname);
1358 case COMP_SERVER_FAST:
1359 compress_opt = " <compress>SERVER-FAST</compress>\n";
1361 case COMP_SERVER_BEST:
1362 compress_opt = " <compress>SERVER-BEST</compress>\n";
1364 case COMP_SERVER_CUST:
1365 compress_opt = " <compress>SERVER-CUSTOM</compress>\n";
1366 if (dp->srvcompprog == NULL) {
1369 _("ERROR: %s:%s server custom compression with no compression program specified\n"),
1370 dp->host->hostname, qdpname);
1374 compress_opt = vstralloc(" <compress>SERVER-CUSTOM"
1375 "<custom-compress-program>",
1377 "</custom-compress-program>\n"
1378 " </compress>\n", NULL);
1383 switch(dp->encrypt) {
1385 if(am_has_feature(their_features, fe_options_encrypt_cust)) {
1386 if(dp->clnt_decrypt_opt) {
1387 if(am_has_feature(their_features, fe_options_client_decrypt_option)) {
1388 decrypt_opt = newvstralloc(decrypt_opt,
1389 " <decrypt-option>",
1390 dp->clnt_decrypt_opt,
1391 "</decrypt-option>\n", NULL);
1394 _("WARNING: %s:%s does not support client decrypt option\n"),
1395 dp->host->hostname, qdpname);
1398 if (dp->clnt_encrypt == NULL) {
1401 _("ERROR: %s:%s encrypt client with no encryption program specified\n"),
1402 dp->host->hostname, qdpname);
1405 } else if (decrypt_opt) {
1406 encrypt_opt = newvstralloc(encrypt_opt,
1408 "<custom-encrypt-program>",
1410 "</custom-encrypt-program>\n",
1412 " </encrypt>\n", NULL);
1414 if (dp->compress == COMP_SERVER_FAST ||
1415 dp->compress == COMP_SERVER_BEST ||
1416 dp->compress == COMP_SERVER_CUST ) {
1419 _("ERROR: %s:Client encryption with server compression is "
1420 "not supported. See amanda.conf(5) for detail.\n"),
1421 dp->host->hostname);
1427 _("WARNING: %s:%s does not support client data encryption\n"),
1428 dp->host->hostname, qdpname);
1431 case ENCRYPT_SERV_CUST:
1432 if (dp->srv_encrypt != NULL && to_server) {
1433 decrypt_opt = newvstralloc(decrypt_opt,
1434 " <decrypt-option>",
1435 dp->srv_decrypt_opt,
1436 "</decrypt-option>\n", NULL);
1437 encrypt_opt = newvstralloc(encrypt_opt,
1438 " <encrypt>SERVER-CUSTOM"
1439 "<custom-encrypt-program>",
1441 "</custom-encrypt-program>\n",
1443 " </encrypt>\n", NULL);
1444 } else if (dp->srv_encrypt == NULL) {
1447 _("ERROR: %s:%s No encryption program specified in dumptypes\n"),
1448 dp->host->hostname, qdpname);
1450 _("Change the dumptype in the disklist or mention "
1451 "the encryption program to use in the dumptypes file\n"));
1459 if(am_has_feature(their_features, fe_options_no_record)) {
1460 record_opt = " <record>NO</record>\n";
1463 fprintf(fdout, _("WARNING: %s:%s does not support no record\n"),
1464 dp->host->hostname, qdpname);
1467 record_opt = " <record>YES</record>\n";
1471 if(am_has_feature(their_features, fe_options_index)) {
1472 index_opt = " <index>YES</index>\n";
1475 fprintf(fdout, _("WARNING: %s:%s does not support index\n"),
1476 dp->host->hostname, qdpname);
1481 if(am_has_feature(their_features, fe_options_kencrypt)) {
1482 kencrypt_opt = " <kencrypt>YES</kencrypt>\n";
1485 fprintf(fdout, _("WARNING: %s:%s does not support kencrypt\n"),
1486 dp->host->hostname, qdpname);
1490 exclude_file = stralloc("");
1491 nb_exclude_file = 0;
1492 if(dp->exclude_file != NULL && dp->exclude_file->nb_element > 0) {
1493 nb_exclude_file = dp->exclude_file->nb_element;
1494 if(am_has_feature(their_features, fe_options_exclude_file)) {
1495 if(am_has_feature(their_features, fe_options_multiple_exclude) ||
1496 dp->exclude_file->nb_element == 1) {
1497 for(excl = dp->exclude_file->first; excl != NULL;
1498 excl = excl->next) {
1499 q64name = amxml_format_tag("file", excl->name);
1500 exc = newvstralloc( exc, " ", q64name, "\n", NULL);
1501 strappend(exclude_file, exc);
1505 q64name = amxml_format_tag("file", dp->exclude_file->last->name);
1506 exc = newvstralloc(exc, " ", q64name, "\n", NULL);
1507 strappend(exclude_file, exc);
1510 _("WARNING: %s:%s does not support multiple exclude\n"),
1511 dp->host->hostname, qdpname);
1516 fprintf(fdout, _("WARNING: %s:%s does not support exclude file\n"),
1517 dp->host->hostname, qdpname);
1520 exclude_list = stralloc("");
1521 if(dp->exclude_list != NULL && dp->exclude_list->nb_element > 0) {
1522 if(am_has_feature(their_features, fe_options_exclude_list)) {
1523 if(am_has_feature(their_features, fe_options_multiple_exclude) ||
1524 (dp->exclude_list->nb_element == 1 && nb_exclude_file == 0)) {
1525 for(excl = dp->exclude_list->first; excl != NULL;
1526 excl = excl->next) {
1527 q64name = amxml_format_tag("list", excl->name);
1528 exc = newvstralloc(exc, " ", q64name, "\n", NULL);
1529 strappend(exclude_list, exc);
1533 q64name = amxml_format_tag("list", dp->exclude_list->last->name);
1534 exc = newvstralloc(exc, " ", q64name, "\n", NULL);
1535 strappend(exclude_list, exc);
1538 _("WARNING: %s:%s does not support multiple exclude\n"),
1539 dp->host->hostname, qdpname);
1544 fprintf(fdout, _("WARNING: %s:%s does not support exclude list\n"),
1545 dp->host->hostname, qdpname);
1549 include_file = stralloc("");
1550 nb_include_file = 0;
1551 if(dp->include_file != NULL && dp->include_file->nb_element > 0) {
1552 nb_include_file = dp->include_file->nb_element;
1553 if(am_has_feature(their_features, fe_options_include_file)) {
1554 if(am_has_feature(their_features, fe_options_multiple_include) ||
1555 dp->include_file->nb_element == 1) {
1556 for(excl = dp->include_file->first; excl != NULL;
1557 excl = excl->next) {
1558 q64name = amxml_format_tag("file", excl->name);
1559 exc = newvstralloc( exc, " ", q64name, "\n", NULL);
1560 strappend(include_file, exc);
1564 q64name = amxml_format_tag("file", dp->include_file->last->name);
1565 exc = newvstralloc(exc, " ", q64name, "\n", NULL);
1566 strappend(include_file, exc);
1569 _("WARNING: %s:%s does not support multiple include\n"),
1570 dp->host->hostname, qdpname);
1575 fprintf(fdout, _("WARNING: %s:%s does not support include file\n"),
1576 dp->host->hostname, qdpname);
1579 include_list = stralloc("");
1580 if(dp->include_list != NULL && dp->include_list->nb_element > 0) {
1581 if(am_has_feature(their_features, fe_options_include_list)) {
1582 if(am_has_feature(their_features, fe_options_multiple_include) ||
1583 (dp->include_list->nb_element == 1 && nb_include_file == 0)) {
1584 for(excl = dp->include_list->first; excl != NULL;
1585 excl = excl->next) {
1586 q64name = amxml_format_tag("list", excl->name);
1587 exc = newvstralloc( exc, " ", q64name, "\n", NULL);
1588 strappend(include_list, exc);
1592 q64name = amxml_format_tag("list", dp->include_list->last->name);
1593 exc = newvstralloc(exc, " ", q64name, "\n", NULL);
1594 strappend(include_list, exc);
1597 _("WARNING: %s:%s does not support multiple include\n"),
1598 dp->host->hostname, qdpname);
1603 fprintf(fdout, _("WARNING: %s:%s does not support include list\n"),
1604 dp->host->hostname, qdpname);
1608 if(dp->exclude_optional) {
1609 if(am_has_feature(their_features, fe_options_optional_exclude)) {
1610 excl_opt = " <optional>YES</optional>\n";
1614 _("WARNING: %s:%s does not support optional exclude\n"),
1615 dp->host->hostname, qdpname);
1618 if(dp->include_optional) {
1619 if(am_has_feature(their_features, fe_options_optional_include)) {
1620 incl_opt = " <optional>YES</optional>\n";
1624 _("WARNING: %s:%s does not support optional include\n"),
1625 dp->host->hostname, qdpname);
1629 if (dp->exclude_file || dp->exclude_list)
1630 exclude = newvstralloc(exclude,
1635 " </exclude>\n", NULL);
1636 if (dp->include_file || dp->include_list)
1637 include = newvstralloc(include,
1642 " </include>\n", NULL);
1643 script_opt = xml_scripts(dp->pp_scriptlist, their_features);
1644 result = vstralloc(auth_opt,
1658 amfree(exclude_list);
1659 amfree(exclude_file);
1661 amfree(include_file);
1662 amfree(include_list);
1664 amfree(decrypt_opt);
1665 amfree(encrypt_opt);
1667 /* result contains at least 'auth=...' */
1677 clean_dle_str_for_client(
1681 char *hack1, *hack2;
1686 rval_dle_str = stralloc(dle_str);
1688 /* Remove everything between " <encrypt>SERVER-CUSTOM" and "</encrypt>\n"
1690 #define SC "</encrypt>\n"
1691 #define SC_LEN strlen(SC)
1692 hack1 = strstr(rval_dle_str, " <encrypt>SERVER-CUSTOM");
1694 hack2 = strstr(hack1, SC);
1695 /* +1 is to also move the trailing '\0' */
1696 memmove(hack1, hack2 + SC_LEN, strlen(hack2 + SC_LEN) + 1);
1701 return rval_dle_str;
1705 am_feature_t *features;
1709 /* A GHFunc (callback for g_hash_table_foreach) */
1710 static void xml_property(
1713 gpointer user_data_p)
1715 char *property_s = key_p;
1717 property_t *property = value_p;
1718 char *b64value_data;
1719 xml_app_t *xml_app = user_data_p;
1722 b64property = amxml_format_tag("name", property_s);
1723 vstrextend(&xml_app->result, " <property>\n",
1724 " ", b64property, "\n", NULL);
1725 // TODO if client have fe_xml_property_priority
1726 if (property->priority &&
1727 am_has_feature(xml_app->features, fe_xml_property_priority)) {
1728 vstrextend(&xml_app->result, " <priority>yes</priority>\n", NULL);
1730 for(value = property->values; value != NULL; value = value->next) {
1731 b64value_data = amxml_format_tag("value", value->data);
1732 vstrextend(&xml_app->result, " ", b64value_data, "\n", NULL);
1733 amfree(b64value_data);
1735 vstrextend(&xml_app->result, " </property>\n", NULL);
1737 amfree(b64property);
1742 application_t *application,
1743 am_feature_t *their_features)
1748 proplist_t proplist;
1750 xml_app.features = their_features;
1751 xml_app.result = NULL;
1752 plugin = application_get_plugin(application);
1753 b64plugin = amxml_format_tag("plugin", plugin);
1754 xml_app.result = vstralloc(" <backup-program>\n",
1755 " ", b64plugin, "\n",
1757 proplist = application_get_property(application);
1758 g_hash_table_foreach(proplist, xml_property, &xml_app);
1759 vstrextend(&xml_app.result, " </backup-program>\n", NULL);
1763 return xml_app.result;
1769 pp_scriptlist_t pp_scriptlist,
1770 am_feature_t *their_features)
1779 execute_on_t execute_on;
1781 proplist_t proplist;
1782 pp_scriptlist_t pp_scriptlist1;
1783 pp_script_t *pp_script;
1786 xml_app.features = their_features;
1787 xml_app.result = stralloc("");
1789 xml_scr = stralloc("");
1790 for (pp_scriptlist1=pp_scriptlist; pp_scriptlist1 != NULL;
1791 pp_scriptlist1 = pp_scriptlist1->next) {
1792 pp_script = pp_scriptlist1->data;
1793 plugin = pp_script_get_plugin(pp_script);
1794 b64plugin = amxml_format_tag("plugin", plugin);
1795 xml_scr1 = vstralloc(" <script>\n",
1796 " ", b64plugin, "\n",
1799 execute_where = pp_script_get_execute_where(pp_script);
1800 switch (execute_where) {
1801 case ES_CLIENT: str = "CLIENT"; break;
1802 case ES_SERVER: str = "SERVER"; break;
1804 xml_scr1 = vstrextend(&xml_scr1, " <execute_where>",
1805 str, "</execute_where>\n", NULL);
1807 execute_on = pp_script_get_execute_on(pp_script);
1810 if (execute_on & EXECUTE_ON_PRE_DLE_AMCHECK) {
1811 eo_str = vstrextend(&eo_str, sep, "PRE-DLE-AMCHECK", NULL);
1814 if (execute_on & EXECUTE_ON_PRE_HOST_AMCHECK) {
1815 eo_str = vstrextend(&eo_str, sep, "PRE-HOST-AMCHECK", NULL);
1818 if (execute_on & EXECUTE_ON_POST_DLE_AMCHECK) {
1819 eo_str = vstrextend(&eo_str, sep, "POST-DLE-AMCHECK", NULL);
1822 if (execute_on & EXECUTE_ON_POST_HOST_AMCHECK) {
1823 eo_str = vstrextend(&eo_str, sep, "POST-HOST-AMCHECK", NULL);
1826 if (execute_on & EXECUTE_ON_PRE_DLE_ESTIMATE) {
1827 eo_str = vstrextend(&eo_str, sep, "PRE-DLE-ESTIMATE", NULL);
1830 if (execute_on & EXECUTE_ON_PRE_HOST_ESTIMATE) {
1831 eo_str = vstrextend(&eo_str, sep, "PRE-HOST-ESTIMATE", NULL);
1834 if (execute_on & EXECUTE_ON_POST_DLE_ESTIMATE) {
1835 eo_str = vstrextend(&eo_str, sep, "POST-DLE-ESTIMATE", NULL);
1838 if (execute_on & EXECUTE_ON_POST_HOST_ESTIMATE) {
1839 eo_str = vstrextend(&eo_str, sep, "POST-HOST-ESTIMATE", NULL);
1842 if (execute_on & EXECUTE_ON_PRE_DLE_BACKUP) {
1843 eo_str = vstrextend(&eo_str, sep, "PRE-DLE-BACKUP", NULL);
1846 if (execute_on & EXECUTE_ON_PRE_HOST_BACKUP) {
1847 eo_str = vstrextend(&eo_str, sep, "PRE-HOST-BACKUP", NULL);
1850 if (execute_on & EXECUTE_ON_POST_DLE_BACKUP) {
1851 eo_str = vstrextend(&eo_str, sep, "POST-DLE-BACKUP", NULL);
1854 if (execute_on & EXECUTE_ON_POST_HOST_BACKUP) {
1855 eo_str = vstrextend(&eo_str, sep, "POST-HOST-BACKUP", NULL);
1858 if (execute_on & EXECUTE_ON_PRE_RECOVER) {
1859 eo_str = vstrextend(&eo_str, sep, "PRE-RECOVER", NULL);
1862 if (execute_on & EXECUTE_ON_POST_RECOVER) {
1863 eo_str = vstrextend(&eo_str, sep, "POST-RECOVER", NULL);
1866 if (execute_on & EXECUTE_ON_PRE_LEVEL_RECOVER) {
1867 eo_str = vstrextend(&eo_str, sep, "PRE-LEVEL-RECOVER", NULL);
1870 if (execute_on & EXECUTE_ON_POST_LEVEL_RECOVER) {
1871 eo_str = vstrextend(&eo_str, sep, "POST-LEVEL-RECOVER", NULL);
1874 if (execute_on & EXECUTE_ON_INTER_LEVEL_RECOVER) {
1875 eo_str = vstrextend(&eo_str, sep, "INTER-LEVEL-RECOVER", NULL);
1878 if (execute_on != 0)
1879 xml_scr1 = vstrextend(&xml_scr1,
1880 " <execute_on>", eo_str,
1881 "</execute_on>\n", NULL);
1883 proplist = pp_script_get_property(pp_script);
1884 g_hash_table_foreach(proplist, xml_property, &xml_app);
1885 xml_scr = vstrextend(&xml_scr, xml_scr1, xml_app.result, " </script>\n", NULL);
1887 amfree(xml_app.result);
1899 char *prevhost = NULL;
1900 char *errstr = NULL;
1910 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1916 for(i=0;i<sargc;i++) {
1918 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1919 if(match_host(sargv[i], dp->host->hostname))
1923 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1924 if(prevhost != NULL &&
1925 match_host(prevhost, dp->host->hostname) &&
1926 (match_disk(sargv[i], dp->name) ||
1927 (dp->device && match_disk(sargv[i], dp->device)))) {
1929 error(_("Argument %s cannot be both a host and a disk"),sargv[i]);
1933 if(dp->todo == -1) {
1942 if(match_a_host == 1) {
1943 if(prev_match == 1) { /* all disk of the previous host */
1944 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1945 if(match_host(prevhost,dp->host->hostname))
1950 prevhost = sargv[i];
1954 char *errstr1 = vstrallocf(_("Argument '%s' matches neither a host nor a disk.\n"), sargv[i]);
1955 vstrextend(&errstr, errstr1, NULL);
1961 if(prev_match == 1) { /* all disk of the previous host */
1962 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1963 if(match_host(prevhost,dp->host->hostname))
1969 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1978 disklist_netifs(void)
1985 static void dump_disk(const disk_t *);
1986 static void dump_disklist(const disklist_t *);
1987 int main(int, char *[]);
1993 g_printf(_(" DISK %s (HOST %s, LINE %d) TYPE %s NAME %s SPINDLE %d\n"),
1994 dp->name, dp->host->hostname, dp->line, dp->dtype_name,
1995 dp->name == NULL? "(null)": dp->name,
2001 const disklist_t * lst)
2003 const disk_t *dp, *prev;
2004 const am_host_t *hp;
2006 if(hostlist == NULL) {
2007 g_printf(_("DISKLIST not read in\n"));
2011 g_printf(_("DISKLIST BY HOSTNAME:\n"));
2013 for(hp = hostlist; hp != NULL; hp = hp->next) {
2014 char *if_name = NULL;
2015 if (hp->netif && hp->netif->config)
2016 if_name = interface_name(hp->netif->config);
2018 g_printf(_("HOST %s INTERFACE %s\n"),
2020 if_name ? _("(null)") : if_name);
2021 for(dp = hp->disks; dp != NULL; dp = dp->hostnext)
2027 g_printf(_("DISKLIST IN FILE ORDER:\n"));
2030 for(dp = lst->head; dp != NULL; prev = dp, dp = dp->next) {
2032 /* check pointers */
2033 if(dp->prev != prev) g_printf(_("*** prev pointer mismatch!\n"));
2034 if(dp->next == NULL && lst->tail != dp) g_printf(_("tail mismatch!\n"));
2044 char *conf_diskfile;
2049 * Configure program for internationalization:
2050 * 1) Only set the message locale for now.
2051 * 2) Set textdomain for all amanda related programs to "amanda"
2052 * We don't want to be forced to support dozens of message catalogs.
2054 setlocale(LC_MESSAGES, "C");
2055 textdomain("amanda");
2059 set_pname("diskfile");
2061 dbopen(DBG_SUBDIR_SERVER);
2063 /* Don't die when child closes pipe */
2064 signal(SIGPIPE, SIG_IGN);
2067 config_init(CONFIG_INIT_EXPLICIT_NAME, argv[1]);
2069 config_init(CONFIG_INIT_USE_CWD, NULL)
2072 if (config_errors(NULL) >= CFGERR_WARNINGS) {
2073 config_print_errors();
2074 if (config_errors(NULL) >= CFGERR_ERRORS) {
2075 g_critical(_("errors processing config file"));
2079 conf_diskfile = config_dir_relative(getconf_str(CNF_DISKFILE));
2080 result = read_diskfile(conf_diskfile, &lst);
2081 if(result == CFGERR_OK) {
2082 dump_disklist(&lst);
2084 config_print_errors();
2086 amfree(conf_diskfile);