summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabiano Fidêncio <fidencio@redhat.com>2017-01-15 12:23:21 +0100
committerLukas Slebodnik <lslebodn@redhat.com>2017-01-23 18:46:37 +0100
commit9e59f73f81612f60c02ec7c23e14db9cebb28e29 (patch)
tree1cfcae49b1d172b5f0107fa992214b55dd2cf73e
parent41e9e8b60e3bed0159914e755aa05df9a2448470 (diff)
downloadsssd-9e59f73f81612f60c02ec7c23e14db9cebb28e29.tar.gz
sssd-9e59f73f81612f60c02ec7c23e14db9cebb28e29.tar.xz
sssd-9e59f73f81612f60c02ec7c23e14db9cebb28e29.zip
UTIL: Introduce --dbus-activated cmd option for responders
Similarly to the --socket-activated cmd option, --dbus-activated cmd option is going to be used for dbus-activated responders in order to easily setup a timeout to shutdown the idle responder in case it has been socket activated and is idle. This option has been encapsulated on is_dbus_activated() function, which will always return "false" when called on platforms where systemd is not supported. For now any of the services are taking advantage of this newly introduced option/function, but later on in this series it's going to be used. In order to use it, just add SSSD_RESPONDER_OPTS to the poptOption structure. Related: https://fedorahosted.org/sssd/ticket/2243 Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> Reviewed-by: Pavel Březina <pbrezina@redhat.com> Reviewed-by: Jakub Hrozek <jhrozek@redhat.com> Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
-rw-r--r--src/responder/common/responder.h1
-rw-r--r--src/responder/common/responder_common.c6
-rw-r--r--src/util/util.c10
-rw-r--r--src/util/util.h8
4 files changed, 22 insertions, 3 deletions
diff --git a/src/responder/common/responder.h b/src/responder/common/responder.h
index 181c96ad1..40c884070 100644
--- a/src/responder/common/responder.h
+++ b/src/responder/common/responder.h
@@ -128,6 +128,7 @@ struct resp_ctx {
bool shutting_down;
bool socket_activated;
+ bool dbus_activated;
};
struct cli_creds;
diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c
index 3e38d3b5b..a64334d9d 100644
--- a/src/responder/common/responder_common.c
+++ b/src/responder/common/responder_common.c
@@ -952,6 +952,7 @@ int sss_process_init(TALLOC_CTX *mem_ctx,
rctx->confdb_service_path = confdb_service_path;
rctx->shutting_down = false;
rctx->socket_activated = is_socket_activated();
+ rctx->dbus_activated = is_dbus_activated();
talloc_set_destructor((TALLOC_CTX*)rctx, sss_responder_ctx_destructor);
@@ -1089,8 +1090,9 @@ int sss_process_init(TALLOC_CTX *mem_ctx,
DEBUG(SSSDBG_TRACE_FUNC,
"Responder initialization complete (%s)\n",
- rctx->socket_activated ? "socket-activated" :
- "explicitly configured");
+ rctx->socket_activated ? "socket-activated" :
+ rctx->dbus_activated ? "dbus-activated" :
+ "explicitly configured");
*responder_ctx = rctx;
return EOK;
diff --git a/src/util/util.c b/src/util/util.c
index 5cc4ac9dc..885f67e66 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -33,6 +33,7 @@
#include "util/sss_utf8.h"
int socket_activated = 0;
+int dbus_activated = 0;
int split_on_separator(TALLOC_CTX *mem_ctx, const char *str,
const char sep, bool trim, bool skip_empty,
@@ -1288,3 +1289,12 @@ bool is_socket_activated(void)
return false;
#endif
}
+
+bool is_dbus_activated(void)
+{
+#ifdef HAVE_SYSTEMD
+ return !!dbus_activated;
+#else
+ return false;
+#endif
+}
diff --git a/src/util/util.h b/src/util/util.h
index 304a3583b..a2dc89b8d 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -84,11 +84,14 @@
_("The group ID to run the server as"), NULL},
extern int socket_activated;
+extern int dbus_activated;
#ifdef HAVE_SYSTEMD
#define SSSD_RESPONDER_OPTS \
{ "socket-activated", 0, POPT_ARG_NONE, &socket_activated, 0, \
- _("Informs that the responder has been socket-activated"), NULL },
+ _("Informs that the responder has been socket-activated"), NULL }, \
+ { "dbus-activated", 0, POPT_ARG_NONE, &dbus_activated, 0, \
+ _("Informs that the responder has been dbus-activated"), NULL },
#else
#define SSSD_RESPONDER_OPTS
#endif
@@ -392,6 +395,9 @@ bool is_user_or_group_name(const char *sudo_user_value);
/* Returns true if the responder has been socket-activated */
bool is_socket_activated(void);
+/* Returns true if the responder has been dbus-activated */
+bool is_dbus_activated(void);
+
/**
* @brief Add two list of strings
*