summaryrefslogtreecommitdiff
path: root/src/sss_client/sudo
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2012-01-17 12:32:28 +0100
committerStephen Gallagher <sgallagh@redhat.com>2012-01-27 09:10:37 -0500
commit9c6b680e55e00642bc3e644fd63e18e6c09ff110 (patch)
tree9657e0348e20a9b58c7d8f2de047d03f0d527cc2 /src/sss_client/sudo
parentc47e9d522f0d87259e5074ea643daaa3dfcb8d92 (diff)
downloadsssd-9c6b680e55e00642bc3e644fd63e18e6c09ff110.tar.gz
sssd-9c6b680e55e00642bc3e644fd63e18e6c09ff110.tar.bz2
sssd-9c6b680e55e00642bc3e644fd63e18e6c09ff110.zip
SUDO Integration - SUDO API can request only cn=defaults record
https://fedorahosted.org/sssd/ticket/1143
Diffstat (limited to 'src/sss_client/sudo')
-rw-r--r--src/sss_client/sudo/sss_sudo.c67
-rw-r--r--src/sss_client/sudo/sss_sudo.h2
2 files changed, 43 insertions, 26 deletions
diff --git a/src/sss_client/sudo/sss_sudo.c b/src/sss_client/sudo/sss_sudo.c
index 01fdee05..3277d9f8 100644
--- a/src/sss_client/sudo/sss_sudo.c
+++ b/src/sss_client/sudo/sss_sudo.c
@@ -36,18 +36,41 @@ static void sss_sudo_free_rules(unsigned int num_rules,
static void sss_sudo_free_attrs(unsigned int num_attrs,
struct sss_attr *attrs);
+static int sss_sudo_send_recv_generic(enum sss_cli_command command,
+ struct sss_cli_req_data *request,
+ uint32_t *_error,
+ struct sss_result **_result)
+{
+ uint8_t *reply_buf = NULL;
+ size_t reply_len = 0;
+ int errnop = 0;
+ int ret = 0;
+
+ /* send query and receive response */
+
+ errnop = 0;
+ ret = sss_sudo_make_request(command, request,
+ &reply_buf, &reply_len, &errnop);
+ if (errnop != EOK) {
+ return errnop;
+ }
+
+ /* parse structure */
+
+ ret = sss_sudo_parse_response((const char*)reply_buf, reply_len,
+ _result, _error);
+
+ free(reply_buf);
+ return ret;
+}
+
int sss_sudo_send_recv(const char *username,
uint32_t *_error,
struct sss_result **_result)
{
- struct sss_result *result = NULL;
struct sss_cli_req_data request;
char *query = NULL;
int query_len = 0;
- uint8_t *reply_buf = NULL;
- size_t reply_len = 0;
- uint32_t responder_error = 0;
- int errnop = 0;
int ret = 0;
/* create query */
@@ -62,33 +85,25 @@ int sss_sudo_send_recv(const char *username,
/* send query and recieve response */
- errnop = 0;
- ret = sss_sudo_make_request(SSS_SUDO_GET_SUDORULES, &request,
- &reply_buf, &reply_len, &errnop);
- if (errnop != EOK) {
- ret = errnop;
- goto done;
- }
-
- /* parse and print structure */
-
- ret = sss_sudo_parse_response((const char*)reply_buf, reply_len,
- &result, &responder_error);
- if (ret != EOK) {
- goto done;
- }
-
- *_error = responder_error;
- *_result = result;
-
- ret = EOK;
+ ret = sss_sudo_send_recv_generic(SSS_SUDO_GET_SUDORULES, &request,
+ _error, _result);
done:
free(query);
-
return ret;
}
+int sss_sudo_send_recv_defaults(uint32_t *_error, struct sss_result **_result)
+{
+ struct sss_cli_req_data request;
+
+ request.len = 0;
+ request.data = (const void*)NULL;
+
+ return sss_sudo_send_recv_generic(SSS_SUDO_GET_DEFAULTS, &request,
+ _error, _result);
+}
+
int sss_sudo_create_query(const char *username, char **_query, int *_query_len)
{
char *data = NULL;
diff --git a/src/sss_client/sudo/sss_sudo.h b/src/sss_client/sudo/sss_sudo.h
index 1b554678..082c8015 100644
--- a/src/sss_client/sudo/sss_sudo.h
+++ b/src/sss_client/sudo/sss_sudo.h
@@ -49,6 +49,8 @@ int sss_sudo_send_recv(const char *username,
uint32_t *_error,
struct sss_result **_result);
+int sss_sudo_send_recv_defaults(uint32_t *_error, struct sss_result **_result);
+
void sss_sudo_free_result(struct sss_result *result);
int sss_sudo_get_values(struct sss_rule *e,