SunOS 4.x port

Todd C. Miller Todd.Miller at courtesan.com
Sat May 13 08:38:56 EST 2000


This is based on openssh-2.0.0beta1.  There are a few rough spots:
 1) SunOS doesn't have ut_type in struct utmp so I just whacked
    in the old login() from openssh-1.2.3.
 2) There is a SUNOS4 section added to defines.h -- this could probably
    be a bit cleaner.
 3) sigaction on SunOS is implemented via #defines to sigvec, thus there
    is no SA_RESTART (this is the default behavior).

This also supports SunOS 4.x shadow passwords (passwd adjunct).

 - todd

--- configure.in.DIST	Fri May 12 15:50:24 2000
+++ configure.in	Fri May 12 16:08:22 2000
@@ -107,6 +107,10 @@
 	need_dash_r=1
 	AC_DEFINE(USE_UTMPX)
 	;;
+*-*-sunos4*)
+	CFLAGS="$CFLAGS -DSUNOS4"
+	AC_CHECK_FUNCS(getpwanam)
+	;;
 *-*-sysv*)
 	CFLAGS="$CFLAGS -I/usr/local/include"
 	LDFLAGS="$LDFLAGS -L/usr/local/lib"
@@ -353,17 +357,6 @@
 	[size_t foo; foo = 1235;],
 	[
 		AC_DEFINE(HAVE_SIZE_T)
-		AC_MSG_RESULT(yes)
-	],
-	[AC_MSG_RESULT(no)]
-)
-
-AC_MSG_CHECKING([for ssize_t])
-AC_TRY_COMPILE(
-	[#include <sys/types.h>],
-	[ssize_t foo; foo = 1235;],
-	[
-		AC_DEFINE(HAVE_SSIZE_T)
 		AC_MSG_RESULT(yes)
 	],
 	[AC_MSG_RESULT(no)]
--- acconfig.h.DIST	Mon May  1 17:56:41 2000
+++ acconfig.h	Fri May 12 16:09:17 2000
@@ -101,6 +101,9 @@
 /* Define if you want have trusted HPUX */
 #undef HAVE_HPUX_TRUSTED_SYSTEM_PW
 
+/* Define if you have getpwanam(3) [SunOS 4.x] */
+#undef HAVE_GETPWANAM
+
 /* Defined if in_systm.h needs to be included with netinet/ip.h (HPUX - <sigh/>) */
 #undef NEED_IN_SYSTM_H
 
@@ -117,6 +120,7 @@
 #undef HAVE_UINTXX_T
 #undef HAVE_SOCKLEN_T
 #undef HAVE_SIZE_T
+#undef HAVE_SSIZE_T
 #undef HAVE_STRUCT_SOCKADDR_STORAGE
 #undef HAVE_STRUCT_ADDRINFO
 #undef HAVE_STRUCT_IN6_ADDR
--- defines.h.DIST	Mon May  1 08:03:56 2000
+++ defines.h	Fri May 12 15:54:59 2000
@@ -150,6 +150,11 @@
 # define HAVE_SIZE_T
 #endif /* HAVE_SIZE_T */
 
+#ifndef HAVE_SSIZE_T
+typedef int ssize_t;
+# define HAVE_SSIZE_T
+#endif /* HAVE_SSIZE_T */
+
 #if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS)
 # define ss_family __ss_family
 #endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */
@@ -279,5 +284,10 @@
 #if defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO)
 # undef HAVE_GETADDRINFO
 #endif /* defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO) */
+
+#ifdef SUNOS4
+# define atexit	on_exit
+# define WCOREDUMP(x)	(((union __wait*)&(x))->__w_coredump)
+#endif
 
 #endif /* _DEFINES_H */
--- auth-passwd.c.DIST	Sat Apr 29 08:47:29 2000
+++ auth-passwd.c	Fri May 12 16:07:36 2000
@@ -28,6 +28,11 @@
 #ifdef HAVE_SHADOW_H
 # include <shadow.h>
 #endif
+#ifdef HAVE_GETPWANAM
+# include <sys/label.h>
+# include <sys/audit.h>
+# include <pwdadj.h>
+#endif
 #if defined(HAVE_MD5_PASSWORDS) && !defined(HAVE_MD5_CRYPT)
 # include "md5crypt.h"
 #endif /* defined(HAVE_MD5_PASSWORDS) && !defined(HAVE_MD5_CRYPT) */
@@ -46,6 +51,9 @@
 #ifdef HAVE_SHADOW_H
 	struct spwd *spw;
 #endif
+#ifdef HAVE_GETPWANAM
+	struct passwd_adjunct *spw;
+#endif
 #ifdef WITH_AIXAUTHENTICATE
 	char *authmsg;
 	char *loginmsg;
@@ -99,6 +107,16 @@
 		pw_password = spw->sp_pwdp;
 	}
 #endif /* defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW) */
+#if defined(HAVE_GETPWANAM) && !defined(DISABLE_SHADOW)
+	if (issecure() && (spw = getpwanam(pw->pw_name)) != NULL)
+	{
+		/* Check for users with no password. */
+		if (strcmp(password, "") == 0 && strcmp(spw->pwa_passwd, "") == 0)
+			return 1;
+
+		pw_password = spw->pwa_passwd;
+	}
+#endif /* defined(HAVE_GETPWANAM) && !defined(DISABLE_SHADOW) */
 
 	if (pw_password[0] != '\0')
 		salt = pw_password;
--- bsd-login.c.DIST	Mon May  1 06:53:53 2000
+++ bsd-login.c	Fri May  5 12:30:48 2000
@@ -60,6 +60,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#ifdef USER_PROCESS
 /*
  * find first matching slot in utmp, or "-1" for none
  *
@@ -93,6 +94,13 @@
 	endutent();
 	return(-1);
 }
+#else
+int find_tty_slot( utp )
+struct utmp * utp;
+{
+	return(ttyslot());
+}
+#endif
 
 #if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
 void
@@ -127,13 +135,16 @@
 	} else {
 		/* If no tty was found... */
 		if (tty == -1) {
+#ifdef USER_PROCESS
 			/* ... append it to utmp on login */
 			if (utp->ut_type == USER_PROCESS) {
 				if ((fd = open(_PATH_UTMP, O_WRONLY|O_APPEND, 0)) >= 0) {
 					(void)write(fd, utp, sizeof(struct utmp));
 					(void)close(fd);
 				}
-			} else {
+			} else
+#endif
+			{
 				/* Shouldn't get to here unless somthing happened to utmp */
 				/* Between login and logout */
 				log("No tty slot found at logout");
--- packet.c.DIST	Fri May  5 11:55:05 2000
+++ packet.c	Fri May  5 11:56:42 2000
@@ -1233,21 +1233,24 @@
 		 * IPTOS_LOWDELAY and TCP_NODELAY.
 		 */
 		int lowdelay = IPTOS_LOWDELAY;
+#ifdef IP_TOS
 		if (setsockopt(connection_in, IPPROTO_IP, IP_TOS, (void *) &lowdelay,
 		    sizeof(lowdelay)) < 0)
 			error("setsockopt IPTOS_LOWDELAY: %.100s", strerror(errno));
+#endif
 		if (setsockopt(connection_in, IPPROTO_TCP, TCP_NODELAY, (void *) &on,
 		    sizeof(on)) < 0)
 			error("setsockopt TCP_NODELAY: %.100s", strerror(errno));
+#ifdef IP_TOS
 	} else {
 		/*
 		 * Set IP options for a non-interactive connection.  Use
 		 * IPTOS_THROUGHPUT.
 		 */
-		int throughput = IPTOS_THROUGHPUT;
 		if (setsockopt(connection_in, IPPROTO_IP, IP_TOS, (void *) &throughput,
 		    sizeof(throughput)) < 0)
 			error("setsockopt IPTOS_THROUGHPUT: %.100s", strerror(errno));
+#endif
 	}
 }
 
--- scp.c.DIST	Mon May  1 05:10:33 2000
+++ scp.c	Fri May  5 12:19:25 2000
@@ -1235,7 +1235,9 @@
 		struct sigaction sa;
 		sa.sa_handler = updateprogressmeter;
 		sigemptyset(&sa.sa_mask);
+#ifdef SA_RESTART
 		sa.sa_flags = SA_RESTART;
+#endif
 		sigaction(SIGALRM, &sa, NULL);
 		alarmtimer(1);
 	} else if (flag == 1) {
--- ssh-agent.c.DIST	Mon May  1 04:59:51 2000
+++ ssh-agent.c	Fri May  5 12:22:05 2000
@@ -507,6 +507,7 @@
 	struct sockaddr_un sunaddr;
 	pid_t pid;
 	char *shell, *format, *pidstr, pidstrbuf[1 + 3 * sizeof pid];
+	extern int optind;
 
 	/* check if RSA support exists */
 	if (rsa_alive() == 0) {





More information about the openssh-unix-dev mailing list