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

📄 dnssec-signzone.c

📁 bind 9.3结合mysql数据库
💻 C
📖 第 1 页 / 共 4 页
字号:
	result = dns_master_dump(mctx, db, version, style, filename);	check_result(result, "dns_master_dump");	isc_mem_put(mctx, filename, filenamelen + 1);	dns_db_closeversion(db, &version, ISC_FALSE);	dns_db_detach(&db);}static voidprint_time(FILE *fp) {	time_t currenttime;	currenttime = time(NULL);	fprintf(fp, "; File written on %s", ctime(&currenttime));}static voidprint_version(FILE *fp) {	fprintf(fp, "; dnssec_signzone version " VERSION "\n");}static voidusage(void) {	fprintf(stderr, "Usage:\n");	fprintf(stderr, "\t%s [options] zonefile [keys]\n", program);	fprintf(stderr, "\n");	fprintf(stderr, "Version: %s\n", VERSION);	fprintf(stderr, "Options: (default value in parenthesis) \n");	fprintf(stderr, "\t-c class (IN)\n");	fprintf(stderr, "\t-d directory\n");	fprintf(stderr, "\t\tdirectory to find keyset files (.)\n");	fprintf(stderr, "\t-g:\t");	fprintf(stderr, "generate DS records from keyset files\n");	fprintf(stderr, "\t-s YYYYMMDDHHMMSS|+offset:\n");	fprintf(stderr, "\t\tRRSIG start time - absolute|offset (now - 1 hour)\n");	fprintf(stderr, "\t-e YYYYMMDDHHMMSS|+offset|\"now\"+offset]:\n");	fprintf(stderr, "\t\tRRSIG end time  - absolute|from start|from now "				"(now + 30 days)\n");	fprintf(stderr, "\t-i interval:\n");	fprintf(stderr, "\t\tcycle interval - resign "				"if < interval from end ( (end-start)/4 )\n");	fprintf(stderr, "\t-v debuglevel (0)\n");	fprintf(stderr, "\t-o origin:\n");	fprintf(stderr, "\t\tzone origin (name of zonefile)\n");	fprintf(stderr, "\t-f outfile:\n");	fprintf(stderr, "\t\tfile the signed zone is written in "				"(zonefile + .signed)\n");	fprintf(stderr, "\t-r randomdev:\n");	fprintf(stderr,	"\t\ta file containing random data\n");	fprintf(stderr, "\t-a:\t");	fprintf(stderr, "verify generated signatures\n");	fprintf(stderr, "\t-p:\t");	fprintf(stderr, "use pseudorandom data (faster but less secure)\n");	fprintf(stderr, "\t-t:\t");	fprintf(stderr, "print statistics\n");	fprintf(stderr, "\t-n ncpus (number of cpus present)\n");	fprintf(stderr, "\t-k key_signing_key\n");	fprintf(stderr, "\t-l lookasidezone\n");	fprintf(stderr, "\t-z:\t");	fprintf(stderr, "ignore KSK flag in DNSKEYs");	fprintf(stderr, "\n");	fprintf(stderr, "Signing Keys: ");	fprintf(stderr, "(default: all zone keys that have private keys)\n");	fprintf(stderr, "\tkeyfile (Kname+alg+tag)\n");	exit(0);}static voidremovetempfile(void) {	if (removefile)		isc_file_remove(tempfile);}static voidprint_stats(isc_time_t *timer_start, isc_time_t *timer_finish) {	isc_uint64_t runtime_us;   /* Runtime in microseconds */	isc_uint64_t runtime_ms;   /* Runtime in milliseconds */	isc_uint64_t sig_ms;	   /* Signatures per millisecond */	runtime_us = isc_time_microdiff(timer_finish, timer_start);	printf("Signatures generated:               %10d\n", nsigned);	printf("Signatures retained:                %10d\n", nretained);	printf("Signatures dropped:                 %10d\n", ndropped);	printf("Signatures successfully verified:   %10d\n", nverified);	printf("Signatures unsuccessfully verified: %10d\n", nverifyfailed);	runtime_ms = runtime_us / 1000;	printf("Runtime in seconds:                %7u.%03u\n", 	       (unsigned int) (runtime_ms / 1000), 	       (unsigned int) (runtime_ms % 1000));	if (runtime_us > 0) {		sig_ms = ((isc_uint64_t)nsigned * 1000000000) / runtime_us;		printf("Signatures per second:             %7u.%03u\n",		       (unsigned int) sig_ms / 1000, 		       (unsigned int) sig_ms % 1000);	}}intmain(int argc, char *argv[]) {	int i, ch;	char *startstr = NULL, *endstr = NULL, *classname = NULL;	char *origin = NULL, *file = NULL, *output = NULL;	char *dskeyfile[MAXDSKEYS];	int ndskeys = 0;	char *endp;	isc_time_t timer_start, timer_finish;	signer_key_t *key;	isc_result_t result;	isc_log_t *log = NULL;	isc_boolean_t pseudorandom = ISC_FALSE;	unsigned int eflags;	isc_boolean_t free_output = ISC_FALSE;	int tempfilelen;	dns_rdataclass_t rdclass;	dns_db_t *udb = NULL;	isc_task_t **tasks = NULL;	isc_buffer_t b;	int len;	masterstyle = &dns_master_style_explicitttl;	check_result(isc_app_start(), "isc_app_start");	result = isc_mem_create(0, 0, &mctx);	if (result != ISC_R_SUCCESS)		fatal("out of memory");	dns_result_register();	while ((ch = isc_commandline_parse(argc, argv,					   "ac:d:e:f:ghi:k:l:n:o:pr:s:Stv:z"))	       != -1) {		switch (ch) {		case 'a':			tryverify = ISC_TRUE;			break;		case 'c':			classname = isc_commandline_argument;			break;		case 'd':			directory = isc_commandline_argument;			break;		case 'e':			endstr = isc_commandline_argument;			break;		case 'f':			output = isc_commandline_argument;			break;		case 'g':			generateds = ISC_TRUE;			break;		case 'h':		default:			usage();			break;		case 'i':			endp = NULL;			cycle = strtol(isc_commandline_argument, &endp, 0);			if (*endp != '\0' || cycle < 0)				fatal("cycle period must be numeric and "				      "positive");			break;		case 'l': 			dns_fixedname_init(&dlv_fixed);			len = strlen(isc_commandline_argument);			isc_buffer_init(&b, isc_commandline_argument, len);			isc_buffer_add(&b, len);			dns_fixedname_init(&dlv_fixed);			dlv = dns_fixedname_name(&dlv_fixed);			result = dns_name_fromtext(dlv, &b, dns_rootname,						   ISC_FALSE, NULL);			check_result(result, "dns_name_fromtext(dlv)");			break;		case 'k':			if (ndskeys == MAXDSKEYS)				fatal("too many key-signing keys specified");			dskeyfile[ndskeys++] = isc_commandline_argument;			break;		case 'n':			endp = NULL;			ntasks = strtol(isc_commandline_argument, &endp, 0);			if (*endp != '\0' || ntasks > ISC_INT32_MAX)				fatal("number of cpus must be numeric");			break;		case 'o':			origin = isc_commandline_argument;			break;		case 'p':			pseudorandom = ISC_TRUE;			break;		case 'r':			setup_entropy(mctx, isc_commandline_argument, &ectx);			break;		case 's':			startstr = isc_commandline_argument;			break;		case 'S':			/* This is intentionally undocumented */			/* -S: simple output style */			masterstyle = &dns_master_style_simple;			break;		case 't':			printstats = ISC_TRUE;			break;		case 'v':			endp = NULL;			verbose = strtol(isc_commandline_argument, &endp, 0);			if (*endp != '\0')				fatal("verbose level must be numeric");			break;		case 'z':			ignoreksk = ISC_TRUE;			break;		}	}	if (ectx == NULL)		setup_entropy(mctx, NULL, &ectx);	eflags = ISC_ENTROPY_BLOCKING;	if (!pseudorandom)		eflags |= ISC_ENTROPY_GOODONLY;	result = dst_lib_init(mctx, ectx, eflags);	if (result != ISC_R_SUCCESS)		fatal("could not initialize dst");	isc_stdtime_get(&now);	if (startstr != NULL)		starttime = strtotime(startstr, now, now);	else		starttime = now - 3600;  /* Allow for some clock skew. */	if (endstr != NULL)		endtime = strtotime(endstr, now, starttime);	else		endtime = starttime + (30 * 24 * 60 * 60);	if (cycle == -1)		cycle = (endtime - starttime) / 4;	if (ntasks == 0)		ntasks = isc_os_ncpus();	vbprintf(4, "using %d cpus\n", ntasks);	rdclass = strtoclass(classname);	setup_logging(verbose, mctx, &log);	argc -= isc_commandline_index;	argv += isc_commandline_index;	if (argc < 1)		usage();	file = argv[0];	argc -= 1;	argv += 1;	if (origin == NULL)		origin = file;	if (output == NULL) {		free_output = ISC_TRUE;		output = isc_mem_allocate(mctx,					  strlen(file) + strlen(".signed") + 1);		if (output == NULL)			fatal("out of memory");		sprintf(output, "%s.signed", file);	}	result = dns_master_stylecreate(&dsstyle,  DNS_STYLEFLAG_NO_TTL,					0, 24, 0, 0, 0, 8, mctx);	check_result(result, "dns_master_stylecreate");						gdb = NULL;	TIME_NOW(&timer_start);	loadzone(file, origin, rdclass, &gdb);	gorigin = dns_db_origin(gdb);	gclass = dns_db_class(gdb);	zonettl = soattl();	ISC_LIST_INIT(keylist);	if (argc == 0) {		loadzonekeys(gdb);	} else {		for (i = 0; i < argc; i++) {			dst_key_t *newkey = NULL;			result = dst_key_fromnamedfile(argv[i],						       DST_TYPE_PUBLIC |						       DST_TYPE_PRIVATE,						       mctx, &newkey);			if (result != ISC_R_SUCCESS)				fatal("cannot load dnskey %s: %s", argv[i], 				      isc_result_totext(result)); 			key = ISC_LIST_HEAD(keylist);			while (key != NULL) {				dst_key_t *dkey = key->key;				if (dst_key_id(dkey) == dst_key_id(newkey) &&				    dst_key_alg(dkey) == dst_key_alg(newkey) &&				    dns_name_equal(dst_key_name(dkey),					    	   dst_key_name(newkey)))				{					if (!dst_key_isprivate(dkey))						fatal("cannot sign zone with "						      "non-private dnskey %s",						      argv[i]);					break;				}				key = ISC_LIST_NEXT(key, link);			}			if (key == NULL) {				key = newkeystruct(newkey, ISC_TRUE);				ISC_LIST_APPEND(keylist, key, link);			} else				dst_key_free(&newkey);		}		loadzonepubkeys(gdb);	}	for (i = 0; i < ndskeys; i++) {		dst_key_t *newkey = NULL;		result = dst_key_fromnamedfile(dskeyfile[i],					       DST_TYPE_PUBLIC |					       DST_TYPE_PRIVATE,					       mctx, &newkey);		if (result != ISC_R_SUCCESS)			fatal("cannot load dnskey %s: %s", dskeyfile[i],			      isc_result_totext(result)); 		key = ISC_LIST_HEAD(keylist);		while (key != NULL) {			dst_key_t *dkey = key->key;			if (dst_key_id(dkey) == dst_key_id(newkey) &&			    dst_key_alg(dkey) == dst_key_alg(newkey) &&			    dns_name_equal(dst_key_name(dkey),				    	   dst_key_name(newkey)))			{				/* Override key flags. */				key->issigningkey = ISC_TRUE;				key->isksk = ISC_TRUE;				key->isdsk = ISC_FALSE;				dst_key_free(&dkey);				key->key = newkey;				break;			}			key = ISC_LIST_NEXT(key, link);		}		if (key == NULL) {			/* Override dnskey flags. */			key = newkeystruct(newkey, ISC_TRUE);			key->isksk = ISC_TRUE;			key->isdsk = ISC_FALSE;			ISC_LIST_APPEND(keylist, key, link);		}	}	if (ISC_LIST_EMPTY(keylist)) {		fprintf(stderr, "%s: warning: No keys specified or found\n",			program);		nokeys = ISC_TRUE;	}	warnifallksk(gdb);	gversion = NULL;	result = dns_db_newversion(gdb, &gversion);	check_result(result, "dns_db_newversion()");	nsecify();	if (!nokeys) {		writeset("keyset-", dns_rdatatype_dnskey);		writeset("dsset-", dns_rdatatype_ds);		if (dlv != NULL) {			writeset("dlvset-", dns_rdatatype_dlv);		}	}	tempfilelen = strlen(output) + 20;	tempfile = isc_mem_get(mctx, tempfilelen);	if (tempfile == NULL)		fatal("out of memory");	result = isc_file_mktemplate(output, tempfile, tempfilelen);	check_result(result, "isc_file_mktemplate");	fp = NULL;	result = isc_file_openunique(tempfile, &fp);	if (result != ISC_R_SUCCESS)		fatal("failed to open temporary output file: %s",		      isc_result_totext(result));	removefile = ISC_TRUE;	setfatalcallback(&removetempfile);	print_time(fp);	print_version(fp);	result = isc_taskmgr_create(mctx, ntasks, 0, &taskmgr);	if (result != ISC_R_SUCCESS)		fatal("failed to create task manager: %s",		      isc_result_totext(result));	master = NULL;	result = isc_task_create(taskmgr, 0, &master);	if (result != ISC_R_SUCCESS)		fatal("failed to create task: %s", isc_result_totext(result));	tasks = isc_mem_get(mctx, ntasks * sizeof(isc_task_t *));	if (tasks == NULL)		fatal("out of memory");	for (i = 0; i < (int)ntasks; i++) {		tasks[i] = NULL;		result = isc_task_create(taskmgr, 0, &tasks[i]);		if (result != ISC_R_SUCCESS)			fatal("failed to create task: %s",			      isc_result_totext(result));		result = isc_app_onrun(mctx, master, startworker, tasks[i]);		if (result != ISC_R_SUCCESS)			fatal("failed to start task: %s",			      isc_result_totext(result));	}	RUNTIME_CHECK(isc_mutex_init(&namelock) == ISC_R_SUCCESS);	if (printstats)		RUNTIME_CHECK(isc_mutex_init(&statslock) == ISC_R_SUCCESS);	presign();	(void)isc_app_run();	if (!finished)		fatal("process aborted by user");	shuttingdown = ISC_TRUE;	for (i = 0; i < (int)ntasks; i++)		isc_task_detach(&tasks[i]);	isc_taskmgr_destroy(&taskmgr);	isc_mem_put(mctx, tasks, ntasks * sizeof(isc_task_t *));	postsign();	if (udb != NULL) {		dumpdb(udb);		dns_db_detach(&udb);	}	result = isc_stdio_close(fp);	check_result(result, "isc_stdio_close");	removefile = ISC_FALSE;	result = isc_file_rename(tempfile, output);	if (result != ISC_R_SUCCESS)		fatal("failed to rename temp file to %s: %s\n",		      output, isc_result_totext(result));	DESTROYLOCK(&namelock);	if (printstats)		DESTROYLOCK(&statslock);	printf("%s\n", output);	dns_db_closeversion(gdb, &gversion, ISC_FALSE);	dns_db_detach(&gdb);	while (!ISC_LIST_EMPTY(keylist)) {		key = ISC_LIST_HEAD(keylist);		ISC_LIST_UNLINK(keylist, key, link);		dst_key_free(&key->key);		isc_mem_put(mctx, key, sizeof(signer_key_t));	}	isc_mem_put(mctx, tempfile, tempfilelen);	if (free_output)		isc_mem_free(mctx, output);	dns_master_styledestroy(&dsstyle, mctx);	cleanup_logging(&log);	dst_lib_destroy();	cleanup_entropy(&ectx);	if (verbose > 10)		isc_mem_stats(mctx, stdout);	isc_mem_destroy(&mctx);	(void) isc_app_finish();	if (printstats) {		TIME_NOW(&timer_finish);		print_stats(&timer_start, &timer_finish);	}	return (0);}

⌨️ 快捷键说明

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