fix mkswap selinux patch
This commit is contained in:
parent
5896f9a7e5
commit
7eb3b23957
@ -1,60 +1,81 @@
|
|||||||
--- util-linux-2.13-pre6/disk-utils/mkswap.c.selinux 2006-02-22 14:07:47.000000000 +0100
|
--- util-linux-2.13-pre6/disk-utils/mkswap.c.selinux 2005-08-14 17:34:49.000000000 +0200
|
||||||
+++ util-linux-2.13-pre6/disk-utils/mkswap.c 2006-02-22 15:16:05.000000000 +0100
|
+++ util-linux-2.13-pre6/disk-utils/mkswap.c 2006-03-08 16:35:08.000000000 +0100
|
||||||
@@ -39,6 +39,8 @@
|
@@ -39,6 +39,12 @@
|
||||||
#include <sys/ioctl.h> /* for _IO */
|
#include <sys/ioctl.h> /* for _IO */
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
+#include <errno.h>
|
+#include <errno.h>
|
||||||
|
+#ifdef HAVE_LIBSELINUX
|
||||||
+#include <selinux/selinux.h>
|
+#include <selinux/selinux.h>
|
||||||
|
+#include <selinux/context.h>
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
#include "swapheader.h"
|
#include "swapheader.h"
|
||||||
#include "xstrncpy.h"
|
#include "xstrncpy.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
@@ -76,6 +78,8 @@
|
@@ -76,6 +82,8 @@
|
||||||
|
|
||||||
#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
|
#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
|
||||||
|
|
||||||
+#define SELINUX_SWAPFILE_LABEL "swapfile_t"
|
+#define SELINUX_SWAPFILE_TYPE "swapfile_t"
|
||||||
+
|
+
|
||||||
static int
|
static int
|
||||||
linux_version_code(void) {
|
linux_version_code(void) {
|
||||||
struct utsname my_utsname;
|
struct utsname my_utsname;
|
||||||
@@ -718,5 +722,30 @@
|
@@ -718,5 +726,39 @@
|
||||||
if (fsync(DEV))
|
if (fsync(DEV))
|
||||||
die(_("fsync failed"));
|
die(_("fsync failed"));
|
||||||
#endif
|
#endif
|
||||||
+
|
+
|
||||||
+ if (S_ISREG(statbuf.st_mode)) {
|
+#ifdef HAVE_LIBSELINUX
|
||||||
+ char *context = NULL;
|
+ if (S_ISREG(statbuf.st_mode) && is_selinux_enabled()) {
|
||||||
|
+ security_context_t context_string;
|
||||||
|
+ security_context_t oldcontext;
|
||||||
|
+ context_t newcontext;
|
||||||
+
|
+
|
||||||
+ if (fgetfilecon(DEV, &context) < 0) {
|
+ if ((fgetfilecon(DEV, &oldcontext) < 0) &&
|
||||||
+ if (errno == ENODATA) {
|
+ (errno != ENODATA)) {
|
||||||
+ context = NULL;
|
+ fprintf(stderr, "%s: %s: unable to obtain selinux file label: %s\n",
|
||||||
+ } else {
|
+ program_name, device_name,
|
||||||
+ perror(device_name);
|
+ strerror(errno));
|
||||||
+ die(_("unable to obtain selinux file label"));
|
+ exit(1);
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
+ }
|
+ }
|
||||||
+ if (context==NULL || strcmp(context, SELINUX_SWAPFILE_LABEL)) {
|
+ if (!(newcontext = context_new(oldcontext)))
|
||||||
+ if (fsetfilecon(DEV, SELINUX_SWAPFILE_LABEL)) {
|
+ die(_("unable to create new selinux context"));
|
||||||
|
+ if (context_type_set(newcontext, SELINUX_SWAPFILE_TYPE))
|
||||||
|
+ die(_("couldn't compute selinux context"));
|
||||||
|
+
|
||||||
|
+ context_string = context_str(newcontext);
|
||||||
|
+
|
||||||
|
+ if (strcmp(context_string, oldcontext)!=0) {
|
||||||
|
+ if (fsetfilecon(DEV, context_string)) {
|
||||||
+ fprintf(stderr, "%s: unable to relabel %s to %s: %s\n",
|
+ fprintf(stderr, "%s: unable to relabel %s to %s: %s\n",
|
||||||
+ program_name, device_name,
|
+ program_name, device_name,
|
||||||
+ SELINUX_SWAPFILE_LABEL,
|
+ context_string,
|
||||||
+ strerror(errno));
|
+ strerror(errno));
|
||||||
+ exit(1);
|
+ exit(1);
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ if (context)
|
+ context_free(newcontext);
|
||||||
+ freecon(context);
|
+ freecon(oldcontext);
|
||||||
+ }
|
+ }
|
||||||
|
+#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
--- util-linux-2.13-pre6/disk-utils/Makefile.am.selinux 2006-02-22 15:23:00.000000000 +0100
|
--- util-linux-2.13-pre6/disk-utils/Makefile.am.selinux 2005-09-10 19:46:10.000000000 +0200
|
||||||
+++ util-linux-2.13-pre6/disk-utils/Makefile.am 2006-02-22 15:23:09.000000000 +0100
|
+++ util-linux-2.13-pre6/disk-utils/Makefile.am 2006-03-08 16:27:03.000000000 +0100
|
||||||
@@ -31,5 +31,5 @@
|
@@ -30,6 +30,13 @@
|
||||||
|
mkfs_cramfs_LDADD = -lz $(top_srcdir)/lib/libmd5.a
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
+mkswap_LDADD =
|
||||||
|
+
|
||||||
if HAVE_UUID
|
if HAVE_UUID
|
||||||
-mkswap_LDADD = -luuid
|
-mkswap_LDADD = -luuid
|
||||||
+mkswap_LDADD = -luuid -lselinux
|
+mkswap_LDADD += -luuid
|
||||||
|
+endif
|
||||||
|
+
|
||||||
|
+if HAVE_SELINUX
|
||||||
|
+mkswap_LDADD += -lselinux
|
||||||
endif
|
endif
|
||||||
|
+
|
||||||
|
@ -25,7 +25,7 @@ BuildRoot: %{_tmppath}/%{name}-root
|
|||||||
Summary: A collection of basic system utilities.
|
Summary: A collection of basic system utilities.
|
||||||
Name: util-linux
|
Name: util-linux
|
||||||
Version: 2.13
|
Version: 2.13
|
||||||
Release: 0.16
|
Release: 0.17
|
||||||
License: distributable
|
License: distributable
|
||||||
Group: System Environment/Base
|
Group: System Environment/Base
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ cp %{SOURCE8} %{SOURCE9} .
|
|||||||
%patch221 -p1
|
%patch221 -p1
|
||||||
%patch222 -p1
|
%patch222 -p1
|
||||||
%patch223 -p1
|
%patch223 -p1
|
||||||
%patch224 -p1
|
%patch224 -p1 -b .selinux
|
||||||
%patch225 -p1
|
%patch225 -p1
|
||||||
%patch226 -p1
|
%patch226 -p1
|
||||||
%patch227 -p1
|
%patch227 -p1
|
||||||
@ -642,6 +642,9 @@ fi
|
|||||||
/sbin/losetup
|
/sbin/losetup
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Mar 8 2006 Karel Zak <kzak@redhat.com> 2.13-0.17
|
||||||
|
- fix #181782 - mkswap selinux relabeling (fix util-linux-2.13-mkswap-selinux.patch)
|
||||||
|
|
||||||
* Wed Feb 22 2006 Karel Zak <kzak@redhat.com> 2.13-0.16
|
* Wed Feb 22 2006 Karel Zak <kzak@redhat.com> 2.13-0.16
|
||||||
- fix #181782 - mkswap should automatically add selinux label to swapfile
|
- fix #181782 - mkswap should automatically add selinux label to swapfile
|
||||||
- fix #180730 - col is exiting with 1 (fix util-linux-2.12p-col-EILSEQ.patch)
|
- fix #180730 - col is exiting with 1 (fix util-linux-2.12p-col-EILSEQ.patch)
|
||||||
|
Loading…
Reference in New Issue
Block a user