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

b0d085
diff --git a/rhnsd.c b/rhnsd.c
b0d085
index 896b433..6190c0a 100644
b0d085
--- a/rhnsd.c
b0d085
+++ b/rhnsd.c
b0d085
@@ -49,9 +49,6 @@ static int write_pid (const char *file);
b0d085
 static void print_version (FILE *stream, struct argp_state *state);
b0d085
 void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
b0d085
 
b0d085
-/* Current rhn_check pid */
b0d085
-pid_t rhn_check_pid;
b0d085
-
b0d085
 /* Definitions of arguments for argp functions.  */
b0d085
 static const struct argp_option options[] =
b0d085
 {
b0d085
@@ -148,34 +145,16 @@ int main (int argc, char **argv)
b0d085
     if (!foreground) {
b0d085
 	int i;
b0d085
 
b0d085
-	    pid_t pid;
b0d085
-        pid = fork();
b0d085
-        if (pid < 0)
b0d085
-	        exit (EXIT_FAILURE);
b0d085
-
b0d085
-        if (pid > 0)
b0d085
-            exit(EXIT_SUCCESS);
b0d085
-
b0d085
+	if (fork ())
b0d085
+	    exit (0);
b0d085
 
b0d085
 	for (i = 0; i < getdtablesize(); i++)
b0d085
 	    close (i);
b0d085
 
b0d085
-	/* read from /dev/null */
b0d085
-	int devnull = open("/dev/null", O_RDONLY);
b0d085
-	if ((devnull >= 0) && (devnull != STDIN_FILENO)) {
b0d085
-	    dup2(devnull, STDIN_FILENO);
b0d085
-	    close(devnull);
b0d085
-	}
b0d085
-
b0d085
-        pid = fork();
b0d085
-        if (pid < 0)
b0d085
-            exit (EXIT_FAILURE);
b0d085
-
b0d085
-        if (pid > 0)
b0d085
-            exit(EXIT_SUCCESS);
b0d085
+	if (fork ())
b0d085
+	    exit (0);
b0d085
 
b0d085
-        if (setsid() < 0)
b0d085
-            exit(EXIT_FAILURE);
b0d085
+	setsid();
b0d085
 
b0d085
 	chdir ("/");
b0d085
 
b0d085
@@ -273,13 +252,11 @@ Written by %s.\n\
b0d085
 static void termination_handler (int signum)
b0d085
 {
b0d085
     syslog(LOG_NOTICE, "Exiting");
b0d085
-    /* Send SIGTERM to current running rhn_check
b0d085
-     * and wait for it to exit. */
b0d085
-    kill(rhn_check_pid, SIGTERM);
b0d085
-    wait(NULL);
b0d085
+
b0d085
     /* Clean up pid file.  */
b0d085
     unlink (_PATH_RHNDPID);
b0d085
-    exit(EXIT_SUCCESS);
b0d085
+
b0d085
+    exit (EXIT_SUCCESS);
b0d085
 }
b0d085
 
b0d085
 /* Returns 1 if the process in pid file FILE is running, 0 if not.  */
b0d085
@@ -417,11 +394,10 @@ static int rhn_do_action(void)
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
+	syslog(LOG_DEBUG, "running program %s", RHN_CHECK);
b0d085
 
b0d085
         unset_signal_handlers ();
b0d085
         /* exec binary helper */
b0d085
-        rhn_check_pid = getpid();
b0d085
         args[0] = RHN_CHECK;
b0d085
         execv(RHN_CHECK, args);
b0d085
 
b0d085
@@ -431,7 +407,6 @@ static int rhn_do_action(void)
b0d085
                strerror(errno));
b0d085
         exit(errno);
b0d085
     } else if (child > 0) {
b0d085
-        set_signal_handlers();
b0d085
 	int ret = 1;
b0d085
 	char *buf, buffer[10];
b0d085
 	int bufsize = 0;
b0d085
diff --git a/rhnsd.init b/rhnsd.init
b0d085
index dead8bf..ee3e811 100644
b0d085
--- a/rhnsd.init
b0d085
+++ b/rhnsd.init
b0d085
@@ -53,7 +53,7 @@ start() {
b0d085
 
b0d085
 stop() {
b0d085
     echo -n $"Stopping Spacewalk Daemon: "
b0d085
-    killproc rhnsd -TERM
b0d085
+    killproc rhnsd
b0d085
     RETVAL=$?
b0d085
     echo
b0d085
     if [ $RETVAL -eq 0 ]; then
b0d085
diff --git a/rhnsd.spec b/rhnsd.spec
b0d085
index 42ad138..2a192f6 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: 8%{?dist}
b0d085
+Release: 9%{?dist}
b0d085
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
b0d085
 
b0d085
 BuildRequires: gettext
b0d085
@@ -138,6 +138,12 @@ rm -fr $RPM_BUILD_ROOT
b0d085
 %doc LICENSE
b0d085
 
b0d085
 %changelog
b0d085
+* Mon Oct 09 2017 Tomas Kasparek <tkasparek@redhat.com> 5.0.13-9
b0d085
+- Related: #1499793 - revert previous reboot loop changes
b0d085
+  (tkasparek@redhat.com)
b0d085
+- Resolves: #1499793 - Revert "1260527 RHEL7 rhnsd reload doesn't work"
b0d085
+  (tkasparek@redhat.com)
b0d085
+
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