summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/monitor/monitor.c113
-rw-r--r--src/providers/child_common.c14
-rw-r--r--src/providers/proxy/proxy_auth.c5
3 files changed, 77 insertions, 55 deletions
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 45744758..dd099841 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -56,6 +56,7 @@
#define MONITOR_DEF_PING_TIME 10
int cmdline_debug_level;
+int cmdline_debug_timestamps;
struct svc_spy;
@@ -943,34 +944,43 @@ static int get_service_config(struct mt_ctx *ctx, const char *name,
}
if (!svc->command) {
- if (cmdline_debug_level == SSSDBG_UNRESOLVED) {
- svc->command = talloc_asprintf(svc, "%s/sssd_%s %s%s",
- SSSD_LIBEXEC_PATH,
- svc->name,
- debug_timestamps?
- "": "--debug-timestamps=0 ",
- debug_to_file?
- "--debug-to-files":"");
- } else {
- /* If the debug level was specified at the command-line,
- * make sure to pass it into the children, overriding the
- * config file.
- */
- svc->command = talloc_asprintf(svc, "%s/sssd_%s -d %#.4x%s%s",
- SSSD_LIBEXEC_PATH,
- svc->name,
- cmdline_debug_level,
- debug_timestamps ?
- "" :
- " --debug-timestamps=0",
- debug_to_file ?
- " --debug-to-files" :
- "");
- }
+ svc->command = talloc_asprintf(
+ svc, "%s/sssd_%s", SSSD_LIBEXEC_PATH, svc->name
+ );
if (!svc->command) {
talloc_free(svc);
return ENOMEM;
}
+
+ if (cmdline_debug_level != SSSDBG_UNRESOLVED) {
+ svc->command = talloc_asprintf_append(
+ svc->command, " -d %#.4x", cmdline_debug_level
+ );
+ if (!svc->command) {
+ talloc_free(svc);
+ return ENOMEM;
+ }
+ }
+
+ if (cmdline_debug_timestamps != SSSDBG_TIMESTAMP_UNRESOLVED) {
+ svc->command = talloc_asprintf_append(
+ svc->command, " --debug-timestamps=%d", cmdline_debug_timestamps
+ );
+ if (!svc->command) {
+ talloc_free(svc);
+ return ENOMEM;
+ }
+ }
+
+ if (debug_to_file) {
+ svc->command = talloc_strdup_append(
+ svc->command, " --debug-to-files"
+ );
+ if (!svc->command) {
+ talloc_free(svc);
+ return ENOMEM;
+ }
+ }
}
ret = confdb_get_int(ctx->cdb, svc, path,
@@ -1089,29 +1099,43 @@ static int get_provider_config(struct mt_ctx *ctx, const char *name,
/* if there are no custom commands, build a default one */
if (!svc->command) {
- if (cmdline_debug_level == SSSDBG_UNRESOLVED) {
- svc->command = talloc_asprintf(svc,
- "%s/sssd_be --domain %s%s%s",
- SSSD_LIBEXEC_PATH,
- svc->name,
- debug_timestamps ? ""
- : " --debug-timestamps=0",
- debug_to_file ? " --debug-to-files" : "");
- } else {
- svc->command = talloc_asprintf(svc,
- "%s/sssd_be --domain %s -d %#.4x%s%s ",
- SSSD_LIBEXEC_PATH,
- svc->name,
- cmdline_debug_level,
- debug_timestamps ? ""
- : " --debug-timestamps=0",
- debug_to_file ? " --debug-to-files" : "");
- }
-
+ svc->command = talloc_asprintf(
+ svc, "%s/sssd_be --domain %s", SSSD_LIBEXEC_PATH, svc->name
+ );
if (!svc->command) {
talloc_free(svc);
return ENOMEM;
}
+
+ if (cmdline_debug_level != SSSDBG_UNRESOLVED) {
+ svc->command = talloc_asprintf_append(
+ svc->command, " -d %#.4x", cmdline_debug_level
+ );
+ if (!svc->command) {
+ talloc_free(svc);
+ return ENOMEM;
+ }
+ }
+
+ if (cmdline_debug_timestamps != SSSDBG_TIMESTAMP_UNRESOLVED) {
+ svc->command = talloc_asprintf_append(
+ svc->command, " --debug-timestamps=%d", cmdline_debug_timestamps
+ );
+ if (!svc->command) {
+ talloc_free(svc);
+ return ENOMEM;
+ }
+ }
+
+ if (debug_to_file) {
+ svc->command = talloc_strdup_append(
+ svc->command, " --debug-to-files"
+ );
+ if (!svc->command) {
+ talloc_free(svc);
+ return ENOMEM;
+ }
+ }
}
*svc_cfg = svc;
@@ -2337,10 +2361,11 @@ int main(int argc, const char *argv[])
CONVERT_AND_SET_DEBUG_LEVEL(debug_level);
- /* If the level was passed at the command-line, we want
+ /* If the level or timestamps was passed at the command-line, we want
* to save it and pass it to the children later.
*/
cmdline_debug_level = debug_level;
+ cmdline_debug_timestamps = debug_timestamps;
if (opt_daemon && opt_interactive) {
fprintf(stderr, "Option -i|--interactive is not allowed together with -D|--daemon\n");
diff --git a/src/providers/child_common.c b/src/providers/child_common.c
index 6e0f6a1a..cde310c3 100644
--- a/src/providers/child_common.c
+++ b/src/providers/child_common.c
@@ -378,7 +378,7 @@ static errno_t prepare_child_argv(TALLOC_CTX *mem_ctx,
const char *binary,
char ***_argv)
{
- uint_t argc = 3; /* program name, debug_level and NULL */
+ uint_t argc = 4; /* program name, debug_level, debug_timestamps and NULL */
char ** argv;
errno_t ret = EINVAL;
@@ -387,7 +387,6 @@ static errno_t prepare_child_argv(TALLOC_CTX *mem_ctx,
bool child_debug_timestamps = debug_timestamps;
if (child_debug_to_file) argc++;
- if (!child_debug_timestamps) argc++;
/* program name, debug_level,
* debug_to_file, debug_timestamps
@@ -416,12 +415,11 @@ static errno_t prepare_child_argv(TALLOC_CTX *mem_ctx,
}
}
- if (!child_debug_timestamps) {
- argv[--argc] = talloc_strdup(argv, "--debug-timestamps=0");
- if (argv[argc] == NULL) {
- ret = ENOMEM;
- goto fail;
- }
+ argv[--argc] = talloc_asprintf(argv, "--debug-timestamps=%d",
+ child_debug_timestamps);
+ if (argv[argc] == NULL) {
+ ret = ENOMEM;
+ goto fail;
}
argv[--argc] = talloc_strdup(argv, binary);
diff --git a/src/providers/proxy/proxy_auth.c b/src/providers/proxy/proxy_auth.c
index adb0d872..81ae896b 100644
--- a/src/providers/proxy/proxy_auth.c
+++ b/src/providers/proxy/proxy_auth.c
@@ -240,9 +240,8 @@ static struct tevent_req *proxy_child_init_send(TALLOC_CTX *mem_ctx,
state->child_ctx = child_ctx;
state->command = talloc_asprintf(req,
- "%s/proxy_child -d %#.4x%s%s --domain %s --id %d",
- SSSD_LIBEXEC_PATH, debug_level,
- (debug_timestamps ? "" : " --debug-timestamps=0"),
+ "%s/proxy_child -d %#.4x --debug-timestamps=%d%s --domain %s --id %d",
+ SSSD_LIBEXEC_PATH, debug_level, debug_timestamps,
(debug_to_file ? " --debug-to-files" : ""),
auth_ctx->be->domain->name,
child_ctx->id);