From bb04b4de9b9b60924d96dbfde827ea9c40fd21f0 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Mon, 2 Feb 2015 16:53:44 +0100 Subject: [PATCH] Re-create policycoreutils-rhat.patch from https://github.com/fedora-selinux/selinux/commit/03cfe4ebfa20c8b1029c96390e72c1d55f17cf1c - We need to cover file_context.XXX.homedir to have fixfiles with exclude_dirs working correctly. - use dnf instead of yum - rhbz#1156547 --- ...work-correctly-if-r-option-is-define.patch | 25 ------- policycoreutils-rhat.patch | 72 +++++++++++++++---- policycoreutils.spec | 6 +- 3 files changed, 61 insertions(+), 42 deletions(-) delete mode 100644 0001-Fix-setfiles-to-work-correctly-if-r-option-is-define.patch diff --git a/0001-Fix-setfiles-to-work-correctly-if-r-option-is-define.patch b/0001-Fix-setfiles-to-work-correctly-if-r-option-is-define.patch deleted file mode 100644 index 53d7bc7..0000000 --- a/0001-Fix-setfiles-to-work-correctly-if-r-option-is-define.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0c71c12b54b0f201edf53f9956c8c9df8efbca41 Mon Sep 17 00:00:00 2001 -From: Miroslav Grepl -Date: Tue, 20 May 2014 12:07:46 +0200 -Subject: [PATCH] Fix setfiles to work correctly if -r option is defined - ---- - policycoreutils/setfiles/setfiles.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/policycoreutils/setfiles/setfiles.c b/policycoreutils/setfiles/setfiles.c -index 85d8d68..b31df58 100644 ---- a/policycoreutils/setfiles/setfiles.c -+++ b/policycoreutils/setfiles/setfiles.c -@@ -334,7 +334,7 @@ int main(int argc, char **argv) - argv[0]); - exit(-1); - } -- set_rootpath(argv[optind++]); -+ set_rootpath(argv[optind]); - break; - case 's': - use_input_file = 1; --- -1.9.0 - diff --git a/policycoreutils-rhat.patch b/policycoreutils-rhat.patch index 925008b..97d4198 100644 --- a/policycoreutils-rhat.patch +++ b/policycoreutils-rhat.patch @@ -654811,7 +654811,7 @@ index 97f3920..c92e394 100644 } diff --git a/policycoreutils-2.3/scripts/fixfiles b/policycoreutils-2.3/scripts/fixfiles -index 5c29eb9..097152f 100755 +index 5c29eb9..db53c0b 100755 --- a/policycoreutils-2.3/scripts/fixfiles +++ b/policycoreutils-2.3/scripts/fixfiles @@ -116,6 +116,7 @@ exclude_dirs() { @@ -654828,7 +654828,7 @@ index 5c29eb9..097152f 100755 +FC_SUB_DIST=${FC}.subs_dist +FC_SUB=${FC}.subs -+ ++FC_HOMEDIRS=${FC}.homedirs # # Log to either syslog or a LOGFILE # @@ -654836,10 +654836,10 @@ index 5c29eb9..097152f 100755 logit "skipping the directory ${p}" done FC=$TEMPFCFILE -+/bin/cp -p ${TEMPFCFILE} ${TEMPFCFILE}.subs_dist &>/dev/null || exit +/bin/cp -p ${FC_SUB_DIST} ${TEMPFCFILE}.subs_dist &>/dev/null || exit -+/bin/cp -p ${TEMPFCFILE} ${TEMPFCFILE}.subs &>/dev/null || exit +/bin/cp -p ${FC_SUB} ${TEMPFCFILE}.subs &>/dev/null || exit ++/bin/cp -p ${FC_HOMEDIRS} ${TEMPFCFILE}.homedirs &>/dev/null || exit ++ fi if [ ! -z "$RPMFILES" ]; then for i in `echo "$RPMFILES" | sed 's/,/ /g'`; do @@ -654848,7 +654848,7 @@ index 5c29eb9..097152f 100755 fi echo "Cleaning up labels on /tmp" -rm -rf /tmp/gconfd-* /tmp/pulse-* /tmp/orbit-* $TEMPFCFILE -+rm -rf /tmp/gconfd-* /tmp/pulse-* /tmp/orbit-* $TEMPFCFILE ${TEMPFCFILE}.subs_dist ${TEMPFCFILE}.subs ++rm -rf /tmp/gconfd-* /tmp/pulse-* /tmp/orbit-* $TEMPFCFILE ${TEMPFCFILE}.subs_dist ${TEMPFCFILE}.subs ${TEMPFCFILE}.homedirs UNDEFINED=`get_undefined_type` || exit $? UNLABELED=`get_unlabeled_type` || exit $? @@ -659099,7 +659099,7 @@ index 9b9a09a..ec3e67e 100755 return tlist diff --git a/policycoreutils-2.3/sepolicy/sepolicy/generate.py b/policycoreutils-2.3/sepolicy/sepolicy/generate.py -index 6b53035..32ea970 100644 +index 6b53035..a27b17b 100644 --- a/policycoreutils-2.3/sepolicy/sepolicy/generate.py +++ b/policycoreutils-2.3/sepolicy/sepolicy/generate.py @@ -27,21 +27,21 @@ import sepolicy @@ -660096,7 +660096,7 @@ index 6b53035..32ea970 100644 for i in self.in_tcp[PORTS] + self.out_tcp[PORTS]: if self.find_port(i,"tcp") == None: -@@ -1167,88 +1170,88 @@ allow %s_t %s_t:%s_socket name_%s; +@@ -1167,97 +1170,99 @@ allow %s_t %s_t:%s_socket name_%s; for i in self.in_udp[PORTS]: if self.find_port(i,"udp") == None: @@ -660262,8 +660262,47 @@ index 6b53035..32ea970 100644 + return fcfile def __extract_rpms(self): - import yum -@@ -1316,10 +1319,10 @@ allow %s_t %s_t:%s_socket name_%s; +- import yum +- yb = yum.YumBase() +- yb.setCacheDir() ++ import dnf ++ base = dnf.Base() ++ base.conf.cachedir = dnf.yum.misc.getCacheDir() ++ base.fill_sack() ++ installed = base.sack.query().installed() + +- for pkg in yb.rpmdb.searchProvides(self.program): ++ for pkg in installed.filter(file=self.program): + self.rpms.append(pkg.name) +- for fname in pkg.dirlist + pkg.filelist + pkg.ghostlist: ++ for fname in pkg.files: + for b in self.DEFAULT_DIRS: + if b == "/etc": + continue +@@ -1267,8 +1272,9 @@ allow %s_t %s_t:%s_socket name_%s; + else: + self.add_dir(fname) + +- for bpkg in yb.rpmdb.searchNames([pkg.base_package_name]): +- for fname in bpkg.dirlist + bpkg.filelist + bpkg.ghostlist: ++ pkg_basename = dnf.rpm.miscutils.splitFilename(pkg.sourcerpm)[0] ++ for bpkg in installed.filter(name=pkg_basename): ++ for fname in bpkg.files: + for b in self.DEFAULT_DIRS: + if b == "/etc": + continue +@@ -1281,8 +1287,8 @@ allow %s_t %s_t:%s_socket name_%s; + # some packages have own systemd subpackage + # tor-systemd for example + binary_name = self.program.split("/")[-1] +- for bpkg in yb.rpmdb.searchNames([ "%s-systemd" % binary_name ]): +- for fname in bpkg.filelist + bpkg.ghostlist + bpkg.dirlist: ++ for bpkg in installed.filter(name="%s-systemd" % binary_name): ++ for fname in bpkg.files: + for b in self.DEFAULT_DIRS: + if b == "/etc": + continue +@@ -1316,10 +1322,10 @@ allow %s_t %s_t:%s_socket name_%s; if os.path.isfile("/etc/rc.d/init.d/%s" % self.name): self.set_init_script("/etc/rc\.d/init\.d/%s" % self.name) @@ -660276,7 +660315,7 @@ index 6b53035..32ea970 100644 temp_dirs = [] try: temp_basepath = self.DEFAULT_DIRS[p][1][0] + "/" -@@ -1334,9 +1337,9 @@ allow %s_t %s_t:%s_socket name_%s; +@@ -1334,9 +1340,9 @@ allow %s_t %s_t:%s_socket name_%s; if len(temp_dirs) is not 0: for i in temp_dirs: @@ -660288,7 +660327,7 @@ index 6b53035..32ea970 100644 del(self.files[i]) else: continue -@@ -1358,10 +1361,10 @@ Warning %s does not exist +@@ -1358,10 +1364,10 @@ Warning %s does not exist for s in fd.read().split(): for b in self.symbols: if s.startswith(b): @@ -663115,7 +663154,7 @@ index 2a7cfa3..95fba09 100644 char path[PATH_MAX + 1]; diff --git a/policycoreutils-2.3/setfiles/setfiles.c b/policycoreutils-2.3/setfiles/setfiles.c -index ac1c39a..0ce821f 100644 +index ac1c39a..184ef52 100644 --- a/policycoreutils-2.3/setfiles/setfiles.c +++ b/policycoreutils-2.3/setfiles/setfiles.c @@ -153,6 +153,9 @@ int main(int argc, char **argv) @@ -663143,6 +663182,15 @@ index ac1c39a..0ce821f 100644 switch (opt) { case 'c': { +@@ -326,7 +334,7 @@ int main(int argc, char **argv) + argv[0]); + exit(-1); + } +- set_rootpath(argv[optind++]); ++ set_rootpath(argv[optind]); + break; + case 's': + use_input_file = 1; @@ -337,7 +345,7 @@ int main(int argc, char **argv) if (r_opts.progress) { fprintf(stderr, diff --git a/policycoreutils.spec b/policycoreutils.spec index d6da8f6..20381d2 100644 --- a/policycoreutils.spec +++ b/policycoreutils.spec @@ -20,7 +20,6 @@ Source4: sepolicy-icons.tgz # use make-rhat-patches.sh to create following patches from https://github.com/fedora-selinux/selinux/ Patch: policycoreutils-rhat.patch Patch1: sepolgen-rhat.patch -Patch2: 0001-Fix-setfiles-to-work-correctly-if-r-option-is-define.patch Obsoletes: policycoreutils < 2.0.61-2 Conflicts: filesystem < 3 Provides: /sbin/fixfiles @@ -52,9 +51,6 @@ to switch roles. # create selinux/ directory and extract %{SOURCE0} there %setup -q -c -n selinux %patch -p1 -b .policycoreutils-rhat -pushd policycoreutils-%{version}/ -%patch2 -p2 -b .setfiles -popd cp %{SOURCE3} policycoreutils-%{version}/gui/ tar -xvf %{SOURCE4} -C policycoreutils-%{version}/ # extract {%SOURCE1} in selinux/ directory @@ -202,7 +198,7 @@ an SELinux environment. Summary: SELinux policy core policy devel utilities Group: System Environment/Base Requires: policycoreutils-python = %{version}-%{release} -Requires: /usr/bin/make yum +Requires: /usr/bin/make dnf Requires: selinux-policy-devel %description devel