/*
SSSD
Copyright (C) Jakub Hrozek <jhrozek@redhat.com> 2010
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 "config.h"
#include <stdio.h>
#ifdef HAVE_SEMANAGE
#include <semanage/semanage.h>
#endif
#ifndef DEFAULT_SERANGE
#endif
#ifdef HAVE_SEMANAGE
/* turn libselinux messages into SSSD DEBUG() calls */
const char *fmt, ...)
{
switch (semanage_msg_get_level(handle)) {
case SEMANAGE_MSG_ERR:
break;
case SEMANAGE_MSG_WARN:
break;
case SEMANAGE_MSG_INFO:
break;
}
if (DEBUG_IS_SET(level)) {
}
}
{
return; /* semanage uses asserts */
}
if (semanage_is_connected(handle)) {
}
}
{
int ret;
if (!handle) {
return NULL;
}
NULL);
if (ret != 1) {
goto fail;
}
if (ret < SEMANAGE_CAN_READ) {
goto fail;
}
if (ret != 0) {
"Cannot estabilish SELinux management connection\n");
goto fail;
}
return handle;
fail:
return NULL;
}
const char *login_name,
const char *seuser_name,
const char *mls)
{
int ret;
if (ret != 0) {
"Cannot create SELinux login mapping for %s\n", login_name);
goto done;
}
if (ret != 0) {
goto done;
}
if (ret != 0) {
"Could not set serange for %s\n", login_name);
goto done;
}
if (ret != 0) {
"Could not set SELinux user for %s\n", login_name);
goto done;
}
if (ret != 0) {
"Could not add login mapping for %s\n", login_name);
goto done;
}
done:
return ret;
}
const char *login_name,
const char *seuser_name,
const char *mls)
{
int ret;
"Could not query seuser for %s\n", login_name);
goto done;
}
if (ret != 0) {
"Could not set serange for %s\n", login_name);
goto done;
}
if (ret != 0) {
goto done;
}
if (ret != 0) {
"Could not modify login mapping for %s\n", login_name);
goto done;
}
done:
return ret;
}
const char *mls)
{
int ret;
int seuser_exists = 0;
if (seuser_name == NULL) {
/* don't care, just let system pick the defaults */
return EOK;
}
handle = sss_semanage_init();
if (!handle) {
goto done;
}
if (ret != 0) {
goto done;
}
if (ret != 0) {
goto done;
}
if (ret < 0) {
goto done;
}
if (seuser_exists) {
mls);
if (ret != 0) {
goto done;
}
} else {
mls);
if (ret != 0) {
goto done;
}
}
if (ret < 0) {
goto done;
}
done:
return ret;
}
{
int ret;
int exists = 0;
handle = sss_semanage_init();
if (!handle) {
goto done;
}
if (ret != 0) {
goto done;
}
if (ret != 0) {
goto done;
}
if (ret < 0) {
goto done;
}
if (!exists) {
"Login mapping for %s is not defined, OK if default mapping "
"was used\n", login_name);
goto done;
}
if (ret < 0) {
goto done;
}
if (!exists) {
"Login mapping for %s is defined in policy, cannot be deleted\n",
goto done;
}
if (ret != 0) {
"Could not delete login mapping for %s\n", login_name);
goto done;
}
if (ret < 0) {
goto done;
}
done:
return ret;
}
char **_seuser, char **_mls_range)
{
const char *seuser;
const char *mls_range;
goto done;
}
goto done;
}
if (ret < 0) {
goto done;
}
goto done;
}
} else {
}
if (*_mls_range == NULL) {
goto done;
}
} else {
}
done:
return ret;
}
#else /* HAVE_SEMANAGE */
const char *mls)
{
return EOK;
}
{
return EOK;
}
char **_seuser, char **_mls_range)
{
return EOK;
}
#endif /* HAVE_SEMANAGE */