void log_fatal (const char * fmt, ... ) { va_list list; do_percentm (fbuf, fmt); /* %Audit% This is log output. %2004.06.17,Safe% * If we truncate we hope the user can get a hint from the log. */ va_start (list, fmt); vsnprintf (mbuf, sizeof mbuf, fbuf, list); va_end (list); #ifndef DEBUG syslog (log_priority | LOG_ERR, "%s", mbuf); #endif /* Also log it to stderr? */ if (log_perror) { IGNORE_RET (write (STDERR_FILENO, mbuf, strlen (mbuf))); IGNORE_RET (write (STDERR_FILENO, "\n", 1)); } #if !defined (NOMINUM) log_error ("%s", ""); log_error ("If you did not get this software from ftp.isc.org, please"); log_error ("get the latest from ftp.isc.org and install that before"); log_error ("requesting help."); log_error ("%s", ""); log_error ("If you did get this software from ftp.isc.org and have not"); log_error ("yet read the README, please read it before requesting help."); log_error ("If you intend to request help from the dhcp-bugs at isc.org"); log_error ("mailing list, please read the section on the README about"); log_error ("submitting bug reports and requests for help."); log_error ("%s", ""); log_error ("Please do not under any circumstances send requests for"); log_error ("help directly to the authors of this software - please"); log_error ("send them to the appropriate mailing list as described in"); log_error ("the README file."); log_error ("%s", ""); log_error ("exiting."); #endif if (log_cleanup) (*log_cleanup) (); exit (1); }
int log_debug (const char *fmt, ...) { va_list list; do_percentm (fbuf, fmt); /* %Audit% This is log output. %2004.06.17,Safe% * If we truncate we hope the user can get a hint from the log. */ va_start (list, fmt); vsnprintf (mbuf, sizeof mbuf, fbuf, list); va_end (list); #ifndef DEBUG syslog (log_priority | LOG_DEBUG, "%s", mbuf); #endif if (log_perror) { IGNORE_RET (write (STDERR_FILENO, mbuf, strlen (mbuf))); IGNORE_RET (write (STDERR_FILENO, "\n", 1)); } return 0; }
void log_fatal (const char * fmt, ... ) { va_list list; do_percentm (fbuf, fmt); /* %Audit% This is log output. %2004.06.17,Safe% * If we truncate we hope the user can get a hint from the log. */ va_start (list, fmt); vsnprintf (mbuf, sizeof mbuf, fbuf, list); va_end (list); #ifndef DEBUG syslog (log_priority | LOG_ERR, "%s", mbuf); #endif /* Also log it to stderr? */ if (log_perror) { IGNORE_RET (write (STDERR_FILENO, mbuf, strlen (mbuf))); IGNORE_RET (write (STDERR_FILENO, "\n", 1)); } log_error ("%s", ""); log_error ("If you think you have received this message due to a bug rather"); log_error ("than a configuration issue please read the section on submitting"); log_error ("bugs on either our web page at www.isc.org or in the README file"); log_error ("before submitting a bug. These pages explain the proper"); log_error ("process and the information we find helpful for debugging.."); log_error ("%s", ""); log_error ("exiting."); if (log_cleanup) (*log_cleanup) (); exit (1); }
int main(int argc, char **argv) { int c; int tnum; int subprocs; pid_t deadpid; int status; int len; isc_boolean_t first; testspec_t *pts; struct sigaction sa; #ifdef BIND_SUPPORT isc_mem_debugging = ISC_MEM_DEBUGRECORD; #endif /* BIND_SUPPORT */ first = ISC_TRUE; subprocs = 1; T_timeout = T_TCTOUT; /* * -a option is now default. */ memset(T_tvec, 0xffff, sizeof(T_tvec)); /* * Parse args. */ while ((c = isc_commandline_parse(argc, argv, ":at:c:d:n:huxq:b:")) != -1) { if (c == 'a') { /* * Flag all tests to be run. */ memset(T_tvec, 0xffff, sizeof(T_tvec)); } else if (c == 'b') { T_dir = isc_commandline_argument; } else if (c == 't') { tnum = atoi(isc_commandline_argument); if ((tnum > 0) && (tnum < T_MAXTESTS)) { if (first) { /* * Turn off effect of -a default * and allow multiple -t and -n * options. */ memset(T_tvec, 0, sizeof(T_tvec)); first = ISC_FALSE; } /* * Flag test tnum to be run. */ tnum -= 1; T_tvec[tnum / 8] |= (0x01 << (tnum % 8)); } } else if (c == 'c') { T_config = isc_commandline_argument; } else if (c == 'd') { T_debug = atoi(isc_commandline_argument); } else if (c == 'n') { pts = &T_testlist[0]; tnum = 0; while (pts->pfv != NULL) { if (! strcmp(pts->func_name, isc_commandline_argument)) { if (first) { memset(T_tvec, 0, sizeof(T_tvec)); first = ISC_FALSE; } T_tvec[tnum/8] |= (0x01 << (tnum%8)); break; } ++pts; ++tnum; } if (pts->pfv == NULL) { fprintf(stderr, "no such test %s\n", isc_commandline_argument); exit(1); } } else if (c == 'h') { printhelp(); exit(0); } else if (c == 'u') { printusage(); exit(0); } else if (c == 'x') { subprocs = 0; } else if (c == 'q') { T_timeout = atoi(isc_commandline_argument); } else if (c == ':') { fprintf(stderr, "Option -%c requires an argument\n", isc_commandline_option); exit(1); } else if (c == '?') { fprintf(stderr, "Unrecognized option -%c\n", isc_commandline_option); exit(1); } } /* * Set cwd. */ if (T_dir != NULL) IGNORE_RET (chdir(T_dir)); /* * We don't want buffered output. */ (void)setbuf(stdout, NULL); (void)setbuf(stderr, NULL); /* * Setup signals. */ sa.sa_flags = 0; sigfillset(&sa.sa_mask); #ifdef SIGCHLD /* * This is mostly here for NetBSD's pthread implementation, until * people catch up to the latest unproven-pthread package. */ sa.sa_handler = SIG_DFL; (void)sigaction(SIGCHLD, &sa, NULL); #endif sa.sa_handler = t_sighandler; (void)sigaction(SIGINT, &sa, NULL); (void)sigaction(SIGALRM, &sa, NULL); /* * Output start stanza to journal. */ snprintf(T_buf, sizeof(T_buf), "%s:", argv[0]); len = strlen(T_buf); (void) t_getdate(T_buf + len, T_BIGBUF - len); t_putinfo("S", T_buf); /* * Setup the test environment using the config file. */ if (T_config == NULL) T_config = T_DEFAULT_CONFIG; t_initconf(T_config); if (T_debug) t_dumpconf(T_config); /* * Now invoke all the test cases. */ tnum = 0; pts = &T_testlist[0]; while (*pts->pfv != NULL) { if (T_tvec[tnum / 8] & (0x01 << (tnum % 8))) { if (subprocs) { T_pid = fork(); if (T_pid == 0) { (*pts->pfv)(); exit(0); } else if (T_pid > 0) { T_int = 0; sa.sa_handler = t_sighandler; (void)sigaction(SIGALRM, &sa, NULL); alarm(T_timeout); deadpid = (pid_t) -1; while (deadpid != T_pid) { deadpid = waitpid(T_pid, &status, 0); if (deadpid == T_pid) { if (WIFSIGNALED(status)) { if (WTERMSIG(status) == SIGTERM) t_info( "the test case timed out\n"); else t_info( "the test case caused exception %d\n", WTERMSIG(status)); t_result(T_UNRESOLVED); } } else if ((deadpid == -1) && (errno == EINTR) && T_int) { kill(T_pid, SIGTERM); T_int = 0; } else if ((deadpid == -1) && ((errno == ECHILD) || (errno == ESRCH))) break; } alarm(0); sa.sa_handler = SIG_IGN; (void)sigaction(SIGALRM, &sa, NULL); } else { t_info("fork failed, errno == %d\n", errno); t_result(T_UNRESOLVED); } } else { (*pts->pfv)(); } } ++pts; ++tnum; } snprintf(T_buf, sizeof(T_buf), "%s:", argv[0]); len = strlen(T_buf); (void) t_getdate(T_buf + len, T_BIGBUF - len); t_putinfo("E", T_buf); return(0); }