Sophie

Sophie

distrib > Mageia > 8 > x86_64 > by-pkgid > 381785ef4c01f103804947e08a58df6e > files > 2

chkconfig-1.14-1.mga8.src.rpm

--- chkconfig-1.14/leveldb.c.OR	2020-07-17 11:29:53.000000000 +0300
+++ chkconfig-1.14/leveldb.c	2020-10-09 14:53:42.200101093 +0300
@@ -19,11 +19,8 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <glob.h>
-#include <libgen.h>
 #include <libintl.h>
 #include <locale.h>
-#include <selinux/label.h>
-#include <selinux/selinux.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -41,47 +38,6 @@
 
 #include "leveldb.h"
 
-int selinux_restore(const char *name) {
-    struct selabel_handle *hnd = NULL;
-    struct stat buf;
-    security_context_t newcon = NULL;
-    int r = -1;
-
-    hnd = selabel_open(SELABEL_CTX_FILE, NULL, 0);
-    if (hnd == NULL)
-        goto out;
-
-    r = stat(name, &buf);
-    if (r < 0)
-        goto out;
-
-    r = selabel_lookup_raw(hnd, &newcon, name, buf.st_mode);
-    if (r < 0)
-        goto out;
-
-    r = setfilecon_raw(name, newcon);
-    if (r < 0)
-        goto out;
-
-    r = 0;
-
-out:
-    if (hnd)
-        selabel_close(hnd);
-    if (newcon)
-        freecon(newcon);
-
-    /* Lets ignore any errors when selinux is disabled.
-     * We still want to run the previous code though,
-     * since we only need selinux policy.
-     * Selinux itself can be turned off.
-     */
-    if (!is_selinux_enabled())
-        return 0;
-
-    return r;
-}
-
 int parseLevels(char *str, int emptyOk) {
     char *chptr = str;
     int rc = 0;
@@ -848,7 +804,6 @@
     char *buf, *ptr, *tmp;
     struct stat sb;
     mode_t mode;
-    int r;
 
     if (on == -1) {
         on = s.enabled ? 1 : 0;
@@ -896,11 +851,7 @@
     }
     close(newfd);
     unlink(oldfname);
-    r = rename(newfname, oldfname);
-    if (selinux_restore(oldfname) != 0)
-        fprintf(stderr, _("Unable to set SELinux context for %s: %s\n"),
-                oldfname, strerror(errno));
-    return (r);
+    return (rename(newfname, oldfname));
 }
 
 int doSetService(struct service s, int level, int on) {