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

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