8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce SELinux-related utility functions
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce Jan Zeleny <jzeleny@redhat.com>
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce Copyright (C) 2012 Red Hat
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce This program is free software; you can redistribute it and/or modify
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce it under the terms of the GNU General Public License as published by
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce the Free Software Foundation; either version 3 of the License, or
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce (at your option) any later version.
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce This program is distributed in the hope that it will be useful,
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce but WITHOUT ANY WARRANTY; without even the implied warranty of
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce GNU General Public License for more details.
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce You should have received a copy of the GNU General Public License
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce along with this program. If not, see <http://www.gnu.org/licenses/>.
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorcestatic bool match_entity(struct ldb_message_element *values,
dee7a89098b698e756f63e4041734d7322ad8b1ePavel Březina for (j = 0; j < sought_values->num_values; j++) {
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce if (values->values[i].length != sought_values->values[j].length) {
2745b0156f12df7a7eb93d57716233243658e4d9Jakub Hrozek if (strncasecmp((char *)values->values[i].data,
b9c563c29243291f40489bb0dcbf3946fca72d58Jakub Hrozek return true;
233a3c6c48972b177e60d6ef4cecfacd3cf31659Simo Sorce return false;
233a3c6c48972b177e60d6ef4cecfacd3cf31659Simo Sorcebool sss_selinux_match(struct sysdb_attrs *usermap,
0161a3c5637a0c0092bf54c436bb3d6508d7df26Jakub Hrozek DEBUG(SSSDBG_MINOR_FAILURE, "NULL given as usermap! Skipping ...\n");
0161a3c5637a0c0092bf54c436bb3d6508d7df26Jakub Hrozek return false;
1319e71fd1680ca4864afe0b1aca2b8c8e4a1ee4Stef Walter /* Search for user and host related elements */
a2ea3f5d9ef9f17efbb61e942c2bc6cff7d1ebf2Jakub Hrozek if (!strcasecmp(usermap->a[i].name, SYSDB_ORIG_MEMBER_USER)) {
78a08d30b5fbf6e1e3b589e0cf67022e0c1faa33Michal Židek } else if (!strcasecmp(usermap->a[i].name, SYSDB_ORIG_MEMBER_HOST)) {
5a5c5cdeb92f4012fc75fd717bfea06598f68f12Pavel Reichl } else if (!strcasecmp(usermap->a[i].name, SYSDB_USER_CATEGORY)) {
1243e093fd31c5660adf1bb3dd477d6935a755beJakub Hrozek } else if (!strcasecmp(usermap->a[i].name, SYSDB_HOST_CATEGORY)) {
64ea4127f463798410a2c20e0261c6b15f60257fJakub Hrozek ret = sysdb_attrs_get_el(user, SYSDB_ORIG_DN, &dn);
b42bf6c0c01db08208fb81d8295a2909d307284aPavel Reichl DEBUG(SSSDBG_MINOR_FAILURE, "User does not have origDN\n");
9118a539a5d59f669f551114f880fe91d6bb8741Jakub Hrozek return false;
19e44537c28f6d5f011cd7ac885c74c1e892605fSimo Sorce ret = sysdb_attrs_get_el(user, SYSDB_ORIG_MEMBEROF, &memberof);
e732d23f3ec986a463d757781a334040e03d1f59Jakub Hrozek "User does not have orig memberof, "
e732d23f3ec986a463d757781a334040e03d1f59Jakub Hrozek "therefore it can't match to any rule\n");
dd285415d7a8d8376207960cfa3e977524c3b98cJakub Hrozek return false;
4714118890e51b365fbce543d0a042b4b59b2b25Michal Zidek * The rule won't match if user category != "all" and user map doesn't
efc65e78fa4e01e6cecc8690a9899af61213be62Fabiano Fidêncio * contain neither user nor any of his groups in memberUser attribute
d4757440418c7b73bbecec7e40baf6dfe8cc9460Sumit Bose if (strcasecmp((char *)usercat->values[i].data, "all") == 0) {
300b9e9217ee1ed8d845ed2370c5ccf5c87afb36Pavel Březina DEBUG(SSSDBG_TRACE_ALL, "No users specified in the rule!\n");
300b9e9217ee1ed8d845ed2370c5ccf5c87afb36Pavel Březina return false;
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce return false;
if (host) {
matched_category = false;
matched_category = true;
if (!matched_category) {
if (matched_name) {
} else if (matched_group) {
const char *username,
goto done;
goto done;
&user_msg);
goto done;
goto done;
done:
return ret;
return NULL;