diff options
author | Sumit Bose <sbose@redhat.com> | 2010-05-17 13:23:32 +0200 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-05-27 14:44:13 -0400 |
commit | eaf3dcc15e9eb093ecf8b934f6c3a82d01236a92 (patch) | |
tree | 173a2ab4dcb91f45c84e0b2ab49bf9dbea4e8da5 /src/providers/krb5 | |
parent | 717bab5b52c755c950eb451d95a805d474d0ef07 (diff) | |
download | sssd-eaf3dcc15e9eb093ecf8b934f6c3a82d01236a92.tar.gz sssd-eaf3dcc15e9eb093ecf8b934f6c3a82d01236a92.tar.bz2 sssd-eaf3dcc15e9eb093ecf8b934f6c3a82d01236a92.zip |
Refactor krb5 SIGTERM handler installation
Diffstat (limited to 'src/providers/krb5')
-rw-r--r-- | src/providers/krb5/krb5_common.c | 33 | ||||
-rw-r--r-- | src/providers/krb5/krb5_common.h | 3 | ||||
-rw-r--r-- | src/providers/krb5/krb5_init.c | 17 |
3 files changed, 39 insertions, 14 deletions
diff --git a/src/providers/krb5/krb5_common.c b/src/providers/krb5/krb5_common.c index f63f5164..c78f0e60 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 f9b61956..342481e5 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 481b0880..c457dc55 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) { |