summaryrefslogtreecommitdiff
path: root/server/responder/pam
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2009-08-05 14:11:12 -0400
committerStephen Gallagher <sgallagh@redhat.com>2009-08-10 09:42:20 -0400
commit11c621b5ee1a0cdc27610f8b172017764acc285e (patch)
tree181c9079440367711c66d7281fc0aecb458fee77 /server/responder/pam
parentf1e4471551aa74015579bff0b64735cc9b085b74 (diff)
downloadsssd-11c621b5ee1a0cdc27610f8b172017764acc285e.tar.gz
sssd-11c621b5ee1a0cdc27610f8b172017764acc285e.tar.bz2
sssd-11c621b5ee1a0cdc27610f8b172017764acc285e.zip
Simplify interfaces initialization
Make as much as possible static, and remove use of talloc_reference and allocation/deallocation of memory when not necessary. Fix also responder use of rctx->conn, was mistakenly used for both monitor and dp connections.
Diffstat (limited to 'server/responder/pam')
-rw-r--r--server/responder/pam/pamsrv.c39
-rw-r--r--server/responder/pam/pamsrv.h2
-rw-r--r--server/responder/pam/pamsrv_dp.c26
3 files changed, 37 insertions, 30 deletions
diff --git a/server/responder/pam/pamsrv.c b/server/responder/pam/pamsrv.c
index cd423714..48286ecd 100644
--- a/server/responder/pam/pamsrv.c
+++ b/server/responder/pam/pamsrv.c
@@ -60,12 +60,20 @@ static int service_pong(DBusMessage *message, struct sbus_connection *conn);
static int service_reload(DBusMessage *message, struct sbus_connection *conn);
static int service_res_init(DBusMessage *message, struct sbus_connection *conn);
-struct sbus_method sss_sbus_methods[] = {
- {SERVICE_METHOD_IDENTITY, service_identity},
- {SERVICE_METHOD_PING, service_pong},
- {SERVICE_METHOD_RELOAD, service_reload},
- {SERVICE_METHOD_RES_INIT, service_res_init},
- {NULL, NULL}
+struct sbus_method monitor_pam_methods[] = {
+ { MON_CLI_METHOD_IDENTITY, service_identity },
+ { MON_CLI_METHOD_PING, service_pong },
+ { MON_CLI_METHOD_RELOAD, service_reload },
+ { MON_CLI_METHOD_RES_INIT, service_res_init },
+ { NULL, NULL }
+};
+
+struct sbus_interface monitor_pam_interface = {
+ MONITOR_INTERFACE,
+ MONITOR_PATH,
+ SBUS_DEFAULT_VTABLE,
+ monitor_pam_methods,
+ NULL
};
static int service_identity(DBusMessage *message, struct sbus_connection *conn)
@@ -142,19 +150,10 @@ static int service_reload(DBusMessage *message, struct sbus_connection *conn) {
static void pam_dp_reconnect_init(struct sbus_connection *conn, int status, void *pvt)
{
- int ret;
struct resp_ctx *rctx = talloc_get_type(pvt, struct resp_ctx);
/* Did we reconnect successfully? */
if (status == SBUS_RECONNECT_SUCCESS) {
- /* Add the methods back to the new connection */
- ret = sbus_conn_add_method_ctx(rctx->conn,
- rctx->sm_ctx);
- if (ret != EOK) {
- DEBUG(0, ("Could not re-add methods on reconnection.\n"));
- pam_shutdown(rctx);
- }
-
DEBUG(1, ("Reconnected to the Data Provider.\n"));
return;
}
@@ -190,7 +189,7 @@ static int pam_process_init(struct main_context *main_ctx,
return ret;
}
- sbus_reconnect_init(rctx->conn, max_retries,
+ sbus_reconnect_init(rctx->dp_conn, max_retries,
pam_dp_reconnect_init, rctx);
return EOK;
@@ -202,7 +201,7 @@ int main(int argc, const char *argv[])
poptContext pc;
struct main_context *main_ctx;
int ret;
- struct sbus_method *pam_dp_methods;
+ struct sbus_interface *pam_dp_interface;
struct sss_cmd_table *sss_cmds;
struct resp_ctx *rctx;
@@ -229,17 +228,17 @@ int main(int argc, const char *argv[])
ret = server_setup("sssd[pam]", 0, PAM_SRV_CONFIG, &main_ctx);
if (ret != EOK) return 2;
- pam_dp_methods = register_pam_dp_methods();
+ pam_dp_interface = get_pam_dp_interface();
sss_cmds = register_sss_cmds();
ret = sss_process_init(main_ctx,
main_ctx->event_ctx,
main_ctx->confdb_ctx,
- sss_sbus_methods,
sss_cmds,
SSS_PAM_SOCKET_NAME,
SSS_PAM_PRIV_SOCKET_NAME,
PAM_SRV_CONFIG,
- pam_dp_methods,
+ pam_dp_interface,
+ &monitor_pam_interface,
&rctx);
if (ret != EOK) return 3;
diff --git a/server/responder/pam/pamsrv.h b/server/responder/pam/pamsrv.h
index fa688fe1..1de1cee8 100644
--- a/server/responder/pam/pamsrv.h
+++ b/server/responder/pam/pamsrv.h
@@ -22,7 +22,7 @@ struct pam_auth_req {
void *data;
};
-struct sbus_method *register_pam_dp_methods(void);
+struct sbus_interface *get_pam_dp_interface(void);
struct sss_cmd_table *register_sss_cmds(void);
int pam_dp_send_req(struct pam_auth_req *preq, int timeout);
diff --git a/server/responder/pam/pamsrv_dp.c b/server/responder/pam/pamsrv_dp.c
index c7a536e8..c0a286b2 100644
--- a/server/responder/pam/pamsrv_dp.c
+++ b/server/responder/pam/pamsrv_dp.c
@@ -92,12 +92,12 @@ int pam_dp_send_req(struct pam_auth_req *preq, int timeout)
* 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->conn) {
+ 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"));
return EIO;
}
- dbus_conn = sbus_get_connection(preq->cctx->rctx->conn);
+ dbus_conn = sbus_get_connection(preq->cctx->rctx->dp_conn);
msg = dbus_message_new_method_call(NULL,
DP_CLI_PATH,
@@ -169,12 +169,20 @@ static int pam_dp_identity(DBusMessage *message, struct sbus_connection *conn)
return EOK;
}
-struct sbus_method *register_pam_dp_methods(void)
-{
- static struct sbus_method pam_dp_methods[] = {
- { DP_CLI_METHOD_IDENTITY, pam_dp_identity },
- { NULL, NULL }
- };
+static struct sbus_method pam_dp_methods[] = {
+ { DP_CLI_METHOD_IDENTITY, pam_dp_identity },
+ { NULL, NULL }
+};
+
+struct sbus_interface pam_dp_interface = {
+ DATA_PROVIDER_INTERFACE,
+ DATA_PROVIDER_PATH,
+ SBUS_DEFAULT_VTABLE,
+ pam_dp_methods,
+ NULL
+};
- return pam_dp_methods;
+struct sbus_interface *get_pam_dp_interface(void)
+{
+ return &pam_dp_interface;
}