summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2011-12-06 12:01:42 +1100
committerAmitay Isaacs <amitay@gmail.com>2011-12-07 10:43:52 +1100
commitb9f4febd405c9ed8c5386cedeb3190aa395b41c4 (patch)
tree956e5d345036ed182080548496d978bc031edd14 /source4
parentde9a4ca831a0928044d7a2bc6d9801d92e23e5d9 (diff)
downloadsamba-b9f4febd405c9ed8c5386cedeb3190aa395b41c4.tar.gz
samba-b9f4febd405c9ed8c5386cedeb3190aa395b41c4.tar.bz2
samba-b9f4febd405c9ed8c5386cedeb3190aa395b41c4.zip
dlz_bind9: Add command line options for URL and debug
To specify debug level, use -d <level> in named.conf. To specify sam db, use -H <path/to/sam.ldb> in named.conf. The default log level is set to 0. The log level specified in smb.conf is not used. To set log level, use -d option.
Diffstat (limited to 'source4')
-rw-r--r--source4/dns_server/dlz_bind9.c35
-rw-r--r--source4/dns_server/wscript_build2
2 files changed, 28 insertions, 9 deletions
diff --git a/source4/dns_server/dlz_bind9.c b/source4/dns_server/dlz_bind9.c
index 7943a90a0c..1240ab7cc3 100644
--- a/source4/dns_server/dlz_bind9.c
+++ b/source4/dns_server/dlz_bind9.c
@@ -35,11 +35,13 @@
#include "gen_ndr/ndr_dnsp.h"
#include "gen_ndr/server_id.h"
#include "messaging/messaging.h"
+#include "lib/cmdline/popt_common.h"
#include "dlz_minimal.h"
struct b9_options {
const char *url;
+ const char *debug;
};
struct dlz_bind9_data {
@@ -437,12 +439,23 @@ static isc_result_t parse_options(struct dlz_bind9_data *state,
unsigned int argc, char *argv[],
struct b9_options *options)
{
- if (argc == 2) {
- options->url = talloc_strdup(state, argv[1]);
- if (options->url == NULL) {
- return ISC_R_NOMEMORY;
+ int opt;
+ poptContext pc;
+ struct poptOption long_options[] = {
+ { "url", 'H', POPT_ARG_STRING, &options->url, 0, "database URL", "URL" },
+ { "debug", 'd', POPT_ARG_STRING, &options->debug, 0, "debug level", "DEBUG" },
+ { NULL }
+ };
+
+ pc = poptGetContext("dlz_bind9", argc, (const char **)argv, long_options,
+ POPT_CONTEXT_KEEP_FIRST);
+ while ((opt = poptGetNextOpt(pc)) != -1) {
+ switch (opt) {
+ default:
+ state->log(ISC_LOG_ERROR, "dlz_bind9: Invalid option %s: %s",
+ poptBadOption(pc, 0), poptStrerror(opt));
+ return ISC_R_FAILURE;
}
- state->log(ISC_LOG_INFO, "samba_dlz: Using samdb URL %s", options->url);
}
return ISC_R_SUCCESS;
@@ -478,6 +491,9 @@ _PUBLIC_ isc_result_t dlz_create(const char *dlzname,
}
va_end(ap);
+ /* Do not install samba signal handlers */
+ fault_setup_disable();
+
/* Start logging */
setup_logging("samba_dlz", DEBUG_DEFAULT_STDERR);
@@ -498,6 +514,12 @@ _PUBLIC_ isc_result_t dlz_create(const char *dlzname,
goto failed;
}
+ if (state->options.debug) {
+ lpcfg_do_global_parameter(state->lp, "log level", state->options.debug);
+ } else {
+ lpcfg_do_global_parameter(state->lp, "log level", "0");
+ }
+
if (smb_krb5_init_context(state, state->ev_ctx, state->lp, &state->smb_krb5_ctx) != 0) {
result = ISC_R_NOMEMORY;
goto failed;
@@ -517,9 +539,6 @@ _PUBLIC_ isc_result_t dlz_create(const char *dlzname,
}
}
- /* Do not install samba signal handlers */
- fault_setup_disable();
-
state->samdb = samdb_connect_url(state, state->ev_ctx, state->lp,
system_session(state->lp), 0, state->options.url);
if (state->samdb == NULL) {
diff --git a/source4/dns_server/wscript_build b/source4/dns_server/wscript_build
index 8c5bb9cca8..04c8188b37 100644
--- a/source4/dns_server/wscript_build
+++ b/source4/dns_server/wscript_build
@@ -16,4 +16,4 @@ bld.SAMBA_LIBRARY('dlz_bind9',
link_name='modules/bind9/dlz_bind9.so',
realname='dlz_bind9.so',
install_path='${MODULESDIR}/bind9',
- deps='samba-hostconfig samdb gensec')
+ deps='samba-hostconfig samdb gensec popt')