diff -ur ../logdaemon-5.12/Makefile logdaemon-5.12.kjm/Makefile
--- ../logdaemon-5.12/Makefile	Wed Jan  5 01:23:03 2000
+++ logdaemon-5.12.kjm/Makefile	Fri Jul 27 13:50:33 2001
@@ -1,5 +1,5 @@
 SHELL	= /bin/sh
-MAKE	= make
+MAKE	= env LANG=C make
 LIST1	= ftpd login rexecd
 LIST2	= rlogind rshd telnetd
 LIST3	= keysu skeysh
@@ -16,12 +16,12 @@
 	@echo "	hpux10		HP-UX 10.x       (no rshd/rlogind/telnetd)"
 	@echo "	irix5		IRIX 5.x         (no rshd/rlogind/telnetd)"
 	@echo "	decosf1		DIGITAL UNIX"
-	@echo "	newsos4		Sony NEWS/OS 4.x (no rshd/rlogind/telnetd)"
-	@echo "	linux		Linux (some version)"
-	@echo ""
+	@echo "	newsos4		Sony NEWS/OS 4.x"
+	@echo "	newsos6		Sony NEWS/OS 6.x"
+	@echo " linux           Linux (some version)"
 	@exit 1;
 
-sunos4 sunos5 ultrix4 freebsd bsdi decosf1 linux:
+sunos4 sunos5 ultrix4 freebsd bsdi decosf1 linux newsos4 newsos6:
 	for i in $(LIST1); \
 	do \
 		(set -e; cd $$i; $(MAKE) $@-skey MAKELEVEL=) || exit 1; \
@@ -31,7 +31,7 @@
 		(set -e; cd $$i; $(MAKE) $@ MAKELEVEL=) || exit 1; \
 	done
 
-hpux9 hpux10 newsos4 irix5:
+hpux9 hpux10 irix5:
 	for i in $(LIST1); \
 	do \
 		(set -e; cd $$i; $(MAKE) $@-skey MAKELEVEL=) || exit 1; \
Only in logdaemon-5.12.kjm/: foo.awk
diff -ur ../logdaemon-5.12/ftpd/Makefile logdaemon-5.12.kjm/ftpd/Makefile
--- ../logdaemon-5.12/ftpd/Makefile	Wed Jan  5 01:23:03 2000
+++ logdaemon-5.12.kjm/ftpd/Makefile	Tue Dec  5 13:12:35 2000
@@ -114,6 +114,15 @@
 	    XFLAGS="-DSYSV4 -DSUNOS5 $(SKEYDEFS)" XLIBS="$(SKEYLIBS)" \
 	    SYSLIBS="-lsocket -lnsl"
 
+newsos6:
+	@$(MAKE) all SYS=newsos6 WTMP=sysv4wtmp \
+	    XFLAGS="-DSYSV4 -DNEWSOS6" SYSLIBS="-lsocket -lnsl"
+
+newsos6-skey:
+	@$(MAKE) all-skey SYS=newsos6 WTMP=sysv4wtmp XOBJ="skey-stuff.o" \
+	    XFLAGS="-DSYSV4 -DNEWSOS6 $(SKEYDEFS)" XLIBS="$(SKEYLIBS)" \
+	    SYSLIBS="-lsocket -lnsl"
+
 sunos5-snk:
 	@make all-snk SYS=sunos5 WTMP=sysv4wtmp OPTIM="-xO4" \
 	    XFLAGS="-DSYSV4 -DSUNOS5 $(SNKDEFS)" XLIBS="$(SNKLIBS)" \
diff -ur ../logdaemon-5.12/ftpd/ftpd.c logdaemon-5.12.kjm/ftpd/ftpd.c
--- ../logdaemon-5.12/ftpd/ftpd.c	Wed Jan  5 22:08:09 2000
+++ logdaemon-5.12.kjm/ftpd/ftpd.c	Thu Jul 26 20:20:56 2001
@@ -545,7 +545,7 @@
 	(void) initgroups(pw->pw_name, pw->pw_gid);
 
 	/* open wtmp before chroot */
-	(void)sprintf(ttyline, "ftp%d", getpid());
+	(void) snprintf(ttyline, sizeof(ttyline), "ftp%d", getpid());
 	logwtmp(ttyline, pw->pw_name, remotehost);
 	logged_in = 1;
 #ifdef STATS
@@ -618,7 +618,7 @@
 		ident = copy(passwd);
 #endif
 #ifdef SETPROCTITLE
-		sprintf(proctitle, "%.100s: anonymous/%.*s", remotehost,
+		snprintf(proctitle, sizeof(proctitle), "%.100s: anonymous/%.*s", remotehost,
 		    sizeof(proctitle) - sizeof(remotehost) -
 		    sizeof(": anonymous/"), passwd);
 		setproctitle(proctitle);
@@ -626,7 +626,7 @@
 	} else {
 		reply(230, "User %s logged in.", pw->pw_name);
 #ifdef SETPROCTITLE
-		sprintf(proctitle, "%.100s: %s", remotehost, pw->pw_name);
+		snprintf(proctitle, sizeof(proctitle), "%.100s: %s", remotehost, pw->pw_name);
 		setproctitle(proctitle);
 #endif /* SETPROCTITLE */
 	}
@@ -656,7 +656,7 @@
 	} else {
 		char line[BUFSIZ];
 
-		(void) sprintf(line, cmd, name), name = line;
+		(void) snprintf(line, sizeof(line), cmd, name), name = line;
 		fin = ftpd_popen(line, "r"), closefunc = ftpd_pclose;
 		st.st_size = -1;
 		st.st_blksize = BUFSIZ;
@@ -774,7 +774,7 @@
 	file_size = size;
 	byte_count = 0;
 	if (size != (off_t) -1)
-		(void) sprintf (sizebuf, " (%ld bytes)", size);
+		(void) snprintf (sizebuf, sizeof(sizebuf), " (%ld bytes)", size);
 	else
 		(void) strcpy(sizebuf, "");
 	if (pdata >= 0) {
@@ -1002,7 +1002,7 @@
 	FILE *fin;
 	int c;
 
-	(void) sprintf(line, "/bin/ls -lgA %s", filename);
+	(void) snprintf(line, sizeof(line), "/bin/ls -lgA %s", filename);
 	fin = ftpd_popen(line, "r");
 	lreply(211, "status of %s:", filename);
 	while ((c = getc(fin)) != EOF) {
@@ -1262,7 +1262,7 @@
 		    sizeof (remotehost));
 	remotehost[sizeof(remotehost) - 1] = 0;
 #ifdef SETPROCTITLE
-	sprintf(proctitle, "%.100s: connected", remotehost);
+	snprintf(proctitle, sizeof(proctitle), "%.100s: connected", remotehost);
 	setproctitle(proctitle);
 #endif /* SETPROCTITLE */
 }
@@ -1392,11 +1392,11 @@
 	}
 	if (cp)
 		*cp = '/';
