From 80e8e7660ae2be4b9b11ab05bd437f140cf904b4 Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Sun, 28 Aug 2005 00:18:43 +0000 Subject: [PATCH] * libamu/xutil.c: debug_flags should always be initialized to D_CONTROL (amq,daemon,fork). (debug_option): allow setting initial immutable debug_flags via amd.conf; afterward, prevent it (i.e., one tries it via "amq -D"). --- ChangeLog | 5 +++++ libamu/xutil.c | 17 +++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 429af7d..8e102e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2005-08-27 Erez Zadok + * libamu/xutil.c: debug_flags should always be initialized to + D_CONTROL (amq,daemon,fork). + (debug_option): allow setting initial immutable debug_flags via + amd.conf; afterward, prevent it (i.e., one tries it via "amq -D"). + * Makefile.am (DISTCLEANFILES): also remove amu_autofs_prot.h, config.cache.old, and dbgcf.h on "make distclean". (CLEANFILES): remove dbgcf on plain "make clean". diff --git a/libamu/xutil.c b/libamu/xutil.c index b020104..274e565 100644 --- a/libamu/xutil.c +++ b/libamu/xutil.c @@ -59,11 +59,7 @@ static char am_hostname[MAXHOSTNAMELEN] = "unknown"; /* Hostname */ pid_t am_mypid = -1; /* process ID */ serv_state amd_state; /* amd's state */ int foreground = 1; /* 1 == this is the top-level server */ -#ifdef DEBUG -u_int debug_flags = 0; /* 0 == uninitialized (get_args will init) */ -#else /* not DEBUG */ -u_int debug_flags = D_CONTROL; /* default when not compiled with debugging */ -#endif /* not DEBUG */ +u_int debug_flags = D_CONTROL; /* set regardless if compiled with debugging */ #ifdef HAVE_SYSLOG int syslogging; @@ -392,21 +388,26 @@ int debug_option(char *opt) { u_int dl = debug_flags; + static int initialized_debug_flags = 0; int rc = cmdoption(opt, dbg_opt, &dl); if (rc) /* if got any error, don't update debug flags */ return EINVAL; /* - * Don't allow "immutable" flags to be changed, because they could mess - * Amd's state and only make sense to be set once when Amd starts. + * If we already initialized the debugging flags once (via amd.conf), then + * don't allow "immutable" flags to be changed again (via amq -D), because + * they could mess Amd's state and only make sense to be set once when Amd + * starts. */ - if (debug_flags != 0 && + if (initialized_debug_flags && + debug_flags != 0 && (dl & D_IMMUTABLE) != (debug_flags & D_IMMUTABLE)) { plog(XLOG_ERROR, "cannot change immutable debug flags"); /* undo any attempted change to an immutable flag */ dl = (dl & ~D_IMMUTABLE) | (debug_flags & D_IMMUTABLE); } + initialized_debug_flags = 1; debug_flags = dl; return rc; -- 2.43.0