Exemplo n.º 1
0
/*
 * Log an error message, then exit.
 */
void
error(char *fmt, ...)
{
	va_list list;

	do_percentm(fbuf, sizeof(fbuf), fmt);

	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) {
		write(2, mbuf, strlen(mbuf));
		write(2, "\n", 1);
	}

	syslog(LOG_CRIT, "exiting.");
	if (log_perror) {
		fprintf(stderr, "exiting.\n");
		fflush(stderr);
	}
	if (pidfile != NULL)
		pidfile_remove(pidfile);
	exit(1);
}
Exemplo n.º 2
0
int
parse_warn(char *fmt, ...)
{
	va_list list;
	static char spaces[] =
	    "                                        "
	    "                                        "; /* 80 spaces */

	do_percentm(mbuf, sizeof(mbuf), fmt);
	snprintf(fbuf, sizeof(fbuf), "%s line %d: %s", tlname, lexline, mbuf);
	va_start(list, fmt);
	vsnprintf(mbuf, sizeof(mbuf), fbuf, list);
	va_end(list);

#ifndef DEBUG
	syslog(log_priority | LOG_ERR, "%s", mbuf);
	syslog(log_priority | LOG_ERR, "%s", token_line);
	if (lexline < 81)
		syslog(log_priority | LOG_ERR,
		    "%s^", &spaces[sizeof(spaces) - lexchar]);
#endif

	if (log_perror) {
		write(2, mbuf, strlen(mbuf));
		write(2, "\n", 1);
		write(2, token_line, strlen(token_line));
		write(2, "\n", 1);
		write(2, spaces, lexchar - 1);
		write(2, "^\n", 2);
	}

	warnings_occurred = 1;

	return (0);
}
Exemplo n.º 3
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));
  }

#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);
}
Exemplo n.º 4
0
/*
 * Log a warning message...
 */
int
warning(char *fmt, ...)
{
	va_list list;

	do_percentm(fbuf, sizeof(fbuf), fmt);

	va_start(list, fmt);
	vsnprintf(mbuf, sizeof(mbuf), fbuf, list);
	va_end(list);

#ifndef DEBUG
	syslog(log_priority | LOG_ERR, "%s", mbuf);
#endif

	if (log_perror) {
		write(2, mbuf, strlen(mbuf));
		write(2, "\n", 1);
	}

	return (0);
}
Exemplo n.º 5
0
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);
}