-	(void) strcpy(new, local);
+	snprintf(new, sizeof(new), "%s", local);
 	cp = new + strlen(new);
 	*cp++ = '.';
 	for (count = 1; count < 100; count++) {
-		(void) sprintf(cp, "%d", count);
+		(void) snprintf(cp, sizeof(new) - (cp - new), "%d", count);
 		if (stat(new, &st) < 0)
 			return(new);
 	}
@@ -1500,7 +1500,7 @@
 			    dir->d_reclen == 2)
 				continue;
 
-			sprintf(nbuf, "%s/%s", dirname, dir->d_name);
+			snprintf(nbuf, sizeof(nbuf), "%s/%s", dirname, dir->d_name);
 
 				if (dout == NULL) {
 					dout = dataconn(whichfiles, (off_t)-1,
@@ -1551,7 +1551,7 @@
 	register int i;
 	char buf[BUFSIZ];
 
-	(void) sprintf(buf, fmt, a, b, c);
+	(void) snprintf(buf, sizeof(buf), fmt, a, b, c);
 
 	/* make ps print our process name */
 	p = Argv[0];
Only in logdaemon-5.12.kjm/ftpd: ftpd.c.20010719
diff -ur ../logdaemon-5.12/ftpd/skey-stuff.c logdaemon-5.12.kjm/ftpd/skey-stuff.c
--- ../logdaemon-5.12/ftpd/skey-stuff.c	Tue Aug 31 03:04:56 1999
+++ logdaemon-5.12.kjm/ftpd/skey-stuff.c	Thu Jul 19 20:10:53 2001
@@ -18,7 +18,7 @@
     /* Display s/key challenge where appropriate. */
 
     if (pwd == 0 || skeyinfo(&skey, pwd->pw_name, buf) != 0)
-	sprintf(buf, "%s required for %s.",
+	snprintf(buf, sizeof(buf), "%s required for %s.",
 		pwok ? "Password" : "S/Key password", name);
     return (buf);
 }
diff -ur ../logdaemon-5.12/ftpd/vers.c logdaemon-5.12.kjm/ftpd/vers.c
--- ../logdaemon-5.12/ftpd/vers.c	Tue Apr 17 04:01:45 2001
+++ logdaemon-5.12.kjm/ftpd/vers.c	Fri Jul 27 13:51:09 2001
@@ -1 +1 @@
-char version[] = "Version 4.137 Mon Apr 16 15:01:45 EDT 2001";
+char version[] = "Version 4.141 Fri Jul 27 13:51:09 JST 2001";
diff -ur ../logdaemon-5.12/ftpd/version logdaemon-5.12.kjm/ftpd/version
--- ../logdaemon-5.12/ftpd/version	Tue Apr 17 04:01:45 2001
+++ logdaemon-5.12.kjm/ftpd/version	Fri Jul 27 13:51:09 2001
@@ -1 +1 @@
-137
+141
Only in logdaemon-5.12.kjm/: install
Only in logdaemon-5.12.kjm/: install.sh
diff -ur ../logdaemon-5.12/keysu/Makefile logdaemon-5.12.kjm/keysu/Makefile
--- ../logdaemon-5.12/keysu/Makefile	Wed Jan  5 01:23:03 2000
+++ logdaemon-5.12.kjm/keysu/Makefile	Tue Dec  5 13:12:36 2000
@@ -37,6 +37,9 @@
 sunos5:
 	@$(MAKE) all SYS=$@ XFLAGS="-DSYSV4 -DSUNOS5 -Dsun"
 
+newsos6:
+	@$(MAKE) all SYS=$@ XFLAGS="-DSYSV4 -DNEWSOS6 -Dsun"
+
 irix5:
 	@$(MAKE) all SYS=$@ XFLAGS="-DIRIX5 -DSYSV4"
 
diff -ur ../logdaemon-5.12/keysu/keysu.c logdaemon-5.12.kjm/keysu/keysu.c
--- ../logdaemon-5.12/keysu/keysu.c	Tue Aug 31 07:10:20 1999
+++ logdaemon-5.12.kjm/keysu/keysu.c	Fri Jul 27 14:05:42 2001
@@ -369,10 +369,12 @@
 
 	buf[0] = 0;
 	if (p = ttyname(STDERR_FILENO))
-		sprintf(buf, " on %s", p);
+		snprintf(buf, sizeof(buf), " on %s", p);
 	if (p = utmp_host()) {
-		strcat(buf, " from ");
-		strncat(buf, p, 100);
+		if (sizeof(buf) - (strlen(buf) + 100 + 6) > 0) {
+		    strcat(buf, " from ");
+		    strncat(buf, p, 100);
+		}
 	}
 	return (buf);
 }
@@ -399,7 +401,7 @@
 		(void)fprintf(stderr, "kerberos su: not in %s's ACL.\n", user);
 		return (1);
 	}
-	(void)sprintf(krbtkfile, "%s_%s_%d", TKT_ROOT, user, getuid());
+	(void)snprintf(krbtkfile, sizeof(krbtkfile), "%s_%s_%d", TKT_ROOT, user, getuid());
 
 	(void)setenv("KRBTKFILE", krbtkfile, 1);
 	(void)krb_set_tkt_string(krbtkfile);
diff -ur ../logdaemon-5.12/lib/Makefile logdaemon-5.12.kjm/lib/Makefile
--- ../logdaemon-5.12/lib/Makefile	Wed Jan  5 01:23:03 2000
+++ logdaemon-5.12.kjm/lib/Makefile	Tue Dec  5 13:12:36 2000
@@ -34,6 +34,11 @@
 	@$(MAKE) XFLAGS=-DSYSV4 OBJS="$(S5R4OBJ) setenv.o getusershell.o" \
 	    RANLIB=echo all
 
+newsos6:
+	@$(MAKE) XFLAGS="-DSYSV4 -DNEWSOS6" \
+	    OBJS="$(S5R4OBJ) setenv.o getusershell.o" \
+	    RANLIB=echo all
+
 sunos5:
 	@$(MAKE) XFLAGS="-DSYSV4 -DSUNOS5" \
 	    OBJS="$(S5R4OBJ) setenv.o getusershell.o" \
