summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2012-10-19 11:43:47 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-03-20 13:29:29 +0100
commit7c9fe57ad82747a32721ca0a08c5569282f3e0c4 (patch)
tree05f8ba655d1f6a0a77ed0e823f7d5c422ad2cc93
parent6f8ae17869f4f8a1496e3f171ae6b5c11af1845c (diff)
downloadsssd-7c9fe57ad82747a32721ca0a08c5569282f3e0c4.tar.gz
sssd-7c9fe57ad82747a32721ca0a08c5569282f3e0c4.tar.bz2
sssd-7c9fe57ad82747a32721ca0a08c5569282f3e0c4.zip
change responder contexts hierarchy
https://fedorahosted.org/sssd/ticket/1575 The hierarchy is now: main_ctx -> responder_ctx -> specific_ctx where specific_ctx is one of sudo, pam, etc.
-rw-r--r--src/responder/autofs/autofssrv.c35
-rw-r--r--src/responder/nss/nsssrv.c35
-rw-r--r--src/responder/pac/pacsrv.c23
-rw-r--r--src/responder/pam/pamsrv.c20
-rw-r--r--src/responder/ssh/sshsrv.c23
-rw-r--r--src/responder/sudo/sudosrv.c23
6 files changed, 94 insertions, 65 deletions
diff --git a/src/responder/autofs/autofssrv.c b/src/responder/autofs/autofssrv.c
index ef90207f..ea4c0494 100644
--- a/src/responder/autofs/autofssrv.c
+++ b/src/responder/autofs/autofssrv.c
@@ -128,6 +128,7 @@ autofs_process_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct confdb_ctx *cdb)
{
+ struct resp_ctx *rctx;
struct sss_cmd_table *autofs_cmds;
struct autofs_ctx *autofs_ctx;
struct be_conn *iter;
@@ -135,20 +136,8 @@ autofs_process_init(TALLOC_CTX *mem_ctx,
int hret;
int max_retries;
- autofs_ctx = talloc_zero(mem_ctx, struct autofs_ctx);
- if (!autofs_ctx) {
- DEBUG(SSSDBG_FATAL_FAILURE, ("fatal error initializing autofs_ctx\n"));
- return ENOMEM;
- }
-
- ret = autofs_get_config(autofs_ctx, cdb);
- if (ret != EOK) {
- DEBUG(SSSDBG_FATAL_FAILURE, ("Cannot read autofs configuration\n"));
- goto fail;
- }
-
autofs_cmds = get_autofs_cmds();
- ret = sss_process_init(autofs_ctx, ev, cdb,
+ ret = sss_process_init(mem_ctx, ev, cdb,
autofs_cmds,
SSS_AUTOFS_SOCKET_NAME, NULL,
CONFDB_AUTOFS_CONF_ENTRY,
@@ -157,10 +146,26 @@ autofs_process_init(TALLOC_CTX *mem_ctx,
&monitor_autofs_interface,
"autofs",
&autofs_dp_interface,
- &autofs_ctx->rctx);
+ &rctx);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_FATAL_FAILURE, ("sss_process_init() failed\n"));
+ return ret;
+ }
+
+ autofs_ctx = talloc_zero(rctx, struct autofs_ctx);
+ if (!autofs_ctx) {
+ DEBUG(SSSDBG_FATAL_FAILURE, ("fatal error initializing autofs_ctx\n"));
+ ret = ENOMEM;
+ goto fail;
+ }
+
+ ret = autofs_get_config(autofs_ctx, cdb);
if (ret != EOK) {
+ DEBUG(SSSDBG_FATAL_FAILURE, ("Cannot read autofs configuration\n"));
goto fail;
}
+
+ autofs_ctx->rctx = rctx;
autofs_ctx->rctx->pvt_ctx = autofs_ctx;
/* Enable automatic reconnection to the Data Provider */
@@ -193,7 +198,7 @@ autofs_process_init(TALLOC_CTX *mem_ctx,
return EOK;
fail:
- talloc_free(autofs_ctx);
+ talloc_free(rctx);
return ret;
}
diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c
index e5334129..709912c2 100644
--- a/src/responder/nss/nsssrv.c
+++ b/src/responder/nss/nsssrv.c
@@ -395,6 +395,7 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct confdb_ctx *cdb)
{
+ struct resp_ctx *rctx;
struct sss_cmd_table *nss_cmds;
struct be_conn *iter;
struct nss_ctx *nctx;
@@ -403,21 +404,9 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
int hret;
int fd_limit;
- nctx = talloc_zero(mem_ctx, struct nss_ctx);
- if (!nctx) {
- DEBUG(0, ("fatal error initializing nss_ctx\n"));
- return ENOMEM;
- }
-
- ret = sss_ncache_init(nctx, &nctx->ncache);
- if (ret != EOK) {
- DEBUG(0, ("fatal error initializing negative cache\n"));
- goto fail;
- }
-
nss_cmds = get_nss_cmds();
- ret = sss_process_init(nctx, ev, cdb,
+ ret = sss_process_init(mem_ctx, ev, cdb,
nss_cmds,
SSS_NSS_SOCKET_NAME, NULL,
CONFDB_NSS_CONF_ENTRY,
@@ -425,10 +414,26 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
NSS_SBUS_SERVICE_VERSION,
&monitor_nss_interface,
"NSS", &nss_dp_interface,
- &nctx->rctx);
+ &rctx);
if (ret != EOK) {
+ DEBUG(SSSDBG_FATAL_FAILURE, ("sss_process_init() failed\n"));
+ return ret;
+ }
+
+ nctx = talloc_zero(rctx, struct nss_ctx);
+ if (!nctx) {
+ DEBUG(0, ("fatal error initializing nss_ctx\n"));
+ ret = ENOMEM;
+ goto fail;
+ }
+
+ ret = sss_ncache_init(rctx, &nctx->ncache);
+ if (ret != EOK) {
+ DEBUG(0, ("fatal error initializing negative cache\n"));
goto fail;
}
+
+ nctx->rctx = rctx;
nctx->rctx->pvt_ctx = nctx;
ret = nss_get_config(nctx, cdb);
@@ -513,7 +518,7 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
return EOK;
fail:
- talloc_free(nctx);
+ talloc_free(rctx);
return ret;
}
diff --git a/src/responder/pac/pacsrv.c b/src/responder/pac/pacsrv.c
index 29447c47..9bc27663 100644
--- a/src/responder/pac/pacsrv.c
+++ b/src/responder/pac/pacsrv.c
@@ -119,6 +119,7 @@ int pac_process_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct confdb_ctx *cdb)
{
+ struct resp_ctx *rctx;
struct sss_cmd_table *pac_cmds;
struct be_conn *iter;
struct pac_ctx *pac_ctx;
@@ -127,15 +128,9 @@ int pac_process_init(TALLOC_CTX *mem_ctx,
int fd_limit;
char *uid_str;
- pac_ctx = talloc_zero(mem_ctx, struct pac_ctx);
- if (!pac_ctx) {
- DEBUG(SSSDBG_FATAL_FAILURE, ("fatal error initializing pac_ctx\n"));
- return ENOMEM;
- }
-
pac_cmds = get_pac_cmds();
- ret = sss_process_init(pac_ctx, ev, cdb,
+ ret = sss_process_init(mem_ctx, ev, cdb,
pac_cmds,
SSS_PAC_SOCKET_NAME, NULL,
CONFDB_PAC_CONF_ENTRY,
@@ -143,10 +138,20 @@ int pac_process_init(TALLOC_CTX *mem_ctx,
PAC_SBUS_SERVICE_VERSION,
&monitor_pac_interface,
"PAC", &pac_dp_interface,
- &pac_ctx->rctx);
+ &rctx);
if (ret != EOK) {
+ DEBUG(SSSDBG_FATAL_FAILURE, ("sss_process_init() failed\n"));
+ return ret;
+ }
+
+ pac_ctx = talloc_zero(rctx, struct pac_ctx);
+ if (!pac_ctx) {
+ DEBUG(SSSDBG_FATAL_FAILURE, ("fatal error initializing pac_ctx\n"));
+ ret = ENOMEM;
goto fail;
}
+
+ pac_ctx->rctx = rctx;
pac_ctx->rctx->pvt_ctx = pac_ctx;
@@ -207,7 +212,7 @@ int pac_process_init(TALLOC_CTX *mem_ctx,
return EOK;
fail:
- talloc_free(pac_ctx);
+ talloc_free(rctx);
return ret;
}
diff --git a/src/responder/pam/pamsrv.c b/src/responder/pam/pamsrv.c
index e5bb9009..c71ef07c 100644
--- a/src/responder/pam/pamsrv.c
+++ b/src/responder/pam/pamsrv.c
@@ -107,6 +107,7 @@ static int pam_process_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct confdb_ctx *cdb)
{
+ struct resp_ctx *rctx;
struct sss_cmd_table *pam_cmds;
struct be_conn *iter;
struct pam_ctx *pctx;
@@ -114,13 +115,8 @@ static int pam_process_init(TALLOC_CTX *mem_ctx,
int id_timeout;
int fd_limit;
- pctx = talloc_zero(mem_ctx, struct pam_ctx);
- if (!pctx) {
- return ENOMEM;
- }
-
pam_cmds = get_pam_cmds();
- ret = sss_process_init(pctx, ev, cdb,
+ ret = sss_process_init(mem_ctx, ev, cdb,
pam_cmds,
SSS_PAM_SOCKET_NAME,
SSS_PAM_PRIV_SOCKET_NAME,
@@ -129,11 +125,19 @@ static int pam_process_init(TALLOC_CTX *mem_ctx,
SSS_PAM_SBUS_SERVICE_VERSION,
&monitor_pam_interface,
"PAM", &pam_dp_interface,
- &pctx->rctx);
+ &rctx);
if (ret != EOK) {
+ DEBUG(SSSDBG_FATAL_FAILURE, ("sss_process_init() failed\n"));
+ return ret;
+ }
+
+ pctx = talloc_zero(rctx, struct pam_ctx);
+ if (!pctx) {
+ ret = ENOMEM;
goto done;
}
+ pctx->rctx = rctx;
pctx->rctx->pvt_ctx = pctx;
/* Enable automatic reconnection to the Data Provider */
@@ -203,7 +207,7 @@ static int pam_process_init(TALLOC_CTX *mem_ctx,
done:
if (ret != EOK) {
- talloc_free(pctx);
+ talloc_free(rctx);
}
return ret;
}
diff --git a/src/responder/ssh/sshsrv.c b/src/responder/ssh/sshsrv.c
index fe6956ab..8a66f223 100644
--- a/src/responder/ssh/sshsrv.c
+++ b/src/responder/ssh/sshsrv.c
@@ -85,20 +85,15 @@ int ssh_process_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct confdb_ctx *cdb)
{
+ struct resp_ctx *rctx;
struct sss_cmd_table *ssh_cmds;
struct ssh_ctx *ssh_ctx;
struct be_conn *iter;
int ret;
int max_retries;
- ssh_ctx = talloc_zero(mem_ctx, struct ssh_ctx);
- if (!ssh_ctx) {
- DEBUG(SSSDBG_FATAL_FAILURE, ("fatal error initializing ssh_ctx\n"));
- return ENOMEM;
- }
-
ssh_cmds = get_ssh_cmds();
- ret = sss_process_init(ssh_ctx, ev, cdb,
+ ret = sss_process_init(mem_ctx, ev, cdb,
ssh_cmds,
SSS_SSH_SOCKET_NAME, NULL,
CONFDB_SSH_CONF_ENTRY,
@@ -107,10 +102,20 @@ int ssh_process_init(TALLOC_CTX *mem_ctx,
&monitor_ssh_interface,
"SSH",
&ssh_dp_interface,
- &ssh_ctx->rctx);
+ &rctx);
if (ret != EOK) {
+ DEBUG(SSSDBG_FATAL_FAILURE, ("sss_process_init() failed\n"));
+ return ret;
+ }
+
+ ssh_ctx = talloc_zero(rctx, struct ssh_ctx);
+ if (!ssh_ctx) {
+ DEBUG(SSSDBG_FATAL_FAILURE, ("fatal error initializing ssh_ctx\n"));
+ ret = ENOMEM;
goto fail;
}
+
+ ssh_ctx->rctx = rctx;
ssh_ctx->rctx->pvt_ctx = ssh_ctx;
/* Enable automatic reconnection to the Data Provider */
@@ -158,7 +163,7 @@ int ssh_process_init(TALLOC_CTX *mem_ctx,
return EOK;
fail:
- talloc_free(ssh_ctx);
+ talloc_free(rctx);
return ret;
}
diff --git a/src/responder/sudo/sudosrv.c b/src/responder/sudo/sudosrv.c
index 40817601..a6344a99 100644
--- a/src/responder/sudo/sudosrv.c
+++ b/src/responder/sudo/sudosrv.c
@@ -86,20 +86,15 @@ int sudo_process_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct confdb_ctx *cdb)
{
+ struct resp_ctx *rctx;
struct sss_cmd_table *sudo_cmds;
struct sudo_ctx *sudo_ctx;
struct be_conn *iter;
int ret;
int max_retries;
- sudo_ctx = talloc_zero(mem_ctx, struct sudo_ctx);
- if (!sudo_ctx) {
- DEBUG(SSSDBG_FATAL_FAILURE, ("fatal error initializing sudo_ctx\n"));
- return ENOMEM;
- }
-
sudo_cmds = get_sudo_cmds();
- ret = sss_process_init(sudo_ctx, ev, cdb,
+ ret = sss_process_init(mem_ctx, ev, cdb,
sudo_cmds,
SSS_SUDO_SOCKET_NAME, NULL,
CONFDB_SUDO_CONF_ENTRY,
@@ -108,10 +103,20 @@ int sudo_process_init(TALLOC_CTX *mem_ctx,
&monitor_sudo_interface,
"SUDO",
&sudo_dp_interface,
- &sudo_ctx->rctx);
+ &rctx);
if (ret != EOK) {
+ DEBUG(SSSDBG_FATAL_FAILURE, ("sss_process_init() failed\n"));
+ return ret;
+ }
+
+ sudo_ctx = talloc_zero(rctx, struct sudo_ctx);
+ if (!sudo_ctx) {
+ DEBUG(SSSDBG_FATAL_FAILURE, ("fatal error initializing sudo_ctx\n"));
+ ret = ENOMEM;
goto fail;
}
+
+ sudo_ctx->rctx = rctx;
sudo_ctx->rctx->pvt_ctx = sudo_ctx;
/* Enable automatic reconnection to the Data Provider */
@@ -148,7 +153,7 @@ int sudo_process_init(TALLOC_CTX *mem_ctx,
return EOK;
fail:
- talloc_free(sudo_ctx);
+ talloc_free(rctx);
return ret;
}