|
|
1b092f |
diff -up sudo-1.8.6p3/plugins/sudoers/sssd.c.sssdfixes sudo-1.8.6p3/plugins/sudoers/sssd.c
|
|
|
1b092f |
--- sudo-1.8.6p3/plugins/sudoers/sssd.c.sssdfixes 2013-08-13 15:20:39.558187669 +0200
|
|
|
1b092f |
+++ sudo-1.8.6p3/plugins/sudoers/sssd.c 2013-08-13 16:24:27.209064162 +0200
|
|
|
1b092f |
@@ -534,30 +534,31 @@ sudo_sss_check_runas_group(struct sudo_s
|
|
|
1b092f |
* Walk through search results and return true if we have a runas match,
|
|
|
1b092f |
* else false. RunAs info is optional.
|
|
|
1b092f |
*/
|
|
|
1b092f |
-static int
|
|
|
1b092f |
+static bool
|
|
|
1b092f |
sudo_sss_check_runas(struct sudo_sss_handle *handle, struct sss_sudo_rule *rule)
|
|
|
1b092f |
{
|
|
|
1b092f |
- int ret;
|
|
|
1b092f |
+ bool ret;
|
|
|
1b092f |
debug_decl(sudo_sss_check_runas, SUDO_DEBUG_SSSD);
|
|
|
1b092f |
|
|
|
1b092f |
if (rule == NULL)
|
|
|
1b092f |
- debug_return_int(false);
|
|
|
1b092f |
+ debug_return_bool(false);
|
|
|
1b092f |
|
|
|
1b092f |
ret = sudo_sss_check_runas_user(handle, rule) != false &&
|
|
|
1b092f |
sudo_sss_check_runas_group(handle, rule) != false;
|
|
|
1b092f |
|
|
|
1b092f |
- debug_return_int(ret);
|
|
|
1b092f |
+ debug_return_bool(ret);
|
|
|
1b092f |
}
|
|
|
1b092f |
|
|
|
1b092f |
-static int
|
|
|
1b092f |
+static bool
|
|
|
1b092f |
sudo_sss_check_host(struct sudo_sss_handle *handle, struct sss_sudo_rule *rule)
|
|
|
1b092f |
{
|
|
|
1b092f |
char **val_array, *val;
|
|
|
1b092f |
- int ret = false, i;
|
|
|
1b092f |
+ bool ret = false;
|
|
|
1b092f |
+ int i;
|
|
|
1b092f |
debug_decl(sudo_sss_check_host, SUDO_DEBUG_SSSD);
|
|
|
1b092f |
|
|
|
1b092f |
if (rule == NULL)
|
|
|
1b092f |
- debug_return_int(ret);
|
|
|
1b092f |
+ debug_return_bool(ret);
|
|
|
1b092f |
|
|
|
1b092f |
/* get the values from the rule */
|
|
|
1b092f |
switch (handle->fn_get_values(rule, "sudoHost", &val_array))
|
|
|
1b092f |
@@ -566,10 +567,10 @@ sudo_sss_check_host(struct sudo_sss_hand
|
|
|
1b092f |
break;
|
|
|
1b092f |
case ENOENT:
|
|
|
1b092f |
sudo_debug_printf(SUDO_DEBUG_INFO, "No result.");
|
|
|
1b092f |
- debug_return_int(false);
|
|
|
1b092f |
+ debug_return_bool(false);
|
|
|
1b092f |
default:
|
|
|
1b092f |
sudo_debug_printf(SUDO_DEBUG_INFO, "handle->fn_get_values(sudoHost): != 0");
|
|
|
1b092f |
- debug_return_int(ret);
|
|
|
1b092f |
+ debug_return_bool(ret);
|
|
|
1b092f |
}
|
|
|
1b092f |
|
|
|
1b092f |
/* walk through values */
|
|
|
1b092f |
@@ -589,7 +590,52 @@ sudo_sss_check_host(struct sudo_sss_hand
|
|
|
1b092f |
|
|
|
1b092f |
handle->fn_free_values(val_array);
|
|
|
1b092f |
|
|
|
1b092f |
- debug_return_int(ret);
|
|
|
1b092f |
+ debug_return_bool(ret);
|
|
|
1b092f |
+}
|
|
|
1b092f |
+
|
|
|
1b092f |
+/*
|
|
|
1b092f |
+ * Look for netgroup specifcations in the sudoUser attribute and
|
|
|
1b092f |
+ * if found, filter according to netgroup membership.
|
|
|
1b092f |
+ * returns:
|
|
|
1b092f |
+ * true -> netgroup spec found && negroup member
|
|
|
1b092f |
+ * false -> netgroup spec found && not a meber of netgroup
|
|
|
1b092f |
+ * true -> netgroup spec not found (filtered by SSSD already, netgroups are an exception)
|
|
|
1b092f |
+ */
|
|
|
1b092f |
+bool sudo_sss_filter_user_netgroup(struct sudo_sss_handle *handle, struct sss_sudo_rule *rule)
|
|
|
1b092f |
+{
|
|
|
1b092f |
+ bool ret = false, netgroup_spec_found = false;
|
|
|
1b092f |
+ char **val_array, *val;
|
|
|
1b092f |
+ int i;
|
|
|
1b092f |
+ debug_decl(sudo_sss_check_user_netgroup, SUDO_DEBUG_SSSD);
|
|
|
1b092f |
+
|
|
|
1b092f |
+ if (!handle || !rule)
|
|
|
1b092f |
+ debug_return_bool(ret);
|
|
|
1b092f |
+
|
|
|
1b092f |
+ switch (handle->fn_get_values(rule, "sudoUser", &val_array)) {
|
|
|
1b092f |
+ case 0:
|
|
|
1b092f |
+ break;
|
|
|
1b092f |
+ case ENOENT:
|
|
|
1b092f |
+ sudo_debug_printf(SUDO_DEBUG_INFO, "No result.");
|
|
|
1b092f |
+ debug_return_bool(ret);
|
|
|
1b092f |
+ default:
|
|
|
1b092f |
+ sudo_debug_printf(SUDO_DEBUG_INFO, "handle->fn_get_values(sudoUser): != 0");
|
|
|
1b092f |
+ debug_return_bool(ret);
|
|
|
1b092f |
+ }
|
|
|
1b092f |
+
|
|
|
1b092f |
+ for (i = 0; val_array[i] != NULL && !ret; ++i) {
|
|
|
1b092f |
+ val = val_array[i];
|
|
|
1b092f |
+ if (*val == '+') {
|
|
|
1b092f |
+ netgroup_spec_found = true;
|
|
|
1b092f |
+ }
|
|
|
1b092f |
+ sudo_debug_printf(SUDO_DEBUG_DEBUG, "val[%d]=%s", i, val);
|
|
|
1b092f |
+ if (strcmp(val, "ALL") == 0 || netgr_matches(val, NULL, NULL, user_name)) {
|
|
|
1b092f |
+ ret = true;
|
|
|
1b092f |
+ sudo_debug_printf(SUDO_DEBUG_DIAG,
|
|
|
1b092f |
+ "sssd/ldap sudoUser '%s' ... MATCH! (%s)", val, user_name);
|
|
|
1b092f |
+ }
|
|
|
1b092f |
+ }
|
|
|
1b092f |
+ handle->fn_free_values(val_array);
|
|
|
1b092f |
+ debug_return_bool(netgroup_spec_found ? ret : true);
|
|
|
1b092f |
}
|
|
|
1b092f |
|
|
|
1b092f |
static int
|
|
|
1b092f |
@@ -599,7 +645,8 @@ sudo_sss_result_filterp(struct sudo_sss_
|
|
|
1b092f |
(void)unused;
|
|
|
1b092f |
debug_decl(sudo_sss_result_filterp, SUDO_DEBUG_SSSD);
|
|
|
1b092f |
|
|
|
1b092f |
- if (sudo_sss_check_host(handle, rule))
|
|
|
1b092f |
+ if (sudo_sss_check_host(handle, rule) &&
|
|
|
1b092f |
+ sudo_sss_filter_user_netgroup(handle, rule))
|
|
|
1b092f |
debug_return_int(1);
|
|
|
1b092f |
else
|
|
|
1b092f |
debug_return_int(0);
|