[libsemanage] Fix handling of umask, so files get created with the correct label.

Daniel J Walsh dwalsh at fedoraproject.org
Thu Oct 20 19:03:09 UTC 2011


commit 86ba998b2520e6bbc2870a1fc3d5d0e7bcfbb78c
Author: Dan Walsh <dwalsh at redhat.com>
Date:   Thu Oct 20 15:03:03 2011 -0400

    Fix handling of umask, so files get created with the correct label.

 libsemanage-rhat.patch |   30 ++++++++++++++++++++++++++++++
 libsemanage.spec       |    5 ++++-
 2 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/libsemanage-rhat.patch b/libsemanage-rhat.patch
index 3214334..0728ced 100644
--- a/libsemanage-rhat.patch
+++ b/libsemanage-rhat.patch
@@ -136,3 +136,33 @@ index 847d87e..2870fa8 100644
  		if (push_user_entry(&head, name, seuname,
  				    prefix, pwent->pw_dir, level) != STATUS_SUCCESS) {
  			*errors = STATUS_ERR;
+diff --git a/libsemanage/src/semanage_store.c b/libsemanage/src/semanage_store.c
+index e322992..a223aa7 100644
+--- a/libsemanage/src/semanage_store.c
++++ b/libsemanage/src/semanage_store.c
+@@ -495,6 +495,7 @@ static int semanage_copy_file(const char *src, const char *dst, mode_t mode)
+ 	int in, out, retval = 0, amount_read, n, errsv = errno;
+ 	char tmp[PATH_MAX];
+ 	char buf[4192];
++	mode_t mask;
+ 
+ 	n = snprintf(tmp, PATH_MAX, "%s.tmp", dst);
+ 	if (n < 0 || n >= PATH_MAX)
+@@ -506,13 +507,16 @@ static int semanage_copy_file(const char *src, const char *dst, mode_t mode)
+ 
+ 	if (!mode)
+ 		mode = S_IRUSR | S_IWUSR;
+-
++	
++	mask = umask(0);
+ 	if ((out = open(tmp, O_WRONLY | O_CREAT | O_TRUNC, mode)) == -1) {
++		umask(mask);
+ 		errsv = errno;
+ 		close(in);
+ 		retval = -1;
+ 		goto out;
+ 	}
++	umask(mask);
+ 	while (retval == 0 && (amount_read = read(in, buf, sizeof(buf))) > 0) {
+ 		if (write(out, buf, amount_read) < 0) {
+ 			errsv = errno;
diff --git a/libsemanage.spec b/libsemanage.spec
index a428dbf..a2e3a78 100644
--- a/libsemanage.spec
+++ b/libsemanage.spec
@@ -10,7 +10,7 @@
 Summary: SELinux binary policy manipulation library 
 Name: libsemanage
 Version: 2.1.4
-Release: 2%{?dist}
+Release: 3%{?dist}
 License: LGPLv2+
 Group: System Environment/Libraries
 Source: libsemanage-%{version}.tgz
@@ -180,6 +180,9 @@ rm -rf ${RPM_BUILD_ROOT}
 %endif # if with_python3
 
 %changelog
+* Wed Oct 19 2011 Dan Walsh <dwalsh at redhat.com> - 2.1.4-2
+-    Fix handling of umask, so files get created with the correct label.
+
 * Mon Sep 19 2011 Dan Walsh <dwalsh at redhat.com> - 2.1.4-2
 -    Add Guido Trentalancia semanage.conf man page
 


More information about the scm-commits mailing list