diff options
author | Arun Scaria <arunscaria91@gmail.com> | 2011-06-29 09:47:43 +0530 |
---|---|---|
committer | Arun Scaria <arunscaria91@gmail.com> | 2011-06-29 09:47:43 +0530 |
commit | 3aa92f744fc8a1e1accaa6fa546e0da7e11cc732 (patch) | |
tree | acf3dd49799ba4ff0d3cd1e633a86f41dd9b9120 | |
parent | 5dde75056bbb42fec73223122a6fe27a47395dec (diff) | |
download | sssd_unused-3aa92f744fc8a1e1accaa6fa546e0da7e11cc732.tar.gz sssd_unused-3aa92f744fc8a1e1accaa6fa546e0da7e11cc732.tar.xz sssd_unused-3aa92f744fc8a1e1accaa6fa546e0da7e11cc732.zip |
fixed sbus-plugin sample communication and Preprocessors added
-rw-r--r-- | src/responder/sudo/sudosrv.c | 24 | ||||
-rw-r--r-- | src/responder/sudo/sudosrv.h | 21 | ||||
-rw-r--r-- | src/sss_client/sudo_plugin/sss_sudo_cli.h | 18 | ||||
-rw-r--r-- | src/sss_client/sudo_plugin/sss_sudoplugin.c | 12 |
4 files changed, 51 insertions, 24 deletions
diff --git a/src/responder/sudo/sudosrv.c b/src/responder/sudo/sudosrv.c index 35ad4939..6f8935cb 100644 --- a/src/responder/sudo/sudosrv.c +++ b/src/responder/sudo/sudosrv.c @@ -41,8 +41,8 @@ static int sudo_client_destructor(void *ctx) { struct sudo_client *sudocli = talloc_get_type(ctx, struct sudo_client); - if (sudocli->sudoctx) { - //sudocli->sudoctx->sudo_cli = NULL; + if (sudocli) { + talloc_zfree(sudocli); DEBUG(4, ("Removed Sudo client\n")); } return 0; @@ -68,7 +68,7 @@ static int sudo_query_validation(DBusMessage *message, struct sbus_connection *c } /* First thing, cancel the timeout */ - DEBUG(4, ("Cancel SUDO ID timeout [%p]\n", sudocli->timeout)); + DEBUG(4, ("Cancel SUDO client timeout [%p]\n", sudocli->timeout)); talloc_zfree(sudocli->timeout); dbus_error_init(&dbus_error); @@ -99,7 +99,7 @@ static int sudo_query_validation(DBusMessage *message, struct sbus_connection *c DBUS_TYPE_UINT16, &version, DBUS_TYPE_INVALID); if (!dbret) { - DEBUG(0, ("Failed to build dbus reply\n")); + DEBUG(0, ("Failed to build sudo dbus reply\n")); dbus_message_unref(reply); sbus_disconnect(conn); return EIO; @@ -121,7 +121,7 @@ static void init_timeout(struct tevent_context *ev, { struct sudo_client *sudocli; - DEBUG(2, ("Client timed out before Identification [%p]!\n", te)); + DEBUG(2, ("Client timed out [%p]!\n", te)); sudocli = talloc_get_type(ptr, struct sudo_client); @@ -159,7 +159,7 @@ static int sudo_client_init(struct sbus_connection *conn, void *data) talloc_zfree(conn); return ENOMEM; } - DEBUG(4, ("Set-up Backend ID timeout [%p]\n", sudocli->timeout)); + DEBUG(4, ("Set-up Sudo client timeout [%p]\n", sudocli->timeout)); /* Attach the client context to the connection context, so that it is * always available when we need to manage the connection. */ @@ -169,24 +169,24 @@ static int sudo_client_init(struct sbus_connection *conn, void *data) } -int sudo_server_connect(TALLOC_CTX *mem_ctx, +int sudo_server_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct sudo_ctx *_ctx) { - char *sudo_address="unix:path=/tmp/sssd/sudo"; int ret; struct sbus_connection *serv; DEBUG(1, ("Setting up the sudo server.\n")); + + - - ret = sbus_new_server(mem_ctx,ev, sudo_address, + ret = sbus_new_server(mem_ctx,ev, SSS_SUDO_SERVICE_PIPE, &sudo_interface, &serv, sudo_client_init, _ctx); if (ret != EOK) { - DEBUG(0, ("Could not set up sbus server.\n")); + DEBUG(0, ("Could not set up sudo sbus server.\n")); return ret; } @@ -206,7 +206,7 @@ int sudo_process_init(TALLOC_CTX *mem_ctx, ctx->cdb = cdb; - ret =sudo_server_connect(mem_ctx,ev,ctx); + ret = sudo_server_init(mem_ctx, ev, ctx); DEBUG(0, ("sudo server returned %d.\n",ret)); return EOK; diff --git a/src/responder/sudo/sudosrv.h b/src/responder/sudo/sudosrv.h index e09eaeb8..3da03bd0 100644 --- a/src/responder/sudo/sudosrv.h +++ b/src/responder/sudo/sudosrv.h @@ -25,9 +25,22 @@ #define CONFDB_SUDO_CONF_ENTRY "config/sudo" -#define SUDO_INTERFACE "org.freedesktop.sssd.sudo" -#define SUDO_PATH "/org/freedesktop/sssd/sudo" +#ifndef SSS_SUDO_SERVICE_PIPE +#define SSS_SUDO_SERVICE_PIPE "unix:path=" PIPE_PATH "/sudo" +#endif + +#ifndef SUDO_SERVER_INTERFACE +#define SUDO_SERVER_INTERFACE "org.freedesktop.sssd.sudo" +#endif + +#ifndef SUDO_SERVER_PATH +#define SUDO_SERVER_PATH "/org/freedesktop/sssd/sudo" +#endif + +#ifndef SUDO_METHOD_QUERY #define SUDO_METHOD_QUERY "queryService" +#endif + static int sudo_query_validation(DBusMessage *message, struct sbus_connection *conn); struct sbus_method sudo_methods[] = { @@ -37,8 +50,8 @@ struct sbus_method sudo_methods[] = { }; struct sbus_interface sudo_interface = { - SUDO_INTERFACE, - SUDO_PATH, + SUDO_SERVER_INTERFACE, + SUDO_SERVER_PATH, SBUS_DEFAULT_VTABLE, sudo_methods, NULL diff --git a/src/sss_client/sudo_plugin/sss_sudo_cli.h b/src/sss_client/sudo_plugin/sss_sudo_cli.h index 799fa632..9bd4997c 100644 --- a/src/sss_client/sudo_plugin/sss_sudo_cli.h +++ b/src/sss_client/sudo_plugin/sss_sudo_cli.h @@ -32,11 +32,25 @@ #undef SSS_START_OF_SUDO_REQUEST #define SSS_START_OF_SUDO_REQUEST 0x436789 -#undef SSS_SUDO_SERVER_ADDRESS -#define SSS_SUDO_SERVER_ADDRESS "unix:path=/tmp/sssd/sudo" +#ifndef SSS_SUDO_SERVICE_PIPE +#define SSS_SUDO_SERVICE_PIPE "unix:path=" PIPE_PATH "/sudo" +#endif #undef SSS_SUDO_TIMEOUT #define SSS_SUDO_TIMEOUT 60 + +#ifndef SUDO_SERVER_INTERFACE +#define SUDO_SERVER_INTERFACE "org.freedesktop.sssd.sudo" +#endif + +#ifndef SUDO_SERVER_PATH +#define SUDO_SERVER_PATH "/org/freedesktop/sssd/sudo" +#endif + +#ifndef SUDO_METHOD_QUERY +#define SUDO_METHOD_QUERY "queryService" +#endif + #ifndef _SSSCLI_H /* If sss_cli.h is not included */ diff --git a/src/sss_client/sudo_plugin/sss_sudoplugin.c b/src/sss_client/sudo_plugin/sss_sudoplugin.c index 616d4bc0..44b589cd 100644 --- a/src/sss_client/sudo_plugin/sss_sudoplugin.c +++ b/src/sss_client/sudo_plugin/sss_sudoplugin.c @@ -701,12 +701,12 @@ int sss_sudo_make_request(struct sss_cli_req_data *rd, dbus_uint32_t status=0; fprintf(stdout,"Calling remote method wit %s\n", param); - + /* initialise the errors */ dbus_error_init(&err); /* connect to the system bus and check for errors */ - conn = dbus_connection_open_private(SSS_SUDO_SERVER_ADDRESS, &err); + conn = dbus_connection_open_private(SSS_SUDO_SERVICE_PIPE, &err); if (dbus_error_is_set(&err)) { fprintf(stderr, "Connection Error (%s)\n", err.message); dbus_error_free(&err); @@ -717,10 +717,10 @@ int sss_sudo_make_request(struct sss_cli_req_data *rd, /* create a new method call and check for errors */ - dbus_msg = dbus_message_new_method_call( NULL, /* target */ - "/org/freedesktop/sssd/sudo", /* object */ - "org.freedesktop.sssd.sudo", /* interface */ - "queryService"); /* method name */ + dbus_msg = dbus_message_new_method_call( NULL, /* target */ + SUDO_SERVER_PATH, /* object */ + SUDO_SERVER_INTERFACE, /* interface */ + SUDO_METHOD_QUERY); /* method name */ if (NULL == dbus_msg) { fprintf(stderr, "Message Null\n"); return SSS_SUDO_SYSTEM_ERR; |