]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
build-sys: remove fallback for security_context_t
authorKarel Zak <kzak@redhat.com>
Wed, 13 Jan 2021 12:12:19 +0000 (13:12 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 13 Jan 2021 12:12:19 +0000 (13:12 +0100)
It seems like overkill to provide this #ifdef. For example coreutils
use "char *" for all selinux contexts (since 2014).

Signed-off-by: Karel Zak <kzak@redhat.com>
configure.ac
disk-utils/mkswap.c
libmount/src/optstr.c
login-utils/chfn.c
login-utils/chsh.c
login-utils/lslogins.c
login-utils/selinux_utils.c
login-utils/sulogin.c
login-utils/vipw.c
sys-utils/mount.c

index d56598a6d285c695eb82d064dcc89703dbf34dd3..20b6c31789129a93d52c95af832c8d8b7fcd9111 100644 (file)
@@ -833,15 +833,7 @@ AC_ARG_WITH([selinux],
 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])]
   )
index 87718331bc194687ef9337d986f0760ae5e064ed..2391b3e5086760deebd10dc064f62c1aa5a73f96 100644 (file)
@@ -628,11 +628,7 @@ int main(int argc, char **argv)
 
 #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) {
index be0c3ee8a2464916d381946bad87bd32b4413d89..921b9318e76fe6b974534f73ded8154499297fd0 100644 (file)
@@ -871,13 +871,7 @@ int mnt_optstr_fix_secontext(char **optstr,
                             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)
@@ -902,11 +896,7 @@ int mnt_optstr_fix_secontext(char **optstr,
 
 
        /* 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));
index 643e6ad3693c18cf0f1c25ab777a55858f601479..be122c78d8d5375a571171b62085f98288434ef4 100644 (file)
@@ -442,11 +442,8 @@ int main(int argc, char **argv)
                        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;
 
index 5631c7dc3a0a32b66b6e5cb1ffb7b8f40f2dd90e..05e475403c682f30d2f7b64b2451399e92e21769 100644 (file)
@@ -291,11 +291,8 @@ int main(int argc, char **argv)
                        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;
 
index 58cb431bb27c13eb1e70ff04f1f2d49f15cf553a..5f950758b65ff4532d4c93e5985c4f492a94da4d 100644 (file)
@@ -132,11 +132,7 @@ struct lslogins_user {
        char *failed_tty;
 
 #ifdef HAVE_LIBSELINUX
-# ifdef HAVE_SELINUX_CONTEXT_T
-       security_context_t context;
-# else
        char *context;
-# endif
 #endif
        char *homedir;
        char *shell;
index c40e610be58a25fcfc177ccfcd812cdba245d4ad..a898b537d268c8dd5dac332512feeede34f40140 100644 (file)
@@ -16,11 +16,8 @@ access_vector_t get_access_vector(const char *tclass, const char *op)
 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) {
index 40690076fe8ac9486afe6d9cabb9c3c4a2eb6fe1..6ed63f1a07d79464d1f22ddbdf05e7fe4db402f2 100644 (file)
@@ -775,13 +775,9 @@ static void sushell(struct passwd *pwd)
 
 #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) {
index eef2c5e4538e77511ef7990b1616a9f66f54a89d..f178c8f2a2a6c40ab57dba0a852d4e9bc748657c 100644 (file)
@@ -150,12 +150,9 @@ static void pw_write(void)
 
 #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);
index 765e1170ec6ba56c2f4beb7703e88142bd159b30..2900717a9c6561181f88e29b7be93d59137fc5fd 100644 (file)
@@ -319,11 +319,7 @@ static void selinux_warning(struct libmnt_context *cxt, const char *tgt)
 {
 
        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) {