ima-setup.c revision 116b6c8687e1da25fcecf80ba6ac16866e308d50
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
Copyright (C) 2012 Roberto Sassu - Politecnico di Torino, Italy
TORSEC group -- http://security.polito.it
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 <errno.h>
#include <fcntl.h>
#include "ima-setup.h"
#include "util.h"
#include "log.h"
#define IMA_SECFS_DIR "/sys/kernel/security/ima"
#define IMA_POLICY_PATH "/etc/ima/ima-policy"
int ima_setup(void) {
int r = 0;
#ifdef HAVE_IMA
char *policy;
log_debug("IMA support is disabled in the kernel, ignoring.");
return 0;
}
if (policyfd < 0) {
return 0;
}
log_warning("Another IMA custom policy has already been loaded, ignoring.");
return 0;
}
if (imafd < 0) {
return 0;
}
if (policy == MAP_FAILED)
if (r < 0)
else
#endif /* HAVE_IMA */
return r;
}