summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/providers/krb5/krb5_common.c33
-rw-r--r--src/providers/krb5/krb5_common.h3
-rw-r--r--src/providers/krb5/krb5_init.c17
3 files changed, 39 insertions, 14 deletions
diff --git a/src/providers/krb5/krb5_common.c b/src/providers/krb5/krb5_common.c
index f63f51641..c78f0e60c 100644
--- a/src/providers/krb5/krb5_common.c
+++ b/src/providers/krb5/krb5_common.c
@@ -587,3 +587,36 @@ done:
return ret;
}
+
+errno_t krb5_install_sigterm_handler(struct tevent_context *ev,
+ struct krb5_ctx *krb5_ctx)
+{
+ const char *krb5_realm;
+ char *sig_realm;
+ struct tevent_signal *sige;
+
+ BlockSignals(false, SIGTERM);
+
+ krb5_realm = dp_opt_get_cstring(krb5_ctx->opts, KRB5_REALM);
+ if (krb5_realm == NULL) {
+ DEBUG(1, ("Missing krb5_realm option!\n"));
+ return EINVAL;
+ }
+
+ sig_realm = talloc_strdup(krb5_ctx, krb5_realm);
+ if (sig_realm == NULL) {
+ DEBUG(1, ("talloc_strdup failed!\n"));
+ return ENOMEM;
+ }
+
+ sige = tevent_add_signal(ev, krb5_ctx, SIGTERM, SA_SIGINFO, krb5_finalize,
+ sig_realm);
+ if (sige == NULL) {
+ DEBUG(1, ("tevent_add_signal failed.\n"));
+ talloc_free(sig_realm);
+ return ENOMEM;
+ }
+ talloc_steal(sige, sig_realm);
+
+ return EOK;
+}
diff --git a/src/providers/krb5/krb5_common.h b/src/providers/krb5/krb5_common.h
index f9b61956f..342481e5d 100644
--- a/src/providers/krb5/krb5_common.h
+++ b/src/providers/krb5/krb5_common.h
@@ -135,4 +135,7 @@ void krb5_finalize(struct tevent_context *ev,
errno_t krb5_install_offline_callback(struct be_ctx *be_ctx,
struct krb5_ctx *krb_ctx);
+
+errno_t krb5_install_sigterm_handler(struct tevent_context *ev,
+ struct krb5_ctx *krb5_ctx);
#endif /* __KRB5_COMMON_H__ */
diff --git a/src/providers/krb5/krb5_init.c b/src/providers/krb5/krb5_init.c
index 481b08804..c457dc55f 100644
--- a/src/providers/krb5/krb5_init.c
+++ b/src/providers/krb5/krb5_init.c
@@ -48,14 +48,12 @@ int sssm_krb5_auth_init(struct be_ctx *bectx,
{
struct krb5_ctx *ctx = NULL;
int ret;
- struct tevent_signal *sige;
unsigned v;
FILE *debug_filep;
const char *krb5_servers;
const char *krb5_kpasswd_servers;
const char *krb5_realm;
const char *errstr;
- char *sig_realm;
int errval;
int errpos;
@@ -135,20 +133,11 @@ int sssm_krb5_auth_init(struct be_ctx *bectx,
goto fail;
}
- BlockSignals(false, SIGTERM);
- sig_realm = talloc_strdup(ctx, krb5_realm);
- if (sig_realm == NULL) {
- ret = ENOMEM;
- goto fail;
- }
- sige = tevent_add_signal(bectx->ev, ctx, SIGTERM, SA_SIGINFO,
- krb5_finalize, sig_realm);
- if (sige == NULL) {
- DEBUG(1, ("tevent_add_signal failed.\n"));
- ret = ENOMEM;
+ ret = krb5_install_sigterm_handler(bectx->ev, ctx);
+ if (ret != EOK) {
+ DEBUG(1, ("krb5_install_sigterm_handler failed.\n"));
goto fail;
}
- talloc_steal(sige, sig_realm);
ret = krb5_install_offline_callback(bectx, ctx);
if (ret != EOK) {