+* [Bug 1848] make check ntpd --saveconfigquit clutters syslog.
(4.2.7p138) 2011/03/08 Released by Harlan Stenn <stenn@ntp.org>
* [Bug 1846] MacOSX: debug symbol not found by propdelay or tickadj.
(4.2.7p137) 2011/03/07 Released by Harlan Stenn <stenn@ntp.org>
* [Bug 1343] ntpd/ntp_io.c close_fd() does not compile on Solaris 7.
* [Bug 1353] ntpq "rv 0 settimeofday" always shows UNKNOWN on unix.
* Do not attempt to execute built binaries from ntpd/Makefile when
- cross-compiling (keyword-gen and ntpd --saveconfigquit).
+ cross-compiling (keyword-gen and ntpd --saveconfigqui).
* sntp/main.c: Remove duplicate global adr_buf[] (also defined in
networking.c) which Piotr Grudzinski identified breaking his build.
* Correct in6addr_any test in configure.ac to attempt link too.
__attribute__((__format__(__printf__, 3, 4)));
extern void msyslog(int, const char *, ...)
__attribute__((__format__(__printf__, 2, 3)));
-extern void init_logging (const char *, u_long, const char *,
- int);
-extern int change_logfile (const char *, const char *);
-extern void setup_logfile (const char *, const char *);
+extern void init_logging (const char *, u_long, int);
+extern int change_logfile (const char *, int);
+extern void setup_logfile (const char *);
#ifndef errno_to_str
extern void errno_to_str(int, char *, size_t);
#endif
init_logging(
const char * name,
u_long def_syslogmask,
- const char * version_str,
int is_daemon
)
{
setlogmask(LOG_UPTO(LOG_DEBUG)); /* @@@ was INFO */
# endif /* LOG_DAEMON */
#endif /* !VMS */
-
- if (NULL != version_str)
- msyslog(LOG_NOTICE, "%s", version_str);
}
int
change_logfile(
const char * fname,
- const char * version_str
+ int leave_crumbs
)
{
FILE * new_file;
}
/* leave a pointer in the old log */
- if (syslogit || log_fname != syslog_abs_fname)
+ if (leave_crumbs && (syslogit || log_fname != syslog_abs_fname))
msyslog(LOG_NOTICE, "switching logging to file %s",
abs_fname);
syslog_abs_fname = abs_fname;
}
syslogit = FALSE;
- if (NULL != version_str)
- msyslog(LOG_NOTICE, "%s", version_str);
return 0;
}
*/
void
setup_logfile(
- const char * name,
- const char * version_str
+ const char * name
)
{
if (NULL == syslog_fname && NULL != name) {
- if (-1 == change_logfile(name, version_str))
+ if (-1 == change_logfile(name, TRUE))
msyslog(LOG_ERR, "Cannot open log file %s, %m",
name);
return ;
if (NULL == syslog_fname)
return;
- if (-1 == change_logfile(syslog_fname, version_str))
+ if (-1 == change_logfile(syslog_fname, FALSE))
msyslog(LOG_ERR, "Cannot reopen log file %s, %m",
syslog_fname);
}
# ifdef HAVE_SETRLIMIT
struct rlimit rl;
# endif
+# endif
+# ifdef HAVE_UMASK
+ uv = umask(0);
+ if (uv)
+ umask(uv);
+ else
+ umask(022);
# endif
progname = argv[0];
initializing = TRUE; /* mark that we are initializing */
parse_cmdline_opts(&argc, &argv);
- /* Open the log file */
- init_logging(progname, NLOG_SYNCMASK, Version, TRUE);
+# ifdef DEBUG
+ debug = DESC(DEBUG_LEVEL).optOccCt;
+# endif
+
+ if (HAVE_OPT(NOFORK) || HAVE_OPT(QUIT)
+# ifdef DEBUG
+ || debug
+# endif
+ || HAVE_OPT(SAVECONFIGQUIT))
+ nofork = TRUE;
+
+ init_logging(progname, NLOG_SYNCMASK, TRUE);
+ /* honor -l/--logfile option to log to a file */
+ if (HAVE_OPT(LOGFILE)) {
+ logfilename = OPT_ARG(LOGFILE);
+ syslogit = FALSE;
+ change_logfile(logfilename, FALSE);
+ } else {
+ logfilename = NULL;
+ if (nofork) {
+ msyslog_term = FALSE;
+ syslogit = FALSE;
+ change_logfile("stderr", FALSE);
+ }
+ }
+ msyslog(LOG_NOTICE, "%s\n", Version);
/*
* Install trap handlers to log errors and assertion failures.
isc_error_setfatal(library_fatal_error);
isc_error_setunexpected(library_unexpected_error);
-# ifdef HAVE_UMASK
- uv = umask(0);
- if (uv)
- umask(uv);
- else
- umask(022);
-# endif
-
/* MPE lacks the concept of root */
# if defined(HAVE_GETUID) && !defined(MPE)
uid = getuid();
if (uid && !HAVE_OPT( SAVECONFIGQUIT )) {
+ msyslog_term = TRUE;
msyslog(LOG_ERR,
"must be run as root, not uid %ld", (long)uid);
- printf("%s must be run as root, not uid %ld\n",
- progname, (long)uid);
exit(1);
}
# endif
-# ifdef DEBUG
- debug = DESC(DEBUG_LEVEL).optOccCt;
- DPRINTF(1, ("%s\n", Version));
-# endif
-
- /* honor -l/--logfile option to log to a file */
- if (HAVE_OPT(LOGFILE))
- logfilename = OPT_ARG(LOGFILE);
- else
- logfilename = NULL;
- setup_logfile(logfilename, Version);
-
/*
* Enable the Multi-Media Timer for Windows?
*/
set_mm_timer(MM_TIMER_HIRES);
# endif
- if (HAVE_OPT( NOFORK ) || HAVE_OPT( QUIT )
-# ifdef DEBUG
- || debug
-# endif
- || HAVE_OPT( SAVECONFIGQUIT )) {
- nofork = 1;
- /* duplicate all syslog to stdout */
- msyslog_term = TRUE;
- }
-
if (HAVE_OPT( NOVIRTUALIPS ))
listen_to_virtual_ips = 0;
dup2(0, 1);
dup2(0, 2);
- init_logging(progname, 0, NULL, TRUE);
+ init_logging(progname, 0, TRUE);
/* we lost our logfile (if any) daemonizing */
- setup_logfile(logfilename, NULL);
+ setup_logfile(logfilename);
# ifdef SYS_DOMAINOS
{
/*
* The default RLIMIT_MEMLOCK is very low on Linux systems.
* Unless we increase this limit malloc calls are likely to
- * fail if we drop root privlege. To be useful the value
+ * fail if we drop root privilege. To be useful the value
* has to be larger than the largest ntpd resident set size.
*/
rl.rlim_cur = rl.rlim_max = 32 * 1024 * 1024;
/*
* lock the process into memory
*/
- if (mlockall(MCL_CURRENT|MCL_FUTURE) < 0)
+ if (!HAVE_OPT(SAVECONFIGQUIT) &&
+ 0 != mlockall(MCL_CURRENT|MCL_FUTURE))
msyslog(LOG_ERR, "mlockall(): %m");
# else /* !HAVE_MLOCKALL || !MCL_CURRENT || !MCL_FUTURE follows */
# ifdef HAVE_PLOCK
/*
* lock the process into memory
*/
- if (plock(PROCLOCK) < 0)
+ if (!HAVE_OPT(SAVECONFIGQUIT) && 0 != plock(PROCLOCK))
msyslog(LOG_ERR, "plock(PROCLOCK): %m");
# else /* !PROCLOCK follows */
# ifdef TXTLOCK
/*
* Lock text into ram
*/
- if (plock(TXTLOCK) < 0)
+ if (!HAVE_OPT(SAVECONFIGQUIT) && 0 != plock(TXTLOCK))
msyslog(LOG_ERR, "plock(TXTLOCK) error: %m");
# else /* !TXTLOCK follows */
msyslog(LOG_ERR, "plock() - don't know what to lock!");