diff options
author | Pavel Březina <pbrezina@redhat.com> | 2011-10-26 18:06:14 +0200 |
---|---|---|
committer | Pavel Březina <pbrezina@redhat.com> | 2011-11-21 16:12:12 +0100 |
commit | 045dcb005b9e19d435c56597fb70949404e5ae2a (patch) | |
tree | a33c5cb1054a511c05e55ebeecb2b75f7ad33b53 | |
parent | 1a0fa55902308c8a7da242f7596540ce6ff464c6 (diff) | |
download | sssd_unused-045dcb005b9e19d435c56597fb70949404e5ae2a.tar.gz sssd_unused-045dcb005b9e19d435c56597fb70949404e5ae2a.tar.xz sssd_unused-045dcb005b9e19d435c56597fb70949404e5ae2a.zip |
SUDO integration - Responder <-> Data provider communication functions
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | src/responder/sudo/sudosrv.h | 2 | ||||
-rw-r--r-- | src/responder/sudo/sudosrv_dp.c | 76 |
3 files changed, 79 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index 9dff335f..ee0b1d58 100644 --- a/Makefile.am +++ b/Makefile.am @@ -431,6 +431,7 @@ sssd_pam_LDADD = \ sssd_sudo_SOURCES = \ src/responder/sudo/sudosrv.c \ src/responder/sudo/sudosrv_cmd.c \ + src/responder/sudo/sudosrv_dp.c \ $(SSSD_RESPONDER_OBJ) sssd_sudo_LDADD = \ $(SSSD_LIBS) \ diff --git a/src/responder/sudo/sudosrv.h b/src/responder/sudo/sudosrv.h index 5abdb809..314fddd6 100644 --- a/src/responder/sudo/sudosrv.h +++ b/src/responder/sudo/sudosrv.h @@ -30,6 +30,8 @@ struct sudo_ctx { int sudo_cmd_execute(struct cli_ctx *cctx); +int sudo_dp_refresh_send(struct cli_ctx *cctx, const char *domain, int timeout); + struct sss_cmd_table *get_sudo_cmds(void); #endif /* SUDOSRV_H_ */ diff --git a/src/responder/sudo/sudosrv_dp.c b/src/responder/sudo/sudosrv_dp.c new file mode 100644 index 00000000..0fc6635d --- /dev/null +++ b/src/responder/sudo/sudosrv_dp.c @@ -0,0 +1,76 @@ +/* + Authors: + Pavel Březina <pbrezina@redhat.com> + + Copyright (C) 2011 Red Hat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <dbus/dbus.h> + +#include "util/util.h" +#include "sbus/sbus_client.h" +#include "providers/data_provider.h" +#include "responder/common/responder.h" +#include "responder/sudo/sudosrv.h" + +static void sudo_dp_process_reply(DBusPendingCall *pending, void *ptr) +{ + DEBUG(0, ("=== received SUDO reply===\n")); +} + +int sudo_dp_refresh_send(struct cli_ctx *cctx, const char *domain, int timeout) +{ + struct be_conn *be_conn; + DBusMessage *msg; + int ret; + + /* double check dp_ctx has actually been initialized. + * in some pathological cases it may happen that sudo starts up before + * dp connection code is actually able to establish a connection. + */ + ret = sss_dp_get_domain_conn(cctx->rctx, + domain, &be_conn); + if (ret != EOK) { + DEBUG(SSSDBG_CRIT_FAILURE, + ("The Data Provider connection for %s is not available! " + "This maybe a bug, it shouldn't happen!\n", + domain)); + return EIO; + } + + msg = dbus_message_new_method_call(NULL, + DP_PATH, + DP_INTERFACE, + DP_METHOD_SUDOHANDLER); + if (msg == NULL) { + DEBUG(SSSDBG_FATAL_FAILURE, ("Out of memory?!\n")); + return ENOMEM; + } + + DEBUG(SSSDBG_TRACE_FUNC, ("Sending SUDOers refresh request\n")); + + ret = sbus_conn_send(be_conn->conn, msg, + timeout, sudo_dp_process_reply, + cctx, NULL); + dbus_message_unref(msg); + + if (ret != EOK) { + DEBUG(SSSDBG_OP_FAILURE, ("Unable to contact data provider " + "for domain %s", domain)); + } + + return ret; +} |