ipa_session.c revision 1a7d1977037864e52858058777af8ff8401547dd
/*
SSSD
IPA Backend Module -- session loading
Authors:
Jan Zeleny <jzeleny@redhat.com>
Copyright (C) 2012 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <security/pam_modules.h>
#include "db/sysdb_selinux.h"
#include "util/sss_selinux.h"
#include "providers/ldap/sdap_async.h"
#include "providers/ipa/ipa_common.h"
#include "providers/ipa/ipa_config.h"
#include "providers/ipa/ipa_session.h"
#include "providers/ipa/ipa_hosts.h"
#include "providers/ipa/ipa_hbac_rules.h"
#include "providers/ipa/ipa_selinux_common.h"
#include "providers/ipa/ipa_selinux_maps.h"
/* FIXME: this is temporary until host map is implemented in ipa_common.c */
#include "providers/ipa/ipa_hbac_private.h"
struct ipa_get_selinux_state {
struct ipa_session_ctx *session_ctx;
struct sdap_id_op *op;
/* Just tmp stuff so we can free it after query */
const char **attrs;
const char *hostname;
struct sysdb_attrs *host;
struct sysdb_attrs *user;
struct sysdb_attrs *defaults;
struct sysdb_attrs **possible_match;
struct sysdb_attrs **confirmed_match;
};
static struct
struct ipa_session_ctx *session_ctx);
struct sysdb_attrs ***maps,
char **default_user,
char **map_order);
{
struct ipa_session_ctx *session_ctx;
struct tevent_req *req;
struct ipa_session_ctx);
goto fail;
}
return;
fail:
}
{
struct sysdb_attrs **maps;
bool in_transaction = false;
char *default_user;
char *map_order;
&default_user, &map_order);
goto fail;
}
in_transaction = true;
goto fail;
}
}
goto fail;
}
}
goto fail;
}
/* Just in case more code will follow after this place in the future */
in_transaction = false;
return;
fail:
if (in_transaction) {
}
}
} else {
}
}
struct ipa_session_ctx *session_ctx)
{
struct tevent_req *req;
struct tevent_req *subreq;
struct ipa_get_selinux_state *state;
bool offline;
return NULL;
}
if (!offline) {
goto immediate;
}
if (!subreq) {
goto immediate;
}
} else {
goto immediate;
}
return req;
} else {
}
return req;
}
{
struct tevent_req);
struct ipa_get_selinux_state);
int dp_error = DP_ERR_FATAL;
int ret;
if (dp_error == DP_ERR_OFFLINE) {
}
goto fail;
}
/* FIXME: detect if HBAC is configured
* - if yes, we can skip host retrieval and get it directly from sysdb
*/
goto fail;
}
goto fail;
}
return;
fail:
}
{
struct tevent_req);
struct ipa_get_selinux_state);
struct sysdb_attrs **hostgroups;
struct sysdb_attrs **host;
goto done;
}
goto done;
}
goto done;
}
goto done;
}
done:
}
}
{
struct tevent_req *req;
struct ipa_get_selinux_state *state;
struct ipa_id_ctx *id_ctx;
struct sysdb_attrs **results;
const char *domain;
const char *tmp_str;
int i;
/* This is returned if no SELinux mapping
* rules were found. In that case no error
* occurred, but we don't want any more processing.*/
}
goto done;
}
"filtering ...\n", count));
count + 1);
count + 1);
goto done;
}
for (i = 0; i < count; i++) {
results[i]);
conf_cnt++;
continue;
}
continue;
}
results[i]);
pos_cnt++;
}
/* Don't shrink the confirmed list, it could be later filled by HBAC rules */
goto done;
}
/* This will free all rules that are neither confirmed nor possible */
if (pos_cnt) {
/* FIXME: detect if HBAC is configured
* - if yes, we can skip HBAC retrieval and get it directly from sysdb
*/
goto done;
}
return;
}
goto done;
}
return;
done:
} else {
}
}
{
struct tevent_req);
struct ipa_get_selinux_state);
struct sysdb_attrs **rules;
struct sysdb_attrs *usermap;
const char *hbac_dn;
const char *seealso_dn;
const char *domain;
int i, j;
&rules);
goto done;
}
for (i = 0; i < rule_count; i++) {
continue;
}
goto done;
}
/* HBAC rule matched, find if it is in the "possible" list */
for (j = 0; state->possible_match[j]; j++) {
continue;
}
goto done;
}
usermap);
/* Just to boost the following lookup */
goto done;
}
goto done;
}
}
}
}
/* Now we can dispose all possible rules, since they aren't possible any more */
goto done;
}
done:
}
}
{
struct tevent_req);
struct ipa_get_selinux_state);
goto done;
}
done:
} else {
}
}
static errno_t
struct sysdb_attrs ***maps,
char **default_user,
char **map_order)
{
struct ipa_get_selinux_state *state =
const char *tmp_str;
int i;
&tmp_str);
return ret;
}
if (*default_user == NULL) {
return ENOMEM;
}
&tmp_str);
return ret;
}
return ENOMEM;
}
} else {
*default_user = NULL;
}
for (i = 0; state->confirmed_match[i]; i++) ;
*count = i;
} else {
*count = 0;
}
return EOK;
}