Пример #1
0
/*
 * Switch on/off debug options
 */
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;

  /*
   * 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 (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
0
/*
 * Switch on/off logging options
 */
int
switch_option(char *opt)
{
  int xl = xlog_level;
  int rc = cmdoption(opt, xlog_opt, &xl);

  if (rc) {
    rc = EINVAL;
  } else {
    /*
     * Keep track of initial log level, and
     * don't allow options to be turned off.
     */
    if (xlog_level_init == ~0)
      xlog_level_init = xl;
    else
      xl |= xlog_level_init;
    xlog_level = xl;
  }
  return rc;
}
Пример #3
0
/*
 * Switch on/off logging options
 */
int
switch_option(char *opt)
{
  u_int xl = xlog_level;
  int rc = cmdoption(opt, xlog_opt, &xl);

  if (rc)			/* if got any error, don't update flags */
    return EINVAL;

  /*
   * Don't allow "mandatory" flags to be turned off, because
   * we must always be able to report on flag re/setting errors.
   */
  if ((xl & XLOG_MANDATORY) != XLOG_MANDATORY) {
    plog(XLOG_ERROR, "cannot turn off mandatory logging options");
    xl |= XLOG_MANDATORY;
  }
  if (xlog_level != xl)
    xlog_level = xl;		/* set new flags */
  return rc;
}
Пример #4
0
/*
 * Switch on/off debug options
 */
int
debug_option(char *opt)
{
  return cmdoption(opt, dbg_opt, &debug_flags);
}
Пример #5
0
/*
 * Create a new map
 */
static mnt_map *
mapc_create(char *map, char *opt)
{
	mnt_map *m = ALLOC(mnt_map);
	map_type *mt;
	time_t modify;
	int alloc = 0;

	(void) cmdoption(opt, mapc_opt, &alloc);

	for (mt = maptypes; mt < maptypes+sizeof(maptypes)/sizeof(maptypes[0]); mt++)
		if ((*mt->init)(map, &modify) == 0)
			break;
	/* assert: mt in maptypes */

	m->flags = alloc & ~MAPC_CACHE_MASK;
	alloc &= MAPC_CACHE_MASK;

	if (alloc == MAPC_DFLT)
		alloc = mt->def_alloc;
	switch (alloc) {
	default:
		plog(XLOG_USER, "Ambiguous map cache type \"%s\"; using \"inc\"", opt);
		alloc = MAPC_INC;
		/* fallthrough... */
	case MAPC_NONE:
	case MAPC_INC:
	case MAPC_ROOT:
		break;
	case MAPC_ALL:
		/*
		 * If there is no support for reload and it was requested
		 * then back off to incremental instead.
		 */
		if (mt->reload == error_reload) {
			plog(XLOG_WARNING, "Map type \"%s\" does not support cache type \"all\"; using \"inc\"", mt->name);
			alloc = MAPC_INC;
		}
		break;
#ifdef HAS_REGEXP
	case MAPC_RE:
		if (mt->reload == error_reload) {
			plog(XLOG_WARNING, "Map type \"%s\" does not support cache type \"re\"", mt->name);
			mt = &maptypes[sizeof(maptypes)/sizeof(maptypes[0]) - 1];
			/* assert: mt->name == "error" */
		}
		break;
#endif
	}

#ifdef DEBUG
	dlog("Map for %s coming from maptype %s", map, mt->name);
#endif

	m->alloc = alloc;
	m->reload = mt->reload;
	m->modify = modify;
	m->search = alloc >= MAPC_ALL ? error_search : mt->search;
	m->mtime = mt->mtime;
	bzero((void *)m->kvhash, sizeof(m->kvhash));
	m->map_name = strdup(map);
	m->refc = 1;
	m->wildcard = 0;

	/*
	 * synchronize cache with reality
	 */
	mapc_sync(m);

	return m;
}