summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2012-01-17 12:32:41 +0100
committerStephen Gallagher <sgallagh@redhat.com>2012-01-27 09:10:37 -0500
commite6092759dc4268b105b79478aa9b1398f21ed7a9 (patch)
treee3e058d6338a82f401c7c30419cd07f3491eade1
parent9c6b680e55e00642bc3e644fd63e18e6c09ff110 (diff)
downloadsssd-e6092759dc4268b105b79478aa9b1398f21ed7a9.tar.gz
sssd-e6092759dc4268b105b79478aa9b1398f21ed7a9.tar.xz
sssd-e6092759dc4268b105b79478aa9b1398f21ed7a9.zip
SUDO Integration - test client changed
Without user name given it displays cn=defaults record. Client no longer display raw data. https://fedorahosted.org/sssd/ticket/1143
-rw-r--r--src/sss_client/sudo_testcli/sudo_testcli.c91
1 files changed, 13 insertions, 78 deletions
diff --git a/src/sss_client/sudo_testcli/sudo_testcli.c b/src/sss_client/sudo_testcli/sudo_testcli.c
index be31037ef..fbfb9964c 100644
--- a/src/sss_client/sudo_testcli/sudo_testcli.c
+++ b/src/sss_client/sudo_testcli/sudo_testcli.c
@@ -32,77 +32,36 @@
#define EOK 0
#endif
-int create_query(const char *username, char **_query, int *_query_len);
void print_sss_result(struct sss_result *result);
int main(int argc, char **argv)
{
- struct sss_cli_req_data request;
- const char *username = NULL;
- char *query = NULL;
- int query_len = 0;
- int errnop = 0;
int ret = 0;
- uint8_t *reply_buf = NULL;
- char *reply_buf_char = NULL;
- size_t reply_len;
- int i = 0;
struct sss_result *result = NULL;
uint32_t error = 0;
- if (argc != 2) {
+ if (argc > 2) {
fprintf(stderr, "Usage: sss_sudo_cli username\n");
goto fail;
}
- username = argv[1];
-
- /* create query */
-
- ret = create_query(username, &query, &query_len);
- if (ret != EOK) {
- fprintf(stderr, "Unable to create query: %s\n", strerror(ret));
- goto fail;
- }
-
- request.len = query_len;
- request.data = (const void*)query;
-
- /* 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) {
- fprintf(stderr, "Unable to contact SSSD responder: %s\n", strerror(errnop));
- goto fail;
- }
+ /* get sss_result - it will send new query to responder */
- reply_buf_char = (char*)reply_buf;
- if (reply_len > 0) {
- printf("Reply length: %d\n", (int)reply_len);
- printf("Reply data:\n");
- for (i = 0; i < reply_len; i++) {
- if (reply_buf_char[i] == '\0') {
- printf("\\0");
- } else {
- printf("%c", reply_buf_char[i]);
- }
+ if (argc == 1) {
+ ret = sss_sudo_send_recv_defaults(&error, &result);
+ if (ret != EOK) {
+ fprintf(stderr, "sss_sudo_send_recv_defaults() failed: %s\n", strerror(ret));
+ goto fail;
}
- printf("\n");
} else {
- printf("No reply received!\n");
- }
-
- /* get sss_result - it will send new query to responder */
-
- ret = sss_sudo_send_recv(username, &error, &result);
- if (ret != EOK) {
- fprintf(stderr, "Usss_sudo_get_result() failed: %s\n", strerror(ret));
- goto fail;
+ ret = sss_sudo_send_recv(argv[1], &error, &result);
+ if (ret != EOK) {
+ fprintf(stderr, "sss_sudo_send_recv() failed: %s\n", strerror(ret));
+ goto fail;
+ }
}
- printf("\n=== Printing response data ===\n");
+ printf("=== Printing response data ===\n");
printf("Response code: %d\n\n", error);
if (error == SSS_SUDO_ERROR_OK) {
print_sss_result(result);
@@ -110,37 +69,13 @@ int main(int argc, char **argv)
sss_sudo_free_result(result);
- free(query);
return 0;
fail:
sss_sudo_free_result(result);
- free(query);
return 1;
}
-int create_query(const char *username, char **_query, int *_query_len)
-{
- char *data = NULL;
- int data_len = strlen(username) + 1;
-
- if (data_len <= 0) {
- return EINVAL;
- }
-
- data = (char*)malloc(data_len * sizeof(char));
- if (data == NULL) {
- return ENOMEM;
- }
-
- memcpy(data, username, data_len);
-
- *_query = data;
- *_query_len = data_len;
-
- return EOK;
-}
-
void print_sss_result(struct sss_result *result)
{
struct sss_rule *rule = NULL;