diff --git a/SOURCES/0001-partly-support-socket-activated-services.patch b/SOURCES/0001-partly-support-socket-activated-services.patch index 3e94b48..35ba5bb 100644 --- a/SOURCES/0001-partly-support-socket-activated-services.patch +++ b/SOURCES/0001-partly-support-socket-activated-services.patch @@ -1,7 +1,7 @@ -From 7b2f13a52e3629f81052faa49e8be973bb9aa3a2 Mon Sep 17 00:00:00 2001 +From 61b0f62df33fa9ac828f566c8b20589524c0e8c4 Mon Sep 17 00:00:00 2001 From: Lukas Nykryn Date: Thu, 15 Aug 2013 09:54:31 +0200 -Subject: [PATCH] partly support socket activated services +Subject: [PATCH 1/6] partly support socket activated services --- chkconfig.c | 9 ++++++--- diff --git a/SOURCES/0002-leveldb-restore-selinux-context-for-xinetd-conf-file.patch b/SOURCES/0002-leveldb-restore-selinux-context-for-xinetd-conf-file.patch new file mode 100644 index 0000000..91e5d2b --- /dev/null +++ b/SOURCES/0002-leveldb-restore-selinux-context-for-xinetd-conf-file.patch @@ -0,0 +1,340 @@ +From 27d9eb3aa202772f57136bc67b30329fb4839b55 Mon Sep 17 00:00:00 2001 +From: Lukas Nykryn +Date: Mon, 16 Feb 2015 17:36:13 +0100 +Subject: [PATCH 2/6] leveldb: restore selinux context for xinetd conf files + +--- + Makefile | 2 +- + leveldb.c | 49 +++++++++++++++++++++++++++++++++---- + po/chkconfig.pot | 74 ++++++++++++++++++++++++++++++++------------------------ + 3 files changed, 87 insertions(+), 38 deletions(-) + +diff --git a/Makefile b/Makefile +index 79e02da..cde8811 100644 +--- a/Makefile ++++ b/Makefile +@@ -2,7 +2,7 @@ VERSION=$(shell awk '/Version:/ { print $$2 }' chkconfig.spec) + TAG = chkconfig-$(VERSION) + + CFLAGS=-g -Wall $(RPM_OPT_FLAGS) -D_GNU_SOURCE +-LDFLAGS+=-g ++LDFLAGS+=-g -lselinux -lsepol + MAN=chkconfig.8 ntsysv.8 alternatives.8 + PROG=chkconfig + BINDIR = /sbin +diff --git a/leveldb.c b/leveldb.c +index 352076c..1af3a6f 100644 +--- a/leveldb.c ++++ b/leveldb.c +@@ -27,6 +27,9 @@ + #include + #include + #include ++#include ++#include ++#include + + /* Changes + 1998-09-22 - Arnaldo Carvalho de Melo +@@ -38,6 +41,36 @@ + + #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: ++ selabel_close(hnd); ++ freecon(newcon); ++ return r; ++} ++ + int parseLevels(char * str, int emptyOk) { + char * chptr = str; + int rc = 0; +@@ -744,6 +777,7 @@ int setXinetdService(struct service s, int on) { + char *buf, *ptr, *tmp; + struct stat sb; + mode_t mode; ++ int r; + + if (on == -1) { + on = s.enabled ? 1 : 0; +@@ -790,7 +824,11 @@ int setXinetdService(struct service s, int on) { + } + close(newfd); + unlink(oldfname); +- return(rename(newfname,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); + } + + int doSetService(struct service s, int level, int on) { +@@ -822,11 +860,12 @@ int doSetService(struct service s, int level, int on) { + + int systemdIsInit() { + char *path = realpath("/sbin/init", NULL); +- char *base; ++ char *base = NULL; + + if (!path) + return 0; + base = basename(path); ++ puts(base); + if (!base) + return 0; + if (strcmp(base,"systemd")) +@@ -1218,10 +1257,10 @@ void checkSystemdDependencies(struct service *s) { + } + } + } +- +- ++ ++ + finish: +- ++ + if(star) { + for (i = 0; i < n_star; i++) + free(star[i]); +diff --git a/po/chkconfig.pot b/po/chkconfig.pot +index d174fdd..2d44f2b 100644 +--- a/po/chkconfig.pot ++++ b/po/chkconfig.pot +@@ -8,7 +8,7 @@ msgid "" + msgstr "" + "Project-Id-Version: PACKAGE VERSION\n" + "Report-Msgid-Bugs-To: \n" +-"POT-Creation-Date: 2013-08-08 17:07+0200\n" ++"POT-Creation-Date: 2015-02-16 17:34+0100\n" + "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" + "Last-Translator: FULL NAME \n" + "Language-Team: LANGUAGE \n" +@@ -197,22 +197,27 @@ msgstr "" + msgid "No services may be managed by ntsysv!\n" + msgstr "" + +-#: ../leveldb.c:263 ++#: ../leveldb.c:296 + #, c-format + msgid "failed to open %s/init.d: %s\n" + msgstr "" + +-#: ../leveldb.c:673 ++#: ../leveldb.c:706 + #, c-format + msgid "failed to glob pattern %s: %s\n" + msgstr "" + +-#: ../leveldb.c:716 ++#: ../leveldb.c:749 + #, c-format + msgid "cannot determine current run level\n" + msgstr "" + +-#: ../leveldb.c:815 ++#: ../leveldb.c:829 ++#, c-format ++msgid "Unable to set selinux context for %s: %s\n" ++msgstr "" ++ ++#: ../leveldb.c:853 + #, c-format + msgid "failed to make symlink %s: %s\n" + msgstr "" +@@ -375,135 +380,140 @@ msgstr "" + msgid "would remove %s\n" + msgstr "" + +-#: ../alternatives.c:383 ../alternatives.c:390 ../alternatives.c:422 ++#: ../alternatives.c:383 ../alternatives.c:390 ../alternatives.c:423 + #, c-format + msgid "failed to remove link %s: %s\n" + msgstr "" + +-#: ../alternatives.c:406 ../alternatives.c:419 ++#: ../alternatives.c:405 ../alternatives.c:420 + #, c-format + msgid "would link %s -> %s\n" + msgstr "" + +-#: ../alternatives.c:411 ../alternatives.c:428 ++#: ../alternatives.c:410 ../alternatives.c:429 + #, c-format + msgid "failed to link %s -> %s: %s\n" + msgstr "" + +-#: ../alternatives.c:460 ++#: ../alternatives.c:416 ++#, c-format ++msgid "failed to link %s -> %s: %s exists and it is not a symlink\n" ++msgstr "" ++ ++#: ../alternatives.c:461 + #, c-format + msgid "%s already exists\n" + msgstr "" + +-#: ../alternatives.c:462 ++#: ../alternatives.c:463 + #, c-format + msgid "failed to create %s: %s\n" + msgstr "" + +-#: ../alternatives.c:493 ++#: ../alternatives.c:494 + #, c-format + msgid "failed to replace %s with %s: %s\n" + msgstr "" + +-#: ../alternatives.c:519 ../alternatives.c:525 ../alternatives.c:536 +-#: ../alternatives.c:542 ++#: ../alternatives.c:520 ../alternatives.c:526 ../alternatives.c:537 ++#: ../alternatives.c:543 + #, c-format + msgid "running %s\n" + msgstr "" + +-#: ../alternatives.c:571 ++#: ../alternatives.c:572 + #, c-format + msgid "the primary link for %s must be %s\n" + msgstr "" + +-#: ../alternatives.c:651 ++#: ../alternatives.c:652 + #, c-format + msgid "link %s incorrect for slave %s (%s %s)\n" + msgstr "" + +-#: ../alternatives.c:692 ++#: ../alternatives.c:693 + #, c-format + msgid "%s - status is auto.\n" + msgstr "" + +-#: ../alternatives.c:694 ++#: ../alternatives.c:695 + #, c-format + msgid "%s - status is manual.\n" + msgstr "" + +-#: ../alternatives.c:696 ++#: ../alternatives.c:697 + #, c-format + msgid " link currently points to %s\n" + msgstr "" + +-#: ../alternatives.c:699 ++#: ../alternatives.c:700 + #, c-format + msgid "%s - priority %d\n" + msgstr "" + +-#: ../alternatives.c:702 ++#: ../alternatives.c:703 + #, c-format + msgid " slave %s: %s\n" + msgstr "" + +-#: ../alternatives.c:707 ++#: ../alternatives.c:708 + #, c-format + msgid "Current `best' version is %s.\n" + msgstr "" + +-#: ../alternatives.c:737 ++#: ../alternatives.c:738 + #, c-format + msgid "There is %d program that provides '%s'.\n" + msgstr "" + +-#: ../alternatives.c:737 ++#: ../alternatives.c:738 + #, c-format + msgid "There are %d programs which provide '%s'.\n" + msgstr "" + +-#: ../alternatives.c:739 ++#: ../alternatives.c:740 + #, c-format + msgid " Selection Command\n" + msgstr "" + +-#: ../alternatives.c:748 ++#: ../alternatives.c:749 + #, c-format + msgid "Enter to keep the current selection[+], or type selection number: " + msgstr "" + +-#: ../alternatives.c:751 ++#: ../alternatives.c:752 + #, c-format + msgid "" + "\n" + "error reading choice\n" + msgstr "" + +-#: ../alternatives.c:778 ../alternatives.c:804 ++#: ../alternatives.c:779 ../alternatives.c:805 + #, c-format + msgid "%s has not been configured as an alternative for %s\n" + msgstr "" + +-#: ../alternatives.c:820 ++#: ../alternatives.c:821 + #, c-format + msgid "(would remove %s\n" + msgstr "" + +-#: ../alternatives.c:822 ++#: ../alternatives.c:823 + #, c-format + msgid "failed to remove %s: %s\n" + msgstr "" + +-#: ../alternatives.c:973 ++#: ../alternatives.c:974 + #, c-format + msgid "altdir %s invalid\n" + msgstr "" + +-#: ../alternatives.c:979 ++#: ../alternatives.c:980 + #, c-format + msgid "admindir %s invalid\n" + msgstr "" + +-#: ../alternatives.c:989 ++#: ../alternatives.c:990 + #, c-format + msgid "alternatives version %s\n" + msgstr "" +-- +1.8.3.1 + diff --git a/SOURCES/0003-leveldb-remove-debug-output.patch b/SOURCES/0003-leveldb-remove-debug-output.patch new file mode 100644 index 0000000..4a4ad46 --- /dev/null +++ b/SOURCES/0003-leveldb-remove-debug-output.patch @@ -0,0 +1,24 @@ +From c561ccf5aeff1c5bff59647d6cba919f0aa67824 Mon Sep 17 00:00:00 2001 +From: Lukas Nykryn +Date: Mon, 16 Feb 2015 18:27:15 +0100 +Subject: [PATCH 3/6] leveldb: remove debug output + +--- + leveldb.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/leveldb.c b/leveldb.c +index 1af3a6f..f4e0f8f 100644 +--- a/leveldb.c ++++ b/leveldb.c +@@ -865,7 +865,6 @@ int systemdIsInit() { + if (!path) + return 0; + base = basename(path); +- puts(base); + if (!base) + return 0; + if (strcmp(base,"systemd")) +-- +1.8.3.1 + diff --git a/SOURCES/0004-fix-combination-type-xinetd-list-service.patch b/SOURCES/0004-fix-combination-type-xinetd-list-service.patch new file mode 100644 index 0000000..d348165 --- /dev/null +++ b/SOURCES/0004-fix-combination-type-xinetd-list-service.patch @@ -0,0 +1,25 @@ +From 793905c0ec22cf4ef19dfa3c6b3b692e5feab698 Mon Sep 17 00:00:00 2001 +From: Lukas Nykryn +Date: Wed, 18 Feb 2015 12:23:22 +0100 +Subject: [PATCH 4/6] fix combination --type xinetd --list service + +--- + chkconfig.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/chkconfig.c b/chkconfig.c +index 6a1fc61..596ef8f 100644 +--- a/chkconfig.c ++++ b/chkconfig.c +@@ -434,7 +434,7 @@ static int showServiceInfoByName(char * name, int type, int forgiving) { + int rc; + struct service s; + +- if (systemdActive() && isOverriddenBySystemd(name)) { ++ if (systemdActive() && isOverriddenBySystemd(name) && !(type & TYPE_XINETD)) { + return forgiving ? 0 : 1; + } + +-- +1.8.3.1 + diff --git a/SOURCES/0005-Makefile-fix-wrongly-behaving-LDFLAGS.patch b/SOURCES/0005-Makefile-fix-wrongly-behaving-LDFLAGS.patch new file mode 100644 index 0000000..05150c8 --- /dev/null +++ b/SOURCES/0005-Makefile-fix-wrongly-behaving-LDFLAGS.patch @@ -0,0 +1,40 @@ +From 9d2f4392e0b50bae5d3883d4052b103e33598769 Mon Sep 17 00:00:00 2001 +From: Lukas Nykryn +Date: Thu, 26 Mar 2015 14:46:56 +0100 +Subject: [PATCH 5/6] Makefile: fix wrongly behaving LDFLAGS + +--- + Makefile | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/Makefile b/Makefile +index cde8811..7603ce4 100644 +--- a/Makefile ++++ b/Makefile +@@ -2,7 +2,7 @@ VERSION=$(shell awk '/Version:/ { print $$2 }' chkconfig.spec) + TAG = chkconfig-$(VERSION) + + CFLAGS=-g -Wall $(RPM_OPT_FLAGS) -D_GNU_SOURCE +-LDFLAGS+=-g -lselinux -lsepol ++LDFLAGS+=-g + MAN=chkconfig.8 ntsysv.8 alternatives.8 + PROG=chkconfig + BINDIR = /sbin +@@ -24,12 +24,12 @@ subdirs: + done && test -z "$$fail" + + chkconfig: $(OBJS) +- $(CC) $(LDFLAGS) -o chkconfig $(OBJS) -lpopt ++ $(CC) $(LDFLAGS) -lselinux -lsepol -o chkconfig $(OBJS) -lpopt + + alternatives: alternatives.o + + ntsysv: $(NTOBJS) +- $(CC) $(LDFLAGS) -o ntsysv $(NTOBJS) -lnewt -lpopt $(LIBMHACK) ++ $(CC) $(LDFLAGS) -lselinux -lsepol -o ntsysv $(NTOBJS) -lnewt -lpopt $(LIBMHACK) + + chkconfig.o: chkconfig.c leveldb.h + $(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -c chkconfig.c +-- +1.8.3.1 + diff --git a/SOURCES/0006-chkconfig-don-t-create-symlinks-if-they-already-exis.patch b/SOURCES/0006-chkconfig-don-t-create-symlinks-if-they-already-exis.patch new file mode 100644 index 0000000..69a8f2f --- /dev/null +++ b/SOURCES/0006-chkconfig-don-t-create-symlinks-if-they-already-exis.patch @@ -0,0 +1,36 @@ +From a91b4d79c1890d19e0deff0a9e33dde5c45bdd9d Mon Sep 17 00:00:00 2001 +From: Lukas Nykryn +Date: Wed, 29 Apr 2015 14:41:00 +0200 +Subject: [PATCH 6/6] chkconfig: don't create symlinks if they already exist + +--- + chkconfig.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/chkconfig.c b/chkconfig.c +index 596ef8f..d334bf2 100644 +--- a/chkconfig.c ++++ b/chkconfig.c +@@ -239,10 +239,16 @@ static int frobOneDependencies(struct service *s, struct service *servs, int num + + if (target || ((s0 != s->sPriority) || (k0 != s->kPriority))) { + for (i = 0; i < 7; i++) { +- if (isConfigured(s->name, i, NULL, NULL)) { ++ int priority; ++ char type; ++ if (isConfigured(s->name, i, &priority, &type)) { + int on = isOn(s->name, i); +- delService(s->name, TYPE_INIT_D, i); +- doSetService(*s, i, on); ++ int new_priority = on ? s->sPriority : s->kPriority; ++ ++ if (new_priority != priority || (on ? 'S' : 'K') != type) { ++ delService(s->name, TYPE_INIT_D, i); ++ doSetService(*s, i, on); ++ } + } else if (target) { + delService(s->name, TYPE_INIT_D, i); + doSetService(*s, i, ((1<levels)); +-- +1.8.3.1 + diff --git a/SPECS/chkconfig.spec b/SPECS/chkconfig.spec index d199763..053652a 100644 --- a/SPECS/chkconfig.spec +++ b/SPECS/chkconfig.spec @@ -1,14 +1,19 @@ Summary: A system tool for maintaining the /etc/rc*.d hierarchy Name: chkconfig Version: 1.3.61 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2 Group: System Environment/Base Source: http://fedorahosted.org/releases/c/h/chkconfig/%{name}-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: newt-devel gettext popt-devel +BuildRequires: newt-devel gettext popt-devel libselinux-devel Conflicts: initscripts <= 5.30-1 Patch0: 0001-partly-support-socket-activated-services.patch +Patch1: 0002-leveldb-restore-selinux-context-for-xinetd-conf-file.patch +Patch2: 0003-leveldb-remove-debug-output.patch +Patch3: 0004-fix-combination-type-xinetd-list-service.patch +Patch4: 0005-Makefile-fix-wrongly-behaving-LDFLAGS.patch +Patch5: 0006-chkconfig-don-t-create-symlinks-if-they-already-exis.patch %description Chkconfig is a basic system utility. It updates and queries runlevel @@ -32,6 +37,11 @@ page), ntsysv configures the current runlevel (5 if you're using X). %setup -q %patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 %build @@ -78,6 +88,11 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/*/ntsysv.8* %changelog +* Thu Apr 30 2015 Lukáš Nykrýn - 1.3.61-5 +- chkconfig: don't create symlinks if they already exist +- fix combination --type xinetd --list service +- leveldb: restore selinux context for xinetd conf files + * Fri Jan 24 2014 Daniel Mach - 1.3.61-4 - Mass rebuild 2014-01-24