summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2012-02-13 09:42:03 +0100
committerStephen Gallagher <sgallagh@redhat.com>2012-02-14 11:56:28 -0500
commit968e2bc3bb28458b25c3b19868ea50f0325d8b0a (patch)
treed50f0c471104bd4cd35dd93733d78582a4145564 /src
parent2ebb3cf3d7062860343c3db1b53173c9c6547038 (diff)
downloadsssd-968e2bc3bb28458b25c3b19868ea50f0325d8b0a.tar.gz
sssd-968e2bc3bb28458b25c3b19868ea50f0325d8b0a.tar.bz2
sssd-968e2bc3bb28458b25c3b19868ea50f0325d8b0a.zip
Refactor sss_result into sss_sudo_result
https://fedorahosted.org/sssd/ticket/1159
Diffstat (limited to 'src')
-rw-r--r--src/sss_client/sudo/sss_sudo.c25
-rw-r--r--src/sss_client/sudo/sss_sudo.h19
-rw-r--r--src/sss_client/sudo/sss_sudo_private.h2
-rw-r--r--src/sss_client/sudo/sss_sudo_response.c18
-rw-r--r--src/sss_client/sudo_testcli/sudo_testcli.c10
5 files changed, 38 insertions, 36 deletions
diff --git a/src/sss_client/sudo/sss_sudo.c b/src/sss_client/sudo/sss_sudo.c
index 3277d9f8..32c405f3 100644
--- a/src/sss_client/sudo/sss_sudo.c
+++ b/src/sss_client/sudo/sss_sudo.c
@@ -31,15 +31,15 @@ static int sss_sudo_create_query(const char *username,
int *_query_len);
static void sss_sudo_free_rules(unsigned int num_rules,
- struct sss_rule *rules);
+ struct sss_sudo_rule *rules);
static void sss_sudo_free_attrs(unsigned int num_attrs,
- struct sss_attr *attrs);
+ struct sss_sudo_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)
+ struct sss_sudo_result **_result)
{
uint8_t *reply_buf = NULL;
size_t reply_len = 0;
@@ -66,7 +66,7 @@ static int sss_sudo_send_recv_generic(enum sss_cli_command command,
int sss_sudo_send_recv(const char *username,
uint32_t *_error,
- struct sss_result **_result)
+ struct sss_sudo_result **_result)
{
struct sss_cli_req_data request;
char *query = NULL;
@@ -93,7 +93,8 @@ done:
return ret;
}
-int sss_sudo_send_recv_defaults(uint32_t *_error, struct sss_result **_result)
+int sss_sudo_send_recv_defaults(uint32_t *_error,
+ struct sss_sudo_result **_result)
{
struct sss_cli_req_data request;
@@ -126,10 +127,10 @@ int sss_sudo_create_query(const char *username, char **_query, int *_query_len)
return EOK;
}
-int sss_sudo_get_values(struct sss_rule *e,
+int sss_sudo_get_values(struct sss_sudo_rule *e,
const char *attrname, char ***_values)
{
- struct sss_attr *attr = NULL;
+ struct sss_sudo_attr *attr = NULL;
char **values = NULL;
int i, j;
@@ -176,7 +177,7 @@ void sss_sudo_free_values(char **values)
free(values);
}
-void sss_sudo_free_result(struct sss_result *result)
+void sss_sudo_free_result(struct sss_sudo_result *result)
{
if (result == NULL) {
return;
@@ -186,9 +187,9 @@ void sss_sudo_free_result(struct sss_result *result)
free(result);
}
-void sss_sudo_free_rules(unsigned int num_rules, struct sss_rule *rules)
+void sss_sudo_free_rules(unsigned int num_rules, struct sss_sudo_rule *rules)
{
- struct sss_rule *rule = NULL;
+ struct sss_sudo_rule *rule = NULL;
int i;
if (rules == NULL) {
@@ -209,9 +210,9 @@ void sss_sudo_free_rules(unsigned int num_rules, struct sss_rule *rules)
free(rules);
}
-void sss_sudo_free_attrs(unsigned int num_attrs, struct sss_attr *attrs)
+void sss_sudo_free_attrs(unsigned int num_attrs, struct sss_sudo_attr *attrs)
{
- struct sss_attr *attr = NULL;;
+ struct sss_sudo_attr *attr = NULL;;
int i, j;
if (attrs == NULL) {
diff --git a/src/sss_client/sudo/sss_sudo.h b/src/sss_client/sudo/sss_sudo.h
index 12d8eb2b..11abc6e3 100644
--- a/src/sss_client/sudo/sss_sudo.h
+++ b/src/sss_client/sudo/sss_sudo.h
@@ -46,7 +46,7 @@
* has exactly one name and one or more values.
*
*/
-struct sss_attr {
+struct sss_sudo_attr {
/** The attribute name */
char *name;
/** A string array that contains all the attribute values */
@@ -63,12 +63,12 @@ struct sss_attr {
* One sudo rule. The rule consists of one or more
* attributes of sss_attr type
*/
-struct sss_rule {
+struct sss_sudo_rule {
/** The number of attributes in the rule */
unsigned int num_attrs;
/** List of rule attributes */
- struct sss_attr *attrs;
+ struct sss_sudo_attr *attrs;
};
/**
@@ -76,7 +76,7 @@ struct sss_rule {
*
* The result consists of zero or more sss_rule elements.
*/
-struct sss_result {
+struct sss_sudo_result {
/**
* The number of rules for the user
*
@@ -87,7 +87,7 @@ struct sss_result {
unsigned int num_rules;
/** List of rules found */
- struct sss_rule *rules;
+ struct sss_sudo_rule *rules;
};
/**
@@ -116,7 +116,7 @@ struct sss_result {
*/
int sss_sudo_send_recv(const char *username,
uint32_t *_error,
- struct sss_result **_result);
+ struct sss_sudo_result **_result);
/**
* @brief Send a request to SSSD to retrieve the default options, commonly
@@ -138,7 +138,8 @@ int sss_sudo_send_recv(const char *username,
* successful. It does not tell whether the result contains any options,
* That information is transferred in the _error parameter.
*/
-int sss_sudo_send_recv_defaults(uint32_t *_error, struct sss_result **_result);
+int sss_sudo_send_recv_defaults(uint32_t *_error,
+ struct sss_sudo_result **_result);
/**
* @brief Free the sss_result structure returned by sss_sudo_send_recv
@@ -146,7 +147,7 @@ int sss_sudo_send_recv_defaults(uint32_t *_error, struct sss_result **_result);
* @param[in] result The sss_result structure to free. The structure was
* previously returned by sss_sudo_get_values().
*/
-void sss_sudo_free_result(struct sss_result *result);
+void sss_sudo_free_result(struct sss_sudo_result *result);
/**
* @brief Get all values for a given attribute in a sss_rule
@@ -164,7 +165,7 @@ void sss_sudo_free_result(struct sss_result *result);
*
* @note the returned values should be freed using sss_sudo_free_values()
*/
-int sss_sudo_get_values(struct sss_rule *e,
+int sss_sudo_get_values(struct sss_sudo_rule *e,
const char *attrname,
char ***values);
diff --git a/src/sss_client/sudo/sss_sudo_private.h b/src/sss_client/sudo/sss_sudo_private.h
index 2b20c1cf..674bf125 100644
--- a/src/sss_client/sudo/sss_sudo_private.h
+++ b/src/sss_client/sudo/sss_sudo_private.h
@@ -26,7 +26,7 @@
int sss_sudo_parse_response(const char *message,
size_t message_len,
- struct sss_result **_result,
+ struct sss_sudo_result **_result,
uint32_t *_error);
#endif /* SSS_SUDO_PRIVATE_H_ */
diff --git a/src/sss_client/sudo/sss_sudo_response.c b/src/sss_client/sudo/sss_sudo_response.c
index f3e250cd..0c11cc00 100644
--- a/src/sss_client/sudo/sss_sudo_response.c
+++ b/src/sss_client/sudo/sss_sudo_response.c
@@ -31,12 +31,12 @@
static int sss_sudo_parse_rule(const char *message,
size_t message_len,
size_t *_cursor,
- struct sss_rule *_rule);
+ struct sss_sudo_rule *_rule);
static int sss_sudo_parse_attr(const char *message,
size_t message_len,
size_t *_cursor,
- struct sss_attr *_attr);
+ struct sss_sudo_attr *_attr);
static int sss_sudo_parse_uint32(const char *message,
size_t message_len,
@@ -50,10 +50,10 @@ static int sss_sudo_parse_string(const char *message,
int sss_sudo_parse_response(const char *message,
size_t message_len,
- struct sss_result **_result,
+ struct sss_sudo_result **_result,
uint32_t *_error)
{
- struct sss_result *result = NULL;
+ struct sss_sudo_result *result = NULL;
size_t cursor = 0;
int ret = EOK;
int i = 0;
@@ -65,7 +65,7 @@ int sss_sudo_parse_response(const char *message,
}
/* result */
- result = malloc(sizeof(struct sss_result));
+ result = malloc(sizeof(struct sss_sudo_result));
if (result == NULL) {
return ENOMEM;
}
@@ -78,7 +78,7 @@ int sss_sudo_parse_response(const char *message,
}
/* rules */
- result->rules = calloc(result->num_rules, sizeof(struct sss_rule));
+ result->rules = calloc(result->num_rules, sizeof(struct sss_sudo_rule));
if (result->rules == NULL) {
ret = ENOMEM;
goto fail;
@@ -104,7 +104,7 @@ fail:
int sss_sudo_parse_rule(const char *message,
size_t message_len,
size_t *_cursor,
- struct sss_rule *_rule)
+ struct sss_sudo_rule *_rule)
{
int ret = EOK;
int i = 0;
@@ -117,7 +117,7 @@ int sss_sudo_parse_rule(const char *message,
}
/* attrs */
- _rule->attrs = calloc(_rule->num_attrs, sizeof(struct sss_attr));
+ _rule->attrs = calloc(_rule->num_attrs, sizeof(struct sss_sudo_attr));
if (_rule->attrs == NULL) {
return ENOMEM;
}
@@ -136,7 +136,7 @@ int sss_sudo_parse_rule(const char *message,
int sss_sudo_parse_attr(const char *message,
size_t message_len,
size_t *_cursor,
- struct sss_attr *_attr)
+ struct sss_sudo_attr *_attr)
{
char *str = NULL;
int ret = EOK;
diff --git a/src/sss_client/sudo_testcli/sudo_testcli.c b/src/sss_client/sudo_testcli/sudo_testcli.c
index fbfb9964..b498acec 100644
--- a/src/sss_client/sudo_testcli/sudo_testcli.c
+++ b/src/sss_client/sudo_testcli/sudo_testcli.c
@@ -32,12 +32,12 @@
#define EOK 0
#endif
-void print_sss_result(struct sss_result *result);
+void print_sss_result(struct sss_sudo_result *result);
int main(int argc, char **argv)
{
int ret = 0;
- struct sss_result *result = NULL;
+ struct sss_sudo_result *result = NULL;
uint32_t error = 0;
if (argc > 2) {
@@ -76,10 +76,10 @@ fail:
return 1;
}
-void print_sss_result(struct sss_result *result)
+void print_sss_result(struct sss_sudo_result *result)
{
- struct sss_rule *rule = NULL;
- struct sss_attr *attr = NULL;
+ struct sss_sudo_rule *rule = NULL;
+ struct sss_sudo_attr *attr = NULL;
int i = 0;
int j = 0;
int k = 0;