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

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