diff -ur ../logdaemon-5.12/lib/rcmd.c logdaemon-5.12.kjm/lib/rcmd.c
--- ../logdaemon-5.12/lib/rcmd.c	Tue Aug 31 04:15:21 1999
+++ logdaemon-5.12.kjm/lib/rcmd.c	Wed Jul 25 17:57:43 2001
@@ -156,7 +156,7 @@
 		if (s2 < 0)
 			goto bad;
 		listen(s2, 1);
-		(void) sprintf(num, "%d", lport);
+		(void) snprintf(num, sizeof(num), "%d", lport);
 		if (write(s, num, strlen(num)+1) != strlen(num)+1) {
 			perror("write: setting up stderr");
 			(void) close(s2);
diff -ur ../logdaemon-5.12/lib/sys_defs.h logdaemon-5.12.kjm/lib/sys_defs.h
--- ../logdaemon-5.12/lib/sys_defs.h	Wed Jan  5 01:23:03 2000
+++ logdaemon-5.12.kjm/lib/sys_defs.h	Fri Jul 27 14:49:22 2001
@@ -61,6 +61,10 @@
 #undef NO_WHEEL_GROUP			/* XXX yes but... */
 #endif
 
+#ifdef NEWSOS6
+#undef NO_WHEEL_GROUP			/* XXX yes but... */
+#endif
+
 #ifdef ULTRIX4
 #define NIS				/* yellow pages */
 #define INT_GROUPS			/* set/getgroups() take int array */
@@ -192,3 +196,4 @@
 #else
 #define ARGS_(x)	()
 #endif
+
diff -ur ../logdaemon-5.12/login/Makefile logdaemon-5.12.kjm/login/Makefile
--- ../logdaemon-5.12/login/Makefile	Wed Jan  5 01:23:03 2000
+++ logdaemon-5.12.kjm/login/Makefile	Tue Dec  5 13:12:37 2000
@@ -88,6 +88,17 @@
 	    XOBJS="$(DES_OBJ)" \
 	    XLIBS="$(SNKLIBS)" SYSLIBS="-lrpcsvc"
 
+newsos6:
+	@$(MAKE) all SYS=newsos6 XFLAGS="-DSYSV4 -DNEWSOS6" \
+	    XOBJS="$(DES_OBJ) $(SVOBJS)" RANLIB=echo \
+	    SYSLIBS="-lrpcsvc -lsocket -lnsl"
+
+newsos6-skey:
+	@$(MAKE) all-skey SYS=newsos6 XFLAGS="-DSYSV4 -DNEWSOS6 $(SKEYDEFS)" \
+	    XOBJS="$(DES_OBJ) $(SVOBJS)" \
+	    RANLIB=echo XLIBS="$(SKEYLIBS)" \
+	    SYSLIBS="-lrpcsvc -lsocket -lnsl"
+
 sunos5:
 	@$(MAKE) all SYS=sunos5 XFLAGS="-DSYSV4 -DSUNOS5" \
 	    XOBJS="$(DES_OBJ) $(SVOBJS)" RANLIB=echo \
diff -ur ../logdaemon-5.12/login/login.c logdaemon-5.12.kjm/login/login.c
--- ../logdaemon-5.12/login/login.c	Tue Aug 31 03:44:57 1999
+++ logdaemon-5.12.kjm/login/login.c	Fri Jul 27 14:22:45 2001
@@ -424,9 +424,9 @@
 	/* Fill in wherefrom if it hasn't been done yet */
 	if (wherefrom[0] == '\0') {
 		if (hostname)
-			sprintf(wherefrom, "from %.100s", hostname);
+			snprintf(wherefrom, sizeof(wherefrom), "from %s", hostname);
 		else
-			sprintf(wherefrom, "on %s", tty);
+			snprintf(wherefrom, sizeof(wherefrom), "on %s", tty);
 	}
 
 	for (cnt = 0;; ask = 1) {
@@ -464,7 +464,47 @@
 			}
 		}
 #else
+# ifdef SUN_C2_SECURITY
+#  define PASSWD_ADJUNCT	"/etc/security/passwd.adjunct"
+		{
+		    if (strlen(pwd->pw_passwd) > 2 && 
+			strncmp(pwd->pw_passwd, "##", 2) == 0) {
+			char linebuf[BUFSIZ];
+			FILE *fp;
+			char *p = NULL;
+
+			if ((fp = fopen(PASSWD_ADJUNCT, "r")) == NULL) {
+			    syslog(LOG_DEBUG, "fopen(PASSWD_ADJUNCT)");
+			    exit(1);
+			}
+
+			while (fgets(linebuf, sizeof(linebuf), fp) != NULL) {
+			    char *hit, *next;
+
+			    if ((hit = strtok(linebuf, ":")) != NULL) {
+				if (strcmp(hit, pwd->pw_name) == 0 && 
+				    (next = strtok(NULL, ":")) != NULL) {
+				    if ((p = malloc(strlen(next) + 1)) == NULL) {
+					syslog(LOG_DEBUG, "malloc(strlen(next) + 1)");
+					exit(1);
+				    }
+				    strcpy(p, next);
+				    pwd->pw_passwd = p;
+				    salt = pwd->pw_passwd;
+				    break;
+				}
+			    }
+			}
+			fclose(fp);
+
+			if (p == NULL) {
+			    salt = "xx";
+			}
+		    }
+		}
+# else
 			salt = pwd->pw_passwd;
+# endif
 #endif
 		else
 			salt = "xx";
@@ -593,7 +633,7 @@
 #ifdef IRIX_LASTLOGIN
 	{ 
 	char lastfile[BUFSIZ]; 
-	sprintf(lastfile, "%s/%s", _PATH_LASTLOG, pwd->pw_name);
+	snprintf(lastfile, sizeof(lastfile), "%s/%s", _PATH_LASTLOG, pwd->pw_name);
 	last_fd = open(lastfile, O_CREAT | O_RDWR, 0644);
 	fchmod(last_fd, 0644);
 	}
@@ -753,9 +793,9 @@
 		strcpy(tbuf, mailpath);
 #else /* WIN */
 #ifdef HOMEDOTMAIL /* Mail in ~/.mail */
-		(void)sprintf(tbuf, "%s/.mail", pwd->pw_dir);
+		(void)snprintf(tbuf, sizeof(tbuf), "%s/.mail", pwd->pw_dir);
 #else /* HOMEDOTMAIL */
-		(void)sprintf(tbuf, "%s/%s", _PATH_MAILDIR, pwd->pw_name);
+		(void)snprintf(tbuf, sizeof(tbuf), "%s/%s", _PATH_MAILDIR, pwd->pw_name);
 #endif /* HOMEDOTMAIL */
 #endif /* WIN */
 		if (stat(tbuf, &st) == 0 && st.st_size != 0)
@@ -854,7 +894,7 @@
 void timedout()
 {
 	fprintf(stderr, "Login timed out after %d seconds\n", timeout);
-	close(0);	/* force EOF */
+	exit(0);
 }
 
 void hungup()
@@ -1025,7 +1065,7 @@
 	getstr(rusername, sizeof (rusername), "remuser");
 	getstr(lusername, sizeof (lusername), "locuser");
 	getstr(term, sizeof(term), "Terminal type");
-	sprintf(wherefrom, "from %s@%s", rusername, host);
+	snprintf(wherefrom, sizeof(wherefrom), "from %s@%s", rusername, host);
 	pwd = getpwnam(lusername);
 	if (pwd == NULL)
 		return(-1);
diff -ur ../logdaemon-5.12/login/mailpath.c logdaemon-5.12.kjm/login/mailpath.c
--- ../logdaemon-5.12/login/mailpath.c	Wed Nov 30 17:46:04 1994
+++ logdaemon-5.12.kjm/login/mailpath.c	Thu Jul 19 20:14:31 2001
@@ -93,9 +93,9 @@
 	*cp = 0;
 	if ((cp = strchr(home_info, '.')) != 0)
 	    *cp = 0;
-	sprintf(mailpath, "%s/%s/%s", _PATH_MAILDIR, home_info, user);
+	snprintf(mailpath, sizeof(mailpath), "%s/%s/%s", _PATH_MAILDIR, home_info, user);
     } else {
-	sprintf(mailpath, "%s/%s", _PATH_MAILDIR, user);
+	snprintf(mailpath, sizeof(mailpath), "%s/%s", _PATH_MAILDIR, user);
     }
     return (mailpath);
 }
