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

This commit is contained in:
Dan Walsh 2011-10-20 15:03:03 -04:00
parent f7a6a5065b
commit 86ba998b25
2 changed files with 34 additions and 1 deletions

View File

@ -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;

View File

@ -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@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@redhat.com> - 2.1.4-2
- Add Guido Trentalancia semanage.conf man page