File netkit-rsh-0.17-fork_before_exec.patch of Package rsh

Index: rshd/rshd.c
===================================================================
--- rshd/rshd.c.orig	2012-10-17 16:01:13.093594194 +0200
+++ rshd/rshd.c	2012-10-17 16:01:40.036397082 +0200
@@ -482,7 +482,28 @@ doit(struct sockaddr *fromp)
 		close(pv[0]);
 		dup2(pv[1], 2);
 		close(pv[1]);
+	} else {
+		pid = fork();
+		if (pid == -1)  {
+			error("Can't fork; try again.\n");
+			exit(1);
+		}
+		if (pid) {
+			close(0);
+			close(1);
+			close(2);
+			int status;
+			wait(&status);
+#ifdef USE_PAM
+			pam_close_session(pamh, 0);
+			pam_end(pamh, PAM_SUCCESS);
+#endif
+    			exit(0);
+			/* NOTREACHED */
+		}
+		setpgrp();
 	}
+
 	theshell = pwd->pw_shell;
 	if (!theshell || !*theshell) {
 	    /* shouldn't we deny access? */
openSUSE Build Service is sponsored by