sss_semanage.c revision 450b472a68abf442479755c7916c757907b35ea5
/*
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>
#if defined(HAVE_SEMANAGE) && defined(HAVE_SELINUX)
#include <semanage/semanage.h>
#endif
#ifndef DEFAULT_SERANGE
#define DEFAULT_SERANGE "s0"
#endif
#if defined(HAVE_SEMANAGE) && defined(HAVE_SELINUX)
/* turn libselinux messages into SSSD DEBUG() calls */
static void sss_semanage_error_callback(void *varg,
const char *fmt, ...)
{
int level = SSSDBG_INVALID;
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;
return EINVAL;
}
if (ret == 0) {
return ERR_SELINUX_NOT_MANAGED;
} else if (ret == -1) {
return EIO;
}
return EOK;
}
{
int ret;
if (!handle) {
goto done;
}
NULL);
goto done;
}
if (ret < SEMANAGE_CAN_READ) {
goto done;
}
if (ret != 0) {
"Cannot estabilish SELinux management connection\n");
goto done;
}
done:
} else {
}
return ret;
}
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;
}
int sss_get_seuser(const char *linuxuser,
char **selinuxuser,
char **level)
{
int ret;
return EIO;
}
NULL);
/* We only needed the handle for this call. Close the handle right
* after it */
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;
}
if (ret == ERR_SELINUX_NOT_MANAGED) {
goto done;
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 del_seuser(const char *login_name)
{
int ret;
int exists = 0;
if (ret == ERR_SELINUX_NOT_MANAGED) {
goto done;
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;
}
#else /* HAVE_SEMANAGE && HAVE_SELINUX */
const char *mls)
{
return EOK;
}
int del_seuser(const char *login_name)
{
return EOK;
}
int sss_get_seuser(const char *linuxuser,
char **selinuxuser,
char **level)
{
return EOK;
}
#endif /* HAVE_SEMANAGE */