summaryrefslogtreecommitdiff
path: root/server/responder
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2009-10-02 19:36:01 -0400
committerSimo Sorce <ssorce@redhat.com>2009-10-09 16:11:08 -0400
commitdc55d62f4d9f6520ffcb4aa8c6beb308896d9fbb (patch)
tree7842b16b9ce9e4367c2a9a6f05db25fc40b2ab08 /server/responder
parent1f2b3f82f9896a99f8f2b8b2145af47402a9c3c6 (diff)
downloadsssd-dc55d62f4d9f6520ffcb4aa8c6beb308896d9fbb.tar.gz
sssd-dc55d62f4d9f6520ffcb4aa8c6beb308896d9fbb.tar.bz2
sssd-dc55d62f4d9f6520ffcb4aa8c6beb308896d9fbb.zip
Remove DP process
Turn the backend process into data provider servers Make Frontends (pam, nss) directly attach to the backends
Diffstat (limited to 'server/responder')
-rw-r--r--server/responder/common/responder.h20
-rw-r--r--server/responder/common/responder_common.c73
-rw-r--r--server/responder/common/responder_dp.c19
-rw-r--r--server/responder/nss/nsssrv.c32
-rw-r--r--server/responder/pam/pamsrv.c31
-rw-r--r--server/responder/pam/pamsrv_dp.c18
6 files changed, 121 insertions, 72 deletions
diff --git a/server/responder/common/responder.h b/server/responder/common/responder.h
index 558cba31..439bf873 100644
--- a/server/responder/common/responder.h
+++ b/server/responder/common/responder.h
@@ -55,6 +55,18 @@ struct cli_protocol_version {
const char *description;
};
+struct be_conn {
+ struct be_conn *next;
+ struct be_conn *prev;
+
+ const char *cli_name;
+ struct sss_domain_info *domain;
+
+ char *sbus_address;
+ struct sbus_interface *intf;
+ struct sbus_connection *conn;
+};
+
struct resp_ctx {
struct tevent_context *ev;
struct tevent_fd *lfde;
@@ -66,7 +78,7 @@ struct resp_ctx {
const char *priv_sock_name;
struct sbus_connection *mon_conn;
- struct sbus_connection *dp_conn;
+ struct be_conn *be_conns;
struct sss_domain_info *domains;
struct sysdb_ctx_list *db_list;
@@ -107,8 +119,7 @@ int sss_process_init(TALLOC_CTX *mem_ctx,
const char *svc_name,
uint16_t svc_version,
struct sbus_interface *monitor_intf,
- uint16_t cli_type, uint16_t cli_version,
- const char *cli_name, const char *cli_domain,
+ const char *cli_name,
struct sbus_interface *dp_intf,
struct resp_ctx **responder_ctx);
@@ -116,6 +127,9 @@ int sss_parse_name(TALLOC_CTX *memctx,
struct sss_names_ctx *snctx,
const char *orig, char **domain, char **name);
+int sss_dp_get_domain_conn(struct resp_ctx *rctx, const char *domain,
+ struct be_conn **_conn);
+
/* responder_cmd.c */
int sss_cmd_execute(struct cli_ctx *cctx, struct sss_cmd_table *sss_cmds);
void sss_cmd_done(struct cli_ctx *cctx, void *freectx);
diff --git a/server/responder/common/responder_common.c b/server/responder/common/responder_common.c
index 92270afd..37bbcb30 100644
--- a/server/responder/common/responder_common.c
+++ b/server/responder/common/responder_common.c
@@ -318,31 +318,40 @@ static int sss_monitor_init(struct resp_ctx *rctx,
static int sss_dp_init(struct resp_ctx *rctx,
struct sbus_interface *intf,
- uint16_t cli_type, uint16_t cli_version,
- const char *cli_name, const char *cli_domain)
+ const char *cli_name,
+ struct sss_domain_info *domain)
{
- char *sbus_address;
+ struct be_conn *be_conn;
int ret;
+ be_conn = talloc_zero(rctx, struct be_conn);
+ if (!be_conn) return ENOMEM;
+
+ be_conn->cli_name = cli_name;
+ be_conn->domain = domain;
+ be_conn->intf = intf;
+
/* Set up SBUS connection to the monitor */
- ret = dp_get_sbus_address(rctx, &sbus_address);
+ ret = dp_get_sbus_address(be_conn, &be_conn->sbus_address, domain->name);
if (ret != EOK) {
DEBUG(0, ("Could not locate DP address.\n"));
return ret;
}
-
- ret = sbus_client_init(rctx, rctx->ev, sbus_address,
- intf, &rctx->dp_conn,
+ ret = sbus_client_init(rctx, rctx->ev,
+ be_conn->sbus_address,
+ intf, &be_conn->conn,
NULL, NULL);
if (ret != EOK) {
DEBUG(0, ("Failed to connect to monitor services.\n"));
return ret;
}
+ DLIST_ADD_END(rctx->be_conns, be_conn, struct be_conn *);
+
/* Identify ourselves to the DP */
- ret = dp_common_send_id(rctx->dp_conn,
- cli_type, cli_version,
- cli_name, cli_domain);
+ ret = dp_common_send_id(be_conn->conn,
+ DATA_PROVIDER_VERSION,
+ cli_name, domain->name);
if (ret != EOK) {
DEBUG(0, ("Failed to identify to the DP!\n"));
return ret;
@@ -489,12 +498,12 @@ int sss_process_init(TALLOC_CTX *mem_ctx,
const char *svc_name,
uint16_t svc_version,
struct sbus_interface *monitor_intf,
- uint16_t cli_type, uint16_t cli_version,
- const char *cli_name, const char *cli_domain,
+ const char *cli_name,
struct sbus_interface *dp_intf,
struct resp_ctx **responder_ctx)
{
struct resp_ctx *rctx;
+ struct sss_domain_info *dom;
int ret;
rctx = talloc_zero(mem_ctx, struct resp_ctx);
@@ -521,16 +530,18 @@ int sss_process_init(TALLOC_CTX *mem_ctx,
return ret;
}
- ret = sss_dp_init(rctx, dp_intf,
- cli_type, cli_version,
- cli_name, cli_domain);
- if (ret != EOK) {
- DEBUG(0, ("fatal error setting up backend connector\n"));
- return ret;
- }
- else if (!rctx->dp_conn) {
- DEBUG(0, ("Data Provider is not yet available. Retrying.\n"));
- return EIO;
+ for (dom = rctx->domains; dom; dom = dom->next) {
+
+ /* skip local domain, it doesn't have a backend */
+ if (strcasecmp(dom->provider, "local") == 0) {
+ continue;
+ }
+
+ ret = sss_dp_init(rctx, dp_intf, cli_name, dom);
+ if (ret != EOK) {
+ DEBUG(0, ("fatal error setting up backend connector\n"));
+ return ret;
+ }
}
ret = sysdb_init(rctx, ev, cdb, NULL, false, &rctx->db_list);
@@ -558,3 +569,21 @@ int sss_process_init(TALLOC_CTX *mem_ctx,
return EOK;
}
+int sss_dp_get_domain_conn(struct resp_ctx *rctx, const char *domain,
+ struct be_conn **_conn)
+{
+ struct be_conn *iter;
+
+ if (!rctx->be_conns) return ENOENT;
+
+ for (iter = rctx->be_conns; iter; iter = iter->next) {
+ if (strcasecmp(domain, iter->domain->name) == 0) break;
+ }
+
+ if (!iter) return ENOENT;
+
+ *_conn = iter;
+
+ return EOK;
+}
+
diff --git a/server/responder/common/responder_dp.c b/server/responder/common/responder_dp.c
index c8200f80..236755f5 100644
--- a/server/responder/common/responder_dp.c
+++ b/server/responder/common/responder_dp.c
@@ -417,25 +417,27 @@ static int sss_dp_send_acct_req_create(struct resp_ctx *rctx,
dbus_bool_t dbret;
struct sss_dp_callback *cb;
struct sss_dp_req *sdp_req;
-
const char *attrs = "core";
+ struct be_conn *be_conn;
+ int ret;
/* double check dp_ctx has actually been initialized.
* in some pathological cases it may happen that nss starts up before
* dp connection code is actually able to establish a connection.
*/
- if (!rctx->dp_conn) {
- DEBUG(1, ("The Data Provider connection is not available yet!"
- " This maybe a bug, it shouldn't happen!\n"));
+ ret = sss_dp_get_domain_conn(rctx, domain, &be_conn);
+ if (ret != EOK) {
+ DEBUG(1, ("The Data Provider connection for %s is not available!"
+ " This maybe a bug, it shouldn't happen!\n", domain));
return EIO;
}
- dbus_conn = sbus_get_connection(rctx->dp_conn);
+ dbus_conn = sbus_get_connection(be_conn->conn);
/* create the message */
msg = dbus_message_new_method_call(NULL,
- DP_CLI_PATH,
- DP_CLI_INTERFACE,
- DP_SRV_METHOD_GETACCTINFO);
+ DP_PATH,
+ DP_INTERFACE,
+ DP_METHOD_GETACCTINFO);
if (msg == NULL) {
DEBUG(0,("Out of memory?!\n"));
return ENOMEM;
@@ -445,7 +447,6 @@ static int sss_dp_send_acct_req_create(struct resp_ctx *rctx,
domain, be_type, attrs, filter));
dbret = dbus_message_append_args(msg,
- DBUS_TYPE_STRING, &domain,
DBUS_TYPE_UINT32, &be_type,
DBUS_TYPE_STRING, &attrs,
DBUS_TYPE_STRING, &filter,
diff --git a/server/responder/nss/nsssrv.c b/server/responder/nss/nsssrv.c
index e7c2307d..319c0b74 100644
--- a/server/responder/nss/nsssrv.c
+++ b/server/responder/nss/nsssrv.c
@@ -229,8 +229,8 @@ static struct sbus_method nss_dp_methods[] = {
};
struct sbus_interface nss_dp_interface = {
- DP_CLI_INTERFACE,
- DP_CLI_PATH,
+ DP_INTERFACE,
+ DP_PATH,
SBUS_DEFAULT_VTABLE,
nss_dp_methods,
NULL
@@ -240,7 +240,7 @@ struct sbus_interface nss_dp_interface = {
static void nss_dp_reconnect_init(struct sbus_connection *conn,
int status, void *pvt)
{
- struct resp_ctx *rctx = talloc_get_type(pvt, struct resp_ctx);
+ struct be_conn *be_conn = talloc_get_type(pvt, struct be_conn);
int ret;
/* Did we reconnect successfully? */
@@ -248,18 +248,19 @@ static void nss_dp_reconnect_init(struct sbus_connection *conn,
DEBUG(1, ("Reconnected to the Data Provider.\n"));
/* Identify ourselves to the data provider */
- ret = dp_common_send_id(conn,
- DP_CLI_FRONTEND,
+ ret = dp_common_send_id(be_conn->conn,
DATA_PROVIDER_VERSION,
- "NSS", "");
+ "NSS", be_conn->domain->name);
/* all fine */
if (ret == EOK) return;
}
/* Failed to reconnect */
- DEBUG(0, ("Could not reconnect to data provider.\n"));
- /* Kill the backend and let the monitor restart it */
- nss_shutdown(rctx);
+ DEBUG(0, ("Could not reconnect to %s provider.\n",
+ be_conn->domain->name));
+
+ /* FIXME: kill the frontend and let the monitor restart it ? */
+ /* nss_shutdown(rctx); */
}
int nss_process_init(TALLOC_CTX *mem_ctx,
@@ -267,6 +268,7 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
struct confdb_ctx *cdb)
{
struct sss_cmd_table *nss_cmds;
+ struct be_conn *iter;
struct nss_ctx *nctx;
int ret, max_retries;
@@ -291,10 +293,7 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
NSS_SBUS_SERVICE_NAME,
NSS_SBUS_SERVICE_VERSION,
&monitor_nss_interface,
- DP_CLI_FRONTEND,
- DATA_PROVIDER_VERSION,
- "NSS", "",
- &nss_dp_interface,
+ "NSS", &nss_dp_interface,
&nctx->rctx);
if (ret != EOK) {
return ret;
@@ -317,9 +316,10 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
return ret;
}
- sbus_reconnect_init(nctx->rctx->dp_conn,
- max_retries,
- nss_dp_reconnect_init, nctx->rctx);
+ for (iter = nctx->rctx->be_conns; iter; iter = iter->next) {
+ sbus_reconnect_init(iter->conn, max_retries,
+ nss_dp_reconnect_init, iter);
+ }
DEBUG(1, ("NSS Initialization complete\n"));
diff --git a/server/responder/pam/pamsrv.c b/server/responder/pam/pamsrv.c
index f8af665b..53478522 100644
--- a/server/responder/pam/pamsrv.c
+++ b/server/responder/pam/pamsrv.c
@@ -88,8 +88,8 @@ static struct sbus_method pam_dp_methods[] = {
};
struct sbus_interface pam_dp_interface = {
- DP_CLI_INTERFACE,
- DP_CLI_PATH,
+ DP_INTERFACE,
+ DP_PATH,
SBUS_DEFAULT_VTABLE,
pam_dp_methods,
NULL
@@ -98,7 +98,7 @@ struct sbus_interface pam_dp_interface = {
static void pam_dp_reconnect_init(struct sbus_connection *conn, int status, void *pvt)
{
- struct resp_ctx *rctx = talloc_get_type(pvt, struct resp_ctx);
+ struct be_conn *be_conn = talloc_get_type(pvt, struct be_conn);
int ret;
/* Did we reconnect successfully? */
@@ -106,18 +106,19 @@ static void pam_dp_reconnect_init(struct sbus_connection *conn, int status, void
DEBUG(1, ("Reconnected to the Data Provider.\n"));
/* Identify ourselves to the data provider */
- ret = dp_common_send_id(conn,
- DP_CLI_FRONTEND,
+ ret = dp_common_send_id(be_conn->conn,
DATA_PROVIDER_VERSION,
- "PAM", "");
+ "PAM", be_conn->domain->name);
/* all fine */
if (ret == EOK) return;
}
/* Handle failure */
- DEBUG(0, ("Could not reconnect to data provider.\n"));
- /* Kill the backend and let the monitor restart it */
- pam_shutdown(rctx);
+ DEBUG(0, ("Could not reconnect to %s provider.\n",
+ be_conn->domain->name));
+
+ /* FIXME: kill the frontend and let the monitor restart it ? */
+ /* pam_shutdown(rctx); */
}
static int pam_process_init(TALLOC_CTX *mem_ctx,
@@ -125,6 +126,7 @@ static int pam_process_init(TALLOC_CTX *mem_ctx,
struct confdb_ctx *cdb)
{
struct sss_cmd_table *pam_cmds;
+ struct be_conn *iter;
struct resp_ctx *rctx;
int ret, max_retries;
@@ -137,10 +139,7 @@ static int pam_process_init(TALLOC_CTX *mem_ctx,
PAM_SBUS_SERVICE_NAME,
PAM_SBUS_SERVICE_VERSION,
&monitor_pam_interface,
- DP_CLI_FRONTEND,
- DATA_PROVIDER_VERSION,
- "PAM", "",
- &pam_dp_interface,
+ "PAM", &pam_dp_interface,
&rctx);
if (ret != EOK) {
return ret;
@@ -157,8 +156,10 @@ static int pam_process_init(TALLOC_CTX *mem_ctx,
return ret;
}
- sbus_reconnect_init(rctx->dp_conn, max_retries,
- pam_dp_reconnect_init, rctx);
+ for (iter = rctx->be_conns; iter; iter = iter->next) {
+ sbus_reconnect_init(iter->conn, max_retries,
+ pam_dp_reconnect_init, iter);
+ }
return EOK;
}
diff --git a/server/responder/pam/pamsrv_dp.c b/server/responder/pam/pamsrv_dp.c
index 7ea2b7e4..071d09b8 100644
--- a/server/responder/pam/pamsrv_dp.c
+++ b/server/responder/pam/pamsrv_dp.c
@@ -82,26 +82,30 @@ done:
int pam_dp_send_req(struct pam_auth_req *preq, int timeout)
{
struct pam_data *pd = preq->pd;
+ struct be_conn *be_conn;
DBusMessage *msg;
DBusPendingCall *pending_reply;
DBusConnection *dbus_conn;
dbus_bool_t ret;
+ int res;
/* double check dp_ctx has actually been initialized.
* in some pathological cases it may happen that nss starts up before
* dp connection code is actually able to establish a connection.
*/
- if (!preq->cctx->rctx->dp_conn) {
- DEBUG(1, ("The Data Provider connection is not available yet!"
- " This maybe a bug, it shouldn't happen!\n"));
+ res = sss_dp_get_domain_conn(preq->cctx->rctx,
+ preq->domain->name, &be_conn);
+ if (res != EOK) {
+ DEBUG(1, ("The Data Provider connection for %s is not available!"
+ " This maybe a bug, it shouldn't happen!\n", preq->domain));
return EIO;
}
- dbus_conn = sbus_get_connection(preq->cctx->rctx->dp_conn);
+ dbus_conn = sbus_get_connection(be_conn->conn);
msg = dbus_message_new_method_call(NULL,
- DP_CLI_PATH,
- DP_CLI_INTERFACE,
- DP_SRV_METHOD_PAMHANDLER);
+ DP_PATH,
+ DP_INTERFACE,
+ DP_METHOD_PAMHANDLER);
if (msg == NULL) {
DEBUG(0,("Out of memory?!\n"));
return ENOMEM;