summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2016-06-29 21:29:25 +0200
committerJakub Hrozek <jhrozek@redhat.com>2016-06-29 21:47:05 +0200
commit2aafa4811cd9f74f70820b0e266df8e4c7ed6ad7 (patch)
tree88b6442dabb4206b173d3c36d7468fd86bdc5e4d
parenta9d46b86993ee8d87fddf0ba50665c0b1b78ebb7 (diff)
downloadsssd-2aafa4811cd9f74f70820b0e266df8e4c7ed6ad7.tar.gz
sssd-2aafa4811cd9f74f70820b0e266df8e4c7ed6ad7.tar.xz
sssd-2aafa4811cd9f74f70820b0e266df8e4c7ed6ad7.zip
Monitor: Add mode to generate confdb only
With this mode we can add socket activated services and have systemd pre exec sssd to genrate the configuration file w/o starting the whole sssd if not necessary. https://fedorahosted.org/sssd/ticket/2243 Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
-rw-r--r--src/monitor/monitor.c24
-rw-r--r--src/util/util.h1
2 files changed, 22 insertions, 3 deletions
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index b616a3454..38ac44e4b 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -2768,6 +2768,7 @@ int main(int argc, const char *argv[])
poptContext pc;
int opt_daemon = 0;
int opt_interactive = 0;
+ int opt_genconf = 0;
int opt_version = 0;
char *opt_config_file = NULL;
char *config_file = NULL;
@@ -2787,8 +2788,11 @@ int main(int argc, const char *argv[])
_("Run interactive (not a daemon)"), NULL}, \
{"config", 'c', POPT_ARG_STRING, &opt_config_file, 0, \
_("Specify a non-default config file"), NULL}, \
- {"version", '\0', POPT_ARG_NONE, &opt_version, 0, \
- _("Print version number and exit"), NULL }, \
+ {"genconf", 'g', POPT_ARG_NONE, &opt_genconf, 0, \
+ _("Refresh the configuration database, then exit"), \
+ NULL}, \
+ {"version", '\0', POPT_ARG_NONE, &opt_version, 0, \
+ _("Print version number and exit"), NULL }, \
POPT_TABLEEND
};
@@ -2826,7 +2830,13 @@ int main(int argc, const char *argv[])
return 1;
}
- if (!opt_daemon && !opt_interactive) {
+ if (opt_genconf && (opt_daemon || opt_interactive)) {
+ fprintf(stderr, "Option -g is incompatible with -D or -i\n");
+ poptPrintUsage(pc, stderr, 0);
+ return 1;
+ }
+
+ if (!opt_daemon && !opt_interactive && !opt_genconf) {
opt_daemon = 1;
}
@@ -2850,6 +2860,10 @@ int main(int argc, const char *argv[])
flags |= FLAGS_INTERACTIVE;
debug_to_stderr = 1;
}
+ if (opt_genconf) {
+ flags |= FLAGS_GEN_CONF;
+ debug_to_stderr = 1;
+ }
if (opt_config_file) {
config_file = talloc_strdup(tmp_ctx, opt_config_file);
@@ -2956,6 +2970,10 @@ int main(int argc, const char *argv[])
return 4;
}
+ /* at this point we are done generating the config file, we may exit
+ * if that's all we were asked to do */
+ if (opt_genconf) return 0;
+
/* set up things like debug , signals, daemonization, etc... */
monitor->conf_path = CONFDB_MONITOR_CONF_ENTRY;
ret = close(STDIN_FILENO);
diff --git a/src/util/util.h b/src/util/util.h
index 96f154f6a..36d8231b9 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -83,6 +83,7 @@
#define FLAGS_DAEMON 0x0001
#define FLAGS_INTERACTIVE 0x0002
#define FLAGS_PID_FILE 0x0004
+#define FLAGS_GEN_CONF 0x0008
#define PIPE_INIT { -1, -1 }