⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 diskfile.c

📁 开源备份软件源码 AMANDA, the Advanced Maryland Automatic Network Disk Archiver, is a backup system that a
💻 C
📖 第 1 页 / 共 3 页
字号:
	 encrypt_opt = newvstralloc(encrypt_opt, "encrypt-cust=",				    dp->clnt_encrypt, ";", NULL);	 if (BSTRNCMP(encrypt_opt, "encrypt-cust=;") == 0) {	    if(fdout) {	      g_fprintf(fdout,		      _("ERROR: %s:%s encrypt client with no encryption program specified\n"),		      dp->host->hostname, qdpname);	    }	    err++;	  }	 if ( dp->compress == COMP_SERVER_FAST || 	      dp->compress == COMP_SERVER_BEST ||	      dp->compress == COMP_SERVER_CUST ) {	   if(fdout) {	      g_fprintf(fdout,		      _("ERROR: %s:Client encryption with server compression is "			"not supported. See amanda.conf(5) for detail.\n"), 			dp->host->hostname);	    }	    err++;	  }	 if(dp->clnt_decrypt_opt) {	   if(am_has_feature(their_features, fe_options_client_decrypt_option)) {	     decrypt_opt = newvstralloc(decrypt_opt, "client-decrypt-option=",					dp->clnt_decrypt_opt, ";", NULL);	   }	   else if(fdout) {	    g_fprintf(fdout,		    _("WARNING: %s:%s does not support client decrypt option\n"),		    dp->host->hostname, qdpname);	   }	 }      }      else if(fdout) {	    g_fprintf(fdout,		    _("WARNING: %s:%s does not support client data encryption\n"),		    dp->host->hostname, qdpname);     }	 break;    case ENCRYPT_SERV_CUST:      if(am_has_feature(their_features, fe_options_encrypt_serv_cust)) {	 encrypt_opt = newvstralloc(encrypt_opt, "encrypt-serv-cust=",				    dp->srv_encrypt, ";", NULL);	 if (BSTRNCMP(encrypt_opt, "encrypt-serv-cust=;") == 0){	    if(fdout) {	      g_fprintf(fdout,		      _("ERROR: %s:%s No encryption program specified in dumptypes\n"),		      dp->host->hostname, qdpname);	      g_fprintf(fdout, _("Change the dumptype in the disklist or mention "			       "the ecnryption program to use in the dumptypes file"));	    }	    err++;	  }	 if(dp->srv_decrypt_opt) {	   if(am_has_feature(their_features, fe_options_server_decrypt_option)) {	     decrypt_opt = newvstralloc(decrypt_opt, "server-decrypt-option=",					dp->srv_decrypt_opt, ";", NULL);	   }	   else if(fdout) {	    g_fprintf(fdout,		    _("WARNING: %s:%s does not support server decrypt option\n"),		    dp->host->hostname, qdpname);	   }	 }      }      else if(fdout) {	    g_fprintf(fdout,		    _("WARNING: %s:%s does not support server data encryption\n"),		    dp->host->hostname, qdpname);      }	 break;    }        if(!dp->record) {	if(am_has_feature(their_features, fe_options_no_record)) {	    record_opt = "no-record;";	}	else if(fdout) {	    g_fprintf(fdout, _("WARNING: %s:%s does not support no record\n"),		    dp->host->hostname, qdpname);	}    }    if(dp->index) {	if(am_has_feature(their_features, fe_options_index)) {	    index_opt = "index;";	}	else if(fdout) {	    g_fprintf(fdout, _("WARNING: %s:%s does not support index\n"),		    dp->host->hostname, qdpname);	}    }    if(dp->kencrypt) kencrypt_opt = "kencrypt;";    exclude_file = stralloc("");    nb_exclude_file = 0;    if(dp->exclude_file != NULL && dp->exclude_file->nb_element > 0) {	nb_exclude_file = dp->exclude_file->nb_element;	if(am_has_feature(their_features, fe_options_exclude_file)) {	    if(am_has_feature(their_features, fe_options_multiple_exclude) ||	       dp->exclude_file->nb_element == 1) {		for(excl = dp->exclude_file->first; excl != NULL;						    excl = excl->next) {		    qname = quote_string(excl->name);		    exc = newvstralloc( exc, "exclude-file=", qname, ";", NULL);		    strappend(exclude_file, exc);		    amfree(qname);		}	    } else {		qname = quote_string(dp->exclude_file->last->name);		exc = newvstralloc(exc, "exclude-file=", qname, ";", NULL);		strappend(exclude_file, exc);		if(fdout) {		    g_fprintf(fdout,		       _("WARNING: %s:%s does not support multiple exclude\n"),		       dp->host->hostname, qdpname);		}		amfree(qname);	    }	} else if(fdout) {	    g_fprintf(fdout, _("WARNING: %s:%s does not support exclude file\n"),		    dp->host->hostname, qdpname);	}    }    exclude_list = stralloc("");    if(dp->exclude_list != NULL && dp->exclude_list->nb_element > 0) {	if(am_has_feature(their_features, fe_options_exclude_list)) {	    if(am_has_feature(their_features, fe_options_multiple_exclude) ||	       (dp->exclude_list->nb_element == 1 && nb_exclude_file == 0)) {		for(excl = dp->exclude_list->first; excl != NULL;						    excl = excl->next) {		    qname = quote_string(excl->name);		    exc = newvstralloc( exc, "exclude-list=", qname, ";", NULL);		    strappend(exclude_list, exc);		    amfree(qname);		}	    } else {		qname = quote_string(dp->exclude_list->last->name);		exc = newvstralloc(exc, "exclude-list=", qname, ";", NULL);		strappend(exclude_list, exc);		if(fdout) {			g_fprintf(fdout,			 _("WARNING: %s:%s does not support multiple exclude\n"),			 dp->host->hostname, qdpname);		}		amfree(qname);	    }	} else if(fdout) {	    g_fprintf(fdout, _("WARNING: %s:%s does not support exclude list\n"),		    dp->host->hostname, qdpname);	}    }    include_file = stralloc("");    nb_include_file = 0;    if(dp->include_file != NULL && dp->include_file->nb_element > 0) {	nb_include_file = dp->include_file->nb_element;	if(am_has_feature(their_features, fe_options_include_file)) {	    if(am_has_feature(their_features, fe_options_multiple_include) ||	       dp->include_file->nb_element == 1) {		for(excl = dp->include_file->first; excl != NULL;						    excl = excl->next) {		    qname = quote_string(excl->name);		    exc = newvstralloc(exc, "include-file=", qname, ";", NULL);		    strappend(include_file, exc);		    amfree(qname);		}	    } else {		qname = quote_string(dp->include_file->last->name);		exc = newvstralloc(exc, "include-file=", qname, ";", NULL);		strappend(include_file, exc);		if(fdout) {		    g_fprintf(fdout,			 _("WARNING: %s:%s does not support multiple include\n"),			 dp->host->hostname, qdpname);		}		amfree(qname);	    }	} else if(fdout) {	    g_fprintf(fdout, _("WARNING: %s:%s does not support include file\n"),		    dp->host->hostname, qdpname);	}    }    include_list = stralloc("");    if(dp->include_list != NULL && dp->include_list->nb_element > 0) {	if(am_has_feature(their_features, fe_options_include_list)) {	    if(am_has_feature(their_features, fe_options_multiple_include) ||	       (dp->include_list->nb_element == 1 && nb_include_file == 0)) {		for(excl = dp->include_list->first; excl != NULL;						    excl = excl->next) {		    qname = quote_string(excl->name);		    exc = newvstralloc(exc, "include-list=", qname, ";", NULL);		    strappend(include_list, exc);		    amfree(qname);		}	    } else {		qname = quote_string(dp->include_list->last->name);		exc = newvstralloc(exc, "include-list=", qname, ";", NULL);		strappend(include_list, exc);		if(fdout) {			g_fprintf(fdout,			 _("WARNING: %s:%s does not support multiple include\n"),			 dp->host->hostname, qdpname);		}		amfree(qname);	    }	} else if(fdout) {	    g_fprintf(fdout, _("WARNING: %s:%s does not support include list\n"),		    dp->host->hostname, qdpname);	}    }    if(dp->exclude_optional) {	if(am_has_feature(their_features, fe_options_optional_exclude)) {	    excl_opt = "exclude-optional;";	}	else if(fdout) {	    g_fprintf(fdout,		    _("WARNING: %s:%s does not support optional exclude\n"),		    dp->host->hostname, qdpname);	}    }    if(dp->include_optional) {	if(am_has_feature(their_features, fe_options_optional_include)) {	   incl_opt = "include-optional;";	}	else if(fdout) {	    g_fprintf(fdout,		    _("WARNING: %s:%s does not support optional include\n"),		    dp->host->hostname, qdpname);	}    }    result = vstralloc(";",		       auth_opt,		       kencrypt_opt,		       compress_opt,		       encrypt_opt,		       decrypt_opt,		       record_opt,		       index_opt,		       exclude_file,		       exclude_list,		       include_file,		       include_list,		       excl_opt,		       incl_opt,		       NULL);    amfree(qdpname);    amfree(auth_opt);    amfree(exclude_list);    amfree(exclude_file);    amfree(include_file);    amfree(include_list);    amfree(exc);    amfree(decrypt_opt);    amfree(encrypt_opt);    /* result contains at least 'auth=...' */    if ( err ) {	amfree(result);	return NULL;    } else {	return result;    }} char *match_disklist(    disklist_t *origqp,    int		sargc,    char **	sargv){    char *prevhost = NULL;    char *errstr = NULL;    int i;    int match_a_host;    int match_a_disk;    int prev_match;    disk_t *dp;    if(sargc <= 0)	return NULL;    for(dp = origqp->head; dp != NULL; dp = dp->next) {	if(dp->todo == 1)	    dp->todo = -1;    }    prev_match = 0;    for(i=0;i<sargc;i++) {	match_a_host = 0;	for(dp = origqp->head; dp != NULL; dp = dp->next) {	    if(match_host(sargv[i], dp->host->hostname))		match_a_host = 1;	}	match_a_disk = 0;	for(dp = origqp->head; dp != NULL; dp = dp->next) {	    if(prevhost != NULL &&	       match_host(prevhost, dp->host->hostname) &&	       (match_disk(sargv[i], dp->name) ||		(dp->device && match_disk(sargv[i], dp->device)))) {		if(match_a_host) {		    error(_("Argument %s cannot be both a host and a disk"),sargv[i]);		    /*NOTREACHED*/		}		else {		    if(dp->todo == -1) {			dp->todo = 1;			match_a_disk = 1;			prev_match = 0;		    }		}	    }	}	if(!match_a_disk) {	    if(match_a_host == 1) {		if(prev_match == 1) { /* all disk of the previous host */		    for(dp = origqp->head; dp != NULL; dp = dp->next) {			if(match_host(prevhost,dp->host->hostname))			    if(dp->todo == -1)				dp->todo = 1;		    }		}		prevhost = sargv[i];		prev_match = 1;	    }	    else {		char *errstr1 = vstrallocf(_("Argument '%s' matches neither a host nor a disk.\n"), sargv[i]);		vstrextend(&errstr, errstr1, NULL);		prev_match = 0;	    }	}    }    if(prev_match == 1) { /* all disk of the previous host */	for(dp = origqp->head; dp != NULL; dp = dp->next) {	    if(match_host(prevhost,dp->host->hostname))		if(dp->todo == -1)		    dp->todo = 1;	}    }    for(dp = origqp->head; dp != NULL; dp = dp->next) {	if(dp->todo == -1)	    dp->todo = 0;    }    return errstr;}netif_t *disklist_netifs(void){    return all_netifs;}#ifdef TESTstatic void dump_disk(const disk_t *);static void dump_disklist(const disklist_t *);int main(int, char *[]);static voiddump_disk(    const disk_t *	dp){    g_printf(_("  DISK %s (HOST %s, LINE %d) TYPE %s NAME %s SPINDLE %d\n"),	   dp->name, dp->host->hostname, dp->line, dp->dtype_name,	   dp->name == NULL? "(null)": dp->name,	   dp->spindle);}static voiddump_disklist(    const disklist_t *	lst){    const disk_t *dp, *prev;    const am_host_t *hp;    if(hostlist == NULL) {	g_printf(_("DISKLIST not read in\n"));	return;    }    g_printf(_("DISKLIST BY HOSTNAME:\n"));    for(hp = hostlist; hp != NULL; hp = hp->next) {	char *if_name = NULL;	if (hp->netif && hp->netif->config)	    if_name = interface_name(hp->netif->config);	g_printf(_("HOST %s INTERFACE %s\n"),	       hp->hostname,	       if_name ? _("(null)") : if_name);	for(dp = hp->disks; dp != NULL; dp = dp->hostnext)	    dump_disk(dp);	putchar('\n');    }    g_printf(_("DISKLIST IN FILE ORDER:\n"));    prev = NULL;    for(dp = lst->head; dp != NULL; prev = dp, dp = dp->next) {	dump_disk(dp);	/* check pointers */	if(dp->prev != prev) g_printf(_("*** prev pointer mismatch!\n"));	if(dp->next == NULL && lst->tail != dp) g_printf(_("tail mismatch!\n"));    }}intmain(    int		argc,    char **	argv){  char *conffile;  char *conf_diskfile;  disklist_t lst;  int result;  /*   * Configure program for internationalization:   *   1) Only set the message locale for now.   *   2) Set textdomain for all amanda related programs to "amanda"   *      We don't want to be forced to support dozens of message catalogs.   */    setlocale(LC_MESSAGES, "C");  textdomain("amanda");   safe_fd(-1, 0);  set_pname("diskfile");  dbopen(DBG_SUBDIR_SERVER);  /* Don't die when child closes pipe */  signal(SIGPIPE, SIG_IGN);  if (argc>1) {    config_name = argv[1];    if (strchr(config_name, '/') != NULL) {      config_dir = stralloc2(argv[1], "/");      config_name = strrchr(config_name, '/') + 1;    } else {      config_dir = vstralloc(CONFIG_DIR, "/", config_name, "/", NULL);    }  } else {    config_dir = stralloc("");  }  conffile = stralloc2(config_dir, CONFFILE_NAME);  if((result = read_conffile(conffile)) == 0) {    conf_diskfile = config_dir_relative(getconf_str(CNF_DISKFILE));    result = read_diskfile(conf_diskfile, &lst);    if(result == 0) {      dump_disklist(&lst);    }    amfree(conf_diskfile);  }  amfree(conffile);  amfree(config_dir);  return result;}#endif /* TEST */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -