kentpeacock / rpms / openssh

Forked from rpms/openssh 2 years ago
Clone
Blob Blame History Raw
Index: b/session.c
===================================================================
--- b.orig/session.c
+++ b/session.c
@@ -2049,6 +2049,8 @@ session_pty_req(struct ssh *ssh, Session
 		return 0;
 	}
 	debug("session_pty_req: session %d alloc %s", s->self, s->tty);
+	verbose("Allocated pty %s for user %s session %d",
+					s->tty, s->pw->pw_name, s->self);
 
 	ssh_tty_parse_modes(ssh, s->ttyfd);
 
@@ -2148,6 +2150,7 @@ session_shell_req(struct ssh *ssh, Sessi
 
 	if ((r = sshpkt_get_end(ssh)) != 0)
 		sshpkt_fatal(ssh, r, "%s: parse packet", __func__);
+	verbose("Shell Request for user %s", s->pw->pw_name);
 	return do_exec(ssh, s, NULL) == 0;
 }
 
@@ -2163,6 +2166,7 @@ session_exec_req(struct ssh *ssh, Sessio
 		sshpkt_fatal(ssh, r, "%s: parse packet", __func__);
 
 	slog_set_command(command);
+	verbose("Exec Request for user %s with command %s", s->pw->pw_name, command);
 	success = do_exec(ssh, s, command) == 0;
 	free(command);
 	return success;
Index: b/regress/session-req.sh
===================================================================
--- /dev/null
+++ b/regress/session-req.sh
@@ -0,0 +1,39 @@
+tid="session req"
+
+start_sshd
+
+test_user_shell_exec_req() {
+  session_shell_req_expected="Exec Request for user $USER with command true"
+  cnt=$(grep -c "$session_shell_req_expected" "$TEST_SSHD_LOGFILE")
+  if [ $cnt == "0" ]; then
+  	fail "No exec request for user log lines found"
+  fi
+}
+
+test_user_pty() {
+  session_pty_req_expected="Allocated pty .* for user $USER session .*"
+  line_count=$(grep -c "$session_req_expected" "$TEST_SSHD_LOGFILE")
+  if [ $line_count == "0" ]; then
+  	fail "No Allocated pty for user session found in log lines"
+  fi
+}
+
+test_user_shell_req() {
+  exit | ${SSH} -F $OBJ/ssh_config somehost
+  if [ $? -ne 0 ]; then
+  	fail "ssh connect with failed"
+  fi
+  session_shell_req_expected="Shell Request for user $USER"
+  line_count=$(grep -c "$session_shell_req_expected" "$TEST_SSHD_LOGFILE")
+  if [ $line_count == "0" ]; then
+  	fail "No session request for user log lines found"
+  fi
+}
+
+${SSH} -F $OBJ/ssh_config somehost true
+if [ $? -ne 0 ]; then
+	fail "ssh connect with failed"
+fi
+test_user_shell_exec_req
+test_user_pty
+test_user_shell_req