diff -ur ../logdaemon-5.12/login/sysv_environ.c logdaemon-5.12.kjm/login/sysv_environ.c
--- ../logdaemon-5.12/login/sysv_environ.c	Thu Apr 10 01:59:18 1997
+++ logdaemon-5.12.kjm/login/sysv_environ.c	Thu Jul 19 20:15:22 2001
@@ -114,7 +114,7 @@
 
     while (argc && *argv) {
 	if (strchr(*argv, '=') == 0) {
-	    sprintf(buf, "L%d", count++);
+	    snprintf(buf, sizeof(buf), "L%d", count++);
 	    setenv(buf, *argv, 1);
 	} else {
 	    for (cp = censored; cp->prefix; cp++)
@@ -137,7 +137,7 @@
     /* Undocumented: HOME, MAIL and LOGNAME are always reset (SunOS 5.1). */
 
     setenv("HOME", pwd->pw_dir, 1);
-    sprintf(buf, "%s/%s", MAILDIR, pwd->pw_name);
+    snprintf(buf, sizeof(buf), "%s/%s", MAILDIR, pwd->pw_name);
     setenv("MAIL", buf, 1);
     setenv("LOGNAME", pwd->pw_name, 1);
 #ifdef ENV_USER
diff -ur ../logdaemon-5.12/rexecd/Makefile logdaemon-5.12.kjm/rexecd/Makefile
--- ../logdaemon-5.12/rexecd/Makefile	Wed Jan  5 01:23:03 2000
+++ logdaemon-5.12.kjm/rexecd/Makefile	Tue Dec  5 13:12:37 2000
@@ -32,6 +32,14 @@
 	@$(MAKE) all-skey SYS=sunos4 XFLAGS="-DSUNOS4 $(SKEYDEFS)" \
 	    XLIBS="$(SKEYLIBS)"
 
+newsos6:
+	@$(MAKE) all SYS=newsos6 XFLAGS="-DSYSV4 -DNEWSOS6" \
+	    SYSLIBS="-lsocket -lnsl"
+
+newsos6-skey:
+	@$(MAKE) all-skey SYS=newsos6 XFLAGS="-DSYSV4 -DNEWSOS6 $(SKEYDEFS)" \
+	    XLIBS="$(SKEYLIBS)" SYSLIBS="-lsocket -lnsl"
+
 ultrix4-skey:
 	@$(MAKE) all-skey SYS=ultrix4 XFLAGS="-DULTRIX4 $(SKEYDEFS)" \
 	    XLIBS="$(SKEYLIBS)"
diff -ur ../logdaemon-5.12/rlogind/Makefile logdaemon-5.12.kjm/rlogind/Makefile
--- ../logdaemon-5.12/rlogind/Makefile	Wed Jan  5 01:23:03 2000
+++ logdaemon-5.12.kjm/rlogind/Makefile	Fri Nov 17 16:50:31 2000
@@ -8,7 +8,7 @@
 
 what:
 	@echo Usage: make system-type. System types are:
-	@echo sunos5 sunos4 ultrix4 hpux9 decosf1 linux
+	@echo sunos5 sunos4 newsos6 newsos4 ultrix4 hpux9 linux bsd44 freebsd bsdi
 	@exit 1;
 
 sysv4:
@@ -17,6 +17,12 @@
 sunos5:
 	@$(MAKE) all SYS=$@ XFLAGS="-DSYSV4 -DSUNOS5" SYSLIBS="-lsocket -lnsl"
 
+newsos6:
+	@$(MAKE) all SYS=$@ XFLAGS="-DSYSV4 -DNEWSOS6" SYSLIBS="-lsocket -lnsl"
+
+newsos4:
+	@$(MAKE) all SYS=$@ XFLAGS=-DNEWSOS4
+
 ultrix4:
 	@$(MAKE) all SYS=$@ XFLAGS=-DULTRIX4
 
@@ -31,9 +37,6 @@
 
 hpux9:
 	@$(MAKE) all SYS=$@ XFLAGS=-DHPUX9
-
-newsos4:
-	@echo newsos4 has not been tested.
 
 decosf1:
 	@$(MAKE) all SYS=$@ XFLAGS="-DDECOSF1"
diff -ur ../logdaemon-5.12/rlogind/rlogind.c logdaemon-5.12.kjm/rlogind/rlogind.c
--- ../logdaemon-5.12/rlogind/rlogind.c	Wed Jan  5 01:23:03 2000
+++ logdaemon-5.12.kjm/rlogind/rlogind.c	Wed Jul 25 18:06:04 2001
@@ -116,7 +116,7 @@
 #define LOG_AUTH        0
 #endif
 
-#ifdef ultrix
+#if defined(ultrix) || defined(NEWSOS4)
 #define setsid()	setpgrp(0,0)
 #endif
 
@@ -136,6 +136,10 @@
 int	pty;
 #endif /* CLOSE_PTY_MASTER */
 
+#ifndef O_NOCTTY
+#define O_NOCTTY	0
+#endif
+
 main(argc, argv)
 	int argc;
 	char **argv;
@@ -294,7 +298,7 @@
 		if (source_routed) {
 			lp = lbuf;
 			for (cp = optbuf; optsize > 0; cp++, optsize--, lp += 3)
-				sprintf(lp, " %2.2x", *cp);
+				snprintf(lp, sizeof(lbuf) - (lp - lbuf), " %2.2x", *cp);
 			syslog(LOG_NOTICE,
 			    "Connection received using IP options (ignored):%s", lbuf);
 			if (setsockopt(0, ipproto, IP_OPTIONS,
@@ -650,7 +654,7 @@
 	char buf[BUFSIZ];
 
 	buf[0] = '\01';		/* error indicator */
-	(void) sprintf(buf + 1, "rlogind: %s.\r\n", msg);
+	(void) snprintf(buf + 1, sizeof(buf) - 1, "rlogind: %s.\r\n", msg);
 	(void) write(f, buf, strlen(buf));
 	exit(1);
 }
@@ -666,9 +670,9 @@
 #endif
 
 	if ((unsigned)errno < sys_nerr)
-		(void) sprintf(buf, "%s: %s", msg, sys_errlist[errno]);
+		(void) snprintf(buf, sizeof(buf), "%s: %s", msg, sys_errlist[errno]);
 	else
-		(void) sprintf(buf, "%s: Error %d", msg, errno);
+		(void) snprintf(buf, sizeof(buf), "%s: Error %d", msg, errno);
 	fatal(f, buf);
 }
 
diff -ur ../logdaemon-5.12/rshd/Makefile logdaemon-5.12.kjm/rshd/Makefile
--- ../logdaemon-5.12/rshd/Makefile	Wed Jan  5 01:23:03 2000
+++ logdaemon-5.12.kjm/rshd/Makefile	Fri Nov 17 16:50:05 2000
@@ -7,7 +7,7 @@
 
 what:
 	@echo Usage: make system-type. System types are:
-	@echo sunos4 sunos5 ultrix4 hpux9 decosf1 linux
+	@echo sunos4 sunos5 newsos6 newsos4 ultrix4 hpux9 decosf1 linux bsd44 freebsd bsdi
 	@exit 1;
 
 sunos5:
@@ -16,6 +16,12 @@
 sunos4: 
 	@$(MAKE) all SYS=$@ XFLAGS=-DSUNOS4
 
+newsos6:
+	@$(MAKE) all SYS=$@ XFLAGS="-DSYSV4 -DNEWSOS6" SYSLIBS="-lsocket -lnsl"
+
+newsos4: 
+	@$(MAKE) all SYS=$@ XFLAGS=-DNEWSOS4
+
 ultrix4: 
 	@$(MAKE) all SYS=$@ XFLAGS=-DULTRIX4
 
@@ -27,9 +33,6 @@
 
 hpux9:
 	@$(MAKE) all SYS=$@ XFLAGS=-DHPUX9
-
-newsos4:
-	@echo newsos4 has not been tested.
 
 decosf1:
 	@$(MAKE) all SYS=$@ XFLAGS=-DDECOSF1
diff -ur ../logdaemon-5.12/rshd/rshd.c logdaemon-5.12.kjm/rshd/rshd.c
--- ../logdaemon-5.12/rshd/rshd.c	Tue Aug 31 03:24:39 1999
+++ logdaemon-5.12.kjm/rshd/rshd.c	Wed Jul 25 19:47:52 2001
@@ -77,7 +77,7 @@
 #define LOG_ODELAY	0
 #endif
 
-#ifdef ultrix
+#if defined(ultrix) || defined(NEWSOS4)
 #define setsid()	setpgrp(0,0)
 #endif
 
@@ -234,7 +234,7 @@
 	      if (source_routed) {
 		lp = lbuf;
 		for (cp = optbuf; optsize > 0; cp++, optsize--, lp += 3)
-			sprintf(lp, " %2.2x", *cp);
+			snprintf(lp, sizeof(lbuf) - (lp - lbuf), " %2.2x", *cp);
 		syslog(LOG_NOTICE,
 		    "Connection received using IP options (ignored):%s", lbuf);
 		if (setsockopt(0, ipproto, IP_OPTIONS,
@@ -468,7 +468,7 @@
 	char buf[BUFSIZ];
 
 	buf[0] = 1;
-	(void) sprintf(buf+1, fmt, a1, a2, a3);
+	(void) snprintf(buf+1, sizeof(buf) - 1, fmt, a1, a2, a3);
 	(void) write(2, buf, strlen(buf));
 }
 
Only in logdaemon-5.12.kjm/skey: 622
diff -ur ../logdaemon-5.12/skey/Makefile logdaemon-5.12.kjm/skey/Makefile
--- ../logdaemon-5.12/skey/Makefile	Fri Sep 20 16:20:05 1996
+++ logdaemon-5.12.kjm/skey/Makefile	Fri Jul 27 14:44:36 2001
@@ -5,7 +5,7 @@
 KEYACCESS= $(KEY_DIR)/skey.access
 KEYFILE	= $(KEY_DIR)/skeykeys
 CFLAGS	= -O $(XFLAGS) -DPERMIT_CONSOLE -DKEYACCESS=\"$(KEYACCESS)\" \
-	-DKEYFILE=\"$(KEYFILE)\" -DMD4
+	-DKEYFILE=\"$(KEYFILE)\" -DMD5 -DRFC1938 -DUSE_CRACKLIB
 OBJS	= skeylogin.o skeysubr.o mdx.o put.o skeyaccess.o skey_getpass.o \
 	skey_crypt.o $(MISSING)
 BINS	= key keyinfo keyinit
@@ -30,6 +30,9 @@
 	$(MAKE) all MISSING=strftime.o
 
 sysv4 sunos5:
+	@$(MAKE) all RANLIB=echo
+
+newsos6:
 	@$(MAKE) all SYSLIBS=-lnsl RANLIB=echo
 
 irix5:
@@ -56,8 +59,8 @@
 install: all
 	cp $(BINS) $(BIN_DIR)
 	cd $(BIN_DIR); chmod 4755 keyinit; chmod 755 key keyinfo
-	touch $(KEYFILE); chmod 644 $(KEYFILE)
-#	touch $(KEYACCESS); chmod 644 $(KEYACCESS)
+	touch $(KEYFILE); chmod 600 $(KEYFILE)
+#	touch $(KEYACCESS); chmod 600 $(KEYACCESS)
 	cp keyinfo.1 keyinit.1 key.1 $(MAN_DIR)/man1
 	cd $(MAN_DIR)/man1; chmod 644 keyinfo.1 keyinit.1 key.1
 	cp skey.access.5 $(MAN_DIR)/man5
Only in logdaemon-5.12.kjm/skey: pam_skey.c
Only in logdaemon-5.12.kjm/skey: pam_skey.so.1
diff -ur ../logdaemon-5.12/skey/skey_getpass.c logdaemon-5.12.kjm/skey/skey_getpass.c
--- ../logdaemon-5.12/skey/skey_getpass.c	Tue Oct 29 15:49:02 1996
+++ logdaemon-5.12.kjm/skey/skey_getpass.c	Tue Mar  3 11:21:08 1998
@@ -38,11 +38,19 @@
 
     if ((sflag = skeyinfo(&skey, username, buf)) == 0) {
 	if (skey.n < 5)
+#ifdef	RFC1938
+	    printf("Warning! Change OTP password soon\n");
+#else	/* RFC1938 */
 	    printf("Warning! Change s/key password soon\n");
+#endif	/* RFC1938 */
 	printf("%s\n", buf);
     }
     if (!pwok) {
+#ifdef  RFC1938
+	printf("(OTP required)\n");
+#else   /* RFC1938 */
 	printf("(s/key required)\n");
+#endif  /* RFC1938 */
     }
     fputs(prompt, stdout);
     fflush(stdout);
diff -ur ../logdaemon-5.12/skey/skeyinit.c logdaemon-5.12.kjm/skey/skeyinit.c
--- ../logdaemon-5.12/skey/skeyinit.c	Tue Aug 31 05:40:03 1999
+++ logdaemon-5.12.kjm/skey/skeyinit.c	Wed Jul 25 20:02:28 2001
@@ -10,6 +10,10 @@
 #include <time.h>
 #include <ctype.h>
 
+#ifdef USE_CRACKLIB
+#include <cracklib.h>
+#endif
+
 extern int optind;
 extern char *optarg;
 
@@ -124,12 +128,12 @@
 	printf("Reminder you need the 6 english words from the skey command.\n");
 	for(i=0;;i++){
 		if(i >= 2) exit(1);
-		printf("Enter sequence count from 1 to 9999: ");
+		printf("Enter sequence count from 1 to 199: ");
 		fgets(tmp,sizeof(tmp),stdin);
 		n = atoi(tmp);
-		if(n > 0 && n < 10000)
+		if(n > 0 && n < 200)
 			break;	/* Valid range */
-		printf("Count must be > 0 and < 10000\n");
+		printf("Count must be > 0 and < 200\n");
 	}
     }
     if( !defaultsetup){
@@ -144,7 +148,15 @@
 	if( seed[0] == '\0') strcpy(seed,defaultseed);
 	for(i=0;;i++){
 		if(i >= 2) exit(1);
+#ifdef  RFC1938
+#ifdef  MD5
+		printf("opt-md5 %d %s\nOTP access password: ",n,seed);
+#else   /* MD5 */
+		printf("opt-md4 %d %s\nOTP access password: ",n,seed);
+#endif  /* MD5 */
+#else   /* RFC1938 */
 		printf("s/key %d %s\ns/key access password: ",n,seed);
+#endif  /* RFC1938 */
 		fgets(tmp,sizeof(tmp),stdin);
 		rip(tmp);
 		if(tmp[0] == '?'){
@@ -166,20 +178,38 @@
 		if(i >= 2) exit(1);
 		fprintf(stderr,"Enter secret password: ");
 		readpass(passwd,sizeof(passwd));
+		/*
 		if(passwd[0] == '\0'){
 			exit(1);
 		}
+		*/
+		if(strlen(passwd) < 10) {
+			fprintf(stderr, "Sorry your password must be longer\n\r");
+			continue;
+		}
+#ifdef USE_CRACKLIB
+		{
+		    char *msg;
+
+		    if (msg = (char *) FascistCheck(passwd, CRACKLIB_DICTPATH)) {
+			fprintf(stderr, "Please use a different password.\n");
+			fprintf(stderr, "The one you have chosen is unsuitable because %s.\n", msg);
+			continue;	/* go round and round until they get it right */
+		    }
+		}
+#endif
 		fprintf(stderr,"Again secret password: ");
 		readpass(passwd2,sizeof(passwd));
 		if(passwd2[0] == '\0'){
 			exit(1);
 		}
-		if(strlen(passwd) < 4 && strlen(passwd2) < 4) {
-			fprintf(stderr, "Sorry your password must be longer\n\r");
-			exit(1);
+		if(strcmp(passwd,passwd2) == 0) 
+		    break;
+		else {
+		    fprintf(stderr, "Sorry no match.\n");
+		    exit(1);
 		}
-		if(strcmp(passwd,passwd2) == 0) break;
-		fprintf(stderr, "Sorry no match\n");
+		fprintf(stderr, "Sorry no match.  Try again.\n");
 		
 	
 	}
@@ -205,7 +235,15 @@
 	fprintf(skey.keyfile,"%s %04d %-16s %s %-21s\n",pp->pw_name,n,
 		seed,skey.val, tbuf);
 	fclose(skey.keyfile);
+#ifdef  RFC1938
+#ifdef  MD5
+	printf("\nID %s otp-md5 is %d %s\n",pp->pw_name,n,seed);
+#else   /* MD5 */
+	printf("\nID %s otp-md4 is %d %s\n",pp->pw_name,n,seed);
+#endif  /* MD5 */
+#else   /* RFC1938 */
 	printf("\nID %s s/key is %d %s\n",pp->pw_name,n,seed);
+#endif  /* RFC1938 */
 	printf("%s\n",btoe(buf,key));
 #ifdef HEXIN
 	printf("%s\n",put8(buf,key));
Only in logdaemon-5.12.kjm/skey: skeyinit.c.dist
diff -ur ../logdaemon-5.12/skey/skeylogin.c logdaemon-5.12.kjm/skey/skeylogin.c
--- ../logdaemon-5.12/skey/skeylogin.c	Mon Oct 30 01:01:39 1995
+++ logdaemon-5.12.kjm/skey/skeylogin.c	Mon Mar  2 18:24:57 1998
@@ -52,7 +52,15 @@
 		return -1;
 	case 0:		/* Lookup succeeded */
 		if (ss != 0) {
+#ifdef	RFC1938
+#ifdef	MD5
+			sprintf(ss, "otp-md5 %d %s",mp->n - 1,mp->seed);
+#else	/* MD5 */
+			sprintf(ss, "otp-md4 %d %s",mp->n - 1,mp->seed);
+#endif	/* MD5 */
+#else	/* RFC1938 */
 			sprintf(ss, "s/key %d %s",mp->n - 1,mp->seed);
+#endif	/* RFC1938 */
 			fclose(mp->keyfile);
 		}
 		return 0;
@@ -82,7 +90,15 @@
 	case -1:	/* File error */
 		return -1;
 	case 0:		/* Lookup succeeded, issue challenge */
+#ifdef	RFC1938
+#ifdef	MD5
+                sprintf(ss, "otp-md5 %d %s",mp->n - 1,mp->seed);
+#else	/* MD5 */
+                sprintf(ss, "otp-md4 %d %s",mp->n - 1,mp->seed);
+#endif	/* MD5 */
+#else	/* RFC1938 */
                 sprintf(ss, "s/key %d %s",mp->n - 1,mp->seed);
+#endif	/* RFC1938 */
 		return 0;
 	case 1:		/* User not found */
 		fclose(mp->keyfile);
diff -ur ../logdaemon-5.12/skeysh/Makefile logdaemon-5.12.kjm/skeysh/Makefile
--- ../logdaemon-5.12/skeysh/Makefile	Wed Jan  5 01:23:03 2000
+++ logdaemon-5.12.kjm/skeysh/Makefile	Tue Dec  5 13:12:38 2000
@@ -35,6 +35,10 @@
 	@$(MAKE) all SYS=$@ XFLAGS="-DSYSV4 -DSUNOS5" RANLIB=echo \
 	    XOBJS="sysv_default.o"
 
+newsos6:
+	@$(MAKE) all SYS=$@ XFLAGS="-DSYSV4 -DNEWSOS6" RANLIB=echo \
+	    XOBJS="sysv_default.o"
+
 irix5:
 	@$(MAKE) all SYS=$@ XFLAGS="-DIRIX5 -DSYSV4" RANLIB=echo \
 	    XOBJS="sysv_default.o"
diff -ur ../logdaemon-5.12/skeysh/skeysh.c logdaemon-5.12.kjm/skeysh/skeysh.c
--- ../logdaemon-5.12/skeysh/skeysh.c	Wed Jul 30 03:04:04 1997
+++ logdaemon-5.12.kjm/skeysh/skeysh.c	Wed Jul 25 19:53:15 2001
@@ -347,7 +347,7 @@
 #ifdef IRIX_LASTLOGIN
 	{
 	char lastfile[BUFSIZ];
-	sprintf(lastfile, "%s/%s", _PATH_LASTLOG, pwd->pw_name);
+	snprintf(lastfile, sizeof(lastfile), "%s/%s", _PATH_LASTLOG, pwd->pw_name);
 	last_fd = open(lastfile, O_CREAT | O_RDWR, 0644);
 	fchmod(last_fd, 0644);
 	}
@@ -417,7 +417,7 @@
 	(void)setenv("HOME", pwd->pw_dir, 1);
 	(void)setenv("SHELL", pwd->pw_shell, 1);
 	(void)setenv("USER", pwd->pw_name, 1);
-	sprintf(tbuf, "%s/%s", _PATH_MAILDIR, pwd->pw_name);
+	snprintf(tbuf, sizeof(tbuf), "%s/%s", _PATH_MAILDIR, pwd->pw_name);
 	setenv("MAIL", tbuf, 1);
 #ifdef SYSV_LOGINDEFS
 	(void)setenv("PATH", pwd->pw_uid ? default_path : default_supath, 0);
@@ -456,7 +456,7 @@
 		struct stat st;
 
 		motd();
-		(void)sprintf(tbuf, "%s/%s", _PATH_MAILDIR, pwd->pw_name);
+		(void)snprintf(tbuf, sizeof(tbuf), "%s/%s", _PATH_MAILDIR, pwd->pw_name);
 		if (stat(tbuf, &st) == 0 && st.st_size != 0)
 			printf("You have %smail.\n",
 			    (st.st_mtime > st.st_atime) ? "new " : "");
diff -ur ../logdaemon-5.12/snk/Makefile logdaemon-5.12.kjm/snk/Makefile
--- ../logdaemon-5.12/snk/Makefile	Tue Aug 31 06:23:41 1999
+++ logdaemon-5.12.kjm/snk/Makefile	Tue Dec  5 13:12:38 2000
@@ -31,7 +31,7 @@
 hpux9:
 	@make all RANLIB=echo
 
-sysv4 sunos5 irix5:
+sysv4 sunos5 irix5 newsos6:
 	@make all SYSLIBS=-lnsl RANLIB=echo
 
 all: libsnk.a snkkey
diff -ur ../logdaemon-5.12/telnetd/Makefile logdaemon-5.12.kjm/telnetd/Makefile
--- ../logdaemon-5.12/telnetd/Makefile	Wed Jan  5 01:23:03 2000
+++ logdaemon-5.12.kjm/telnetd/Makefile	Fri Nov 17 16:51:02 2000
@@ -7,7 +7,7 @@
 
 what:
 	@echo Usage: make system-type. System types are:
-	@echo sunos5 sunos4 ultrix4 decosf1 linux
+	@echo sunos5 sunos4 newsos6 newsos4 ultrix4 decosf1 linux bsd44 freebsd bsdi
 	@exit 1;
 
 all:	lib telnetd
@@ -17,6 +17,12 @@
 
 sunos4:
 	@$(MAKE) all SYS=$@ XFLAGS=-DSUNOS4
+
+newsos6:
+	@$(MAKE) all SYS=$@ XFLAGS="-DSYSV4 -DNEWSOS6" SYSLIBS="-lsocket -lnsl"
+
+newsos4:
+	@$(MAKE) all SYS=$@ XFLAGS=-DNEWSOS4
 
 ultrix4:
 	@$(MAKE) all SYS=$@ XFLAGS=-DULTRIX4
diff -ur ../logdaemon-5.12/telnetd/telnetd.c logdaemon-5.12.kjm/telnetd/telnetd.c
--- ../logdaemon-5.12/telnetd/telnetd.c	Thu Jul 19 22:42:33 2001
+++ logdaemon-5.12.kjm/telnetd/telnetd.c	Fri Jul 27 14:43:31 2001
@@ -93,7 +93,7 @@
 #define LOG_ODELAY	0
 #endif
 
-#ifdef ultrix
+#if defined(ultrix) || defined(NEWSOS4)
 #define setsid()	setpgrp(0,0)
 #endif
 
@@ -130,6 +130,7 @@
 			}
 
 char	netobuf[BUFSIZ], *nfrontp = netobuf, *nbackp = netobuf;
+#define	NETOBUF_REMAIN	(sizeof(netobuf) - (nfrontp - netobuf))
 char	*neturg = 0;		/* one past last bye of urgent data */
 	/* the remote system seems to NOT be an old 4.2 */
 int	not42 = 1;
@@ -154,6 +155,14 @@
 #define BANNER	"\r\n\r\Digital UNIX (%s)\r\n\r\r\n\r"
 #endif
 
+#ifdef NEWSOS4
+#define	BANNER	"\r\n\r\nNEWS-OS Release 4.x (%s)\r\n\r\r\n\r"
+#endif
+
+#ifdef NEWSOS6
+#define	BANNER	"\r\n\r\nNEWS-OS Release 6.x (%s)\r\n\r\r\n\r"
+#endif
+
 #ifndef BANNER
 #define	BANNER	"\r\n\r\n4.3 BSD UNIX (%s)\r\n\r\r\n\r"
 #endif
@@ -200,6 +209,10 @@
 
 #define	settimer(x)	(clocks.x = ++clocks.system)
 #define	sequenceIs(x,y)	(clocks.x < clocks.y)
+
+#ifndef O_NOCTTY
+#define O_NOCTTY	0
+#endif
 
 main(argc, argv)
 	char *argv[];
@@ -308,6 +321,8 @@
     static char sbuf[] = { IAC, DO, TELOPT_TTYPE };
 
     settimer(getterminal);
+    while (NETOBUF_REMAIN < sizeof(sbuf))
+	netflush();
     bcopy(sbuf, nfrontp, sizeof sbuf);
     nfrontp += sizeof sbuf;
     hisopts[TELOPT_TTYPE] = OPT_YES_BUT_ALWAYS_LOOK;
@@ -317,6 +332,8 @@
     if (hisopts[TELOPT_TTYPE] == OPT_YES) {
 	static char sbbuf[] = { IAC, SB, TELOPT_TTYPE, TELQUAL_SEND, IAC, SE };
 
+	while (NETOBUF_REMAIN < sizeof(sbuf))
+	    netflush();
 	bcopy(sbbuf, nfrontp, sizeof sbbuf);
 	nfrontp += sizeof sbbuf;
 	while (sequenceIs(ttypesubopt, getterminal)) {
@@ -458,7 +475,7 @@
 {
 	char buf[BUFSIZ];
 
-	(void) sprintf(buf, "telnetd: %s.\r\n", msg);
+	(void) snprintf(buf, sizeof(buf), "telnetd: %s.\r\n", msg);
 	(void) write(f, buf, strlen(buf));
 	exit(1);
 }
@@ -472,7 +489,7 @@
 	extern char *sys_errlist[];
 #endif
 
-	(void) sprintf(buf, "%s: %s\r\n", msg, sys_errlist[errno]);
+	(void) snprintf(buf, sizeof(buf), "%s: %s\r\n", msg, sys_errlist[errno]);
 	fatal(f, buf);
 }
 
@@ -557,6 +574,8 @@
 	 * WE, the server, sends it; it does NOT mean that the client will
 	 * echo the terminal input).
 	 */
+	while (NETOBUF_REMAIN < sizeof(doopt) - 2) 
+	    netflush();
 	(void) sprintf(nfrontp, doopt, TELOPT_ECHO);
 	nfrontp += sizeof doopt-2;
 	hisopts[TELOPT_ECHO] = OPT_YES_BUT_ALWAYS_LOOK;
@@ -585,7 +604,7 @@
 			putf(IM, ptyibuf+1);
 	} else {
 #endif
-		sprintf(ptyibuf+1, BANNER, hostname);
+		snprintf(ptyibuf+1, sizeof(ptyibuf) - 1, BANNER, hostname);
 #if 0
 	}
 #endif
@@ -742,6 +761,8 @@
 		if (ptyibuf[0] & TIOCPKT_FLUSHWRITE) {
 			netclear();	/* clear buffer back */
 #ifndef BROKEN_OOB
+			while (NETOBUF_REMAIN < 2)
+			    netflush();
 			*nfrontp++ = IAC;
 			*nfrontp++ = DM;
 			neturg = nfrontp-1;  /* off by one XXX */
@@ -854,8 +875,8 @@
 			 * Are You There?
 			 */
 			case AYT:
-				if (nfrontp + 9 >= netobuf + sizeof(netobuf))
-					break;
+				while (NETOBUF_REMAIN < 9)
+				    netflush();
 				strcpy(nfrontp, "\r\n[Yes]\r\n");
 				nfrontp += 9;
 				break;
@@ -867,6 +888,8 @@
 					ptyflush();	/* half-hearted */
 					tcflush(pty, TCOFLUSH);
 					netclear();	/* clear buffer back */
+					while (NETOBUF_REMAIN < 2)
+					    netflush();
 					*nfrontp++ = IAC;
 					*nfrontp++ = DM;
 					neturg = nfrontp-1; /* off by one XXX */
@@ -1042,6 +1065,8 @@
 	} else {
 		hisopts[option] = OPT_NO;
 	}
+	while (NETOBUF_REMAIN < sizeof (dont) - 2) 
+	    netflush();
 	(void) sprintf(nfrontp, fmt, option);
 	nfrontp += sizeof (dont) - 2;
 }
@@ -1067,6 +1092,8 @@
 
 	fmt = dont;
 	hisopts[option] = OPT_NO;
+	while (NETOBUF_REMAIN < sizeof (doopt) - 2)
+	    netflush();
 	(void) sprintf(nfrontp, fmt, option);
 	nfrontp += sizeof (doopt) - 2;
 }
@@ -1109,6 +1136,8 @@
 	} else {
 	    myopts[option] = OPT_NO;
 	}
+	while (NETOBUF_REMAIN < sizeof (doopt) - 2)
+	    netflush();
 	(void) sprintf(nfrontp, fmt, option);
 	nfrontp += sizeof (doopt) - 2;
 }
@@ -1135,6 +1164,8 @@
     } else {
 	myopts[option] = OPT_YES;
     }
+    while (NETOBUF_REMAIN < sizeof (wont) - 2)
+	netflush();
     (void) sprintf(nfrontp, fmt, option);
     nfrontp += sizeof (wont) - 2;
 }
