2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 University of Maryland at College Park
4 * Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved.
7 * Permission to use, copy, modify, distribute, and sell this software and its
8 * documentation for any purpose is hereby granted without fee, provided that
9 * the above copyright notice appear in all copies and that both that
10 * copyright notice and this permission notice appear in supporting
11 * documentation, and that the name of U.M. not be used in advertising or
12 * publicity pertaining to distribution of the software without specific,
13 * written prior permission. U.M. makes no representations about the
14 * suitability of this software for any purpose. It is provided "as is"
15 * without express or implied warranty.
17 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
19 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
21 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 * Author: James da Silva, Systems Design and Analysis Group
25 * Computer Science Department
26 * University of Maryland at College Park
29 * $Id: diskfile.c,v 1.95 2006/07/26 15:17:37 martinea Exp $
41 static am_host_t *hostlist;
42 static netif_t *all_netifs;
45 static char *upcase(char *st);
46 static int parse_diskline(disklist_t *, const char *, FILE *, int *, char **);
47 static void disk_parserror(const char *, int, const char *, ...)
62 lst->head = lst->tail = NULL;
65 /* if we already have config errors, then don't bother */
66 if (config_errors(NULL) >= CFGERR_ERRORS) {
67 return config_errors(NULL);
70 if ((diskf = fopen(filename, "r")) == NULL) {
71 config_add_error(CFGERR_ERRORS,
72 vstrallocf(_("Could not open '%s': %s"), filename, strerror(errno)));
77 while ((line = agets(diskf)) != NULL) {
79 if (line[0] != '\0') {
80 if (parse_diskline(lst, filename, diskf, &line_num, &line) < 0) {
90 return config_errors(NULL);
101 const char *hostname)
105 for (p = hostlist; p != NULL; p = p->next) {
106 if(strcasecmp(p->hostname, hostname) == 0) return p;
113 const char *hostname,
114 const char *diskname)
119 host = lookup_host(hostname);
123 for (disk = host->disks; disk != NULL; disk = disk->hostnext) {
124 if (strcmp(disk->name, diskname) == 0)
132 * put disk on end of queue
140 if(list->tail == NULL) list->head = disk;
141 else list->tail->next = disk;
142 disk->prev = list->tail;
150 * put disk on head of queue
158 if(list->head == NULL) list->tail = disk;
159 else list->head->prev = disk;
160 disk->next = list->head;
168 * insert in sorted order
175 int (*cmp)(disk_t *a, disk_t *b))
183 if(cmp(disk, ptr) < 0) break;
190 if(prev == NULL) list->head = disk;
191 else prev->next = disk;
192 if(ptr == NULL) list->tail = disk;
193 else ptr->prev = disk;
205 disk = alloc(SIZEOF(disk_t));
206 bzero(disk, SIZEOF(disk_t));
208 disk->allow_split = 0;
209 disk->max_warnings = 20;
210 disk->splitsize = (off_t)0;
211 disk->tape_splitsize = (off_t)0;
212 disk->split_diskbuffer = NULL;
213 disk->fallback_splitsize = (off_t)0;
214 disk->hostname = stralloc(hostname);
215 disk->name = stralloc(diskname);
216 disk->device = stralloc(diskname);
219 disk->compress = COMP_NONE;
220 disk->encrypt = ENCRYPT_NONE;
224 disk->exclude_list = NULL;
225 disk->exclude_file = NULL;
226 disk->include_list = NULL;
227 disk->include_file = NULL;
228 disk->application = NULL;
229 disk->pp_scriptlist = NULL;
231 host = lookup_host(hostname);
233 host = alloc(SIZEOF(am_host_t));
234 host->next = hostlist;
237 host->hostname = stralloc(hostname);
239 host->inprogress = 0;
244 host->features = NULL;
245 host->pre_script = 0;
246 host->post_script = 0;
248 enqueue_disk(list, disk);
251 disk->hostnext = host->disks;
259 * check if disk is present in list. Return true if so, false otherwise.
270 while ((t != NULL) && (t != disk)) {
285 int (*cmp)(disk_t *a, disk_t *b))
290 tmp = in; /* just in case in == out */
292 out->head = (disk_t *)0;
293 out->tail = (disk_t *)0;
295 while((disk = dequeue_disk(tmp)))
296 insert_disk(out, disk, cmp);
301 * remove disk from front of queue
310 if(list->head == NULL) return NULL;
313 list->head = disk->next;
315 if(list->head == NULL) list->tail = NULL;
316 else list->head->prev = NULL;
318 disk->prev = disk->next = NULL; /* for debugging */
327 if(disk->prev == NULL) list->head = disk->next;
328 else disk->prev->next = disk->next;
330 if(disk->next == NULL) list->tail = disk->prev;
331 else disk->next->prev = disk->prev;
333 disk->prev = disk->next = NULL;
341 am_host_t *host, *hostnext;
342 netif_t *netif, *next_if;
344 while (dl->head != NULL) {
345 dp = dequeue_disk(dl);
346 amfree(dp->filename);
348 amfree(dp->hostname);
350 free_sl(dp->exclude_file);
351 free_sl(dp->exclude_list);
352 free_sl(dp->include_file);
353 free_sl(dp->include_list);
357 for(host=hostlist; host != NULL; host = hostnext) {
358 amfree(host->hostname);
359 am_release_feature_set(host->features);
360 host->features = NULL;
361 hostnext = host->next;
366 for (netif = all_netifs; netif != NULL; netif = next_if) {
367 next_if = netif->next;
380 if(islower((int)*s)) *s = (char)toupper((int)*s);
387 /* return 0 on success */
388 /* return -1 on error */
392 const char *filename,
395 /*@keep@*/ char ** line_p)
400 netif_t *netif = NULL;
401 interface_t *cfg_if = NULL;
402 char *hostname = NULL;
403 char *diskname, *diskdevice;
407 char *line = *line_p;
408 int line_num = *line_num_p;
416 assert(filename != NULL);
417 assert(line_num > 0);
418 assert(line != NULL);
422 skip_whitespace(s, ch);
423 if(ch == '\0' || ch == '#')
427 skip_non_whitespace(s, ch);
429 if (g_str_equal(fp, "includefile")) {
431 char *include_filename;
432 skip_whitespace(s, ch);
433 if (ch == '\0' || ch == '#') {
434 disk_parserror(filename, line_num, _("include filename name expected"));
438 skip_quoted_string(s, ch);
440 include_name = unquote_string(fp);
441 include_filename = config_dir_relative(include_name);
442 read_diskfile(include_filename, lst);
443 g_free(include_filename);
444 g_free(include_name);
445 if (config_errors(NULL) >= CFGERR_WARNINGS) {
451 host = lookup_host(fp);
453 hostname = stralloc(fp);
455 hostname = stralloc(host->hostname);
456 if (strcmp(host->hostname, fp) != 0) {
457 disk_parserror(filename, line_num, _("Same host with different case: \"%s\" and \"%s\"."), host->hostname, fp);
462 shost = sanitise_filename(hostname);
463 for (p = hostlist; p != NULL; p = p->next) {
464 char *shostp = sanitise_filename(p->hostname);
465 if (strcmp(hostname, p->hostname) &&
466 !strcmp(shost, shostp)) {
467 disk_parserror(filename, line_num, _("Two hosts are mapping to the same name: \"%s\" and \"%s\""), p->hostname, hostname);
470 else if (strcasecmp(hostname, p->hostname) &&
471 match_host(hostname, p->hostname) &&
472 match_host(p->hostname, hostname)) {
473 disk_parserror(filename, line_num, _("Duplicate host name: \"%s\" and \"%s\""), p->hostname, hostname);
480 skip_whitespace(s, ch);
481 if(ch == '\0' || ch == '#') {
482 disk_parserror(filename, line_num, _("disk device name expected"));
488 skip_quoted_string(s, ch);
490 diskname = unquote_string(fp);
491 if (strlen(diskname) == 0) {
492 disk_parserror(filename, line_num, _("invalid empty diskname"));
496 skip_whitespace(s, ch);
497 if(ch == '\0' || ch == '#') {
498 disk_parserror(filename, line_num, _("disk dumptype expected"));
504 skip_quoted_string(s, ch);
511 dumptype = unquote_string(fp);
512 if (strlen(dumptype) == 0) {
513 disk_parserror(filename, line_num, _("invalid empty diskdevice"));
517 if (lookup_dumptype(dumptype) == NULL) {
518 diskdevice = dumptype;
519 skip_whitespace(s, ch);
520 if(ch == '\0' || ch == '#') {
521 disk_parserror(filename, line_num,
522 _("disk dumptype '%s' not found"), dumptype);
530 skip_quoted_string(s, ch);
533 dumptype = unquote_string(fp);
538 /* check for duplicate disk */
541 if ((disk = lookup_disk(hostname, diskname)) != NULL) {
547 a1 = clean_regex(diskname, 1);
548 a2 = clean_regex(disk->name, 1);
550 if (match_disk(a1, disk->name) && match_disk(a2, diskname)) {
553 disk = disk->hostnext;
558 while (dup == 0 && disk != NULL);
561 disk_parserror(filename, line_num,
562 _("duplicate disk record, previous on line %d"),
567 disk = alloc(SIZEOF(disk_t));
568 disk->filename = g_strdup(filename);
569 disk->line = line_num;
570 disk->hostname = hostname;
571 disk->name = diskname;
572 disk->device = diskdevice;
575 disk->inprogress = 0;
576 disk->application = NULL;
577 disk->pp_scriptlist = NULL;
578 disk->dataport_list = NULL;
582 sdisk = sanitise_filename(diskname);
583 for (dp = host->disks; dp != NULL; dp = dp->hostnext) {
584 char *sdiskp = sanitise_filename(dp->name);
585 if (strcmp(diskname, dp->name) != 0 &&
586 strcmp(sdisk, sdiskp) == 0) {
587 disk_parserror(filename, line_num,
588 _("Two disks are mapping to the same name: \"%s\" and \"%s\"; you must use different diskname"),
600 skip_whitespace(s, ch);
601 if (ch != '\0' && ch != '#') {
602 disk_parserror(filename, line_num,
603 _("expected line break after `{\', ignoring rest of line"));
606 if (strchr(s-1, '}') &&
607 (strchr(s-1, '#') == NULL ||
608 strchr(s-1, '}') < strchr(s-1, '#'))) {
609 disk_parserror(filename, line_num,_("'}' on same line than '{'"));
612 amfree(disk->device);
621 dtype = read_dumptype(vstralloc("custom(", hostname,
622 ":", disk->name, ")",
623 ".", anonymous_value(), NULL),
624 diskf, (char*)filename, line_num_p);
625 if (dtype == NULL || dup) {
626 disk_parserror(filename, line_num,
627 _("read of custom dumptype failed"));
630 amfree(disk->device);
641 *line_p = line = agets(diskf);
642 line_num = *line_num_p; /* no incr, read_dumptype did it already */
645 *line_p = line = stralloc("");
649 if((dtype = lookup_dumptype(dumptype)) == NULL) {
650 char *qdt = quote_string(dumptype);
652 disk_parserror(filename, line_num, _("undefined dumptype `%s'"), qdt);
656 amfree(disk->device);
669 /* disk_parserror already called, above */
670 g_assert(config_errors(NULL) != CFGERR_OK);
677 disk->dtype_name = dumptype_name(dtype);
678 disk->config = dtype;
679 disk->program = dumptype_get_program(dtype);
680 disk->exclude_list = duplicate_sl(dumptype_get_exclude(dtype).sl_list);
681 disk->exclude_file = duplicate_sl(dumptype_get_exclude(dtype).sl_file);
682 disk->exclude_optional = dumptype_get_exclude(dtype).optional;
683 disk->include_list = duplicate_sl(dumptype_get_include(dtype).sl_list);
684 disk->include_file = duplicate_sl(dumptype_get_include(dtype).sl_file);
685 disk->include_optional = dumptype_get_include(dtype).optional;
686 disk->priority = dumptype_get_priority(dtype);
687 disk->dumpcycle = dumptype_get_dumpcycle(dtype);
688 /* disk->frequency = dumptype_get_frequency(dtype);*/
689 disk->auth = dumptype_get_auth(dtype);
690 disk->maxdumps = dumptype_get_maxdumps(dtype);
691 disk->allow_split = dumptype_get_allow_split(dtype);
692 disk->max_warnings = dumptype_get_max_warnings(dtype);
693 disk->tape_splitsize = dumptype_get_tape_splitsize(dtype);
694 disk->split_diskbuffer = dumptype_get_split_diskbuffer(dtype);
695 disk->fallback_splitsize = dumptype_get_fallback_splitsize(dtype);
696 if (disk->allow_split) {
697 tapetype_t *tapetype = lookup_tapetype(getconf_str(CNF_TAPETYPE));
698 disk->splitsize = tapetype_get_part_size(tapetype);
700 disk->splitsize = disk->tape_splitsize;
702 disk->maxpromoteday = dumptype_get_maxpromoteday(dtype);
703 disk->bumppercent = dumptype_get_bumppercent(dtype);
704 disk->bumpsize = dumptype_get_bumpsize(dtype);
705 disk->bumpdays = dumptype_get_bumpdays(dtype);
706 disk->bumpmult = dumptype_get_bumpmult(dtype);
707 disk->starttime = dumptype_get_starttime(dtype);
708 disk->application = dumptype_get_application(dtype);
709 disk->pp_scriptlist = dumptype_get_scriptlist(dtype);
711 if (disk->starttime > 0) {
714 stm = localtime(&st);
715 disk->start_t -= stm->tm_sec + 60 * stm->tm_min + 3600 * stm->tm_hour;
716 disk->start_t += disk->starttime / 100 * 3600 +
717 disk->starttime % 100 * 60;
718 if ((disk->start_t - st) < -43200)
719 disk->start_t += 86400;
721 disk->strategy = dumptype_get_strategy(dtype);
722 disk->ignore = dumptype_get_ignore(dtype);
723 disk->estimatelist = dumptype_get_estimatelist(dtype);
724 disk->compress = dumptype_get_compress(dtype);
725 disk->srvcompprog = dumptype_get_srvcompprog(dtype);
726 disk->clntcompprog = dumptype_get_clntcompprog(dtype);
727 disk->encrypt = dumptype_get_encrypt(dtype);
728 disk->srv_decrypt_opt = dumptype_get_srv_decrypt_opt(dtype);
729 disk->clnt_decrypt_opt = dumptype_get_clnt_decrypt_opt(dtype);
730 disk->srv_encrypt = dumptype_get_srv_encrypt(dtype);
731 disk->clnt_encrypt = dumptype_get_clnt_encrypt(dtype);
732 disk->amandad_path = dumptype_get_amandad_path(dtype);
733 disk->client_username = dumptype_get_client_username(dtype);
734 disk->client_port = dumptype_get_client_port(dtype);
735 disk->ssh_keys = dumptype_get_ssh_keys(dtype);
736 disk->comprate[0] = dumptype_get_comprate(dtype)[0];
737 disk->comprate[1] = dumptype_get_comprate(dtype)[1];
738 disk->data_path = dumptype_get_data_path(dtype);
739 disk->dump_limit = dumptype_get_dump_limit(dtype);
742 * Boolean parameters with no value (Appears here as value 2) defaults
743 * to TRUE for backward compatibility and for logical consistency.
745 disk->record = dumptype_get_record(dtype) != 0;
746 disk->skip_incr = dumptype_get_skip_incr(dtype) != 0;
747 disk->skip_full = dumptype_get_skip_full(dtype) != 0;
748 disk->to_holdingdisk = dumptype_get_to_holdingdisk(dtype);
749 disk->kencrypt = dumptype_get_kencrypt(dtype) != 0;
750 disk->index = dumptype_get_index(dtype) != 0;
754 skip_whitespace(s, ch);
756 if(ch && ch != '#') { /* get optional spindle number */
760 skip_non_whitespace(s, ch);
763 if (*fp1 == '-') fp1++;
764 for(;*fp1!='\0';fp1++) {
765 if(!isdigit((int)*fp1)) {
770 disk_parserror(filename, line_num, _("non-integer spindle `%s'"), fp);
776 disk->spindle = atoi(fp);
780 skip_whitespace(s, ch);
782 if(ch && ch != '#') { /* get optional network interface */
783 skip_non_whitespace(s, ch);
785 if((cfg_if = lookup_interface(upcase(fp))) == NULL) {
786 disk_parserror(filename, line_num,
787 _("undefined network interface `%s'"), fp);
794 cfg_if = lookup_interface("default");
797 /* see if we already have a netif_t for this interface */
798 for (netif = all_netifs; netif != NULL; netif = netif->next) {
799 if (netif->config == cfg_if)
803 /* nope; make up a new one */
805 netif = alloc(sizeof(*netif));
806 netif->next = all_netifs;
808 netif->config = cfg_if;
812 skip_whitespace(s, ch);
813 if(ch && ch != '#') { /* now we have garbage, ignore it */
814 disk_parserror(filename, line_num, _("end of line expected"));
817 if (disk->program && disk->application &&
818 strcmp(disk->program,"APPLICATION")) {
819 disk_parserror(filename, line_num,
820 _("Both program and application set"));
823 if (disk->program && strcmp(disk->program,"APPLICATION")==0 &&
824 !disk->application) {
825 disk_parserror(filename, line_num,
826 _("program set to APPLICATION but no application set"));
829 if (disk->application) {
830 application_t *application;
833 application = lookup_application(disk->application);
834 g_assert(application != NULL);
835 plugin = application_get_plugin(application);
836 if (!plugin || strlen(plugin) == 0) {
837 disk_parserror(filename, line_num,
838 _("plugin not set for application"));
842 for (pp_iter = disk->pp_scriptlist; pp_iter != NULL;
843 pp_iter = pp_iter->next) {
844 pp_script_t *pp_script;
846 char *pp_script_name;
848 pp_script_name = (char*)pp_iter->data;
849 pp_script = lookup_pp_script(pp_script_name);
850 g_assert(pp_script != NULL);
851 plugin = pp_script_get_plugin(pp_script);
852 if (!plugin || strlen(plugin) == 0) {
853 disk_parserror(filename, line_num, _("plugin not set for script"));
857 /* success, add disk to lists */
859 if(host == NULL) { /* new host */
860 host = alloc(SIZEOF(am_host_t));
861 host->next = hostlist;
864 host->hostname = stralloc(hostname);
867 host->inprogress = 0;
868 host->maxdumps = 1; /* will be overwritten */
872 host->features = NULL;
873 host->pre_script = 0;
874 host->post_script = 0;
879 enqueue_disk(lst, disk);
882 disk->hostnext = host->disks;
884 host->maxdumps = disk->maxdumps;
890 printf_arglist_function2(void disk_parserror, const char *, filename,
891 int, line_num, const char *, format)
897 /* format the error message and hand it off to conffile */
899 arglist_start(argp, format);
900 msg = g_strdup_vprintf(format, argp);
901 errstr = g_strdup_printf("\"%s\", line %d: %s", filename, line_num, msg);
905 config_add_error(CFGERR_ERRORS, errstr);
913 int npr, /* we print first npr disks on queue, plus last two */
921 g_fprintf(f, _("%s QUEUE: empty\n"), st);
924 g_fprintf(f, _("%s QUEUE:\n"), st);
925 for(pos = 0, d = q.head, p = NULL; d != NULL; p = d, d = d->next, pos++) {
926 qname = quote_string(d->name);
927 if(pos < npr) g_fprintf(f, "%3d: %-10s %-4s\n",
928 pos, d->host->hostname, qname);
932 if(pos > npr+2) g_fprintf(f, " ...\n");
935 g_fprintf(f, "%3d: %-10s %-4s\n", pos-2, d->host->hostname, d->name);
938 g_fprintf(f, "%3d: %-10s %-4s\n", pos-1, d->host->hostname, d->name);
949 am_feature_t *their_features = dp->host->features;
952 assert(dp->host != NULL);
954 errarray = g_ptr_array_new();
956 if (!am_has_feature(their_features, fe_options_auth)) {
957 if (strcasecmp(dp->auth, "bsd") == 0)
958 if (!am_has_feature(their_features, fe_options_bsd_auth))
959 g_ptr_array_add(errarray, _("does not support auth"));
962 switch(dp->compress) {
964 if (!am_has_feature(their_features, fe_options_compress_fast)) {
965 g_ptr_array_add(errarray, _("does not support fast compression"));
969 if (!am_has_feature(their_features, fe_options_compress_best)) {
970 g_ptr_array_add(errarray, _("does not support best compression"));
974 if (am_has_feature(their_features, fe_options_compress_cust)) {
975 if (dp->clntcompprog == NULL || strlen(dp->clntcompprog) == 0) {
976 g_ptr_array_add(errarray, _("client custom compression with no compression program specified"));
979 g_ptr_array_add(errarray, _("does not support client custom compression"));
982 case COMP_SERVER_FAST:
984 case COMP_SERVER_BEST:
986 case COMP_SERVER_CUST:
987 if (dp->srvcompprog == NULL || strlen(dp->srvcompprog) == 0) {
988 g_ptr_array_add(errarray, _("server custom compression with no compression program specified"));
993 switch(dp->encrypt) {
995 if (am_has_feature(their_features, fe_options_encrypt_cust)) {
996 if (dp->clnt_decrypt_opt) {
997 if (!am_has_feature(their_features, fe_options_client_decrypt_option)) {
998 g_ptr_array_add(errarray, _("does not support client decrypt option"));
1001 if (dp->clnt_encrypt == NULL || strlen(dp->clnt_encrypt) == 0) {
1002 g_ptr_array_add(errarray, _("encrypt client with no encryption program specified"));
1004 if (dp->compress == COMP_SERVER_FAST ||
1005 dp->compress == COMP_SERVER_BEST ||
1006 dp->compress == COMP_SERVER_CUST ) {
1007 g_ptr_array_add(errarray, _("Client encryption with server compression is not supported. See amanda.conf(5) for detail"));
1010 g_ptr_array_add(errarray, _("does not support client data encryption"));
1013 case ENCRYPT_SERV_CUST:
1014 if (dp->srv_encrypt == NULL || strlen(dp->srv_encrypt) == 0) {
1015 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"));
1021 if (!am_has_feature(their_features, fe_options_no_record)) {
1022 g_ptr_array_add(errarray, _("does not support no record"));
1027 if (!am_has_feature(their_features, fe_options_index)) {
1028 g_ptr_array_add(errarray, _("does not support index"));
1033 if (!am_has_feature(their_features, fe_options_kencrypt)) {
1034 g_ptr_array_add(errarray, _("does not support kencrypt"));
1039 if (dp->exclude_file != NULL && dp->exclude_file->nb_element > 0) {
1040 nb_exclude = dp->exclude_file->nb_element;
1041 if (!am_has_feature(their_features, fe_options_exclude_file)) {
1042 g_ptr_array_add(errarray, _("does not support exclude file"));
1046 if (dp->exclude_list != NULL && dp->exclude_list->nb_element > 0) {
1047 nb_exclude += dp->exclude_list->nb_element;
1048 if (!am_has_feature(their_features, fe_options_exclude_list)) {
1049 g_ptr_array_add(errarray, _("does not support exclude list"));
1053 if (nb_exclude > 1 &&
1054 !am_has_feature(their_features, fe_options_multiple_exclude)) {
1055 g_ptr_array_add(errarray, _("does not support multiple exclude"));
1059 if (dp->include_file != NULL && dp->include_file->nb_element > 0) {
1060 nb_include = dp->include_file->nb_element;
1061 if (!am_has_feature(their_features, fe_options_include_file)) {
1062 g_ptr_array_add(errarray, ("does not support include file"));
1066 if (dp->include_list != NULL && dp->include_list->nb_element > 0) {
1067 nb_include += dp->include_list->nb_element;
1068 if (!am_has_feature(their_features, fe_options_include_list)) {
1069 g_ptr_array_add(errarray, _("does not support include list"));
1073 if (nb_include > 1 &&
1074 !am_has_feature(their_features, fe_options_multiple_exclude)) {
1075 g_ptr_array_add(errarray, _("does not support multiple include"));
1078 if (dp->exclude_optional) {
1079 if (!am_has_feature(their_features, fe_options_optional_exclude)) {
1080 g_ptr_array_add(errarray, _("does not support optional exclude"));
1083 if (dp->include_optional) {
1084 if (!am_has_feature(their_features, fe_options_optional_include)) {
1085 g_ptr_array_add(errarray, _("does not support optional include"));
1096 char *auth_opt = NULL;
1097 char *kencrypt_opt = "";
1098 char *compress_opt = "";
1099 char *encrypt_opt = stralloc("");
1100 char *decrypt_opt = stralloc("");
1101 char *record_opt = "";
1102 char *index_opt = "";
1103 char *exclude_file = NULL;
1104 char *exclude_list = NULL;
1105 char *include_file = NULL;
1106 char *include_list = NULL;
1107 char *excl_opt = "";
1108 char *incl_opt = "";
1110 char *result = NULL;
1114 am_feature_t *their_features = dp->host->features;
1117 assert(dp->host != NULL);
1119 qdpname = quote_string(dp->name);
1120 if (am_has_feature(their_features, fe_options_auth)) {
1121 auth_opt = vstralloc("auth=", dp->auth, ";", NULL);
1122 } else if(strcasecmp(dp->auth, "bsd") == 0) {
1123 if(am_has_feature(their_features, fe_options_bsd_auth))
1124 auth_opt = stralloc("bsd-auth;");
1127 switch(dp->compress) {
1129 compress_opt = "compress-fast;";
1132 compress_opt = "compress-best;";
1135 compress_opt = vstralloc("comp-cust=", dp->clntcompprog, ";", NULL);
1137 case COMP_SERVER_FAST:
1138 compress_opt = "srvcomp-fast;";
1140 case COMP_SERVER_BEST:
1141 compress_opt = "srvcomp-best;";
1143 case COMP_SERVER_CUST:
1144 compress_opt = vstralloc("srvcomp-cust=", dp->srvcompprog, ";", NULL);
1148 switch(dp->encrypt) {
1150 encrypt_opt = newvstralloc(encrypt_opt, "encrypt-cust=",
1151 dp->clnt_encrypt, ";", NULL);
1152 if (dp->clnt_decrypt_opt) {
1153 decrypt_opt = newvstralloc(decrypt_opt, "client-decrypt-option=",
1154 dp->clnt_decrypt_opt, ";", NULL);
1157 case ENCRYPT_SERV_CUST:
1158 encrypt_opt = newvstralloc(encrypt_opt, "encrypt-serv-cust=",
1159 dp->srv_encrypt, ";", NULL);
1160 if (dp->srv_decrypt_opt) {
1161 decrypt_opt = newvstralloc(decrypt_opt, "server-decrypt-option=",
1162 dp->srv_decrypt_opt, ";", NULL);
1168 record_opt = "no-record;";
1172 index_opt = "index;";
1176 kencrypt_opt = "kencrypt;";
1179 exclude_file = stralloc("");
1180 if (dp->exclude_file != NULL && dp->exclude_file->nb_element > 0) {
1181 for(excl = dp->exclude_file->first; excl != NULL;
1182 excl = excl->next) {
1183 qname = quote_string(excl->name);
1184 exc = newvstralloc( exc, "exclude-file=", qname, ";", NULL);
1185 strappend(exclude_file, exc);
1189 exclude_list = stralloc("");
1190 if (dp->exclude_list != NULL && dp->exclude_list->nb_element > 0) {
1191 for(excl = dp->exclude_list->first; excl != NULL;
1192 excl = excl->next) {
1193 qname = quote_string(excl->name);
1194 exc = newvstralloc( exc, "exclude-list=", qname, ";", NULL);
1195 strappend(exclude_list, exc);
1200 include_file = stralloc("");
1201 if (dp->include_file != NULL && dp->include_file->nb_element > 0) {
1202 for(excl = dp->include_file->first; excl != NULL;
1203 excl = excl->next) {
1204 qname = quote_string(excl->name);
1205 exc = newvstralloc(exc, "include-file=", qname, ";", NULL);
1206 strappend(include_file, exc);
1210 include_list = stralloc("");
1211 if (dp->include_list != NULL && dp->include_list->nb_element > 0) {
1212 for(excl = dp->include_list->first; excl != NULL;
1213 excl = excl->next) {
1214 qname = quote_string(excl->name);
1215 exc = newvstralloc(exc, "include-list=", qname, ";", NULL);
1216 strappend(include_list, exc);
1221 if (dp->exclude_optional) {
1222 excl_opt = "exclude-optional;";
1224 if (dp->include_optional) {
1225 incl_opt = "include-optional;";
1228 result = vstralloc(";",
1245 amfree(exclude_list);
1246 amfree(exclude_file);
1247 amfree(include_file);
1248 amfree(include_list);
1250 amfree(decrypt_opt);
1251 amfree(encrypt_opt);
1253 /* result contains at least 'auth=...' */
1258 am_feature_t *features;
1262 /* A GHFunc (callback for g_hash_table_foreach) */
1263 static void xml_property(
1266 gpointer user_data_p)
1269 property_t *property = value_p;
1270 xml_app_t *xml_app = user_data_p;
1274 strbuf = g_string_new(xml_app->result);
1276 tmp = amxml_format_tag("name", (char *)key_p);
1277 g_string_append_printf(strbuf, " <property>\n %s\n", tmp);
1280 // TODO if client have fe_xml_property_priority
1281 if (property->priority
1282 && am_has_feature(xml_app->features, fe_xml_property_priority))
1283 g_string_append(strbuf, " <priority>yes</priority>\n");
1285 for (value = property->values; value != NULL; value = value->next) {
1286 tmp = amxml_format_tag("value", value->data);
1287 g_string_append_printf(strbuf, " %s", tmp);
1290 g_string_append_printf(strbuf, "\n </property>\n");
1292 g_free(xml_app->result);
1293 xml_app->result = g_string_free(strbuf, FALSE);
1304 char *encrypt_opt = stralloc("");
1305 char *decrypt_opt = stralloc("");
1308 char *data_path_opt = stralloc("");
1309 char *exclude = stralloc("");
1310 char *exclude_file = NULL;
1311 char *exclude_list = NULL;
1312 char *include = stralloc("");
1313 char *include_file = NULL;
1314 char *include_list = NULL;
1315 char *excl_opt = "";
1316 char *incl_opt = "";
1319 char *result = NULL;
1323 am_feature_t *their_features = dp->host->features;
1326 assert(dp->host != NULL);
1328 qdpname = quote_string(dp->name);
1329 if (am_has_feature(their_features, fe_options_auth)) {
1330 auth_opt = vstralloc(" <auth>", dp->auth, "</auth>\n", NULL);
1332 auth_opt = stralloc("");
1335 switch(dp->compress) {
1337 compress_opt = stralloc(" <compress>FAST</compress>\n");
1340 compress_opt = stralloc(" <compress>BEST</compress>\n");
1343 compress_opt = vstralloc(" <compress>CUSTOM"
1344 "<custom-compress-program>",
1346 "</custom-compress-program>\n"
1347 " </compress>\n", NULL);
1349 case COMP_SERVER_FAST:
1350 compress_opt = stralloc(" <compress>SERVER-FAST</compress>\n");
1352 case COMP_SERVER_BEST:
1353 compress_opt = stralloc(" <compress>SERVER-BEST</compress>\n");
1355 case COMP_SERVER_CUST:
1356 compress_opt = vstralloc(" <compress>SERVER-CUSTOM"
1357 "<custom-compress-program>",
1359 "</custom-compress-program>\n"
1360 " </compress>\n", NULL);
1363 compress_opt = stralloc("");
1366 switch(dp->encrypt) {
1368 if (dp->clnt_decrypt_opt) {
1369 decrypt_opt = newvstralloc(decrypt_opt,
1370 " <decrypt-option>",
1371 dp->clnt_decrypt_opt,
1372 "</decrypt-option>\n", NULL);
1375 encrypt_opt = newvstralloc(encrypt_opt,
1377 "<custom-encrypt-program>",
1379 "</custom-encrypt-program>\n",
1381 " </encrypt>\n", NULL);
1384 case ENCRYPT_SERV_CUST:
1386 decrypt_opt = newvstralloc(decrypt_opt,
1387 " <decrypt-option>",
1388 dp->srv_decrypt_opt,
1389 "</decrypt-option>\n", NULL);
1390 encrypt_opt = newvstralloc(encrypt_opt,
1391 " <encrypt>SERVER-CUSTOM"
1392 "<custom-encrypt-program>",
1394 "</custom-encrypt-program>\n",
1396 " </encrypt>\n", NULL);
1402 record_opt = " <record>NO</record>\n";
1404 record_opt = " <record>YES</record>\n";
1408 index_opt = " <index>YES</index>\n";
1414 kencrypt_opt = " <kencrypt>YES</kencrypt>\n";
1419 if (am_has_feature(their_features, fe_xml_data_path)) {
1420 switch(dp->data_path) {
1421 case DATA_PATH_AMANDA:
1422 amfree(data_path_opt);
1423 data_path_opt = stralloc(" <datapath>AMANDA</datapath>\n");
1425 case DATA_PATH_DIRECTTCP:
1426 { /* dp->dataport_list is not set for selfcheck/sendsize */
1427 if (am_has_feature(their_features, fe_xml_directtcp_list)) {
1429 char *value, *b64value;
1431 amfree(data_path_opt);
1432 data_path_opt = stralloc(" <datapath>DIRECTTCP");
1433 if (dp->dataport_list) {
1434 s = sc = stralloc(dp->dataport_list);
1442 b64value = amxml_format_tag("directtcp", value);
1443 vstrextend(&data_path_opt, "\n ", b64value, NULL);
1447 strappend(data_path_opt, "\n ");
1449 strappend(data_path_opt, "</datapath>\n");
1456 exclude_file = stralloc("");
1457 if (dp->exclude_file != NULL && dp->exclude_file->nb_element > 0) {
1458 for(excl = dp->exclude_file->first; excl != NULL;
1459 excl = excl->next) {
1460 q64name = amxml_format_tag("file", excl->name);
1461 exc = newvstralloc( exc, " ", q64name, "\n", NULL);
1462 strappend(exclude_file, exc);
1466 exclude_list = stralloc("");
1467 if (dp->exclude_list != NULL && dp->exclude_list->nb_element > 0) {
1468 for(excl = dp->exclude_list->first; excl != NULL;
1469 excl = excl->next) {
1470 q64name = amxml_format_tag("list", excl->name);
1471 exc = newvstralloc(exc, " ", q64name, "\n", NULL);
1472 strappend(exclude_list, exc);
1477 include_file = stralloc("");
1478 if (dp->include_file != NULL && dp->include_file->nb_element > 0) {
1479 for(excl = dp->include_file->first; excl != NULL;
1480 excl = excl->next) {
1481 q64name = amxml_format_tag("file", excl->name);
1482 exc = newvstralloc( exc, " ", q64name, "\n", NULL);
1483 strappend(include_file, exc);
1487 include_list = stralloc("");
1488 if (dp->include_list != NULL && dp->include_list->nb_element > 0) {
1489 for(excl = dp->include_list->first; excl != NULL;
1490 excl = excl->next) {
1491 q64name = amxml_format_tag("list", excl->name);
1492 exc = newvstralloc( exc, " ", q64name, "\n", NULL);
1493 strappend(include_list, exc);
1498 if (dp->exclude_optional) {
1499 excl_opt = " <optional>YES</optional>\n";
1501 if (dp->include_optional) {
1502 incl_opt = " <optional>YES</optional>\n";
1505 if (dp->exclude_file || dp->exclude_list)
1506 exclude = newvstralloc(exclude,
1511 " </exclude>\n", NULL);
1512 if (dp->include_file || dp->include_list)
1513 include = newvstralloc(include,
1518 " </include>\n", NULL);
1519 script_opt = xml_scripts(dp->pp_scriptlist, their_features);
1520 result = vstralloc(auth_opt,
1534 amfree(data_path_opt);
1535 amfree(compress_opt);
1537 amfree(exclude_list);
1538 amfree(exclude_file);
1540 amfree(include_file);
1541 amfree(include_list);
1543 amfree(decrypt_opt);
1544 amfree(encrypt_opt);
1547 /* result contains at least 'auth=...' */
1552 xml_dumptype_properties(
1555 xml_app_t xml_dumptype;
1557 xml_dumptype.result = g_strdup("");
1558 xml_dumptype.features = NULL;
1559 if (dp && dp->config) {
1560 g_hash_table_foreach(dumptype_get_property(dp->config), xml_property,
1563 return xml_dumptype.result;
1568 estimatelist_t estimatelist,
1569 am_feature_t *their_features)
1574 if (am_has_feature(their_features, fe_xml_estimatelist)) {
1575 vstrextend(&l, " <estimate>", NULL);
1576 for (el=estimatelist; el != NULL; el = el->next) {
1577 switch (GPOINTER_TO_INT(el->data)) {
1578 case ES_CLIENT : vstrextend(&l, "CLIENT ", NULL); break;
1579 case ES_SERVER : vstrextend(&l, "SERVER ", NULL); break;
1580 case ES_CALCSIZE: vstrextend(&l, "CALCSIZE ", NULL); break;
1583 vstrextend(&l, "</estimate>", NULL);
1584 } else { /* add the first estimate only */
1585 if (am_has_feature(their_features, fe_xml_estimate)) {
1586 vstrextend(&l, " <estimate>", NULL);
1587 switch (GPOINTER_TO_INT(estimatelist->data)) {
1588 case ES_CLIENT : vstrextend(&l, "CLIENT", NULL); break;
1589 case ES_SERVER : vstrextend(&l, "SERVER", NULL); break;
1590 case ES_CALCSIZE: vstrextend(&l, "CALCSIZE", NULL); break;
1593 vstrextend(&l, "</estimate>", NULL);
1594 if (GPOINTER_TO_INT(estimatelist->data) == ES_CALCSIZE) {
1595 vstrextend(&l, " <calcsize>YES</calcsize>", NULL);
1603 clean_dle_str_for_client(
1605 am_feature_t *their_features)
1608 char *hack1, *hack2;
1609 char *pend, *pscript, *pproperty, *eproperty;
1615 rval_dle_str = stralloc(dle_str);
1617 /* Remove everything between " <encrypt>SERVER-CUSTOM" and "</encrypt>\n"
1619 #define SC "</encrypt>\n"
1620 #define SC_LEN strlen(SC)
1621 hack1 = strstr(rval_dle_str, " <encrypt>SERVER-CUSTOM");
1623 hack2 = strstr(hack1, SC);
1624 /* +1 is to also move the trailing '\0' */
1625 memmove(hack1, hack2 + SC_LEN, strlen(hack2 + SC_LEN) + 1);
1630 if (!am_has_feature(their_features, fe_dumptype_property)) {
1631 #define SC "</property>\n"
1632 #define SC_LEN strlen(SC)
1633 /* remove all dle properties, they are before backup-program or script
1635 hack1 = rval_dle_str;
1636 pend = strstr(rval_dle_str, "<backup-program>");
1637 pscript = strstr(rval_dle_str, "<script>");
1638 if (pscript && pscript < pend)
1640 if (!pend) /* the complete string */
1641 pend = rval_dle_str + strlen(rval_dle_str);
1643 pproperty = strstr(hack1, " <property>");
1644 if (pproperty && pproperty < pend) { /* remove it */
1645 eproperty = strstr(pproperty, SC);
1646 len = eproperty + SC_LEN - pproperty;
1647 memmove(pproperty, eproperty + SC_LEN, strlen(eproperty + SC_LEN) + 1);
1659 return rval_dle_str;
1665 disk_t *dp G_GNUC_UNUSED,
1666 application_t *application,
1667 am_feature_t *their_features)
1673 proplist_t proplist;
1675 xml_app.features = their_features;
1676 xml_app.result = NULL;
1677 plugin = application_get_plugin(application);
1678 b64plugin = amxml_format_tag("plugin", plugin);
1679 xml_app.result = vstralloc(" <backup-program>\n",
1680 " ", b64plugin, "\n",
1682 proplist = application_get_property(application);
1683 g_hash_table_foreach(proplist, xml_property, &xml_app);
1685 client_name = application_get_client_name(application);
1686 if (client_name && strlen(client_name) > 0 &&
1687 am_has_feature(their_features, fe_application_client_name)) {
1688 char *b64client_name = amxml_format_tag("client_name", client_name);
1689 vstrextend(&xml_app.result, " ", b64client_name, "\n", NULL);
1692 vstrextend(&xml_app.result, " </backup-program>\n", NULL);
1696 return xml_app.result;
1702 identlist_t pp_scriptlist,
1703 am_feature_t *their_features)
1713 execute_on_t execute_on;
1715 proplist_t proplist;
1716 identlist_t pp_iter;
1717 pp_script_t *pp_script;
1720 xml_app.features = their_features;
1722 xml_scr = stralloc("");
1723 for (pp_iter = pp_scriptlist; pp_iter != NULL;
1724 pp_iter = pp_iter->next) {
1725 char *pp_script_name = pp_iter->data;
1726 pp_script = lookup_pp_script(pp_script_name);
1727 g_assert(pp_script != NULL);
1728 plugin = pp_script_get_plugin(pp_script);
1729 b64plugin = amxml_format_tag("plugin", plugin);
1730 xml_scr1 = vstralloc(" <script>\n",
1731 " ", b64plugin, "\n",
1734 execute_where = pp_script_get_execute_where(pp_script);
1735 switch (execute_where) {
1736 case ES_CLIENT: str = "CLIENT"; break;
1737 case ES_SERVER: str = "SERVER"; break;
1739 xml_scr1 = vstrextend(&xml_scr1, " <execute_where>",
1740 str, "</execute_where>\n", NULL);
1742 execute_on = pp_script_get_execute_on(pp_script);
1744 eo_str = stralloc("");
1745 if (execute_on & EXECUTE_ON_PRE_DLE_AMCHECK) {
1746 eo_str = vstrextend(&eo_str, sep, "PRE-DLE-AMCHECK", NULL);
1749 if (execute_on & EXECUTE_ON_PRE_HOST_AMCHECK) {
1750 eo_str = vstrextend(&eo_str, sep, "PRE-HOST-AMCHECK", NULL);
1753 if (execute_on & EXECUTE_ON_POST_DLE_AMCHECK) {
1754 eo_str = vstrextend(&eo_str, sep, "POST-DLE-AMCHECK", NULL);
1757 if (execute_on & EXECUTE_ON_POST_HOST_AMCHECK) {
1758 eo_str = vstrextend(&eo_str, sep, "POST-HOST-AMCHECK", NULL);
1761 if (execute_on & EXECUTE_ON_PRE_DLE_ESTIMATE) {
1762 eo_str = vstrextend(&eo_str, sep, "PRE-DLE-ESTIMATE", NULL);
1765 if (execute_on & EXECUTE_ON_PRE_HOST_ESTIMATE) {
1766 eo_str = vstrextend(&eo_str, sep, "PRE-HOST-ESTIMATE", NULL);
1769 if (execute_on & EXECUTE_ON_POST_DLE_ESTIMATE) {
1770 eo_str = vstrextend(&eo_str, sep, "POST-DLE-ESTIMATE", NULL);
1773 if (execute_on & EXECUTE_ON_POST_HOST_ESTIMATE) {
1774 eo_str = vstrextend(&eo_str, sep, "POST-HOST-ESTIMATE", NULL);
1777 if (execute_on & EXECUTE_ON_PRE_DLE_BACKUP) {
1778 eo_str = vstrextend(&eo_str, sep, "PRE-DLE-BACKUP", NULL);
1781 if (execute_on & EXECUTE_ON_PRE_HOST_BACKUP) {
1782 eo_str = vstrextend(&eo_str, sep, "PRE-HOST-BACKUP", NULL);
1785 if (execute_on & EXECUTE_ON_POST_DLE_BACKUP) {
1786 eo_str = vstrextend(&eo_str, sep, "POST-DLE-BACKUP", NULL);
1789 if (execute_on & EXECUTE_ON_POST_HOST_BACKUP) {
1790 eo_str = vstrextend(&eo_str, sep, "POST-HOST-BACKUP", NULL);
1793 if (execute_on & EXECUTE_ON_PRE_RECOVER) {
1794 eo_str = vstrextend(&eo_str, sep, "PRE-RECOVER", NULL);
1797 if (execute_on & EXECUTE_ON_POST_RECOVER) {
1798 eo_str = vstrextend(&eo_str, sep, "POST-RECOVER", NULL);
1801 if (execute_on & EXECUTE_ON_PRE_LEVEL_RECOVER) {
1802 eo_str = vstrextend(&eo_str, sep, "PRE-LEVEL-RECOVER", NULL);
1805 if (execute_on & EXECUTE_ON_POST_LEVEL_RECOVER) {
1806 eo_str = vstrextend(&eo_str, sep, "POST-LEVEL-RECOVER", NULL);
1809 if (execute_on & EXECUTE_ON_INTER_LEVEL_RECOVER) {
1810 eo_str = vstrextend(&eo_str, sep, "INTER-LEVEL-RECOVER", NULL);
1813 if (execute_on != 0)
1814 xml_scr1 = vstrextend(&xml_scr1,
1815 " <execute_on>", eo_str,
1816 "</execute_on>\n", NULL);
1818 proplist = pp_script_get_property(pp_script);
1819 xml_app.result = stralloc("");
1820 g_hash_table_foreach(proplist, xml_property, &xml_app);
1822 client_name = pp_script_get_client_name(pp_script);
1823 if (client_name && strlen(client_name) > 0 &&
1824 am_has_feature(their_features, fe_script_client_name)) {
1825 char *b64client_name = amxml_format_tag("client_name",
1827 vstrextend(&xml_app.result, " ", b64client_name, "\n", NULL);
1830 xml_scr = vstrextend(&xml_scr, xml_scr1, xml_app.result, " </script>\n", NULL);
1832 amfree(xml_app.result);
1845 for (dp = origqp->head; dp != NULL; dp = dp->next) {
1846 if (dp->ignore || dp->strategy == DS_SKIP)
1855 gboolean exact_match,
1859 char *prevhost = NULL;
1860 char *errstr = NULL;
1867 char **new_sargv = NULL;
1873 new_sargv = g_new0(char *, sargc+1);
1874 for (i=0; i<sargc; i++) {
1875 if (*sargv[i] == '=') {
1876 new_sargv[i] = g_strdup(sargv[i]);
1878 new_sargv[i] = g_strconcat("=", sargv[i], NULL);
1885 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1891 for(i=0;i<sargc;i++) {
1893 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1894 if(match_host(sargv[i], dp->host->hostname))
1899 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1900 if(prevhost != NULL &&
1901 match_host(prevhost, dp->host->hostname) &&
1902 (match_disk(sargv[i], dp->name) ||
1903 (dp->device && match_disk(sargv[i], dp->device)))) {
1905 error(_("Argument %s cannot be both a host and a disk"),sargv[i]);
1909 if(dp->todo == -1) {
1913 } else if (dp->todo == 0) {
1917 } else { /* dp->todo == 1 */
1925 if(match_a_host == 1) {
1926 if(prev_match == 1) { /* all disk of the previous host */
1927 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1928 if(match_host(prevhost,dp->host->hostname))
1929 if(dp->todo == -1) {
1934 if (!match_a_disk) {
1936 errstr1 = vstrallocf(_("All disks on host '%s' are ignored or have strategy \"skip\".\n"), prevhost);
1937 vstrextend(&errstr, errstr1, NULL);
1941 prevhost = sargv[i];
1946 if (strchr(sargv[i], (int)'\\')) {
1947 errstr1 = vstrallocf(_("Argument '%s' matches neither a host nor a disk; quoting may not be correct.\n"), sargv[i]);
1949 errstr1 = vstrallocf(_("Argument '%s' matches neither a host nor a disk.\n"), sargv[i]);
1951 vstrextend(&errstr, errstr1, NULL);
1955 } else if (dp_skip) {
1957 if (dp_skip->strategy == DS_SKIP) {
1958 errstr1 = vstrallocf(_("Argument '%s' matches a disk with strategy \"skip\".\n"), sargv[i]);
1960 errstr1 = vstrallocf(_("Argument '%s' matches a disk marked \"ignore\".\n"), sargv[i]);
1962 vstrextend(&errstr, errstr1, NULL);
1968 if(prev_match == 1) { /* all disk of the previous host */
1970 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1971 if(match_host(prevhost,dp->host->hostname))
1972 if(dp->todo == -1) {
1977 if (!match_a_disk) {
1979 errstr1 = vstrallocf(_("All disks on host '%s' are ignored or have strategy \"skip\".\n"), prevhost);
1980 vstrextend(&errstr, errstr1, NULL);
1985 for(dp = origqp->head; dp != NULL; dp = dp->next) {
1991 for (i=0; i<sargc; i++)
1992 g_free(new_sargv[i]);
2001 gboolean exact_match,
2009 /* rather than try to reproduce the adaptive matching logic in
2010 * match_disklist, this simply creates a new, fake disklist with one
2011 * element in it, and calls match_disklist directly */
2013 bzero(&h, sizeof(h));
2014 h.hostname = file->name;
2017 bzero(&d, sizeof(d));
2019 d.hostname = file->name;
2020 d.name = file->disk;
2021 d.device = file->disk;
2024 dl.head = dl.tail = &d;
2026 (void)match_disklist(&dl, exact_match, sargc, sargv);
2031 disklist_netifs(void)
2038 static void dump_disk(const disk_t *);
2039 static void dump_disklist(const disklist_t *);
2040 int main(int, char *[]);
2046 g_printf(_(" DISK %s (HOST %s, LINE %d) TYPE %s NAME %s SPINDLE %d\n"),
2047 dp->name, dp->host->hostname, dp->line, dp->dtype_name,
2048 dp->name == NULL? "(null)": dp->name,
2054 const disklist_t * lst)
2056 const disk_t *dp, *prev;
2057 const am_host_t *hp;
2059 if(hostlist == NULL) {
2060 g_printf(_("DISKLIST not read in\n"));
2064 g_printf(_("DISKLIST BY HOSTNAME:\n"));
2066 for(hp = hostlist; hp != NULL; hp = hp->next) {
2067 char *if_name = NULL;
2068 if (hp->netif && hp->netif->config)
2069 if_name = interface_name(hp->netif->config);
2071 g_printf(_("HOST %s INTERFACE %s\n"),
2073 if_name ? _("(null)") : if_name);
2074 for(dp = hp->disks; dp != NULL; dp = dp->hostnext)
2080 g_printf(_("DISKLIST IN FILE ORDER:\n"));
2083 for(dp = lst->head; dp != NULL; prev = dp, dp = dp->next) {
2085 /* check pointers */
2086 if(dp->prev != prev) g_printf(_("*** prev pointer mismatch!\n"));
2087 if(dp->next == NULL && lst->tail != dp) g_printf(_("tail mismatch!\n"));
2097 char *conf_diskfile;
2102 * Configure program for internationalization:
2103 * 1) Only set the message locale for now.
2104 * 2) Set textdomain for all amanda related programs to "amanda"
2105 * We don't want to be forced to support dozens of message catalogs.
2107 setlocale(LC_MESSAGES, "C");
2108 textdomain("amanda");
2112 set_pname("diskfile");
2114 dbopen(DBG_SUBDIR_SERVER);
2116 /* Don't die when child closes pipe */
2117 signal(SIGPIPE, SIG_IGN);
2120 config_init(CONFIG_INIT_EXPLICIT_NAME, argv[1]);
2122 config_init(CONFIG_INIT_USE_CWD, NULL)
2125 if (config_errors(NULL) >= CFGERR_WARNINGS) {
2126 config_print_errors();
2127 if (config_errors(NULL) >= CFGERR_ERRORS) {
2128 g_critical(_("errors processing config file"));
2132 conf_diskfile = config_dir_relative(getconf_str(CNF_DISKFILE));
2133 result = read_diskfile(conf_diskfile, &lst);
2134 if(result == CFGERR_OK) {
2135 dump_disklist(&lst);
2137 config_print_errors();
2139 amfree(conf_diskfile);