summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun Scaria <arunscaria91@gmail.com>2011-07-08 23:28:45 +0530
committerArun Scaria <arunscaria91@gmail.com>2011-07-08 23:28:45 +0530
commitafc975dbb0f48756ac7949887628c7e4b11c5d1d (patch)
treed99a45da1c380ce696c00c86487aef8ab2dc0887
parent7f4c3cabdb8453ab751383b4744ac2805595f883 (diff)
downloadsssd_unused-afc975dbb0f48756ac7949887628c7e4b11c5d1d.tar.gz
sssd_unused-afc975dbb0f48756ac7949887628c7e4b11c5d1d.tar.xz
sssd_unused-afc975dbb0f48756ac7949887628c7e4b11c5d1d.zip
added create_settings_hash_table()
-rw-r--r--src/sss_client/sudo_plugin/sss_sudo_cli.h18
-rw-r--r--src/sss_client/sudo_plugin/sss_sudoplugin.c170
2 files changed, 182 insertions, 6 deletions
diff --git a/src/sss_client/sudo_plugin/sss_sudo_cli.h b/src/sss_client/sudo_plugin/sss_sudo_cli.h
index 45f5786b..7f4377bd 100644
--- a/src/sss_client/sudo_plugin/sss_sudo_cli.h
+++ b/src/sss_client/sudo_plugin/sss_sudo_cli.h
@@ -49,7 +49,7 @@
#define CHECK_AND_RETURN_PI_STRING(s) ((s != NULL && *s != '\0')? s : "(not available)")
#endif
-#define INIT_SETTINGS_TABLE_SIZE 14
+#define INIT_SETTINGS_TABLE_SIZE 15
#define INIT_ENV_TABLE_SIZE 10
@@ -124,6 +124,22 @@ struct sss_sudo_msg_contents
int cli_pid;
};
+#define SSS_SUDO_ITEM_RUSER "runas_user"
+#define SSS_SUDO_ITEM_RGROUP "runas_group"
+#define SSS_SUDO_ITEM_PROMPT "prompt"
+#define SSS_SUDO_ITEM_NETADDR "net_addr"
+#define SSS_SUDO_ITEM_USE_SUDOEDIT "use_sudoedit"
+#define SSS_SUDO_ITEM_USE_SETHOME "use_sethome"
+#define SSS_SUDO_ITEM_USE_PRESERV_ENV "use_preserve_env"
+#define SSS_SUDO_ITEM_USE_IMPLIED_SHELL "use_implied_shell"
+#define SSS_SUDO_ITEM_USE_LOGIN_SHELL "use_login_shell"
+#define SSS_SUDO_ITEM_USE_RUN_SHELL "use_run_shell"
+#define SSS_SUDO_ITEM_USE_PRE_GROUPS "use_preserve_groups"
+#define SSS_SUDO_ITEM_USE_IGNORE_TICKET "use_ignore_ticket"
+#define SSS_SUDO_ITEM_USE_NON_INTERACTIVE "use_non_interactive"
+#define SSS_SUDO_ITEM_DEBUG_LEVEL "use_debug_level"
+#define SSS_SUDO_ITEM_CLI_PID "client_pid"
+
void print_sudo_items(void);
diff --git a/src/sss_client/sudo_plugin/sss_sudoplugin.c b/src/sss_client/sudo_plugin/sss_sudoplugin.c
index de6cee86..7ae9168b 100644
--- a/src/sss_client/sudo_plugin/sss_sudoplugin.c
+++ b/src/sss_client/sudo_plugin/sss_sudoplugin.c
@@ -632,7 +632,7 @@ int create_env_hash_table(char ** env, hash_table_t ** table_out) {
delete_callback,
NULL);
if (err_h != HASH_SUCCESS) {
- fprintf(stderr, "cannot create hash table (%s)\n", hash_error_string(err_h));
+ fprintf(stderr, "couldn't create hash table (%s)\n", hash_error_string(err_h));
return err_h;
}
@@ -645,7 +645,7 @@ int create_env_hash_table(char ** env, hash_table_t ** table_out) {
value.ptr = tmp+1;
if ((err_h = hash_enter(local_table, &key, &value)) != HASH_SUCCESS) {
- fprintf(stderr, "cannot add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h));
+ fprintf(stderr, "couldn't add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h));
return err_h;
}
*tmp = '=' ;
@@ -655,6 +655,159 @@ int create_env_hash_table(char ** env, hash_table_t ** table_out) {
return HASH_SUCCESS;
}
+int create_settings_hash_table(hash_table_t ** table_out) {
+
+ hash_table_t *local_table = NULL;
+ hash_key_t key;
+ hash_value_t value;
+
+ char * tmp;
+ char ** ui;
+
+ int err_h;
+
+ err_h = hash_create((unsigned long)INIT_SETTINGS_TABLE_SIZE,
+ &local_table,
+ delete_callback,
+ NULL);
+ if (err_h != HASH_SUCCESS) {
+ fprintf(stderr, "couldn't create hash table (%s)\n", hash_error_string(err_h));
+ return err_h;
+ }
+ key.type = HASH_KEY_STRING;
+ value.type = HASH_VALUE_PTR;
+ key.str = strdup(SSS_SUDO_ITEM_RUSER);
+ value.ptr = msg.runas_user;
+ if ((err_h = hash_enter(local_table, &key, &value)) != HASH_SUCCESS) {
+ fprintf(stderr, "cannot add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h));
+ return err_h;
+ }
+ free(key.str);
+
+ key.str = strdup(SSS_SUDO_ITEM_RGROUP);
+ value.ptr = msg.runas_group;
+ if ((err_h = hash_enter(local_table, &key, &value)) != HASH_SUCCESS) {
+ fprintf(stderr, "cannot add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h));
+ return err_h;
+ }
+ free(key.str);
+
+ key.str = strdup(SSS_SUDO_ITEM_PROMPT);
+ value.ptr = msg.prompt;
+ if ((err_h = hash_enter(local_table, &key, &value)) != HASH_SUCCESS) {
+ fprintf(stderr, "cannot add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h));
+ return err_h;
+ }
+ free(key.str);
+
+ key.str = strdup(SSS_SUDO_ITEM_NETADDR);
+ value.ptr = msg.network_addrs;
+ if ((err_h = hash_enter(local_table, &key, &value)) != HASH_SUCCESS) {
+ fprintf(stderr, "cannot add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h));
+ return err_h;
+ }
+ free(key.str);
+
+ value.type = HASH_VALUE_INT;
+
+ key.str = strdup(SSS_SUDO_ITEM_USE_SUDOEDIT);
+ value.i = msg.use_sudoedit;
+ if ((err_h = hash_enter(local_table, &key, &value)) != HASH_SUCCESS) {
+ fprintf(stderr, "cannot add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h));
+ return err_h;
+ }
+ free(key.str);
+
+ key.str = strdup(SSS_SUDO_ITEM_USE_SETHOME);
+ value.i = msg.use_set_home;
+ if ((err_h = hash_enter(local_table, &key, &value)) != HASH_SUCCESS) {
+ fprintf(stderr, "cannot add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h));
+ return err_h;
+ }
+ free(key.str);
+
+ key.str = strdup(SSS_SUDO_ITEM_USE_PRESERV_ENV);
+ value.i = msg.use_preserve_environment;
+ if ((err_h = hash_enter(local_table, &key, &value)) != HASH_SUCCESS) {
+ fprintf(stderr, "cannot add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h));
+ return err_h;
+ }
+ free(key.str);
+
+ key.str = strdup(SSS_SUDO_ITEM_USE_IMPLIED_SHELL);
+ value.i = msg.use_implied_shell;
+ if ((err_h = hash_enter(local_table, &key, &value)) != HASH_SUCCESS) {
+ fprintf(stderr, "cannot add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h));
+ return err_h;
+ }
+ free(key.str);
+
+
+ key.str = strdup(SSS_SUDO_ITEM_USE_LOGIN_SHELL);
+ value.i = msg.use_login_shell;
+ if ((err_h = hash_enter(local_table, &key, &value)) != HASH_SUCCESS) {
+ fprintf(stderr, "cannot add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h));
+ return err_h;
+ }
+ free(key.str);
+
+
+ key.str = strdup(SSS_SUDO_ITEM_USE_RUN_SHELL);
+ value.i = msg.use_run_shell;
+ if ((err_h = hash_enter(local_table, &key, &value)) != HASH_SUCCESS) {
+ fprintf(stderr, "cannot add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h));
+ return err_h;
+ }
+ free(key.str);
+
+
+ key.str = strdup(SSS_SUDO_ITEM_USE_PRE_GROUPS);
+ value.i = msg.use_preserve_groups;
+ if ((err_h = hash_enter(local_table, &key, &value)) != HASH_SUCCESS) {
+ fprintf(stderr, "cannot add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h));
+ return err_h;
+ }
+ free(key.str);
+
+
+ key.str = strdup(SSS_SUDO_ITEM_USE_IGNORE_TICKET);
+ value.i = msg.use_ignore_ticket;
+ if ((err_h = hash_enter(local_table, &key, &value)) != HASH_SUCCESS) {
+ fprintf(stderr, "cannot add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h));
+ return err_h;
+ }
+ free(key.str);
+
+
+ key.str = strdup(SSS_SUDO_ITEM_USE_NON_INTERACTIVE);
+ value.i = msg.use_noninteractive;
+ if ((err_h = hash_enter(local_table, &key, &value)) != HASH_SUCCESS) {
+ fprintf(stderr, "cannot add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h));
+ return err_h;
+ }
+ free(key.str);
+
+ key.str = strdup(SSS_SUDO_ITEM_DEBUG_LEVEL);
+ value.i = msg.debug_level;
+ if ((err_h = hash_enter(local_table, &key, &value)) != HASH_SUCCESS) {
+ fprintf(stderr, "cannot add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h));
+ return err_h;
+ }
+ free(key.str);
+
+ key.str = strdup(SSS_SUDO_ITEM_CLI_PID);
+ value.i = msg.cli_pid;
+ if ((err_h = hash_enter(local_table, &key, &value)) != HASH_SUCCESS) {
+ fprintf(stderr, "cannot add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h));
+ return err_h;
+ }
+ free(key.str);
+
+
+ *table_out = local_table;
+
+ return HASH_SUCCESS;
+}
@@ -710,7 +863,7 @@ int sss_sudo_make_request(struct sss_cli_req_data *rd,
dbus_bool_t ret=FALSE;
- //hash_table_t **settings_table;
+ hash_table_t **settings_table;
hash_table_t **env_table;
@@ -721,10 +874,17 @@ int sss_sudo_make_request(struct sss_cli_req_data *rd,
}
err_status = create_env_hash_table(msg.user_env,env_table);
- if(err_status != HASH_SUCCESS) {
+ if(err_status != HASH_SUCCESS) {
fprintf(stderr, "ccouldn't create table: %s\n", hash_error_string(err_status));
return SSS_SUDO_MESSAGE_ERR;
- }
+ }
+
+
+ err_status = create_settings_hash_table(msg.user_env,env_table);
+ if(err_status != HASH_SUCCESS) {
+ fprintf(stderr, "ccouldn't create table: %s\n", hash_error_string(err_status));
+ return SSS_SUDO_MESSAGE_ERR;
+ }
/* initialise the errors */
dbus_error_init(&err);