AS_IF([test "x$with_selinux" = xno], [
AM_CONDITIONAL([HAVE_SELINUX], [false])
], [
- PKG_CHECK_MODULES([SELINUX], [libselinux >= 3.1], [have_selinux=yes], [have_selinux=no])
- AS_IF([test "x$have_selinux" = xno], [
- PKG_CHECK_MODULES([SELINUX], [libselinux >= 2.0],
- [have_selinux=yes
- AC_DEFINE([HAVE_SELINUX_CONTEXT_T], [1], [Do we need deprecated selinux_context_t?])
- ],
- [have_selinux=no])
- ])
-
+ PKG_CHECK_MODULES([SELINUX], [libselinux >= 2.5], [have_selinux=yes], [have_selinux=no])
AS_CASE([$with_selinux:$have_selinux],
[yes:no], [AC_MSG_ERROR([SELinux selected but libselinux not found or too old])]
)
#ifdef HAVE_LIBSELINUX
if (S_ISREG(ctl.devstat.st_mode) && is_selinux_enabled() > 0) {
-# ifdef HAVE_SELINUX_CONTEXT_T
- security_context_t context_string, oldcontext; /* deprecated */
-# else
- char *context_string, *oldcontext; /* since libselinux >= 3.1 */
-# endif
+ char *context_string, *oldcontext;
context_t newcontext;
if (fgetfilecon(ctl.fd, &oldcontext) < 0) {
char **next)
{
int rc = 0;
-# ifdef HAVE_SELINUX_CONTEXT_T
- security_context_t raw = NULL; /* deprecated */
-# else
- char *raw = NULL; /* since libselinux >= 3.1 */
-# endif
-
- char *p, *val, *begin, *end;
+ char *p, *val, *begin, *end, *raw = NULL;
size_t sz;
if (!optstr || !*optstr || !value || !valsz)
/* translate the context */
- rc = selinux_trans_to_raw_context(
-# ifdef HAVE_SELINUX_CONTEXT_T
- (security_context_t)
-# endif
- p, &raw);
+ rc = selinux_trans_to_raw_context(p, &raw);
DBG(CXT, ul_debug("SELinux context '%s' translated to '%s'",
p, rc == -1 ? "FAILED" : (char *) raw));
access_vector_t av = get_access_vector("passwd", "chfn");
if (selinux_check_passwd_access(av) != 0) {
-# ifdef HAVE_SELINUX_CONTEXT_T
- security_context_t user_context; /* deprecated */
-# else
- char *user_context; /* since libselinux >= 3.1 */
-# endif
+ char *user_context;
+
if (getprevcon(&user_context) < 0)
user_context = NULL;
access_vector_t av = get_access_vector("passwd", "chsh");
if (selinux_check_passwd_access(av) != 0) {
-# ifdef HAVE_SELINUX_CONTEXT_T
- security_context_t user_context; /* deprecated */
-# else
- char *user_context; /* since libselinux >= 3.1 */
-# endif
+ char *user_context;
+
if (getprevcon(&user_context) < 0)
user_context = NULL;
char *failed_tty;
#ifdef HAVE_LIBSELINUX
-# ifdef HAVE_SELINUX_CONTEXT_T
- security_context_t context;
-# else
char *context;
-# endif
#endif
char *homedir;
char *shell;
int setupDefaultContext(char *orig_file)
{
if (is_selinux_enabled() > 0) {
-#ifdef HAVE_SELINUX_CONTEXT_T
- security_context_t scontext = NULL; /* deprecated */
-#else
- char *scontext = NULL; /* since libselinux >= 3.1 */
-#endif
+ char *scontext = NULL;
+
if (getfilecon(orig_file, &scontext) < 0)
return 1;
if (setfscreatecon(scontext) < 0) {
#ifdef HAVE_LIBSELINUX
if (is_selinux_enabled() > 0) {
-# ifdef HAVE_SELINUX_CONTEXT_T
- security_context_t scon = NULL; /* deprecated */
-# else
- char *scon = NULL; /* since libselinux >= 3.1 */
-# endif
- char *seuser=NULL;
- char *level=NULL;
+ char *scon = NULL;
+ char *seuser = NULL;
+ char *level = NULL;
if (getseuserbyname("root", &seuser, &level) == 0) {
if (get_default_context_with_level(seuser, level, 0, &scon) == 0) {
#ifdef HAVE_LIBSELINUX
if (is_selinux_enabled() > 0) {
-# ifdef HAVE_SELINUX_CONTEXT_T
- security_context_t passwd_context = NULL; /* deprecated */
-# else
- char *passwd_context = NULL; /* since libselinux >= 3.1 */
-# endif
+ char *passwd_context = NULL;
int ret = 0;
+
if (getfilecon(orig_file, &passwd_context) < 0) {
warnx(_("Can't get context for %s"), orig_file);
pw_error(orig_file, 1, 1);
{
if (tgt && mnt_context_is_verbose(cxt) && is_selinux_enabled() > 0) {
-# ifdef HAVE_SELINUX_CONTEXT_T
- security_context_t raw = NULL, def = NULL; /* deprecated */
-# else
- char *raw = NULL, *def = NULL; /* since libselinux >= 3.1 */
-# endif
+ char *raw = NULL, *def = NULL;
if (getfilecon(tgt, &raw) > 0
&& security_get_initial_context("file", &def) == 0) {