Blame SOURCES/rhnsd-5.0.13-7-el7-to-rhnsd-5.0.13-8-el7.patch

cc76d3
diff --git a/rhnsd.c b/rhnsd.c
630c23
index ad2100d..896b433 100644
cc76d3
--- a/rhnsd.c
cc76d3
+++ b/rhnsd.c
630c23
@@ -176,7 +176,6 @@ int main (int argc, char **argv)
630c23
 
630c23
         if (setsid() < 0)
630c23
             exit(EXIT_FAILURE);
630c23
-	umask(0);
630c23
 
630c23
 	chdir ("/");
630c23
 
630c23
@@ -310,8 +309,12 @@ static int write_pid (const char *file)
cc76d3
     FILE *fp;
cc76d3
 
cc76d3
     fp = fopen (file, "w");
cc76d3
-    if (fp == NULL)
cc76d3
-	return -1;
cc76d3
+    if (fp == NULL) {
cc76d3
+        return -1;
cc76d3
+    } else if (chmod (file, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) != 0) {
cc76d3
+        fclose(fp);
cc76d3
+        return -1;
cc76d3
+    }
cc76d3
 
cc76d3
     fprintf (fp, "%d\n", getpid ());
cc76d3
     if (fflush (fp) || ferror (fp)) {
630c23
@@ -397,6 +400,10 @@ static int rhn_do_action(void)
630c23
 
630c23
 	/* close the read end of the pipe */
630c23
 	close(fds[0]);
630c23
+
630c23
+	/* close syslog file descriptor */
630c23
+	closelog();
630c23
+
630c23
 	/* redirect stdout */
630c23
 	if (fds[1] != STDOUT_FILENO) {
630c23
 	    dup2(fds[1], STDOUT_FILENO);
630c23
@@ -406,6 +413,9 @@ static int rhn_do_action(void)
630c23
 	/* make sure this child has a stderr */
630c23
 	dup2(STDOUT_FILENO, STDERR_FILENO);
630c23
 
630c23
+	/* open a new syslog connection for the child */
630c23
+	openlog("rhnsd", LOG_CONS | LOG_ODELAY | LOG_PID, LOG_DAEMON);
630c23
+
630c23
 	/* syslog for safekeeping */
630c23
 	syslog(LOG_NOTICE, "running program %s with PID %d", RHN_CHECK, getpid());
630c23
 
cc76d3
diff --git a/rhnsd.spec b/rhnsd.spec
630c23
index 333a555..42ad138 100644
cc76d3
--- a/rhnsd.spec
cc76d3
+++ b/rhnsd.spec
cc76d3
@@ -5,7 +5,7 @@ Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.
cc76d3
 URL:     https://fedorahosted.org/spacewalk
cc76d3
 Name: rhnsd
cc76d3
 Version: 5.0.13
cc76d3
-Release: 7%{?dist}
630c23
+Release: 8%{?dist}
cc76d3
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
cc76d3
 
cc76d3
 BuildRequires: gettext
630c23
@@ -138,6 +138,13 @@ rm -fr $RPM_BUILD_ROOT
cc76d3
 %doc LICENSE
cc76d3
 
cc76d3
 %changelog
630c23
+* Wed Sep 20 2017 Tomas Kasparek <tkasparek@redhat.com> 5.0.13-8
630c23
+- Resolves: #1480306 - change permissions for rhnsd.pid (grinrag@gmail.com)
630c23
+- Resolves: #1489989 - umask(0) does not reset to default umask
630c23
+  (tkasparek@redhat.com)
630c23
+- Resolves: #1475039 - close and reopen syslog when redirecting child output
630c23
+  (martin.matuska@axelspringer.de)
cc76d3
+
cc76d3
 * Mon Mar 06 2017 Gennadii Altukhov <galt@redhat.com> 5.0.13-7
cc76d3
 - Resolves: #1409562 - fix BZ IDs in spec file (galt@redhat.com)
cc76d3