|
|
d115b2 |
From 27d9eb3aa202772f57136bc67b30329fb4839b55 Mon Sep 17 00:00:00 2001
|
|
|
d115b2 |
From: Lukas Nykryn <lnykryn@redhat.com>
|
|
|
d115b2 |
Date: Mon, 16 Feb 2015 17:36:13 +0100
|
|
|
d115b2 |
Subject: [PATCH 2/6] leveldb: restore selinux context for xinetd conf files
|
|
|
d115b2 |
|
|
|
d115b2 |
---
|
|
|
d115b2 |
Makefile | 2 +-
|
|
|
d115b2 |
leveldb.c | 49 +++++++++++++++++++++++++++++++++----
|
|
|
d115b2 |
po/chkconfig.pot | 74 ++++++++++++++++++++++++++++++++------------------------
|
|
|
d115b2 |
3 files changed, 87 insertions(+), 38 deletions(-)
|
|
|
d115b2 |
|
|
|
d115b2 |
diff --git a/Makefile b/Makefile
|
|
|
d115b2 |
index 79e02da..cde8811 100644
|
|
|
d115b2 |
--- a/Makefile
|
|
|
d115b2 |
+++ b/Makefile
|
|
|
d115b2 |
@@ -2,7 +2,7 @@ VERSION=$(shell awk '/Version:/ { print $$2 }' chkconfig.spec)
|
|
|
d115b2 |
TAG = chkconfig-$(VERSION)
|
|
|
d115b2 |
|
|
|
d115b2 |
CFLAGS=-g -Wall $(RPM_OPT_FLAGS) -D_GNU_SOURCE
|
|
|
d115b2 |
-LDFLAGS+=-g
|
|
|
d115b2 |
+LDFLAGS+=-g -lselinux -lsepol
|
|
|
d115b2 |
MAN=chkconfig.8 ntsysv.8 alternatives.8
|
|
|
d115b2 |
PROG=chkconfig
|
|
|
d115b2 |
BINDIR = /sbin
|
|
|
d115b2 |
diff --git a/leveldb.c b/leveldb.c
|
|
|
d115b2 |
index 352076c..1af3a6f 100644
|
|
|
d115b2 |
--- a/leveldb.c
|
|
|
d115b2 |
+++ b/leveldb.c
|
|
|
d115b2 |
@@ -27,6 +27,9 @@
|
|
|
d115b2 |
#include <stdio.h>
|
|
|
d115b2 |
#include <string.h>
|
|
|
d115b2 |
#include <unistd.h>
|
|
|
d115b2 |
+#include <selinux/selinux.h>
|
|
|
d115b2 |
+#include <selinux/label.h>
|
|
|
d115b2 |
+#include <libgen.h>
|
|
|
d115b2 |
|
|
|
d115b2 |
/* Changes
|
|
|
d115b2 |
1998-09-22 - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
|
|
|
d115b2 |
@@ -38,6 +41,36 @@
|
|
|
d115b2 |
|
|
|
d115b2 |
#include "leveldb.h"
|
|
|
d115b2 |
|
|
|
d115b2 |
+int selinux_restore(const char *name) {
|
|
|
d115b2 |
+ struct selabel_handle *hnd = NULL;
|
|
|
d115b2 |
+ struct stat buf;
|
|
|
d115b2 |
+ security_context_t newcon = NULL;
|
|
|
d115b2 |
+ int r = -1;
|
|
|
d115b2 |
+
|
|
|
d115b2 |
+ hnd = selabel_open(SELABEL_CTX_FILE, NULL, 0);
|
|
|
d115b2 |
+ if (hnd == NULL)
|
|
|
d115b2 |
+ goto out;
|
|
|
d115b2 |
+
|
|
|
d115b2 |
+ r = stat(name, &buf;;
|
|
|
d115b2 |
+ if (r < 0)
|
|
|
d115b2 |
+ goto out;
|
|
|
d115b2 |
+
|
|
|
d115b2 |
+ r = selabel_lookup_raw(hnd, &newcon, name, buf.st_mode);
|
|
|
d115b2 |
+ if (r < 0)
|
|
|
d115b2 |
+ goto out;
|
|
|
d115b2 |
+
|
|
|
d115b2 |
+ r = setfilecon_raw(name, newcon);
|
|
|
d115b2 |
+ if (r < 0)
|
|
|
d115b2 |
+ goto out;
|
|
|
d115b2 |
+
|
|
|
d115b2 |
+ r = 0;
|
|
|
d115b2 |
+
|
|
|
d115b2 |
+ out:
|
|
|
d115b2 |
+ selabel_close(hnd);
|
|
|
d115b2 |
+ freecon(newcon);
|
|
|
d115b2 |
+ return r;
|
|
|
d115b2 |
+}
|
|
|
d115b2 |
+
|
|
|
d115b2 |
int parseLevels(char * str, int emptyOk) {
|
|
|
d115b2 |
char * chptr = str;
|
|
|
d115b2 |
int rc = 0;
|
|
|
d115b2 |
@@ -744,6 +777,7 @@ int setXinetdService(struct service s, int on) {
|
|
|
d115b2 |
char *buf, *ptr, *tmp;
|
|
|
d115b2 |
struct stat sb;
|
|
|
d115b2 |
mode_t mode;
|
|
|
d115b2 |
+ int r;
|
|
|
d115b2 |
|
|
|
d115b2 |
if (on == -1) {
|
|
|
d115b2 |
on = s.enabled ? 1 : 0;
|
|
|
d115b2 |
@@ -790,7 +824,11 @@ int setXinetdService(struct service s, int on) {
|
|
|
d115b2 |
}
|
|
|
d115b2 |
close(newfd);
|
|
|
d115b2 |
unlink(oldfname);
|
|
|
d115b2 |
- return(rename(newfname,oldfname));
|
|
|
d115b2 |
+ r = rename(newfname,oldfname);
|
|
|
d115b2 |
+ if (selinux_restore(oldfname) != 0)
|
|
|
d115b2 |
+ fprintf(stderr, _("Unable to set selinux context for %s: %s\n"), oldfname,
|
|
|
d115b2 |
+ strerror(errno));
|
|
|
d115b2 |
+ return(r);
|
|
|
d115b2 |
}
|
|
|
d115b2 |
|
|
|
d115b2 |
int doSetService(struct service s, int level, int on) {
|
|
|
d115b2 |
@@ -822,11 +860,12 @@ int doSetService(struct service s, int level, int on) {
|
|
|
d115b2 |
|
|
|
d115b2 |
int systemdIsInit() {
|
|
|
d115b2 |
char *path = realpath("/sbin/init", NULL);
|
|
|
d115b2 |
- char *base;
|
|
|
d115b2 |
+ char *base = NULL;
|
|
|
d115b2 |
|
|
|
d115b2 |
if (!path)
|
|
|
d115b2 |
return 0;
|
|
|
d115b2 |
base = basename(path);
|
|
|
d115b2 |
+ puts(base);
|
|
|
d115b2 |
if (!base)
|
|
|
d115b2 |
return 0;
|
|
|
d115b2 |
if (strcmp(base,"systemd"))
|
|
|
d115b2 |
@@ -1218,10 +1257,10 @@ void checkSystemdDependencies(struct service *s) {
|
|
|
d115b2 |
}
|
|
|
d115b2 |
}
|
|
|
d115b2 |
}
|
|
|
d115b2 |
-
|
|
|
d115b2 |
-
|
|
|
d115b2 |
+
|
|
|
d115b2 |
+
|
|
|
d115b2 |
finish:
|
|
|
d115b2 |
-
|
|
|
d115b2 |
+
|
|
|
d115b2 |
if(star) {
|
|
|
d115b2 |
for (i = 0; i < n_star; i++)
|
|
|
d115b2 |
free(star[i]);
|
|
|
d115b2 |
diff --git a/po/chkconfig.pot b/po/chkconfig.pot
|
|
|
d115b2 |
index d174fdd..2d44f2b 100644
|
|
|
d115b2 |
--- a/po/chkconfig.pot
|
|
|
d115b2 |
+++ b/po/chkconfig.pot
|
|
|
d115b2 |
@@ -8,7 +8,7 @@ msgid ""
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
"Project-Id-Version: PACKAGE VERSION\n"
|
|
|
d115b2 |
"Report-Msgid-Bugs-To: \n"
|
|
|
d115b2 |
-"POT-Creation-Date: 2013-08-08 17:07+0200\n"
|
|
|
d115b2 |
+"POT-Creation-Date: 2015-02-16 17:34+0100\n"
|
|
|
d115b2 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
|
|
d115b2 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
|
|
d115b2 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
|
|
d115b2 |
@@ -197,22 +197,27 @@ msgstr ""
|
|
|
d115b2 |
msgid "No services may be managed by ntsysv!\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../leveldb.c:263
|
|
|
d115b2 |
+#: ../leveldb.c:296
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "failed to open %s/init.d: %s\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../leveldb.c:673
|
|
|
d115b2 |
+#: ../leveldb.c:706
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "failed to glob pattern %s: %s\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../leveldb.c:716
|
|
|
d115b2 |
+#: ../leveldb.c:749
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "cannot determine current run level\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../leveldb.c:815
|
|
|
d115b2 |
+#: ../leveldb.c:829
|
|
|
d115b2 |
+#, c-format
|
|
|
d115b2 |
+msgid "Unable to set selinux context for %s: %s\n"
|
|
|
d115b2 |
+msgstr ""
|
|
|
d115b2 |
+
|
|
|
d115b2 |
+#: ../leveldb.c:853
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "failed to make symlink %s: %s\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
@@ -375,135 +380,140 @@ msgstr ""
|
|
|
d115b2 |
msgid "would remove %s\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:383 ../alternatives.c:390 ../alternatives.c:422
|
|
|
d115b2 |
+#: ../alternatives.c:383 ../alternatives.c:390 ../alternatives.c:423
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "failed to remove link %s: %s\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:406 ../alternatives.c:419
|
|
|
d115b2 |
+#: ../alternatives.c:405 ../alternatives.c:420
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "would link %s -> %s\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:411 ../alternatives.c:428
|
|
|
d115b2 |
+#: ../alternatives.c:410 ../alternatives.c:429
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "failed to link %s -> %s: %s\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:460
|
|
|
d115b2 |
+#: ../alternatives.c:416
|
|
|
d115b2 |
+#, c-format
|
|
|
d115b2 |
+msgid "failed to link %s -> %s: %s exists and it is not a symlink\n"
|
|
|
d115b2 |
+msgstr ""
|
|
|
d115b2 |
+
|
|
|
d115b2 |
+#: ../alternatives.c:461
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "%s already exists\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:462
|
|
|
d115b2 |
+#: ../alternatives.c:463
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "failed to create %s: %s\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:493
|
|
|
d115b2 |
+#: ../alternatives.c:494
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "failed to replace %s with %s: %s\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:519 ../alternatives.c:525 ../alternatives.c:536
|
|
|
d115b2 |
-#: ../alternatives.c:542
|
|
|
d115b2 |
+#: ../alternatives.c:520 ../alternatives.c:526 ../alternatives.c:537
|
|
|
d115b2 |
+#: ../alternatives.c:543
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "running %s\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:571
|
|
|
d115b2 |
+#: ../alternatives.c:572
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "the primary link for %s must be %s\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:651
|
|
|
d115b2 |
+#: ../alternatives.c:652
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "link %s incorrect for slave %s (%s %s)\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:692
|
|
|
d115b2 |
+#: ../alternatives.c:693
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "%s - status is auto.\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:694
|
|
|
d115b2 |
+#: ../alternatives.c:695
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "%s - status is manual.\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:696
|
|
|
d115b2 |
+#: ../alternatives.c:697
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid " link currently points to %s\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:699
|
|
|
d115b2 |
+#: ../alternatives.c:700
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "%s - priority %d\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:702
|
|
|
d115b2 |
+#: ../alternatives.c:703
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid " slave %s: %s\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:707
|
|
|
d115b2 |
+#: ../alternatives.c:708
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "Current `best' version is %s.\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:737
|
|
|
d115b2 |
+#: ../alternatives.c:738
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "There is %d program that provides '%s'.\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:737
|
|
|
d115b2 |
+#: ../alternatives.c:738
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "There are %d programs which provide '%s'.\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:739
|
|
|
d115b2 |
+#: ../alternatives.c:740
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid " Selection Command\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:748
|
|
|
d115b2 |
+#: ../alternatives.c:749
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "Enter to keep the current selection[+], or type selection number: "
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:751
|
|
|
d115b2 |
+#: ../alternatives.c:752
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid ""
|
|
|
d115b2 |
"\n"
|
|
|
d115b2 |
"error reading choice\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:778 ../alternatives.c:804
|
|
|
d115b2 |
+#: ../alternatives.c:779 ../alternatives.c:805
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "%s has not been configured as an alternative for %s\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:820
|
|
|
d115b2 |
+#: ../alternatives.c:821
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "(would remove %s\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:822
|
|
|
d115b2 |
+#: ../alternatives.c:823
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "failed to remove %s: %s\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:973
|
|
|
d115b2 |
+#: ../alternatives.c:974
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "altdir %s invalid\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:979
|
|
|
d115b2 |
+#: ../alternatives.c:980
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "admindir %s invalid\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
|
|
|
d115b2 |
-#: ../alternatives.c:989
|
|
|
d115b2 |
+#: ../alternatives.c:990
|
|
|
d115b2 |
#, c-format
|
|
|
d115b2 |
msgid "alternatives version %s\n"
|
|
|
d115b2 |
msgstr ""
|
|
|
d115b2 |
--
|
|
|
d115b2 |
1.8.3.1
|
|
|
d115b2 |
|