From 27c8952a2cb5c486ca51e3cbb8653bcb67c66eb3 Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Thu, 1 Nov 2007 13:22:12 +0000 Subject: [PATCH] touch up clear and verbose. git-svn-id: file:///svn/unbound/trunk@728 be551aaa-1e26-0410-a405-d3ace91eadb9 --- daemon/unbound.c | 10 ++++++++-- doc/Changelog | 2 ++ util/storage/lruhash.c | 4 ++-- util/storage/lruhash.h | 1 + 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/daemon/unbound.c b/daemon/unbound.c index 7d4ecce76..c2e541d2e 100644 --- a/daemon/unbound.c +++ b/daemon/unbound.c @@ -263,11 +263,13 @@ do_chroot(struct daemon* daemon, struct config_file* cfg, int debug_mode) log_assert(cfg); /* daemonize last to be able to print error to user */ - if(cfg->directory && cfg->directory[0]) + if(cfg->directory && cfg->directory[0]) { if(chdir(cfg->directory)) { fatal_exit("Could not chdir to %s: %s", cfg->directory, strerror(errno)); } + verbose(VERB_DETAIL, "chdir to %s", cfg->directory); + } if(cfg->username && cfg->username[0]) { struct passwd *pwd; if((pwd = getpwnam(cfg->username)) == NULL) @@ -277,11 +279,15 @@ do_chroot(struct daemon* daemon, struct config_file* cfg, int debug_mode) if(setuid(pwd->pw_uid) != 0) fatal_exit("unable to set user id: %s", strerror(errno)); endpwent(); + verbose(VERB_DETAIL, "drop user privileges, run as %s", + cfg->username); } - if(cfg->chrootdir && cfg->chrootdir[0]) + if(cfg->chrootdir && cfg->chrootdir[0]) { if(chroot(cfg->chrootdir)) fatal_exit("unable to chroot to %s: %s", cfg->chrootdir, strerror(errno)); + verbose(VERB_DETAIL, "chroot to %s", cfg->chrootdir); + } /* check old pid file before forking */ if(cfg->pidfile && cfg->pidfile[0]) { checkoldpid(cfg); diff --git a/doc/Changelog b/doc/Changelog index ed4e54ccb..8709e9410 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -3,6 +3,8 @@ dealloc during deinit. - Fixup of chroot call. Happens after privileges are dropped, so that checking the passwd entry still works. + - minor touch up of clear() hashtable function. + - VERB_DETAIL prints out what chdir, username, chroot is being done. 31 October 2007: Wouter - cache-max-ttl config option. diff --git a/util/storage/lruhash.c b/util/storage/lruhash.c index 3f33e7f76..3c85f60e0 100644 --- a/util/storage/lruhash.c +++ b/util/storage/lruhash.c @@ -426,10 +426,10 @@ void lruhash_clear(struct lruhash* table) { size_t i; - log_assert(fptr_whitelist_hash_delkeyfunc(table->delkeyfunc)); - log_assert(fptr_whitelist_hash_deldatafunc(table->deldatafunc)); if(!table) return; + log_assert(fptr_whitelist_hash_delkeyfunc(table->delkeyfunc)); + log_assert(fptr_whitelist_hash_deldatafunc(table->deldatafunc)); lock_quick_lock(&table->lock); for(i=0; isize; i++) { diff --git a/util/storage/lruhash.h b/util/storage/lruhash.h index d1ea80588..b0a36eb67 100644 --- a/util/storage/lruhash.h +++ b/util/storage/lruhash.h @@ -134,6 +134,7 @@ typedef int (*lruhash_compfunc_t)(void*, void*); * If is_locked is not set, then this item is not locked. This allows the * routine to perform operations within the critical region of the lock * of the key. The critical region has been locked before the delete happened. + * The RRset type has to revoke its ID number inside the critical region. * This function is called: func(key, userarg, is_locked) */ typedef void (*lruhash_delkeyfunc_t)(void*, void*, int); -- 2.47.2