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 $
40 static am_host_t *hostlist;
41 static netif_t *all_netifs;
44 static char *upcase(char *st);
45 static int parse_diskline(disklist_t *, const char *, FILE *, int *, char **);
46 static void disk_parserror(const char *, int, const char *, ...)
61 lst->head = lst->tail = NULL;
64 /* if we already have config errors, then don't bother */
65 if (config_errors(NULL) >= CFGERR_ERRORS) {
66 return config_errors(NULL);
69 if ((diskf = fopen(filename, "r")) == NULL) {
70 config_add_error(CFGERR_ERRORS,
71 vstrallocf(_("Could not open '%s': %s"), filename, strerror(errno)));
76 while ((line = agets(diskf)) != NULL) {
78 if (line[0] != '\0') {
79 if (parse_diskline(lst, filename, diskf, &line_num, &line) < 0) {
89 return config_errors(NULL);
100 const char *hostname)
104 for (p = hostlist; p != NULL; p = p->next) {
105 if(strcasecmp(p->hostname, hostname) == 0) return p;
112 const char *hostname,
113 const char *diskname)
118 host = lookup_host(hostname);
122 for (disk = host->disks; disk != NULL; disk = disk->hostnext) {
123 if (strcmp(disk->name, diskname) == 0)
131 * put disk on end of queue
139 if(list->tail == NULL) list->head = disk;
140 else list->tail->next = disk;
141 disk->prev = list->tail;
149 * put disk on head of queue
157 if(list->head == NULL) list->tail = disk;
158 else list->head->prev = disk;
159 disk->next = list->head;
167 * insert in sorted order
174 int (*cmp)(disk_t *a, disk_t *b))
182 if(cmp(disk, ptr) < 0) break;
189 if(prev == NULL) list->head = disk;
190 else prev->next = disk;
191 if(ptr == NULL) list->tail = disk;
192 else ptr->prev = disk;
204 disk = alloc(SIZEOF(disk_t));
205 bzero(disk, SIZEOF(disk_t));
207 disk->allow_split = 0;
208 disk->splitsize = (off_t)0;
209 disk->tape_splitsize = (off_t)0;
210 disk->split_diskbuffer = NULL;
211 disk->fallback_splitsize = (off_t)0;
212 disk->hostname = stralloc(hostname);
213 disk->name = stralloc(diskname);
214 disk->device = stralloc(diskname);
217 disk->compress = COMP_NONE;
218 disk->encrypt = ENCRYPT_NONE;
222 disk->exclude_list = NULL;
223 disk->exclude_file = NULL;
224 disk->include_list = NULL;
225 disk->include_file = NULL;
226 disk->application = NULL;
227 disk->pp_scriptlist = NULL;
229 host = lookup_host(hostname);
231 host = alloc(SIZEOF(am_host_t));
232 host->next = hostlist;
235 host->hostname = stralloc(hostname);
237 host->inprogress = 0;
242 host->features = NULL;
243 host->pre_script = 0;
244 host->post_script = 0;
246 enqueue_disk(list, disk);
249 disk->hostnext = host->disks;
257 * check if disk is present in list. Return true if so, false otherwise.
268 while ((t != NULL) && (t != disk)) {
283 int (*cmp)(disk_t *a, disk_t *b))
288 tmp = in; /* just in case in == out */
290 out->head = (disk_t *)0;
291 out->tail = (disk_t *)0;
293 while((disk = dequeue_disk(tmp)))
294 insert_disk(out, disk, cmp);
299 * remove disk from front of queue
308 if(list->head == NULL) return NULL;
311 list->head = disk->next;
313 if(list->head == NULL) list->tail = NULL;
314 else list->head->prev = NULL;
316 disk->prev = disk->next = NULL; /* for debugging */
325 if(disk->prev == NULL) list->head = disk->next;
326 else disk->prev->next = disk->next;
328 if(disk->next == NULL) list->tail = disk->prev;
329 else disk->next->prev = disk->prev;
331 disk->prev = disk->next = NULL;
339 am_host_t *host, *hostnext;
340 netif_t *netif, *next_if;
342 while (dl->head != NULL) {
343 dp = dequeue_disk(dl);
344 amfree(dp->filename);
346 amfree(dp->hostname);
348 free_sl(dp->exclude_file);
349 free_sl(dp->exclude_list);
350 free_sl(dp->include_file);
351 free_sl(dp->include_list);
355 for(host=hostlist; host != NULL; host = hostnext) {
356 amfree(host->hostname);
357 am_release_feature_set(host->features);
358 host->features = NULL;
359 hostnext = host->next;
364 for (netif = all_netifs; netif != NULL; netif = next_if) {
365 next_if = netif->next;
378 if(islower((int)*s)) *s = (char)toupper((int)*s);
385 /* return 0 on success */
386 /* return -1 on error */
390 const char *filename,
393 /*@keep@*/ char ** line_p)
398 netif_t *netif = NULL;
399 interface_t *cfg_if = NULL;
400 char *hostname = NULL;
401 char *diskname, *diskdevice;
405 char *line = *line_p;
406 int line_num = *line_num_p;
414 assert(filename != NULL);
415 assert(line_num > 0);
416 assert(line != NULL);
420 skip_whitespace(s, ch);
421 if(ch == '\0' || ch == '#')
425 skip_non_whitespace(s, ch);
427 if (g_str_equal(fp, "includefile")) {
429 char *include_filename;
430 skip_whitespace(s, ch);
431 if (ch == '\0' || ch == '#') {
432 disk_parserror(filename, line_num, _("include filename name expected"));
436 skip_quoted_string(s, ch);
438 include_name = unquote_string(fp);
439 include_filename = config_dir_relative(include_name);
440 read_diskfile(include_filename, lst);
441 g_free(include_filename);
442 g_free(include_name);
443 if (config_errors(NULL) >= CFGERR_WARNINGS) {
449 host = lookup_host(fp);
451 hostname = stralloc(fp);
453 hostname = stralloc(host->hostname);
454 if (strcmp(host->hostname, fp) != 0) {
455 disk_parserror(filename, line_num, _("Same host with different case: \"%s\" and \"%s\"."), host->hostname, fp);
460 shost = sanitise_filename(hostname);
461 for (p = hostlist; p != NULL; p = p->next) {
462 char *shostp = sanitise_filename(p->hostname);
463 if (strcmp(hostname, p->hostname) &&
464 !strcmp(shost, shostp)) {
465 disk_parserror(filename, line_num, _("Two hosts are mapping to the same name: \"%s\" and \"%s\""), p->hostname, hostname);
468 else if (strcasecmp(hostname, p->hostname) &&
469 match_host(hostname, p->hostname) &&
470 match_host(p->hostname, hostname)) {
471 disk_parserror(filename, line_num, _("Duplicate host name: \"%s\" and \"%s\""), p->hostname, hostname);
478 skip_whitespace(s, ch);
479 if(ch == '\0' || ch == '#') {
480 disk_parserror(filename, line_num, _("disk device name expected"));
486 skip_quoted_string(s, ch);
488 diskname = unquote_string(fp);
489 if (strlen(diskname) == 0) {
490 disk_parserror(filename, line_num, _("invalid empty diskname"));
494 skip_whitespace(s, ch);
495 if(ch == '\0' || ch == '#') {
496 disk_parserror(filename, line_num, _("disk dumptype expected"));
502 skip_quoted_string(s, ch);
509 dumptype = unquote_string(fp);
510 if (strlen(dumptype) == 0) {
511 disk_parserror(filename, line_num, _("invalid empty diskdevice"));
515 if ((dtype = lookup_dumptype(dumptype)) == NULL) {
516 diskdevice = dumptype;
517 skip_whitespace(s, ch);
518 if(ch == '\0' || ch == '#') {
519 disk_parserror(filename, line_num,
520 _("disk dumptype '%s' not found"), dumptype);
528 skip_quoted_string(s, ch);
531 dumptype = unquote_string(fp);
536 /* check for duplicate disk */
539 if ((disk = lookup_disk(hostname, diskname)) != NULL) {
545 a1 = clean_regex(diskname, 1);
546 a2 = clean_regex(disk->name, 1);
548 if (match_disk(a1, disk->name) && match_disk(a2, diskname)) {
551 disk = disk->hostnext;
556 while (dup == 0 && disk != NULL);
559 disk_parserror(filename, line_num,
560 _("duplicate disk record, previous on line %d"),
565 disk = alloc(SIZEOF(disk_t));
566 disk->filename = g_strdup(filename);
567 disk->line = line_num;
568 disk->hostname = hostname;
569 disk->name = diskname;
570 disk->device = diskdevice;
573 disk->inprogress = 0;
574 disk->application = NULL;
575 disk->pp_scriptlist = NULL;
576 disk->dataport_list = NULL;
580 sdisk = sanitise_filename(diskname);
581 for (dp = host->disks; dp != NULL; dp = dp->hostnext) {
582 char *sdiskp = sanitise_filename(dp->name);
583 if (strcmp(diskname, dp->name) != 0 &&
584 strcmp(sdisk, sdiskp) == 0) {
585 disk_parserror(filename, line_num,
586 _("Two disks are mapping to the same name: \"%s\" and \"%s\"; you must use different diskname"),
598 skip_whitespace(s, ch);
599 if (ch != '\0' && ch != '#') {
600 disk_parserror(filename, line_num,
601 _("expected line break after `{\', ignoring rest of line"));
604 if (strchr(s-1, '}') &&
605 (strchr(s-1, '#') == NULL ||
606 strchr(s-1, '}') < strchr(s-1, '#'))) {
607 disk_parserror(filename, line_num,_("'}' on same line than '{'"));
610 amfree(disk->device);
619 dtype = read_dumptype(vstralloc("custom(", hostname,
620 ":", disk->name, ")",
621 ".", anonymous_value(), NULL),
622 diskf, (char*)filename, line_num_p);
623 if (dtype == NULL || dup) {
624 disk_parserror(filename, line_num,
625 _("read of custom dumptype failed"));
628 amfree(disk->device);
639 *line_p = line = agets(diskf);
640 line_num = *line_num_p; /* no incr, read_dumptype did it already */
643 *line_p = line = stralloc("");
647 if((dtype = lookup_dumptype(dumptype)) == NULL) {
648 char *qdt = quote_string(dumptype);
650 disk_parserror(filename, line_num, _("undefined dumptype `%s'"), qdt);
654 amfree(disk->device);
667 /* disk_parserror already called, above */
668 g_assert(config_errors(NULL) != CFGERR_OK);
675 disk->dtype_name = dumptype_name(dtype);
676 disk->config = dtype;
677 disk->program = dumptype_get_program(dtype);
678 disk->exclude_list = duplicate_sl(dumptype_get_exclude(dtype).sl_list);
679 disk->exclude_file = duplicate_sl(dumptype_get_exclude(dtype).sl_file);
680 disk->exclude_optional = dumptype_get_exclude(dtype).optional;
681 disk->include_list = duplicate_sl(dumptype_get_include(dtype).sl_list);
682 disk->include_file = duplicate_sl(dumptype_get_include(dtype).sl_file);
683 disk->include_optional = dumptype_get_include(dtype).optional;
684 disk->priority = dumptype_get_priority(dtype);
685 disk->dumpcycle = dumptype_get_dumpcycle(dtype);
686 /* disk->frequency = dumptype_get_frequency(dtype);*/
687 disk->auth = dumptype_get_auth(dtype);
688 disk->maxdumps = dumptype_get_maxdumps(dtype);
689 disk->allow_split = dumptype_get_allow_split(dtype);
690 disk->tape_splitsize = dumptype_get_tape_splitsize(dtype);
691 disk->split_diskbuffer = dumptype_get_split_diskbuffer(dtype);
692 disk->fallback_splitsize = dumptype_get_fallback_splitsize(dtype);
693 if (disk->allow_split) {
694 tapetype_t *tapetype = lookup_tapetype(getconf_str(CNF_TAPETYPE));
695 disk->splitsize = tapetype_get_part_size(tapetype);
697 disk->splitsize = disk->tape_splitsize;
699 disk->maxpromoteday = dumptype_get_maxpromoteday(dtype);
700 disk->bumppercent = dumptype_get_bumppercent(dtype);
701 disk->bumpsize = dumptype_get_bumpsize(dtype);
702 disk->bumpdays = dumptype_get_bumpdays(dtype);
703 disk->bumpmult = dumptype_get_bumpmult(dtype);
704 disk->starttime = dumptype_get_starttime(dtype);
705 disk->application = dumptype_get_application(dtype);
706 disk->pp_scriptlist = dumptype_get_scriptlist(dtype);
708 if (disk->starttime > 0) {
711 stm = localtime(&st);
712 disk->start_t -= stm->tm_sec + 60 * stm->tm_min + 3600 * stm->tm_hour;
713 disk->start_t += disk->starttime / 100 * 3600 +
714 disk->starttime % 100 * 60;
715 if ((disk->start_t - st) < -43200)
716 disk->start_t += 86400;
718 disk->strategy = dumptype_get_strategy(dtype);
719 disk->ignore = dumptype_get_ignore(dtype);
720 disk->estimatelist = dumptype_get_estimatelist(dtype);
721 disk->compress = dumptype_get_compress(dtype);
722 disk->srvcompprog = dumptype_get_srvcompprog(dtype);
723 disk->clntcompprog = dumptype_get_clntcompprog(dtype);
724 disk->encrypt = dumptype_get_encrypt(dtype);
725 disk->srv_decrypt_opt = dumptype_get_srv_decrypt_opt(dtype);
726 disk->clnt_decrypt_opt = dumptype_get_clnt_decrypt_opt(dtype);
727 disk->srv_encrypt = dumptype_get_srv_encrypt(dtype);
728 disk->clnt_encrypt = dumptype_get_clnt_encrypt(dtype);
729 disk->amandad_path = dumptype_get_amandad_path(dtype);
730 disk->client_username = dumptype_get_client_username(dtype);
731 disk->client_port = dumptype_get_client_port(dtype);
732 disk->ssh_keys = dumptype_get_ssh_keys(dtype);
733 disk->comprate[0] = dumptype_get_comprate(dtype)[0];
734 disk->comprate[1] = dumptype_get_comprate(dtype)[1];
735 disk->data_path = dumptype_get_data_path(dtype);
736 disk->dump_limit = dumptype_get_dump_limit(dtype);
739 * Boolean parameters with no value (Appears here as value 2) defaults
740 * to TRUE for backward compatibility and for logical consistency.
742 disk->record = dumptype_get_record(dtype) != 0;
743 disk->skip_incr = dumptype_get_skip_incr(dtype) != 0;
744 disk->skip_full = dumptype_get_skip_full(dtype) != 0;
745 disk->to_holdingdisk = dumptype_get_to_holdingdisk(dtype);
746 disk->kencrypt = dumptype_get_kencrypt(dtype) != 0;
747 disk->index = dumptype_get_index(dtype) != 0;
751 skip_whitespace(s, ch);
753 if(ch && ch != '#') { /* get optional spindle number */
757 skip_non_whitespace(s, ch);
760 if (*fp1 == '-') fp1++;
761 for(;*fp1!='\0';fp1++) {
762 if(!isdigit((int)*fp1)) {
767 disk_parserror(filename, line_num, _("non-integer spindle `%s'"), fp);
773 disk->spindle = atoi(fp);
777 skip_whitespace(s, ch);
779 if(ch && ch != '#') { /* get optional network interface */
780 skip_non_whitespace(s, ch);
782 if((cfg_if = lookup_interface(upcase(fp))) == NULL) {
783 disk_parserror(filename, line_num,
784 _("undefined network interface `%s'"), fp);
791 cfg_if = lookup_interface("default");
794 /* see if we already have a netif_t for this interface */
795 for (netif = all_netifs; netif != NULL; netif = netif->next) {
796 if (netif->config == cfg_if)
800 /* nope; make up a new one */
802 netif = alloc(sizeof(*netif));
803 netif->next = all_netifs;
805 netif->config = cfg_if;
809 skip_whitespace(s, ch);
810 if(ch && ch != '#') { /* now we have garbage, ignore it */
811 disk_parserror(filename, line_num, _("end of line expected"));
814 if (disk->program && disk->application &&
815 strcmp(disk->program,"APPLICATION")) {
816 disk_parserror(filename, line_num,
817 _("Both program and application set"));
820 if (disk->program && strcmp(disk->program,"APPLICATION")==0 &&
821 !disk->application) {
822 disk_parserror(filename, line_num,
823 _("program set to APPLICATION but no application set"));
826 if (disk->application) {
827 application_t *application;
830 application = lookup_application(disk->application);
831 g_assert(application != NULL);
832 plugin = application_get_plugin(application);
833 if (!plugin || strlen(plugin) == 0) {
834 disk_parserror(filename, line_num,
835 _("plugin not set for application"));
839 for (pp_iter = disk->pp_scriptlist; pp_iter != NULL;
840 pp_iter = pp_iter->next) {
841 pp_script_t *pp_script;
843 char *pp_script_name;
845 pp_script_name = (char*)pp_iter->data;
846 pp_script = lookup_pp_script(pp_script_name);
847 g_assert(pp_script != NULL);
848 plugin = pp_script_get_plugin(pp_script);
849 if (!plugin || strlen(plugin) == 0) {
850 disk_parserror(filename, line_num, _("plugin not set for script"));
854 /* success, add disk to lists */
856 if(host == NULL) { /* new host */
857 host = alloc(SIZEOF(am_host_t));
858 host->next = hostlist;
861 host->hostname = stralloc(hostname);
864 host->inprogress = 0;
865 host->maxdumps = 1; /* will be overwritten */
869 host->features = NULL;
870 host->pre_script = 0;
871 host->post_script = 0;
876 enqueue_disk(lst, disk);
879 disk->hostnext = host->disks;
881 host->maxdumps = disk->maxdumps;
887 printf_arglist_function2(void disk_parserror, const char *, filename,
888 int, line_num, const char *, format)
894 /* format the error message and hand it off to conffile */
896 arglist_start(argp, format);
897 msg = g_strdup_vprintf(format, argp);
898 errstr = g_strdup_printf("\"%s\", line %d: %s", filename, line_num, msg);
902 config_add_error(CFGERR_ERRORS, errstr);
910 int npr, /* we print first npr disks on queue, plus last two */
918 g_fprintf(f, _("%s QUEUE: empty\n"), st);
921 g_fprintf(f, _("%s QUEUE:\n"), st);
922 for(pos = 0, d = q.head, p = NULL; d != NULL; p = d, d = d->next, pos++) {
923 qname = quote_string(d->name);
924 if(pos < npr) g_fprintf(f, "%3d: %-10s %-4s\n",
925 pos, d->host->hostname, qname);
929 if(pos > npr+2) g_fprintf(f, " ...\n");
932 g_fprintf(f, "%3d: %-10s %-4s\n", pos-2, d->host->hostname, d->name);
935 g_fprintf(f, "%3d: %-10s %-4s\n", pos-1, d->host->hostname, d->name);
946 am_feature_t *their_features = dp->host->features;
949 assert(dp->host != NULL);
951 errarray = g_ptr_array_new();
953 if (!am_has_feature(their_features, fe_options_auth)) {
954 if (strcasecmp(dp->auth, "bsd") == 0)
955 if (!am_has_feature(their_features, fe_options_bsd_auth))
956 g_ptr_array_add(errarray, _("does not support auth"));
959 switch(dp->compress) {
961 if (!am_has_feature(their_features, fe_options_compress_fast)) {
962 g_ptr_array_add(errarray, _("does not support fast compression"));
966 if (!am_has_feature(their_features, fe_options_compress_best)) {
967 g_ptr_array_add(errarray, _("does not support best compression"));
971 if (am_has_feature(their_features, fe_options_compress_cust)) {
972 if (dp->clntcompprog == NULL || strlen(dp->clntcompprog) == 0) {
973 g_ptr_array_add(errarray, _("client custom compression with no compression program specified"));
976 g_ptr_array_add(errarray, _("does not support client custom compression"));
979 case COMP_SERVER_FAST:
981 case COMP_SERVER_BEST:
983 case COMP_SERVER_CUST:
984 if (dp->srvcompprog == NULL || strlen(dp->srvcompprog) == 0) {
985 g_ptr_array_add(errarray, _("server custom compression with no compression program specified"));
990 switch(dp->encrypt) {
992 if (am_has_feature(their_features, fe_options_encrypt_cust)) {
993 if (dp->clnt_decrypt_opt) {
994 if (!am_has_feature(their_features, fe_options_client_decrypt_option)) {
995 g_ptr_array_add(errarray, _("does not support client decrypt option"));
998 if (dp->clnt_encrypt == NULL || strlen(dp->clnt_encrypt) == 0) {
999 g_ptr_array_add(errarray, _("encrypt client with no encryption program specified"));
1001 if (dp->compress == COMP_SERVER_FAST ||
1002 dp->compress == COMP_SERVER_BEST ||
1003 dp->compress == COMP_SERVER_CUST ) {
1004 g_ptr_array_add(errarray, _("Client encryption with server compression is not supported. See amanda.conf(5) for detail"));
1007 g_ptr_array_add(errarray, _("does not support client data encryption"));
1010 case ENCRYPT_SERV_CUST:
1011 if (dp->srv_encrypt == NULL || strlen(dp->srv_encrypt) == 0) {
1012 g_ptr_array_add(errarray, _("No encryption program specified in dumptypes, Change the dumptype in the disklist or mention the encryption program to use in the dumptypes file"));
1018 if (!am_has_feature(their_features, fe_options_no_record)) {
1019 g_ptr_array_add(errarray, _("does not support no record"));
1024 if (!am_has_feature(their_features, fe_options_index)) {
1025 g_ptr_array_add(errarray, _("does not support index"));
1030 if (!am_has_feature(their_features, fe_options_kencrypt)) {
1031 g_ptr_array_add(errarray, _("does not support kencrypt"));
1036 if (dp->exclude_file != NULL && dp->exclude_file->nb_element > 0) {
1037 nb_exclude = dp->exclude_file->nb_element;
1038 if (!am_has_feature(their_features, fe_options_exclude_file)) {
1039 g_ptr_array_add(errarray, _("does not support exclude file"));
1043 if (dp->exclude_list != NULL && dp->exclude_list->nb_element > 0) {
1044 nb_exclude += dp->exclude_list->nb_element;
1045 if (!am_has_feature(their_features, fe_options_exclude_list)) {
1046 g_ptr_array_add(errarray, _("does not support exclude list"));
1050 if (nb_exclude > 1 &&
1051 !am_has_feature(their_features, fe_options_multiple_exclude)) {
1052 g_ptr_array_add(errarray, _("does not support multiple exclude"));
1056 if (dp->include_file != NULL && dp->include_file->nb_element > 0) {
1057 nb_include = dp->include_file->nb_element;
1058 if (!am_has_feature(their_features, fe_options_include_file)) {
1059 g_ptr_array_add(errarray, ("does not support include file"));
1063 if (dp->include_list != NULL && dp->include_list->nb_element > 0) {
1064 nb_include += dp->include_list->nb_element;
1065 if (!am_has_feature(their_features, fe_options_include_list)) {
1066 g_ptr_array_add(errarray, _("does not support include list"));
1070 if (nb_include > 1 &&
1071 !am_has_feature(their_features, fe_options_multiple_exclude)) {
1072 g_ptr_array_add(errarray, _("does not support multiple include"));
1075 if (dp->exclude_optional) {
1076 if (!am_has_feature(their_features, fe_options_optional_exclude)) {
1077 g_ptr_array_add(errarray, _("does not support optional exclude"));
1080 if (dp->include_optional) {
1081 if (!am_has_feature(their_features, fe_options_optional_include)) {
1082 g_ptr_array_add(errarray, _("does not support optional include"));
1093 char *auth_opt = NULL;
1094 char *kencrypt_opt = "";
1095 char *compress_opt = "";
1096 char *encrypt_opt = stralloc("");
1097 char *decrypt_opt = stralloc("");
1098 char *record_opt = "";
1099 char *index_opt = "";
1100 char *exclude_file = NULL;
1101 char *exclude_list = NULL;
1102 char *include_file = NULL;
1103 char *include_list = NULL;
1104 char *excl_opt = "";
1105 char *incl_opt = "";
1107 char *result = NULL;
1111 am_feature_t *their_features = dp->host->features;
1114 assert(dp->host != NULL);
1116 qdpname = quote_string(dp->name);
1117 if (am_has_feature(their_features, fe_options_auth)) {
1118 auth_opt = vstralloc("auth=", dp->auth, ";", NULL);
1119 } else if(strcasecmp(dp->auth, "bsd") == 0) {
1120 if(am_has_feature(their_features, fe_options_bsd_auth))
1121 auth_opt = stralloc("bsd-auth;");
1124 switch(dp->compress) {
1126 compress_opt = "compress-fast;";
1129 compress_opt = "compress-best;";
1132 compress_opt = vstralloc("comp-cust=", dp->clntcompprog, ";", NULL);
1134 case COMP_SERVER_FAST:
1135 compress_opt = "srvcomp-fast;";
1137 case COMP_SERVER_BEST:
1138 compress_opt = "srvcomp-best;";
1140 case COMP_SERVER_CUST:
1141 compress_opt = vstralloc("srvcomp-cust=", dp->srvcompprog, ";", NULL);
1145 switch(dp->encrypt) {
1147 encrypt_opt = newvstralloc(encrypt_opt, "encrypt-cust=",
1148 dp->clnt_encrypt, ";", NULL);
1149 if (dp->clnt_decrypt_opt) {
1150 decrypt_opt = newvstralloc(decrypt_opt, "client-decrypt-option=",
1151 dp->clnt_decrypt_opt, ";", NULL);
1154 case ENCRYPT_SERV_CUST:
1155 encrypt_opt = newvstralloc(encrypt_opt, "encrypt-serv-cust=",
1156 dp->srv_encrypt, ";", NULL);
1157 if (dp->srv_decrypt_opt) {
1158 decrypt_opt = newvstralloc(decrypt_opt, "server-decrypt-option=",
1159 dp->srv_decrypt_opt, ";", NULL);
1165 record_opt = "no-record;";
1169 index_opt = "index;";
1173 kencrypt_opt = "kencrypt;";
1176 exclude_file = stralloc("");
1177 if (dp->exclude_file != NULL && dp->exclude_file->nb_element > 0) {
1178 for(excl = dp->exclude_file->first; excl != NULL;
1179 excl = excl->next) {
1180 qname = quote_string(excl->name);
1181 exc = newvstralloc( exc, "exclude-file=", qname, ";", NULL);
1182 strappend(exclude_file, exc);
1186 exclude_list = stralloc("");
1187 if (dp->exclude_list != NULL && dp->exclude_list->nb_element > 0) {
1188 for(excl = dp->exclude_list->first; excl != NULL;
1189 excl = excl->next) {
1190 qname = quote_string(excl->name);
1191 exc = newvstralloc( exc, "exclude-list=", qname, ";", NULL);
1192 strappend(exclude_list, exc);
1197 include_file = stralloc("");
1198 if (dp->include_file != NULL && dp->include_file->nb_element > 0) {
1199 for(excl = dp->include_file->first; excl != NULL;
1200 excl = excl->next) {
1201 qname = quote_string(excl->name);
1202 exc = newvstralloc(exc, "include-file=", qname, ";", NULL);
1203 strappend(include_file, exc);
1207 include_list = stralloc("");
1208 if (dp->include_list != NULL && dp->include_list->nb_element > 0) {
1209 for(excl = dp->include_list->first; excl != NULL;
1210 excl = excl->next) {
1211 qname = quote_string(excl->name);
1212 exc = newvstralloc(exc, "include-list=", qname, ";", NULL);
1213 strappend(include_list, exc);
1218 if (dp->exclude_optional) {
1219 excl_opt = "exclude-optional;";
1221 if (dp->include_optional) {
1222 incl_opt = "include-optional;";
1225 result = vstralloc(";",
1242 amfree(exclude_list);
1243 amfree(exclude_file);
1244 amfree(include_file);
1245 amfree(include_list);
1247 amfree(decrypt_opt);
1248 amfree(encrypt_opt);
1250 /* result contains at least 'auth=...' */
1255 am_feature_t *features;
1259 /* A GHFunc (callback for g_hash_table_foreach) */
1260 static void xml_property(
1263 gpointer user_data_p)
1266 property_t *property = value_p;
1267 xml_app_t *xml_app = user_data_p;
1271 strbuf = g_string_new(xml_app->result);
1273 tmp = amxml_format_tag("name", (char *)key_p);
1274 g_string_append_printf(strbuf, " <property>\n %s\n", tmp);
1277 // TODO if client have fe_xml_property_priority
1278 if (property->priority
1279 && am_has_feature(xml_app->features, fe_xml_property_priority))
1280 g_string_append(strbuf, " <priority>yes</priority>\n");
1282 for (value = property->values; value != NULL; value = value->next) {
1283 tmp = amxml_format_tag("value", value->data);
1284 g_string_append_printf(strbuf, " %s", tmp);
1287 g_string_append_printf(strbuf, "\n </property>\n");
1289 g_free(xml_app->result);
1290 xml_app->result = g_string_free(strbuf, FALSE);
1301 char *encrypt_opt = stralloc("");
1302 char *decrypt_opt = stralloc("");
1305 char *data_path_opt = stralloc("");
1306 char *exclude = stralloc("");
1307 char *exclude_file = NULL;
1308 char *exclude_list = NULL;
1309 char *include = stralloc("");
1310 char *include_file = NULL;
1311 char *include_list = NULL;
1312 char *excl_opt = "";
1313 char *incl_opt = "";
1316 char *result = NULL;
1320 am_feature_t *their_features = dp->host->features;
1323 assert(dp->host != NULL);
1325 qdpname = quote_string(dp->name);
1326 if (am_has_feature(their_features, fe_options_auth)) {
1327 auth_opt = vstralloc(" <auth>", dp->auth, "</auth>\n", NULL);
1329 auth_opt = stralloc("");
1332 switch(dp->compress) {
1334 compress_opt = stralloc(" <compress>FAST</compress>\n");
1337 compress_opt = stralloc(" <compress>BEST</compress>\n");
1340 compress_opt = vstralloc(" <compress>CUSTOM"
1341 "<custom-compress-program>",
1343 "</custom-compress-program>\n"
1344 " </compress>\n", NULL);
1346 case COMP_SERVER_FAST:
1347 compress_opt = stralloc(" <compress>SERVER-FAST</compress>\n");
1349 case COMP_SERVER_BEST:
1350 compress_opt = stralloc(" <compress>SERVER-BEST</compress>\n");
1352 case COMP_SERVER_CUST:
1353 compress_opt = vstralloc(" <compress>SERVER-CUSTOM"
1354 "<custom-compress-program>",
1356 "</custom-compress-program>\n"
1357 " </compress>\n", NULL);
1360 compress_opt = stralloc("");
1363 switch(dp->encrypt) {
1365 if (dp->clnt_decrypt_opt) {
1366 decrypt_opt = newvstralloc(decrypt_opt,
1367 " <decrypt-option>",
1368 dp->clnt_decrypt_opt,
1369 "</decrypt-option>\n", NULL);
1372 encrypt_opt = newvstralloc(encrypt_opt,
1374 "<custom-encrypt-program>",
1376 "</custom-encrypt-program>\n",
1378 " </encrypt>\n", NULL);
1381 case ENCRYPT_SERV_CUST:
1383 decrypt_opt = newvstralloc(decrypt_opt,
1384 " <decrypt-option>",
1385 dp->srv_decrypt_opt,
1386 "</decrypt-option>\n", NULL);
1387 encrypt_opt = newvstralloc(encrypt_opt,
1388 " <encrypt>SERVER-CUSTOM"
1389 "<custom-encrypt-program>",
1391 "</custom-encrypt-program>\n",
1393 " </encrypt>\n", NULL);
1399 record_opt = " <record>NO</record>\n";
1401 record_opt = " <record>YES</record>\n";
1405 index_opt = " <index>YES</index>\n";
1411 kencrypt_opt = " <kencrypt>YES</kencrypt>\n";
1416 if (am_has_feature(their_features, fe_xml_data_path)) {
1417 switch(dp->data_path) {
1418 case DATA_PATH_AMANDA:
1419 amfree(data_path_opt);
1420 data_path_opt = stralloc(" <datapath>AMANDA</datapath>\n");
1422 case DATA_PATH_DIRECTTCP:
1423 { /* dp->dataport_list is not set for selfcheck/sendsize */
1424 if (am_has_feature(their_features, fe_xml_directtcp_list)) {
1426 char *value, *b64value;
1428 amfree(data_path_opt);
1429 data_path_opt = stralloc(" <datapath>DIRECTTCP");
1430 if (dp->dataport_list) {
1431 s = sc = stralloc(dp->dataport_list);
1439 b64value = amxml_format_tag("directtcp", value);
1440 vstrextend(&data_path_opt, "\n ", b64value, NULL);
1444 strappend(data_path_opt, "\n ");
1446 strappend(data_path_opt, "</datapath>\n");
1453 exclude_file = stralloc("");
1454 if (dp->exclude_file != NULL && dp->exclude_file->nb_element > 0) {
1455 for(excl = dp->exclude_file->first; excl != NULL;
1456 excl = excl->next) {
1457 q64name = amxml_format_tag("file", excl->name);
1458 exc = newvstralloc( exc, " ", q64name, "\n", NULL);
1459 strappend(exclude_file, exc);
1463 exclude_list = stralloc("");
1464 if (dp->exclude_list != NULL && dp->exclude_list->nb_element > 0) {
1465 for(excl = dp->exclude_list->first; excl != NULL;
1466 excl = excl->next) {
1467 q64name = amxml_format_tag("list", excl->name);
1468 exc = newvstralloc(exc, " ", q64name, "\n", NULL);
1469 strappend(exclude_list, exc);
1474 include_file = stralloc("");
1475 if (dp->include_file != NULL && dp->include_file->nb_element > 0) {
1476 for(excl = dp->include_file->first; excl != NULL;
1477 excl = excl->next) {
1478 q64name = amxml_format_tag("file", excl->name);
1479 exc = newvstralloc( exc, " ", q64name, "\n", NULL);
1480 strappend(include_file, exc);
1484 include_list = stralloc("");
1485 if (dp->include_list != NULL && dp->include_list->nb_element > 0) {
1486 for(excl = dp->include_list->first; excl != NULL;
1487 excl = excl->next) {
1488 q64name = amxml_format_tag("list", excl->name);
1489 exc = newvstralloc( exc, " ", q64name, "\n", NULL);
1490 strappend(include_list, exc);
1495 if (dp->exclude_optional) {
1496 excl_opt = " <optional>YES</optional>\n";
1498 if (dp->include_optional) {
1499 incl_opt = " <optional>YES</optional>\n";
1502 if (dp->exclude_file || dp->exclude_list)
1503 exclude = newvstralloc(exclude,
1508 " </exclude>\n", NULL);
1509 if (dp->include_file || dp->include_list)
1510 include = newvstralloc(include,
1515 " </include>\n", NULL);
1516 script_opt = xml_scripts(dp->pp_scriptlist, their_features);
1517 result = vstralloc(auth_opt,
1531 amfree(data_path_opt);
1532 amfree(compress_opt);
1534 amfree(exclude_list);
1535 amfree(exclude_file);
1537 amfree(include_file);
1538 amfree(include_list);
1540 amfree(decrypt_opt);
1541 amfree(encrypt_opt);
1544 /* result contains at least 'auth=...' */
1549 xml_dumptype_properties(
1552 xml_app_t xml_dumptype;
1554 xml_dumptype.result = g_strdup("");
1555 xml_dumptype.features = NULL;
1556 if (dp && dp->config) {
1557 g_hash_table_foreach(dumptype_get_property(dp->config), xml_property,
1560 return xml_dumptype.result;
1565 estimatelist_t estimatelist,
1566 am_feature_t *their_features)
1571 if (am_has_feature(their_features, fe_xml_estimatelist)) {
1572 vstrextend(&l, " <estimate>", NULL);
1573 for (el=estimatelist; el != NULL; el = el->next) {
1574 switch (GPOINTER_TO_INT(el->data)) {
1575 case ES_CLIENT : vstrextend(&l, "CLIENT ", NULL); break;
1576 case ES_SERVER : vstrextend(&l, "SERVER ", NULL); break;
1577 case ES_CALCSIZE: vstrextend(&l, "CALCSIZE ", NULL); break;
1580 vstrextend(&l, "</estimate>", NULL);
1581 } else { /* add the first estimate only */
1582 if (am_has_feature(their_features, fe_xml_estimate)) {
1583 vstrextend(&l, " <estimate>", NULL);
1584 switch (GPOINTER_TO_INT(estimatelist->data)) {
1585 case ES_CLIENT : vstrextend(&l, "CLIENT", NULL); break;
1586 case ES_SERVER : vstrextend(&l, "SERVER", NULL); break;
1587 case ES_CALCSIZE: vstrextend(&l, "CALCSIZE", NULL); break;
1590 vstrextend(&l, "</estimate>", NULL);
1591 if (GPOINTER_TO_INT(estimatelist->data) == ES_CALCSIZE) {
1592 vstrextend(&l, " <calcsize>YES</calcsize>", NULL);
1600 clean_dle_str_for_client(
1602 am_feature_t *their_features)
1605 char *hack1, *hack2;
1606 char *pend, *pscript, *pproperty, *eproperty;
1612 rval_dle_str = stralloc(dle_str);
1614 /* Remove everything between " <encrypt>SERVER-CUSTOM" and "</encrypt>\n"
1616 #define SC "</encrypt>\n"
1617 #define SC_LEN strlen(SC)
1618 hack1 = strstr(rval_dle_str, " <encrypt>SERVER-CUSTOM");
1620 hack2 = strstr(hack1, SC);
1621 /* +1 is to also move the trailing '\0' */
1622 memmove(hack1, hack2 + SC_LEN, strlen(hack2 + SC_LEN) + 1);
1627 if (!am_has_feature(their_features, fe_dumptype_property)) {
1628 #define SC "</property>\n"
1629 #define SC_LEN strlen(SC)
1630 /* remove all dle properties, they are before backup-program or script
1632 hack1 = rval_dle_str;
1633 pend = strstr(rval_dle_str, "<backup-program>");
1634 pscript = strstr(rval_dle_str, "<script>");
1635 if (pscript && pscript < pend)
1637 if (!pend) /* the complete string */
1638 pend = rval_dle_str + strlen(rval_dle_str);
1640 pproperty = strstr(hack1, " <property>");
1641 if (pproperty && pproperty < pend) { /* remove it */
1642 eproperty = strstr(pproperty, SC);
1643 len = eproperty + SC_LEN - pproperty;
1644 memmove(pproperty, eproperty + SC_LEN, strlen(eproperty + SC_LEN) + 1);
1656 return rval_dle_str;
1662 disk_t *dp G_GNUC_UNUSED,
1663 application_t *application,
1664 am_feature_t *their_features)
1670 proplist_t proplist;
1672 xml_app.features = their_features;
1673 xml_app.result = NULL;
1674 plugin = application_get_plugin(application);
1675 b64plugin = amxml_format_tag("plugin", plugin);
1676 xml_app.result = vstralloc(" <backup-program>\n",
1677 " ", b64plugin, "\n",
1679 proplist = application_get_property(application);
1680 g_hash_table_foreach(proplist, xml_property, &xml_app);
1682 client_name = application_get_client_name(application);
1683 if (client_name && strlen(client_name) > 0 &&
1684 am_has_feature(their_features, fe_application_client_name)) {
1685 char *b64client_name = amxml_format_tag("client_name", client_name);
1686 vstrextend(&xml_app.result, " ", b64client_name, "\n", NULL);
1689 vstrextend(&xml_app.result, " </backup-program>\n", NULL);
1693 return xml_app.result;
1699 identlist_t pp_scriptlist,
1700 am_feature_t *their_features)
1710 execute_on_t execute_on;
1712 proplist_t proplist;
1713 identlist_t pp_iter;
1714 pp_script_t *pp_script;
1717 xml_app.features = their_features;
1719 xml_scr = stralloc("");
1720 for (pp_iter = pp_scriptlist; pp_iter != NULL;
1721 pp_iter = pp_iter->next) {
1722 char *pp_script_name = pp_iter->data;
1723 pp_script = lookup_pp_script(pp_script_name);
1724 g_assert(pp_script != NULL);
1725 plugin = pp_script_get_plugin(pp_script);
1726 b64plugin = amxml_format_tag("plugin", plugin);
1727 xml_scr1 = vstralloc(" <script>\n",
1728 " ", b64plugin, "\n",
1731 execute_where = pp_script_get_execute_where(pp_script);
1732 switch (execute_where) {
1733 case ES_CLIENT: str = "CLIENT"; break;
1734 case ES_SERVER: str = "SERVER"; break;
1736 xml_scr1 = vstrextend(&xml_scr1, " <execute_where>",
1737 str, "</execute_where>\n", NULL);
1739 execute_on = pp_script_get_execute_on(pp_script);
1741 eo_str = stralloc("");
1742 if (execute_on & EXECUTE_ON_PRE_DLE_AMCHECK) {
1743 eo_str = vstrextend(&eo_str, sep, "PRE-DLE-AMCHECK", NULL);
1746 if (execute_on & EXECUTE_ON_PRE_HOST_AMCHECK) {
1747 eo_str = vstrextend(&eo_str, sep, "PRE-HOST-AMCHECK", NULL);
1750 if (execute_on & EXECUTE_ON_POST_DLE_AMCHECK) {
1751 eo_str = vstrextend(&eo_str, sep, "POST-DLE-AMCHECK", NULL);
1754 if (execute_on & EXECUTE_ON_POST_HOST_AMCHECK) {
1755 eo_str = vstrextend(&eo_str, sep, "POST-HOST-AMCHECK", NULL);
1758 if (execute_on & EXECUTE_ON_PRE_DLE_ESTIMATE) {
1759 eo_str = vstrextend(&eo_str, sep, "PRE-DLE-ESTIMATE", NULL);
1762 if (execute_on & EXECUTE_ON_PRE_HOST_ESTIMATE) {
1763 eo_str = vstrextend(&eo_str, sep, "PRE-HOST-ESTIMATE", NULL);
1766 if (execute_on & EXECUTE_ON_POST_DLE_ESTIMATE) {
1767 eo_str = vstrextend(&eo_str, sep, "POST-DLE-ESTIMATE", NULL);
1770 if (execute_on & EXECUTE_ON_POST_HOST_ESTIMATE) {
1771 eo_str = vstrextend(&eo_str, sep, "POST-HOST-ESTIMATE", NULL);
1774 if (execute_on & EXECUTE_ON_PRE_DLE_BACKUP) {
1775 eo_str = vstrextend(&eo_str, sep, "PRE-DLE-BACKUP", NULL);
1778 if (execute_on & EXECUTE_ON_PRE_HOST_BACKUP) {
1779 eo_str = vstrextend(&eo_str, sep, "PRE-HOST-BACKUP", NULL);
1782 if (execute_on & EXECUTE_ON_POST_DLE_BACKUP) {
1783 eo_str = vstrextend(&eo_str, sep, "POST-DLE-BACKUP", NULL);
1786 if (execute_on & EXECUTE_ON_POST_HOST_BACKUP) {
1787 eo_str = vstrextend(&eo_str, sep, "POST-HOST-BACKUP", NULL);
1790 if (execute_on & EXECUTE_ON_PRE_RECOVER) {
1791 eo_str = vstrextend(&eo_str, sep, "PRE-RECOVER", NULL);
1794 if (execute_on & EXECUTE_ON_POST_RECOVER) {
1795 eo_str = vstrextend(&eo_str, sep, "POST-RECOVER", NULL);
1798 if (execute_on & EXECUTE_ON_PRE_LEVEL_RECOVER) {
1799 eo_str = vstrextend(&eo_str, sep, "PRE-LEVEL-RECOVER", NULL);
1802 if (execute_on & EXECUTE_ON_POST_LEVEL_RECOVER) {
1803 eo_str = vstrextend(&eo_str, sep, "POST-LEVEL-RECOVER", NULL);
1806 if (execute_on & EXECUTE_ON_INTER_LEVEL_RECOVER) {
1807 eo_str = vstrextend(&eo_str, sep, "INTER-LEVEL-RECOVER", NULL);
1810 if (execute_on != 0)
1811 xml_scr1 = vstrextend(&xml_scr1,
1812 " <execute_on>", eo_str,
1813 "</execute_on>\n", NULL);
1815 proplist = pp_script_get_property(pp_script);
1816 xml_app.result = stralloc("");
1817 g_hash_table_foreach(proplist, xml_property, &xml_app);
1819 client_name = pp_script_get_client_name(pp_script);
1820 if (client_name && strlen(client_name) > 0 &&
1821 am_has_feature(their_features, fe_script_client_name)) {
1822 char *b64client_name = amxml_format_tag("client_name",
1824 vstrextend(&xml_app.result, " ", b64client_name, "\n", NULL);
1827 xml_scr = vstrextend(&xml_scr, xml_scr1, xml_app.result, " </script>\n", NULL);
1829 amfree(xml_app.result);
1842 for (dp = origqp->head; dp != NULL; dp = dp->next) {
1843 if (dp->ignore || dp->strategy == DS_SKIP)
1855 char *prevhost = NULL;
1856 char *errstr = NULL;
1867 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1873 for(i=0;i<sargc;i++) {
1875 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1876 if(match_host(sargv[i], dp->host->hostname))
1881 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1882 if(prevhost != NULL &&
1883 match_host(prevhost, dp->host->hostname) &&
1884 (match_disk(sargv[i], dp->name) ||
1885 (dp->device && match_disk(sargv[i], dp->device)))) {
1887 error(_("Argument %s cannot be both a host and a disk"),sargv[i]);
1891 if(dp->todo == -1) {
1895 } else if (dp->todo == 0) {
1899 } else { /* dp->todo == 1 */
1907 if(match_a_host == 1) {
1908 if(prev_match == 1) { /* all disk of the previous host */
1909 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1910 if(match_host(prevhost,dp->host->hostname))
1911 if(dp->todo == -1) {
1916 if (!match_a_disk) {
1918 errstr1 = vstrallocf(_("All disks on host '%s' are ignored or have strategy \"skip\".\n"), prevhost);
1919 vstrextend(&errstr, errstr1, NULL);
1923 prevhost = sargv[i];
1928 if (strchr(sargv[i], (int)'\\')) {
1929 errstr1 = vstrallocf(_("Argument '%s' matches neither a host nor a disk; quoting may not be correct.\n"), sargv[i]);
1931 errstr1 = vstrallocf(_("Argument '%s' matches neither a host nor a disk.\n"), sargv[i]);
1933 vstrextend(&errstr, errstr1, NULL);
1937 } else if (dp_skip) {
1939 if (dp_skip->strategy == DS_SKIP) {
1940 errstr1 = vstrallocf(_("Argument '%s' matches a disk with strategy \"skip\".\n"), sargv[i]);
1942 errstr1 = vstrallocf(_("Argument '%s' matches a disk marked \"ignore\".\n"), sargv[i]);
1944 vstrextend(&errstr, errstr1, NULL);
1950 if(prev_match == 1) { /* all disk of the previous host */
1952 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1953 if(match_host(prevhost,dp->host->hostname))
1954 if(dp->todo == -1) {
1959 if (!match_a_disk) {
1961 errstr1 = vstrallocf(_("All disks on host '%s' are ignored or have strategy \"skip\".\n"), prevhost);
1962 vstrextend(&errstr, errstr1, NULL);
1967 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1985 /* rather than try to reproduce the adaptive matching logic in
1986 * match_disklist, this simply creates a new, fake disklist with one
1987 * element in it, and calls match_disklist directly */
1989 bzero(&h, sizeof(h));
1990 h.hostname = file->name;
1993 bzero(&d, sizeof(d));
1995 d.hostname = file->name;
1996 d.name = file->disk;
1997 d.device = file->disk;
2000 dl.head = dl.tail = &d;
2002 (void)match_disklist(&dl, sargc, sargv);
2007 disklist_netifs(void)
2014 static void dump_disk(const disk_t *);
2015 static void dump_disklist(const disklist_t *);
2016 int main(int, char *[]);
2022 g_printf(_(" DISK %s (HOST %s, LINE %d) TYPE %s NAME %s SPINDLE %d\n"),
2023 dp->name, dp->host->hostname, dp->line, dp->dtype_name,
2024 dp->name == NULL? "(null)": dp->name,
2030 const disklist_t * lst)
2032 const disk_t *dp, *prev;
2033 const am_host_t *hp;
2035 if(hostlist == NULL) {
2036 g_printf(_("DISKLIST not read in\n"));
2040 g_printf(_("DISKLIST BY HOSTNAME:\n"));
2042 for(hp = hostlist; hp != NULL; hp = hp->next) {
2043 char *if_name = NULL;
2044 if (hp->netif && hp->netif->config)
2045 if_name = interface_name(hp->netif->config);
2047 g_printf(_("HOST %s INTERFACE %s\n"),
2049 if_name ? _("(null)") : if_name);
2050 for(dp = hp->disks; dp != NULL; dp = dp->hostnext)
2056 g_printf(_("DISKLIST IN FILE ORDER:\n"));
2059 for(dp = lst->head; dp != NULL; prev = dp, dp = dp->next) {
2061 /* check pointers */
2062 if(dp->prev != prev) g_printf(_("*** prev pointer mismatch!\n"));
2063 if(dp->next == NULL && lst->tail != dp) g_printf(_("tail mismatch!\n"));
2073 char *conf_diskfile;
2078 * Configure program for internationalization:
2079 * 1) Only set the message locale for now.
2080 * 2) Set textdomain for all amanda related programs to "amanda"
2081 * We don't want to be forced to support dozens of message catalogs.
2083 setlocale(LC_MESSAGES, "C");
2084 textdomain("amanda");
2088 set_pname("diskfile");
2090 dbopen(DBG_SUBDIR_SERVER);
2092 /* Don't die when child closes pipe */
2093 signal(SIGPIPE, SIG_IGN);
2096 config_init(CONFIG_INIT_EXPLICIT_NAME, argv[1]);
2098 config_init(CONFIG_INIT_USE_CWD, NULL)
2101 if (config_errors(NULL) >= CFGERR_WARNINGS) {
2102 config_print_errors();
2103 if (config_errors(NULL) >= CFGERR_ERRORS) {
2104 g_critical(_("errors processing config file"));
2108 conf_diskfile = config_dir_relative(getconf_str(CNF_DISKFILE));
2109 result = read_diskfile(conf_diskfile, &lst);
2110 if(result == CFGERR_OK) {
2111 dump_disklist(&lst);
2113 config_print_errors();
2115 amfree(conf_diskfile);