diff -Nur ksh/charclass.h ksh.new/charclass.h
--- ksh/charclass.h	1969-12-31 19:00:00.000000000 -0500
+++ ksh.new/charclass.h	2009-06-04 14:21:22.000000000 -0400
@@ -0,0 +1,33 @@
+/*
+ * Public domain, 2008, Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * $OpenBSD: charclass.h,v 1.1 2008/10/01 23:04:13 millert Exp $
+ */
+
+#include <ctype.h>
+
+#define isblank(c)    __isctype((c), _ISblank)
+
+/*
+ * POSIX character class support for fnmatch() and glob().
+ */
+static struct cclass {
+	const char *name;
+	int (*isctype)(int);
+} cclasses[] = {
+	{ "alnum",	isalnum },
+	{ "alpha",	isalpha },
+//	{ "blank",	isblank },
+	{ "cntrl",	iscntrl },
+	{ "digit",	isdigit },
+	{ "graph",	isgraph },
+	{ "lower",	islower },
+	{ "print",	isprint },
+	{ "punct",	ispunct },
+	{ "space",	isspace },
+	{ "upper",	isupper },
+	{ "xdigit",	isxdigit },
+	{ NULL,		NULL }
+};
+
+#define NCCLASSES	(sizeof(cclasses) / sizeof(cclasses[0]) - 1)
diff -Nur ksh/c_sh.c ksh.new/c_sh.c
--- ksh/c_sh.c	2009-06-04 14:19:21.000000000 -0400
+++ ksh.new/c_sh.c	2009-06-04 14:21:22.000000000 -0400
@@ -843,6 +843,7 @@
 	while ((optc = ksh_getopt(wp, &builtin_opt, "m:")) != -1) {
 		switch (optc) {
 		case 'm':
+			/*
 			set = setmode(builtin_opt.optarg);
 			if (set == NULL) {
 				bi_errorf("invalid file mode");
@@ -850,6 +851,7 @@
 			}
 			mode = getmode(set, DEFFILEMODE);
 			free(set);
+			*/
 			break;
 		default:
 			goto usage;
diff -Nur ksh/jobs.c ksh.new/jobs.c
--- ksh/jobs.c	2009-06-04 14:19:21.000000000 -0400
+++ ksh.new/jobs.c	2009-06-04 14:21:22.000000000 -0400
@@ -143,7 +143,8 @@
 void
 j_init(int mflagset)
 {
-	child_max = CHILD_MAX; /* so syscon() isn't always being called */
+	// from syslimits.h	
+	child_max = 256; /* so syscon() isn't always being called */
 
 	sigemptyset(&sm_default);
 	sigprocmask(SIG_SETMASK, &sm_default, (sigset_t *) 0);
diff -Nur ksh/main.c ksh.new/main.c
--- ksh/main.c	2009-06-04 14:19:21.000000000 -0400
+++ ksh.new/main.c	2009-06-04 14:21:22.000000000 -0400
@@ -63,7 +63,8 @@
 	NULL
 };
 
-char username[_PW_NAME_LEN + 1];
+// from pwd.h
+char username[31 + 1];
 
 #define version_param  (initcoms[2])
 
diff -Nur ksh/Makefile ksh.new/Makefile
--- ksh/Makefile	2009-06-04 14:19:21.000000000 -0400
+++ ksh.new/Makefile	2009-06-04 14:31:13.000000000 -0400
@@ -1,10 +1,16 @@
 #	$OpenBSD: Makefile,v 1.27 2009/03/03 20:01:01 millert Exp $
 
+BINDIR=/usr/bin
+
 PROG=	ksh
 SRCS=	alloc.c c_ksh.c c_sh.c c_test.c c_ulimit.c edit.c emacs.c eval.c \
 	exec.c expr.c history.c io.c jobs.c lex.c mail.c main.c mknod.c \
 	misc.c path.c shf.c syn.c table.c trap.c tree.c tty.c var.c \
 	version.c vi.c
+OBJS=	alloc.o c_ksh.o c_sh.o c_test.o c_ulimit.o edit.o emacs.o eval.o \
+	exec.o expr.o history.o io.o jobs.o lex.o mail.o main.o mknod.o \
+	misc.o path.o shf.o syn.o table.o trap.o tree.o tty.o var.o \
+	version.o vi.o strlcpy.o strlcat.o
 
 DEFS=	-Wall
 CFLAGS+=${DEFS} -I. -I${.CURDIR} -I${.CURDIR}/../../lib/libc/gen
@@ -16,13 +22,28 @@
 LINKS+=	${BINDIR}/ksh ${BINDIR}/sh
 MLINKS=	ksh.1 rksh.1
 
+all: $(PROG)
+
+$(PROG): $(OBJS)
+	gcc $(OBJS) -o ksh
+
+$(OBS): %.o: %.c
+	$(CC) $(CFLAGS) -c $<
+
+install:
+	install -m 755 ksh /bin
+	gzip ksh.1 -c > /usr/share/man/man1/ksh.1.gz
+
+clean:
+	rm -f $(OBJS) $(PROG) emacs.out
+
 .depend emacs.o: emacs.out
 
 emacs.out: emacs.c
-	/bin/sh ${.CURDIR}/emacs-gen.sh ${.CURDIR}/emacs.c > emacs.out
+	/bin/sh emacs-gen.sh emacs.c > emacs.out
 
 check test:
 	/usr/bin/perl ${.CURDIR}/tests/th -s ${.CURDIR}/tests -p ./ksh -C \
 	    pdksh,sh,ksh,posix,posix-upu
 
-.include <bsd.prog.mk>
+# .include <bsd.prog.mk>
diff -Nur ksh/strlcat.c ksh.new/strlcat.c
--- ksh/strlcat.c	1969-12-31 19:00:00.000000000 -0500
+++ ksh.new/strlcat.c	2009-06-04 14:21:22.000000000 -0400
@@ -0,0 +1,62 @@
+/*	$OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $	*/
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* OPENBSD ORIGINAL: lib/libc/string/strlcat.c */
+
+// #include "includes.h"
+#ifndef HAVE_STRLCAT
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Appends src to string dst of size siz (unlike strncat, siz is the
+ * full size of dst, not space left).  At most siz-1 characters
+ * will be copied.  Always NUL terminates (unless siz <= strlen(dst)).
+ * Returns strlen(src) + MIN(siz, strlen(initial dst)).
+ * If retval >= siz, truncation occurred.
+ */
+size_t
+strlcat(char *dst, const char *src, size_t siz)
+{
+	char *d = dst;
+	const char *s = src;
+	size_t n = siz;
+	size_t dlen;
+
+	/* Find the end of dst and adjust bytes left but don't go past end */
+	while (n-- != 0 && *d != '\0')
+		d++;
+	dlen = d - dst;
+	n = siz - dlen;
+
+	if (n == 0)
+		return(dlen + strlen(s));
+	while (*s != '\0') {
+		if (n != 1) {
+			*d++ = *s;
+			n--;
+		}
+		s++;
+	}
+	*d = '\0';
+
+	return(dlen + (s - src));	/* count does not include NUL */
+}
+
+#endif /* !HAVE_STRLCAT */
diff -Nur ksh/strlcpy.c ksh.new/strlcpy.c
--- ksh/strlcpy.c	1969-12-31 19:00:00.000000000 -0500
+++ ksh.new/strlcpy.c	2009-06-04 14:21:22.000000000 -0400
@@ -0,0 +1,58 @@
+/*	$OpenBSD: strlcpy.c,v 1.10 2005/08/08 08:05:37 espie Exp $	*/
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* OPENBSD ORIGINAL: lib/libc/string/strlcpy.c */
+
+// #include "includes.h"
+#ifndef HAVE_STRLCPY
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Copy src to string dst of size siz.  At most siz-1 characters
+ * will be copied.  Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ */
+size_t
+strlcpy(char *dst, const char *src, size_t siz)
+{
+	char *d = dst;
+	const char *s = src;
+	size_t n = siz;
+
+	/* Copy as many bytes as will fit */
+	if (n != 0 && --n != 0) {
+		do {
+			if ((*d++ = *s++) == 0)
+				break;
+		} while (--n != 0);
+	}
+
+	/* Not enough room in dst, add NUL and traverse rest of src */
+	if (n == 0) {
+		if (siz != 0)
+			*d = '\0';		/* NUL-terminate dst */
+		while (*s++)
+			;
+	}
+
+	return(s - src - 1);	/* count does not include NUL */
+}
+
+#endif /* !HAVE_STRLCPY */
diff -Nur ksh/trap.c ksh.new/trap.c
--- ksh/trap.c	2009-06-04 14:19:21.000000000 -0400
+++ ksh.new/trap.c	2009-06-04 14:21:22.000000000 -0400
@@ -18,13 +18,8 @@
 	/* Populate sigtraps based on sys_signame and sys_siglist. */
 	for (i = 0; i <= NSIG; i++) {
 		sigtraps[i].signal = i;
-		if (i == SIGERR_) {
-			sigtraps[i].name = "ERR";
-			sigtraps[i].mess = "Error handler";
-		} else {
-			sigtraps[i].name = sys_signame[i];
-			sigtraps[i].mess = sys_siglist[i];
-		}
+		sigtraps[i].name = "ERR";
+		sigtraps[i].mess = "Error handler";
 	}
 	sigtraps[SIGEXIT_].name = "EXIT";	/* our name for signal 0 */
 
diff -Nur ksh/var.c ksh.new/var.c
--- ksh/var.c	2009-06-04 14:19:21.000000000 -0400
+++ ksh.new/var.c	2009-06-04 14:21:22.000000000 -0400
@@ -926,10 +926,7 @@
 		break;
 	case V_RANDOM:
 		vp->flag &= ~SPECIAL;
-		if (use_rand)
-			setint(vp, (long) (rand() & 0x7fff));
-		else
-			setint(vp, (long) (arc4random() & 0x7fff));
+		setint(vp, (long) (rand() & 0x7fff));
 		vp->flag |= SPECIAL;
 		break;
 #ifdef HISTORY
