changeset 5018:9d2303147d54

6598158 ssh compatibility flag SSH_BUG_DFLT_CLNT_EXIT_0 wasn't a good idea 6598255 sshd may print bogus error messages in lastlog_get_entry()
author jp161948
date Mon, 10 Sep 2007 12:53:43 -0700
parents 3e669302a3e8
children cfc9eff7091a
files usr/src/cmd/ssh/include/compat.h usr/src/cmd/ssh/libssh/common/compat.c usr/src/cmd/ssh/ssh/clientloop.c usr/src/cmd/ssh/sshd/loginrec.c
diffstat 4 files changed, 24 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/ssh/include/compat.h	Mon Sep 10 08:13:47 2007 -0700
+++ b/usr/src/cmd/ssh/include/compat.h	Mon Sep 10 12:53:43 2007 -0700
@@ -34,7 +34,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 /*
- * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -71,7 +71,6 @@
 #define SSH_BUG_GSSAPI_BER	0x04000000
 #define SSH_BUG_FIRSTKEX	0x08000000
 
-#define SSH_BUG_DFLT_CLNT_EXIT_0	0x10000000
 #define SSH_BUG_GSSKEX_HOSTKEY	0x20000000
 
 void     enable_compat13(void);
--- a/usr/src/cmd/ssh/libssh/common/compat.c	Mon Sep 10 08:13:47 2007 -0700
+++ b/usr/src/cmd/ssh/libssh/common/compat.c	Mon Sep 10 12:53:43 2007 -0700
@@ -22,7 +22,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 /*
- * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -101,10 +101,8 @@
 		  "OpenSSH_3.8*",       SSH_BUG_GSSKEX_HOSTKEY},
 		{ "OpenSSH*",		0 },
 		{ "Sun_SSH_1.0.*",	SSH_BUG_NOREKEY|
-					SSH_BUG_DFLT_CLNT_EXIT_0|
 					SSH_BUG_LOCALES_NOT_LANGTAGS},
 		{ "Sun_SSH_1.0*",	SSH_BUG_NOREKEY|SSH_BUG_EXTEOF|
-					SSH_BUG_DFLT_CLNT_EXIT_0|
 					SSH_BUG_LOCALES_NOT_LANGTAGS},
 		{ "*MindTerm*",		0 },
 		{ "2.1.0*",		SSH_BUG_SIGBLOB|SSH_BUG_HMAC|
--- a/usr/src/cmd/ssh/ssh/clientloop.c	Mon Sep 10 08:13:47 2007 -0700
+++ b/usr/src/cmd/ssh/ssh/clientloop.c	Mon Sep 10 12:53:43 2007 -0700
@@ -1029,8 +1029,6 @@
 	escape_pending = 0;
 	last_was_cr = 1;
 	exit_status = -1;
-	if (datafellows & SSH_BUG_DFLT_CLNT_EXIT_0)
-		exit_status = 0;
 	stdin_eof = 0;
 	buffer_high = 64 * 1024;
 	connection_in = packet_get_connection_in();
--- a/usr/src/cmd/ssh/sshd/loginrec.c	Mon Sep 10 08:13:47 2007 -0700
+++ b/usr/src/cmd/ssh/sshd/loginrec.c	Mon Sep 10 12:53:43 2007 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 /*
@@ -1526,22 +1526,32 @@
 lastlog_get_entry(struct logininfo *li)
 {
 	struct lastlog last;
-	int fd;
+	int fd, ret;
 
 	if (!lastlog_openseek(li, &fd, O_RDONLY))
-		return 0;
+		return (0);
+
+	ret = atomicio(read, fd, &last, sizeof(last));
+	close(fd);
 
-	if (atomicio(read, fd, &last, sizeof(last)) != sizeof(last)) {
-		(void) close(fd);
-		log("lastlog_get_entry: Error reading from %s: %s",
+	switch (ret) {
+	case 0:
+		memset(&last, '\0', sizeof(last));
+		/* FALLTHRU */
+	case sizeof(last):
+		lastlog_populate_entry(li, &last);
+		return (1);
+	case -1:
+		error("%s: Error reading from %s: %s", __func__,
 		    LASTLOG_FILE, strerror(errno));
-		return 0;
+		return (0);
+	default:
+		error("%s: Error reading from %s: Expecting %d, got %d",
+		    __func__, LASTLOG_FILE, (int)sizeof(last), ret);
+		return (0);
 	}
 
-	(void) close(fd);
-
-	lastlog_populate_entry(li, &last);
-
-	return 1;
+	/* NOTREACHED */
+	return (0);
 }
 #endif /* USE_LASTLOG */