selinux-setup.c revision 2fa4092c2829dd14e50c430ae2f23551d23c6c1d
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SELINUX
#endif
#include "selinux-setup.h"
#include "selinux-util.h"
#include "label.h"
#include "mount-setup.h"
#include "macro.h"
#include "util.h"
#include "log.h"
#ifdef HAVE_SELINUX
return 0;
}
#endif
int selinux_setup(bool *loaded_policy) {
#ifdef HAVE_SELINUX
int enforce = 0;
int r;
union selinux_callback cb;
/* Turn off all of SELinux' own logging, we want to do that */
/* Already initialized by somebody else? */
r = getcon_raw(&con);
if (r == 0) {
bool initialized;
if (initialized)
return 0;
}
/* Make sure we have no fds open while loading the policy and
* transitioning */
log_close();
/* Now load the policy */
r = selinux_init_load_policy(&enforce);
if (r == 0) {
char timespan[FORMAT_TIMESPAN_MAX];
char *label;
/* Transition to the new context */
log_open();
log_error("Failed to compute init label, ignoring.");
} else {
log_open();
if (r < 0)
}
log_info("Successfully loaded SELinux policy in %s.",
*loaded_policy = true;
} else {
log_open();
if (enforce > 0) {
log_error("Failed to load SELinux policy. Freezing.");
return -EIO;
} else
log_debug("Unable to load SELinux policy. Ignoring.");
}
#endif
return 0;
}