diff options
Diffstat (limited to 'system/ksh')
25 files changed, 765 insertions, 673 deletions
diff --git a/system/ksh/README b/system/ksh/README index 9582a1b4c9..56d8252f8e 100644 --- a/system/ksh/README +++ b/system/ksh/README @@ -8,7 +8,7 @@ from OpenBSD's repository. PD-ksh is a clone of the AT&T Korn shell. PD-ksh has most of the ksh88 features, not much of the ksh93 features, -and a number of its own features. It is free and quite portable - you -should be able to compile it easily on pretty much any unix box. +and a number of its own features. It is free and quite portable - you +should be able to compile it easily on pretty much any unix box. The vi editing mode is better (IMHO) than that of ksh88 or ksh93 -(command/file completion using tab (optional), less buggy). +(command/file completion using tab (optional), less buggy). diff --git a/system/ksh/ksh.SlackBuild b/system/ksh/ksh.SlackBuild index d7bf7b1ba0..b0db7e1f68 100644 --- a/system/ksh/ksh.SlackBuild +++ b/system/ksh/ksh.SlackBuild @@ -1,8 +1,8 @@ #!/bin/sh - + # Copyright (c) 2010 Daniel LEVAI # All rights reserved. -# +# # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright @@ -13,7 +13,7 @@ # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# +# # THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -28,7 +28,7 @@ # Build script for the Linux port of OpenBSD's ksh PRGNAM=ksh -VERSION=openbsd48 +VERSION=openbsd49 BUILD=${BUILD:-1} TAG=${TAG:-_SBo} @@ -48,8 +48,8 @@ OUTPUT=${OUTPUT:-/tmp} if [ "${ARCH}" == "i486" ];then SLKCFLAGS='-march=i486 -mtune=i686' LIBDIRSUFFIX="" -elif [ "$ARCH" == "i686" ]; then - SLKCFLAGS="-march=i686 -mtune=i686" +elif [ "$ARCH" == "i686" ]; then + SLKCFLAGS="-march=i686 -mtune=i686" LIBDIRSUFFIX="" elif [ "${ARCH}" == "x86_64" ];then SLKCFLAGS='-fPIC' @@ -74,8 +74,11 @@ find . \ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ -exec chmod 644 {} \; -for patch in "${CWD}"/patches/*;do - patch -p1 < "${patch}" +for patch in "${CWD}"/patches/linux/*.diff;do + patch -p1 < "${patch}" +done +for patch in "${CWD}"/patches/*.diff;do + patch -p1 < "${patch}" done CFLAGS="$SLKCFLAGS $(getconf LFS_CFLAGS)" make diff --git a/system/ksh/ksh.info b/system/ksh/ksh.info index fca879af0a..30d21021b2 100644 --- a/system/ksh/ksh.info +++ b/system/ksh/ksh.info @@ -1,10 +1,10 @@ PRGNAM="ksh" -VERSION="openbsd48" -HOMEPAGE="http://leva.ecentrum.hu/slackbuilds/ksh-openbsd48.tar.gz" -DOWNLOAD="http://leva.ecentrum.hu/slackbuilds/ksh-openbsd48.tar.gz" -MD5SUM="54a531fafd378bb864ebb1d84d6fb921" +VERSION="openbsd49" +HOMEPAGE="http://leva.ecentrum.hu/slackbuilds/ksh-openbsd49.tar.gz" +DOWNLOAD="http://leva.ecentrum.hu/slackbuilds/ksh-openbsd49.tar.gz" +MD5SUM="fd0c66373e7ae03673b0b7913e73a986" DOWNLOAD_x86_64="" MD5SUM_x86_64="" MAINTAINER="Daniel LEVAI" EMAIL="leva@ecentrum.hu" -APPROVED="rworkman" +APPROVED="dsomero" diff --git a/system/ksh/patches/00_completion.diff b/system/ksh/patches/00_completion.diff new file mode 100644 index 0000000000..ee843032ca --- /dev/null +++ b/system/ksh/patches/00_completion.diff @@ -0,0 +1,117 @@ +Index: bin/ksh/edit.c +=================================================================== +RCS file: /cvs/src/bin/ksh/edit.c,v +retrieving revision 1.34 +diff -u -r1.34 edit.c +--- ksh/edit.c 20 May 2010 01:13:07 -0000 1.34 ++++ ksh/edit.c 9 May 2011 19:44:06 -0000 +@@ -357,20 +357,6 @@ + + toglob = add_glob(str, slen); + +- /* remove all escaping backward slashes */ +- escaping = 0; +- for (i = 0, idx = 0; toglob[i]; i++) { +- if (toglob[i] == '\\' && !escaping) { +- escaping = 1; +- continue; +- } +- +- toglob[idx] = toglob[i]; +- idx++; +- if (escaping) escaping = 0; +- } +- toglob[idx] = '\0'; +- + /* + * Convert "foo*" (toglob) to an array of strings (words) + */ +@@ -378,7 +364,7 @@ + s = pushs(SWSTR, ATEMP); + s->start = s->str = toglob; + source = s; +- if (yylex(ONEWORD) != LWORD) { ++ if (yylex(ONEWORD|RMBKSLSH) != LWORD) { + source = sold; + internal_errorf(0, "fileglob: substitute error"); + return 0; +@@ -394,6 +380,20 @@ + if (nwords == 1) { + struct stat statb; + ++ /* remove all escaping backward slashes (see below) */ ++ escaping = 0; ++ for (i = 0, idx = 0; toglob[i]; i++) { ++ if (toglob[i] == '\\' && !escaping) { ++ escaping = 1; ++ continue; ++ } ++ ++ toglob[idx] = toglob[i]; ++ idx++; ++ if (escaping) escaping = 0; ++ } ++ toglob[idx] = '\0'; ++ + /* Check if globbing failed (returned glob pattern), + * but be careful (E.g. toglob == "ab*" when the file + * "ab*" exists is not an error). +@@ -821,7 +821,7 @@ + int rval = 0; + + for (add = 0, wlen = len; wlen - add > 0; add++) { +- if (strchr("\"#$&'()*;<=>?[\\]`{|}", s[add]) || ++ if (strchr(ESCAPEDCHARS, s[add]) || + strchr(ifs, s[add])) { + if (putbuf_func(s, add) != 0) { + rval = -1; +Index: bin/ksh/lex.c +=================================================================== +RCS file: /cvs/src/bin/ksh/lex.c,v +retrieving revision 1.45 +diff -u -r1.45 lex.c +--- ksh/lex.c 9 Mar 2011 09:30:39 -0000 1.45 ++++ ksh/lex.c 9 May 2011 19:44:07 -0000 +@@ -299,6 +299,10 @@ + } + /* FALLTHROUGH */ + default: ++ if ((cf & RMBKSLSH) && strchr(" " ESCAPEDCHARS, c)) { ++ *wp++ = QCHAR, *wp++ = c; ++ break; ++ } + Xcheck(ws, wp); + if (c) { /* trailing \ is lost */ + *wp++ = CHAR, *wp++ = '\\'; +Index: bin/ksh/lex.h +=================================================================== +RCS file: /cvs/src/bin/ksh/lex.h,v +retrieving revision 1.11 +diff -u -r1.11 lex.h +--- ksh/lex.h 29 May 2006 18:22:24 -0000 1.11 ++++ ksh/lex.h 9 May 2011 19:44:07 -0000 +@@ -113,6 +113,7 @@ + #define CMDWORD BIT(8) /* parsing simple command (alias related) */ + #define HEREDELIM BIT(9) /* parsing <<,<<- delimiter */ + #define HEREDOC BIT(10) /* parsing heredoc */ ++#define RMBKSLSH BIT(11) /* remove backslashes */ + + #define HERES 10 /* max << in line */ + +Index: bin/ksh/sh.h +=================================================================== +RCS file: /cvs/src/bin/ksh/sh.h,v +retrieving revision 1.30 +diff -u -r1.30 sh.h +--- ksh/sh.h 4 Jan 2010 18:07:11 -0000 1.30 ++++ ksh/sh.h 9 May 2011 19:44:07 -0000 +@@ -398,6 +398,9 @@ + #define OBRACE '{' + #define CBRACE '}' + ++/* Characters to be escaped */ ++#define ESCAPEDCHARS "\"#$&'()*;<=>?[\\]`{|}" ++ + /* Determine the location of the system (common) profile */ + #define KSH_SYSTEM_PROFILE "/etc/profile" + diff --git a/system/ksh/patches/linux/Makefile.diff b/system/ksh/patches/linux/Makefile.diff new file mode 100644 index 0000000000..7c9ca8f8ca --- /dev/null +++ b/system/ksh/patches/linux/Makefile.diff @@ -0,0 +1,58 @@ +--- ksh-openbsd_cvs/Makefile 2010-02-23 12:49:12.000000000 +0100 ++++ ksh-openbsd_cvs.new/Makefile 2010-04-01 21:21:23.498239164 +0200 +@@ -1,28 +1,43 @@ +-# $OpenBSD: Makefile,v 1.27 2009/03/03 20:01:01 millert Exp $ ++ifdef ${PREFIX} ++PREFIX=${PREFIX} ++else ++PREFIX=/usr ++endif ++BINDIR=${DESTDIR}/bin ++MANDIR=${DESTDIR}${PREFIX}/man + + 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 +- +-DEFS= -Wall +-CFLAGS+=${DEFS} -I. -I${.CURDIR} -I${.CURDIR}/../../lib/libc/gen +-MAN= ksh.1 sh.1 ++ version.c vi.c strlcpy.c strlcat.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 + + CLEANFILES+= emacs.out + +-LINKS= ${BINDIR}/ksh ${BINDIR}/rksh +-LINKS+= ${BINDIR}/ksh ${BINDIR}/sh +-MLINKS= ksh.1 rksh.1 ++all: $(PROG) ++ ++CFLAGS+=-Wall ++$(PROG): $(OBJS) ++ gcc $(OBJS) -o ksh ++ ++install: ++ install -m755 -d $(BINDIR) ++ install -m755 --strip --no-target-directory ksh $(BINDIR)/pdksh ++ install -m755 -d $(MANDIR)/man1 ++ install -m644 --no-target-directory ksh.1 $(MANDIR)/man1/pdksh.1 ++ ++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> diff --git a/system/ksh/patches/linux/c_sh_c.diff b/system/ksh/patches/linux/c_sh_c.diff new file mode 100644 index 0000000000..09b74c7a0b --- /dev/null +++ b/system/ksh/patches/linux/c_sh_c.diff @@ -0,0 +1,49 @@ +--- ksh-openbsd_cvs/c_sh.c 2010-03-27 17:25:30.000000000 +0100 ++++ ksh-openbsd_cvs.new/c_sh.c 2010-04-01 21:01:24.132137763 +0200 +@@ -837,19 +837,13 @@ c_mknod(char **wp) + { + int argc, optc, ismkfifo = 0, ret; + char **argv; +- void *set = NULL; +- mode_t mode = 0, oldmode = 0; ++ mode_t mode = 0, old_umask = -1; + + 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"); +- return 1; +- } +- mode = getmode(set, DEFFILEMODE); +- free(set); ++ old_umask = umask(0); ++ mode |= strtoul(builtin_opt.optarg, NULL, 8); + break; + default: + goto usage; +@@ -866,18 +860,17 @@ c_mknod(char **wp) + } else if (argc != 4) + goto usage; + +- if (set) +- oldmode = umask(0); +- else +- mode = DEFFILEMODE; ++ if (old_umask == -1) ++ mode |= DEFFILEMODE; + + if (ismkfifo) + ret = domkfifo(argc, argv, mode); + else + ret = domknod(argc, argv, mode); + +- if (set) +- umask(oldmode); ++ if (old_umask != -1) ++ umask(old_umask); ++ + return ret; + usage: + builtin_argv0 = NULL; diff --git a/system/ksh/patches/linux/charclass_h.diff b/system/ksh/patches/linux/charclass_h.diff new file mode 100644 index 0000000000..05e7957075 --- /dev/null +++ b/system/ksh/patches/linux/charclass_h.diff @@ -0,0 +1,36 @@ +--- ksh-openbsd_cvs/charclass.h 1970-01-01 01:00:00.000000000 +0100 ++++ ksh-openbsd_cvs.new/charclass.h 2010-04-01 21:01:24.132137763 +0200 +@@ -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 --git a/system/ksh/patches/linux/emacs_c.diff b/system/ksh/patches/linux/emacs_c.diff new file mode 100644 index 0000000000..4bf6c2a6bc --- /dev/null +++ b/system/ksh/patches/linux/emacs_c.diff @@ -0,0 +1,10 @@ +--- ksh-openbsd_cvs/emacs.c 2010-02-23 12:49:15.000000000 +0100 ++++ ksh-openbsd_cvs.new/emacs.c 2010-04-01 21:01:24.133232595 +0200 +@@ -16,6 +16,7 @@ + #include <ctype.h> + #include <locale.h> + #include "edit.h" ++#include "strlcpy.h" + + static Area aedit; + #define AEDIT &aedit /* area for kill ring and macro defns */ diff --git a/system/ksh/patches/linux/eval_c.diff b/system/ksh/patches/linux/eval_c.diff new file mode 100644 index 0000000000..9d580d8a63 --- /dev/null +++ b/system/ksh/patches/linux/eval_c.diff @@ -0,0 +1,19 @@ +--- ksh.orig/eval.c.orig 2011-03-27 14:33:38.000000000 +0200 ++++ ksh/eval.c 2011-03-27 15:08:25.986119913 +0200 +@@ -8,6 +8,7 @@ + #include <pwd.h> + #include <dirent.h> + #include <sys/stat.h> ++#include "strlcpy.h" + + /* + * string expansion +@@ -692,7 +693,7 @@ + int c; + int state; /* next state: XBASE, XARG, XSUB, XNULLSUB */ + int stype; /* substitution type */ +- int slen; ++ int slen = 0; + char *p; + struct tbl *vp; + diff --git a/system/ksh/patches/linux/history_c.diff b/system/ksh/patches/linux/history_c.diff new file mode 100644 index 0000000000..674e33781e --- /dev/null +++ b/system/ksh/patches/linux/history_c.diff @@ -0,0 +1,10 @@ +--- ksh-openbsd_cvs/history.c 2010-02-23 12:49:16.000000000 +0100 ++++ ksh-openbsd_cvs.new/history.c 2010-04-01 21:01:24.133232595 +0200 +@@ -17,6 +17,7 @@ + + #include "sh.h" + #include <sys/stat.h> ++#include "strlcat.h" + + #ifdef HISTORY + # include <sys/file.h> diff --git a/system/ksh/patches/linux/jobs_c.diff b/system/ksh/patches/linux/jobs_c.diff new file mode 100644 index 0000000000..e50ffd3a94 --- /dev/null +++ b/system/ksh/patches/linux/jobs_c.diff @@ -0,0 +1,22 @@ +--- ksh-openbsd_cvs/jobs.c 2010-02-23 12:49:17.000000000 +0100 ++++ ksh-openbsd_cvs.new/jobs.c 2010-04-01 21:01:24.133232595 +0200 +@@ -21,6 +21,19 @@ + #include <sys/time.h> + #include <sys/resource.h> + #include "tty.h" ++#include "strlcpy.h" ++ ++#ifndef CHILD_MAX ++# if defined(HAVE_SYSCONF) && defined(_SC_CHILD_MAX) ++# define CHILD_MAX sysconf(_SC_CHILD_MAX) ++# else /* _SC_CHILD_MAX */ ++# ifdef _POSIX_CHILD_MAX ++# define CHILD_MAX ((_POSIX_CHILD_MAX) * 2) ++# else /* _POSIX_CHILD_MAX */ ++# define CHILD_MAX 20 ++# endif /* _POSIX_CHILD_MAX */ ++# endif /* _SC_CHILD_MAX */ ++#endif /* !CHILD_MAX */ + + /* Order important! */ + #define PRUNNING 0 diff --git a/system/ksh/patches/linux/lex_c.diff b/system/ksh/patches/linux/lex_c.diff new file mode 100644 index 0000000000..40fd4234f1 --- /dev/null +++ b/system/ksh/patches/linux/lex_c.diff @@ -0,0 +1,11 @@ +--- ksh-openbsd_cvs/lex.c 2010-02-23 12:49:19.000000000 +0100 ++++ ksh-openbsd_cvs.new/lex.c 2010-04-01 21:01:24.134232647 +0200 +@@ -7,6 +7,8 @@ + #include "sh.h" + #include <libgen.h> + #include <ctype.h> ++#include <time.h> ++#include "strlcpy.h" + + + /* Structure to keep track of the lexing state and the various pieces of info diff --git a/system/ksh/patches/linux/main_c.diff b/system/ksh/patches/linux/main_c.diff new file mode 100644 index 0000000000..a5d90620c1 --- /dev/null +++ b/system/ksh/patches/linux/main_c.diff @@ -0,0 +1,15 @@ +--- ksh-openbsd_cvs/main.c 2010-02-23 12:49:19.000000000 +0100 ++++ ksh-openbsd_cvs.new/main.c 2010-04-01 21:01:24.134232647 +0200 +@@ -9,7 +9,12 @@ + #include "sh.h" + #include <sys/stat.h> + #include <pwd.h> ++#include "strlcpy.h" + ++/* on Linux we do not have _PW_NAME_LEN, but libc6 allows us 32 character usernames */ ++#ifndef _PW_NAME_LEN ++# define _PW_NAME_LEN 31 ++#endif + extern char **environ; + + /* diff --git a/system/ksh/patches/linux/misc_c.diff b/system/ksh/patches/linux/misc_c.diff new file mode 100644 index 0000000000..9b09fba62c --- /dev/null +++ b/system/ksh/patches/linux/misc_c.diff @@ -0,0 +1,12 @@ +--- ksh-openbsd_cvs/misc.c 2010-02-23 12:49:20.000000000 +0100 ++++ ksh-openbsd_cvs.new/misc.c 2010-04-01 21:01:24.134232647 +0200 +@@ -7,7 +7,9 @@ + #include "sh.h" + #include <ctype.h> + #include <sys/param.h> /* for MAXPATHLEN */ ++#include <grp.h> + #include "charclass.h" ++#include "strlcpy.h" + + short ctypes [UCHAR_MAX+1]; /* type bits for unsigned char */ + diff --git a/system/ksh/patches/linux/posix_signals_h.diff b/system/ksh/patches/linux/posix_signals_h.diff new file mode 100644 index 0000000000..2d6b8cec4d --- /dev/null +++ b/system/ksh/patches/linux/posix_signals_h.diff @@ -0,0 +1,128 @@ +--- ksh-openbsd_cvs/posix_signals.h 1970-01-01 01:00:00.000000000 +0100 ++++ ksh-openbsd_cvs.new/posix_signals.h 2010-04-01 21:01:24.134232647 +0200 +@@ -0,0 +1,125 @@ ++/* ++ * Copyright (c) 1988, 1993, 1994 ++ * The Regents of the University of California. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. All advertising materials mentioning features or use of this software ++ * must display the following acknowledgement: ++ * This product includes software developed by the University of ++ * California, Berkeley and its contributors. ++ * 4. Neither the name of the University nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++/* ++ Taken from misc-utils/kill.c in the util-linux-ng package. ++ ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/ ++ */ ++ ++#ifndef POSIX_SIGNALS_H ++#define POSIX_SIGNALS_H ++ ++struct signv { ++ char *name; ++ int val; ++} sys_signame[NSIG] = { ++ /* POSIX signals */ ++ { "HUP", SIGHUP }, /* 1 */ ++ { "INT", SIGINT }, /* 2 */ ++ { "QUIT", SIGQUIT }, /* 3 */ ++ { "ILL", SIGILL }, /* 4 */ ++ { "ABRT", SIGABRT }, /* 6 */ ++ { "FPE", SIGFPE }, /* 8 */ ++ { "KILL", SIGKILL }, /* 9 */ ++ { "SEGV", SIGSEGV }, /* 11 */ ++ { "PIPE", SIGPIPE }, /* 13 */ ++ { "ALRM", SIGALRM }, /* 14 */ ++ { "TERM", SIGTERM }, /* 15 */ ++ { "USR1", SIGUSR1 }, /* 10 (arm,i386,m68k,ppc), 30 (alpha,sparc*), 16 (mips) */ ++ { "USR2", SIGUSR2 }, /* 12 (arm,i386,m68k,ppc), 31 (alpha,sparc*), 17 (mips) */ ++ { "CHLD", SIGCHLD }, /* 17 (arm,i386,m68k,ppc), 20 (alpha,sparc*), 18 (mips) */ ++ { "CONT", SIGCONT }, /* 18 (arm,i386,m68k,ppc), 19 (alpha,sparc*), 25 (mips) */ ++ { "STOP", SIGSTOP }, /* 19 (arm,i386,m68k,ppc), 17 (alpha,sparc*), 23 (mips) */ ++ { "TSTP", SIGTSTP }, /* 20 (arm,i386,m68k,ppc), 18 (alpha,sparc*), 24 (mips) */ ++ { "TTIN", SIGTTIN }, /* 21 (arm,i386,m68k,ppc,alpha,sparc*), 26 (mips) */ ++ { "TTOU", SIGTTOU }, /* 22 (arm,i386,m68k,ppc,alpha,sparc*), 27 (mips) */ ++ /* Miscellaneous other signals */ ++#ifdef SIGTRAP ++ { "TRAP", SIGTRAP }, /* 5 */ ++#endif ++#ifdef SIGIOT ++ { "IOT", SIGIOT }, /* 6, same as SIGABRT */ ++#endif ++#ifdef SIGEMT ++ { "EMT", SIGEMT }, /* 7 (mips,alpha,sparc*) */ ++#endif ++#ifdef SIGBUS ++ { "BUS", SIGBUS }, /* 7 (arm,i386,m68k,ppc), 10 (mips,alpha,sparc*) */ ++#endif ++#ifdef SIGSYS ++ { "SYS", SIGSYS }, /* 12 (mips,alpha,sparc*) */ ++#endif ++#ifdef SIGSTKFLT ++ { "STKFLT", SIGSTKFLT }, /* 16 (arm,i386,m68k,ppc) */ ++#endif ++#ifdef SIGURG ++ { "URG", SIGURG }, /* 23 (arm,i386,m68k,ppc), 16 (alpha,sparc*), 21 (mips) */ ++#endif ++#ifdef SIGIO ++ { "IO", SIGIO }, /* 29 (arm,i386,m68k,ppc), 23 (alpha,sparc*), 22 (mips) */ ++#endif ++#ifdef SIGPOLL ++ { "POLL", SIGPOLL }, /* same as SIGIO */ ++#endif ++#ifdef SIGCLD ++ { "CLD", SIGCLD }, /* same as SIGCHLD (mips) */ ++#endif ++#ifdef SIGXCPU ++ { "XCPU", SIGXCPU }, /* 24 (arm,i386,m68k,ppc,alpha,sparc*), 30 (mips) */ ++#endif ++#ifdef SIGXFSZ ++ { "XFSZ", SIGXFSZ }, /* 25 (arm,i386,m68k,ppc,alpha,sparc*), 31 (mips) */ ++#endif ++#ifdef SIGVTALRM ++ { "VTALRM", SIGVTALRM }, /* 26 (arm,i386,m68k,ppc,alpha,sparc*), 28 (mips) */ ++#endif ++#ifdef SIGPROF ++ { "PROF", SIGPROF }, /* 27 (arm,i386,m68k,ppc,alpha,sparc*), 29 (mips) */ ++#endif ++#ifdef SIGPWR ++ { "PWR", SIGPWR }, /* 30 (arm,i386,m68k,ppc), 29 (alpha,sparc*), 19 (mips) */ ++#endif ++#ifdef SIGINFO ++ { "INFO", SIGINFO }, /* 29 (alpha) */ ++#endif ++#ifdef SIGLOST ++ { "LOST", SIGLOST }, /* 29 (arm,i386,m68k,ppc,sparc*) */ ++#endif ++#ifdef SIGWINCH ++ { "WINCH", SIGWINCH }, /* 28 (arm,i386,m68k,ppc,alpha,sparc*), 20 (mips) */ ++#endif ++#ifdef SIGUNUSED ++ { "UNUSED", SIGUNUSED }, /* 31 (arm,i386,m68k,ppc) */ ++#endif ++}; /* sys_signame[] */ ++ ++#endif /* POSIX_SIGNALS_H */ diff --git a/system/ksh/patches/linux/sh_h.diff b/system/ksh/patches/linux/sh_h.diff new file mode 100644 index 0000000000..df6de9c4c9 --- /dev/null +++ b/system/ksh/patches/linux/sh_h.diff @@ -0,0 +1,10 @@ +--- ksh-openbsd_cvs/sh.h 2010-02-23 12:49:21.000000000 +0100 ++++ ksh-openbsd_cvs.new/sh.h 2010-04-01 21:01:24.135232661 +0200 +@@ -16,6 +16,7 @@ + #include <stdbool.h> + #include <stddef.h> + #include <stdlib.h> ++#define __USE_GNU /* needed for setresuid() and setresgid() */ + #include <unistd.h> + #include <string.h> + #include <stdarg.h> diff --git a/system/ksh/patches/linux/strlcat_c.diff b/system/ksh/patches/linux/strlcat_c.diff new file mode 100644 index 0000000000..1137522fcb --- /dev/null +++ b/system/ksh/patches/linux/strlcat_c.diff @@ -0,0 +1,65 @@ +--- ksh-openbsd_cvs/strlcat.c 1970-01-01 01:00:00.000000000 +0100 ++++ ksh-openbsd_cvs.new/strlcat.c 2010-04-01 21:01:24.135232661 +0200 +@@ -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 --git a/system/ksh/patches/linux/strlcat_h.diff b/system/ksh/patches/linux/strlcat_h.diff new file mode 100644 index 0000000000..60eb6361f7 --- /dev/null +++ b/system/ksh/patches/linux/strlcat_h.diff @@ -0,0 +1,7 @@ +--- ksh-openbsd_cvs/strlcat.h 1970-01-01 01:00:00.000000000 +0100 ++++ ksh-openbsd_cvs.new/strlcat.h 2010-04-01 21:01:24.135232661 +0200 +@@ -0,0 +1,4 @@ ++#ifndef STRLCAT_H ++#define STRLCAT_H ++size_t strlcat(char *, const char *, size_t); ++#endif /* STRLCAT_H */ diff --git a/system/ksh/patches/linux/strlcpy_c.diff b/system/ksh/patches/linux/strlcpy_c.diff new file mode 100644 index 0000000000..a08f2614bf --- /dev/null +++ b/system/ksh/patches/linux/strlcpy_c.diff @@ -0,0 +1,61 @@ +--- ksh-openbsd_cvs/strlcpy.c 1970-01-01 01:00:00.000000000 +0100 ++++ ksh-openbsd_cvs.new/strlcpy.c 2010-04-01 21:01:24.145380963 +0200 +@@ -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 --git a/system/ksh/patches/linux/strlcpy_h.diff b/system/ksh/patches/linux/strlcpy_h.diff new file mode 100644 index 0000000000..d9f75cd41e --- /dev/null +++ b/system/ksh/patches/linux/strlcpy_h.diff @@ -0,0 +1,7 @@ +--- ksh-openbsd_cvs/strlcpy.h 1970-01-01 01:00:00.000000000 +0100 ++++ ksh-openbsd_cvs.new/strlcpy.h 2010-04-01 21:01:24.145380963 +0200 +@@ -0,0 +1,4 @@ ++#ifndef STRLCPY_H ++#define STRLCPY_H ++size_t strlcpy(char *, const char *, size_t); ++#endif /* STRLCPY_H */ diff --git a/system/ksh/patches/linux/trap_c.diff b/system/ksh/patches/linux/trap_c.diff new file mode 100644 index 0000000000..10f067ff06 --- /dev/null +++ b/system/ksh/patches/linux/trap_c.diff @@ -0,0 +1,45 @@ +--- ksh-openbsd_cvs/trap.c 2010-02-23 12:49:23.000000000 +0100 ++++ ksh-openbsd_cvs.new/trap.c 2010-04-01 21:30:25.819238979 +0200 +@@ -5,6 +5,7 @@ + */ + + #include "sh.h" ++#include "posix_signals.h" /* sys_signame[] */ + + Trap sigtraps[NSIG + 1]; + +@@ -13,20 +14,29 @@ static struct sigaction Sigact_ign, Siga + void + inittraps(void) + { +- int i; ++ int i, j; + +- /* Populate sigtraps based on sys_signame and sys_siglist. */ +- for (i = 0; i <= NSIG; i++) { ++ /* Populate sigtraps based on posix_signals.h */ ++ for (i = 1; 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]; ++ for(j = 0; j < NSIG; j++) /* find the corresponding SIGNAL number's name in the sys_signame[] array */ ++ { ++ if( sys_signame[j].val == sigtraps[i].signal ) /* we got a match */ ++ { ++ sigtraps[i].name = sys_signame[j].name; ++ break; ++ } ++ } ++ sigtraps[i].mess = strsignal(sigtraps[i].signal); + } + } ++ sigtraps[SIGEXIT_].signal = SIGEXIT_; + sigtraps[SIGEXIT_].name = "EXIT"; /* our name for signal 0 */ ++ sigtraps[SIGEXIT_].mess = "Exited"; + + sigemptyset(&Sigact_ign.sa_mask); + Sigact_ign.sa_flags = 0; /* interruptible */ diff --git a/system/ksh/patches/linux/var_c.diff b/system/ksh/patches/linux/var_c.diff new file mode 100644 index 0000000000..9483a3b4ce --- /dev/null +++ b/system/ksh/patches/linux/var_c.diff @@ -0,0 +1,53 @@ +--- ksh-openbsd_cvs/var.c 2010-02-23 12:49:23.000000000 +0100 ++++ ksh-openbsd_cvs.new/var.c 2010-04-01 21:01:24.145380963 +0200 +@@ -5,6 +5,7 @@ + #include "ksh_limval.h" + #include <sys/stat.h> + #include <ctype.h> ++#include "strlcpy.h" + + /* + * Variables +@@ -865,12 +866,6 @@ makenv(void) + } + + /* +- * Someone has set the srand() value, therefore from now on +- * we return values from rand() instead of arc4random() +- */ +-int use_rand = 0; +- +-/* + * Called after a fork in parent to bump the random number generator. + * Done to ensure children will not get the same random number sequence + * if the parent doesn't use $RANDOM. +@@ -878,8 +873,7 @@ int use_rand = 0; + void + change_random(void) + { +- if (use_rand) +- rand(); ++ rand(); + } + + /* +@@ -926,10 +920,7 @@ getspec(struct tbl *vp) + 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 +@@ -1030,7 +1021,6 @@ setspec(struct tbl *vp) + case V_RANDOM: + vp->flag &= ~SPECIAL; + srand((unsigned int)intval(vp)); +- use_rand = 1; + vp->flag |= SPECIAL; + break; + case V_SECONDS: diff --git a/system/ksh/patches/linux/vi_c.diff b/system/ksh/patches/linux/vi_c.diff new file mode 100644 index 0000000000..9372933d8e --- /dev/null +++ b/system/ksh/patches/linux/vi_c.diff @@ -0,0 +1,10 @@ +--- ksh-openbsd_cvs/vi.c 2010-02-23 12:49:24.000000000 +0100 ++++ ksh-openbsd_cvs.new/vi.c 2010-04-01 21:01:24.146107949 +0200 +@@ -13,6 +13,7 @@ + #include <ctype.h> + #include <sys/stat.h> /* completion */ + #include "edit.h" ++#include "strlcpy.h" + + #define CMDLEN 2048 + #define Ctrl(c) (c&0x1f) diff --git a/system/ksh/patches/port_to_linux.patch b/system/ksh/patches/port_to_linux.patch deleted file mode 100644 index ae9ba62f3d..0000000000 --- a/system/ksh/patches/port_to_linux.patch +++ /dev/null @@ -1,656 +0,0 @@ -diff -puNr ksh-openbsd_cvs/charclass.h ksh-openbsd_cvs.new/charclass.h ---- ksh-openbsd_cvs/charclass.h 1970-01-01 01:00:00.000000000 +0100 -+++ ksh-openbsd_cvs.new/charclass.h 2010-04-01 21:01:24.132137763 +0200 -@@ -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 -puNr ksh-openbsd_cvs/c_sh.c ksh-openbsd_cvs.new/c_sh.c ---- ksh-openbsd_cvs/c_sh.c 2010-03-27 17:25:30.000000000 +0100 -+++ ksh-openbsd_cvs.new/c_sh.c 2010-04-01 21:01:24.132137763 +0200 -@@ -837,19 +837,13 @@ c_mknod(char **wp) - { - int argc, optc, ismkfifo = 0, ret; - char **argv; -- void *set = NULL; -- mode_t mode = 0, oldmode = 0; -+ mode_t mode = 0, old_umask = -1; - - 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"); -- return 1; -- } -- mode = getmode(set, DEFFILEMODE); -- free(set); -+ old_umask = umask(0); -+ mode |= strtoul(builtin_opt.optarg, NULL, 8); - break; - default: - goto usage; -@@ -866,18 +860,17 @@ c_mknod(char **wp) - } else if (argc != 4) - goto usage; - -- if (set) -- oldmode = umask(0); -- else -- mode = DEFFILEMODE; -+ if (old_umask == -1) -+ mode |= DEFFILEMODE; - - if (ismkfifo) - ret = domkfifo(argc, argv, mode); - else - ret = domknod(argc, argv, mode); - -- if (set) -- umask(oldmode); -+ if (old_umask != -1) -+ umask(old_umask); -+ - return ret; - usage: - builtin_argv0 = NULL; -diff -puNr ksh-openbsd_cvs/emacs.c ksh-openbsd_cvs.new/emacs.c ---- ksh-openbsd_cvs/emacs.c 2010-02-23 12:49:15.000000000 +0100 -+++ ksh-openbsd_cvs.new/emacs.c 2010-04-01 21:01:24.133232595 +0200 -@@ -16,6 +16,7 @@ - #include <ctype.h> - #include <locale.h> - #include "edit.h" -+#include "strlcpy.h" - - static Area aedit; - #define AEDIT &aedit /* area for kill ring and macro defns */ -diff -puNr ksh-openbsd_cvs/eval.c ksh-openbsd_cvs.new/eval.c ---- ksh-openbsd_cvs/eval.c 2010-03-26 19:46:20.000000000 +0100 -+++ ksh-openbsd_cvs.new/eval.c 2010-04-01 21:01:24.133232595 +0200 -@@ -8,6 +8,7 @@ - #include <pwd.h> - #include <dirent.h> - #include <sys/stat.h> -+#include "strlcpy.h" - - /* - * string expansion -@@ -265,7 +266,7 @@ expand(char *cp, /* input word */ - { - char *varname = ++sp; /* skip the { or x (}) */ - int stype; -- int slen; -+ int slen = 0; - - sp = strchr(sp, '\0') + 1; /* skip variable */ - type = varsub(&x, varname, sp, &stype, &slen); -@@ -689,7 +690,7 @@ varsub(Expand *xp, char *sp, char *word, - int c; - int state; /* next state: XBASE, XARG, XSUB, XNULLSUB */ - int stype; /* substitution type */ -- int slen; -+ int slen = 0; - char *p; - struct tbl *vp; - -diff -puNr ksh-openbsd_cvs/history.c ksh-openbsd_cvs.new/history.c ---- ksh-openbsd_cvs/history.c 2010-02-23 12:49:16.000000000 +0100 -+++ ksh-openbsd_cvs.new/history.c 2010-04-01 21:01:24.133232595 +0200 -@@ -17,6 +17,7 @@ - - #include "sh.h" - #include <sys/stat.h> -+#include "strlcat.h" - - #ifdef HISTORY - # include <sys/file.h> -diff -puNr ksh-openbsd_cvs/jobs.c ksh-openbsd_cvs.new/jobs.c ---- ksh-openbsd_cvs/jobs.c 2010-02-23 12:49:17.000000000 +0100 -+++ ksh-openbsd_cvs.new/jobs.c 2010-04-01 21:01:24.133232595 +0200 -@@ -21,6 +21,19 @@ - #include <sys/time.h> - #include <sys/resource.h> - #include "tty.h" -+#include "strlcpy.h" -+ -+#ifndef CHILD_MAX -+# if defined(HAVE_SYSCONF) && defined(_SC_CHILD_MAX) -+# define CHILD_MAX sysconf(_SC_CHILD_MAX) -+# else /* _SC_CHILD_MAX */ -+# ifdef _POSIX_CHILD_MAX -+# define CHILD_MAX ((_POSIX_CHILD_MAX) * 2) -+# else /* _POSIX_CHILD_MAX */ -+# define CHILD_MAX 20 -+# endif /* _POSIX_CHILD_MAX */ -+# endif /* _SC_CHILD_MAX */ -+#endif /* !CHILD_MAX */ - - /* Order important! */ - #define PRUNNING 0 -diff -puNr ksh-openbsd_cvs/lex.c ksh-openbsd_cvs.new/lex.c ---- ksh-openbsd_cvs/lex.c 2010-02-23 12:49:19.000000000 +0100 -+++ ksh-openbsd_cvs.new/lex.c 2010-04-01 21:01:24.134232647 +0200 -@@ -7,6 +7,8 @@ - #include "sh.h" - #include <libgen.h> - #include <ctype.h> -+#include <time.h> -+#include "strlcpy.h" - - - /* Structure to keep track of the lexing state and the various pieces of info -diff -puNr ksh-openbsd_cvs/main.c ksh-openbsd_cvs.new/main.c ---- ksh-openbsd_cvs/main.c 2010-02-23 12:49:19.000000000 +0100 -+++ ksh-openbsd_cvs.new/main.c 2010-04-01 21:01:24.134232647 +0200 -@@ -9,7 +9,12 @@ - #include "sh.h" - #include <sys/stat.h> - #include <pwd.h> -+#include "strlcpy.h" - -+/* on Linux we do not have _PW_NAME_LEN, but libc6 allows us 32 character usernames */ -+#ifndef _PW_NAME_LEN -+# define _PW_NAME_LEN 31 -+#endif - extern char **environ; - - /* -diff -puNr ksh-openbsd_cvs/Makefile ksh-openbsd_cvs.new/Makefile ---- ksh-openbsd_cvs/Makefile 2010-02-23 12:49:12.000000000 +0100 -+++ ksh-openbsd_cvs.new/Makefile 2010-04-01 21:21:23.498239164 +0200 -@@ -1,28 +1,43 @@ --# $OpenBSD: Makefile,v 1.27 2009/03/03 20:01:01 millert Exp $ -+ifdef ${PREFIX} -+PREFIX=${PREFIX} -+else -+PREFIX=/usr -+endif -+BINDIR=${DESTDIR}/bin -+MANDIR=${DESTDIR}${PREFIX}/man - - 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 -- --DEFS= -Wall --CFLAGS+=${DEFS} -I. -I${.CURDIR} -I${.CURDIR}/../../lib/libc/gen --MAN= ksh.1 sh.1 -+ version.c vi.c strlcpy.c strlcat.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 - - CLEANFILES+= emacs.out - --LINKS= ${BINDIR}/ksh ${BINDIR}/rksh --LINKS+= ${BINDIR}/ksh ${BINDIR}/sh --MLINKS= ksh.1 rksh.1 -+all: $(PROG) -+ -+CFLAGS+=-Wall -+$(PROG): $(OBJS) -+ gcc $(OBJS) -o ksh -+ -+install: -+ install -m755 -d $(BINDIR) -+ install -m755 --strip --no-target-directory ksh $(BINDIR)/pdksh -+ install -m755 -d $(MANDIR)/man1 -+ install -m644 --no-target-directory ksh.1 $(MANDIR)/man1/pdksh.1 -+ -+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> -diff -puNr ksh-openbsd_cvs/misc.c ksh-openbsd_cvs.new/misc.c ---- ksh-openbsd_cvs/misc.c 2010-02-23 12:49:20.000000000 +0100 -+++ ksh-openbsd_cvs.new/misc.c 2010-04-01 21:01:24.134232647 +0200 -@@ -7,7 +7,9 @@ - #include "sh.h" - #include <ctype.h> - #include <sys/param.h> /* for MAXPATHLEN */ -+#include <grp.h> - #include "charclass.h" -+#include "strlcpy.h" - - short ctypes [UCHAR_MAX+1]; /* type bits for unsigned char */ - -diff -puNr ksh-openbsd_cvs/posix_signals.h ksh-openbsd_cvs.new/posix_signals.h ---- ksh-openbsd_cvs/posix_signals.h 1970-01-01 01:00:00.000000000 +0100 -+++ ksh-openbsd_cvs.new/posix_signals.h 2010-04-01 21:01:24.134232647 +0200 -@@ -0,0 +1,125 @@ -+/* -+ * Copyright (c) 1988, 1993, 1994 -+ * The Regents of the University of California. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in the -+ * documentation and/or other materials provided with the distribution. -+ * 3. All advertising materials mentioning features or use of this software -+ * must display the following acknowledgement: -+ * This product includes software developed by the University of -+ * California, Berkeley and its contributors. -+ * 4. Neither the name of the University nor the names of its contributors -+ * may be used to endorse or promote products derived from this software -+ * without specific prior written permission. -+ * -+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -+ * SUCH DAMAGE. -+ */ -+/* -+ Taken from misc-utils/kill.c in the util-linux-ng package. -+ ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/ -+ */ -+ -+#ifndef POSIX_SIGNALS_H -+#define POSIX_SIGNALS_H -+ -+struct signv { -+ char *name; -+ int val; -+} sys_signame[NSIG] = { -+ /* POSIX signals */ -+ { "HUP", SIGHUP }, /* 1 */ -+ { "INT", SIGINT }, /* 2 */ -+ { "QUIT", SIGQUIT }, /* 3 */ -+ { "ILL", SIGILL }, /* 4 */ -+ { "ABRT", SIGABRT }, /* 6 */ -+ { "FPE", SIGFPE }, /* 8 */ -+ { "KILL", SIGKILL }, /* 9 */ -+ { "SEGV", SIGSEGV }, /* 11 */ -+ { "PIPE", SIGPIPE }, /* 13 */ -+ { "ALRM", SIGALRM }, /* 14 */ -+ { "TERM", SIGTERM }, /* 15 */ -+ { "USR1", SIGUSR1 }, /* 10 (arm,i386,m68k,ppc), 30 (alpha,sparc*), 16 (mips) */ -+ { "USR2", SIGUSR2 }, /* 12 (arm,i386,m68k,ppc), 31 (alpha,sparc*), 17 (mips) */ -+ { "CHLD", SIGCHLD }, /* 17 (arm,i386,m68k,ppc), 20 (alpha,sparc*), 18 (mips) */ -+ { "CONT", SIGCONT }, /* 18 (arm,i386,m68k,ppc), 19 (alpha,sparc*), 25 (mips) */ -+ { "STOP", SIGSTOP }, /* 19 (arm,i386,m68k,ppc), 17 (alpha,sparc*), 23 (mips) */ -+ { "TSTP", SIGTSTP }, /* 20 (arm,i386,m68k,ppc), 18 (alpha,sparc*), 24 (mips) */ -+ { "TTIN", SIGTTIN }, /* 21 (arm,i386,m68k,ppc,alpha,sparc*), 26 (mips) */ -+ { "TTOU", SIGTTOU }, /* 22 (arm,i386,m68k,ppc,alpha,sparc*), 27 (mips) */ -+ /* Miscellaneous other signals */ -+#ifdef SIGTRAP -+ { "TRAP", SIGTRAP }, /* 5 */ -+#endif -+#ifdef SIGIOT -+ { "IOT", SIGIOT }, /* 6, same as SIGABRT */ -+#endif -+#ifdef SIGEMT -+ { "EMT", SIGEMT }, /* 7 (mips,alpha,sparc*) */ -+#endif -+#ifdef SIGBUS -+ { "BUS", SIGBUS }, /* 7 (arm,i386,m68k,ppc), 10 (mips,alpha,sparc*) */ -+#endif -+#ifdef SIGSYS -+ { "SYS", SIGSYS }, /* 12 (mips,alpha,sparc*) */ -+#endif -+#ifdef SIGSTKFLT -+ { "STKFLT", SIGSTKFLT }, /* 16 (arm,i386,m68k,ppc) */ -+#endif -+#ifdef SIGURG -+ { "URG", SIGURG }, /* 23 (arm,i386,m68k,ppc), 16 (alpha,sparc*), 21 (mips) */ -+#endif -+#ifdef SIGIO -+ { "IO", SIGIO }, /* 29 (arm,i386,m68k,ppc), 23 (alpha,sparc*), 22 (mips) */ -+#endif -+#ifdef SIGPOLL -+ { "POLL", SIGPOLL }, /* same as SIGIO */ -+#endif -+#ifdef SIGCLD -+ { "CLD", SIGCLD }, /* same as SIGCHLD (mips) */ -+#endif -+#ifdef SIGXCPU -+ { "XCPU", SIGXCPU }, /* 24 (arm,i386,m68k,ppc,alpha,sparc*), 30 (mips) */ -+#endif -+#ifdef SIGXFSZ -+ { "XFSZ", SIGXFSZ }, /* 25 (arm,i386,m68k,ppc,alpha,sparc*), 31 (mips) */ -+#endif -+#ifdef SIGVTALRM -+ { "VTALRM", SIGVTALRM }, /* 26 (arm,i386,m68k,ppc,alpha,sparc*), 28 (mips) */ -+#endif -+#ifdef SIGPROF -+ { "PROF", SIGPROF }, /* 27 (arm,i386,m68k,ppc,alpha,sparc*), 29 (mips) */ -+#endif -+#ifdef SIGPWR -+ { "PWR", SIGPWR }, /* 30 (arm,i386,m68k,ppc), 29 (alpha,sparc*), 19 (mips) */ -+#endif -+#ifdef SIGINFO -+ { "INFO", SIGINFO }, /* 29 (alpha) */ -+#endif -+#ifdef SIGLOST -+ { "LOST", SIGLOST }, /* 29 (arm,i386,m68k,ppc,sparc*) */ -+#endif -+#ifdef SIGWINCH -+ { "WINCH", SIGWINCH }, /* 28 (arm,i386,m68k,ppc,alpha,sparc*), 20 (mips) */ -+#endif -+#ifdef SIGUNUSED -+ { "UNUSED", SIGUNUSED }, /* 31 (arm,i386,m68k,ppc) */ -+#endif -+}; /* sys_signame[] */ -+ -+#endif /* POSIX_SIGNALS_H */ -diff -puNr ksh-openbsd_cvs/sh.h ksh-openbsd_cvs.new/sh.h ---- ksh-openbsd_cvs/sh.h 2010-02-23 12:49:21.000000000 +0100 -+++ ksh-openbsd_cvs.new/sh.h 2010-04-01 21:01:24.135232661 +0200 -@@ -16,6 +16,7 @@ - #include <stdbool.h> - #include <stddef.h> - #include <stdlib.h> -+#define __USE_GNU /* needed for setresuid() and setresgid() */ - #include <unistd.h> - #include <string.h> - #include <stdarg.h> -diff -puNr ksh-openbsd_cvs/strlcat.c ksh-openbsd_cvs.new/strlcat.c ---- ksh-openbsd_cvs/strlcat.c 1970-01-01 01:00:00.000000000 +0100 -+++ ksh-openbsd_cvs.new/strlcat.c 2010-04-01 21:01:24.135232661 +0200 -@@ -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 -puNr ksh-openbsd_cvs/strlcat.h ksh-openbsd_cvs.new/strlcat.h ---- ksh-openbsd_cvs/strlcat.h 1970-01-01 01:00:00.000000000 +0100 -+++ ksh-openbsd_cvs.new/strlcat.h 2010-04-01 21:01:24.135232661 +0200 -@@ -0,0 +1,4 @@ -+#ifndef STRLCAT_H -+#define STRLCAT_H -+size_t strlcat(char *, const char *, size_t); -+#endif /* STRLCAT_H */ -diff -puNr ksh-openbsd_cvs/strlcpy.c ksh-openbsd_cvs.new/strlcpy.c ---- ksh-openbsd_cvs/strlcpy.c 1970-01-01 01:00:00.000000000 +0100 -+++ ksh-openbsd_cvs.new/strlcpy.c 2010-04-01 21:01:24.145380963 +0200 -@@ -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 -puNr ksh-openbsd_cvs/strlcpy.h ksh-openbsd_cvs.new/strlcpy.h ---- ksh-openbsd_cvs/strlcpy.h 1970-01-01 01:00:00.000000000 +0100 -+++ ksh-openbsd_cvs.new/strlcpy.h 2010-04-01 21:01:24.145380963 +0200 -@@ -0,0 +1,4 @@ -+#ifndef STRLCPY_H -+#define STRLCPY_H -+size_t strlcpy(char *, const char *, size_t); -+#endif /* STRLCPY_H */ -diff -puNr ksh-openbsd_cvs/trap.c ksh-openbsd_cvs.new/trap.c ---- ksh-openbsd_cvs/trap.c 2010-02-23 12:49:23.000000000 +0100 -+++ ksh-openbsd_cvs.new/trap.c 2010-04-01 21:30:25.819238979 +0200 -@@ -5,6 +5,7 @@ - */ - - #include "sh.h" -+#include "posix_signals.h" /* sys_signame[] */ - - Trap sigtraps[NSIG + 1]; - -@@ -13,20 +14,29 @@ static struct sigaction Sigact_ign, Siga - void - inittraps(void) - { -- int i; -+ int i, j; - -- /* Populate sigtraps based on sys_signame and sys_siglist. */ -- for (i = 0; i <= NSIG; i++) { -+ /* Populate sigtraps based on posix_signals.h */ -+ for (i = 1; 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]; -+ for(j = 0; j < NSIG; j++) /* find the corresponding SIGNAL number's name in the sys_signame[] array */ -+ { -+ if( sys_signame[j].val == sigtraps[i].signal ) /* we got a match */ -+ { -+ sigtraps[i].name = sys_signame[j].name; -+ break; -+ } -+ } -+ sigtraps[i].mess = strsignal(sigtraps[i].signal); - } - } -+ sigtraps[SIGEXIT_].signal = SIGEXIT_; - sigtraps[SIGEXIT_].name = "EXIT"; /* our name for signal 0 */ -+ sigtraps[SIGEXIT_].mess = "Exited"; - - sigemptyset(&Sigact_ign.sa_mask); - Sigact_ign.sa_flags = 0; /* interruptible */ -diff -puNr ksh-openbsd_cvs/var.c ksh-openbsd_cvs.new/var.c ---- ksh-openbsd_cvs/var.c 2010-02-23 12:49:23.000000000 +0100 -+++ ksh-openbsd_cvs.new/var.c 2010-04-01 21:01:24.145380963 +0200 -@@ -5,6 +5,7 @@ - #include "ksh_limval.h" - #include <sys/stat.h> - #include <ctype.h> -+#include "strlcpy.h" - - /* - * Variables -@@ -865,12 +866,6 @@ makenv(void) - } - - /* -- * Someone has set the srand() value, therefore from now on -- * we return values from rand() instead of arc4random() -- */ --int use_rand = 0; -- --/* - * Called after a fork in parent to bump the random number generator. - * Done to ensure children will not get the same random number sequence - * if the parent doesn't use $RANDOM. -@@ -878,8 +873,7 @@ int use_rand = 0; - void - change_random(void) - { -- if (use_rand) -- rand(); -+ rand(); - } - - /* -@@ -926,10 +920,7 @@ getspec(struct tbl *vp) - 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 -@@ -1030,7 +1021,6 @@ setspec(struct tbl *vp) - case V_RANDOM: - vp->flag &= ~SPECIAL; - srand((unsigned int)intval(vp)); -- use_rand = 1; - vp->flag |= SPECIAL; - break; - case V_SECONDS: -diff -puNr ksh-openbsd_cvs/vi.c ksh-openbsd_cvs.new/vi.c ---- ksh-openbsd_cvs/vi.c 2010-02-23 12:49:24.000000000 +0100 -+++ ksh-openbsd_cvs.new/vi.c 2010-04-01 21:01:24.146107949 +0200 -@@ -13,6 +13,7 @@ - #include <ctype.h> - #include <sys/stat.h> /* completion */ - #include "edit.h" -+#include "strlcpy.h" - - #define CMDLEN 2048 - #define Ctrl(c) (c&0x1f) diff --git a/system/ksh/slack-desc b/system/ksh/slack-desc index 9e0371da83..9977de06f3 100644 --- a/system/ksh/slack-desc +++ b/system/ksh/slack-desc @@ -9,7 +9,7 @@ ksh: ksh (OpenBSD ksh ported to Linux) ksh: ksh: This package is a patched version of the OpenBSD ksh, which is based -ksh: on the original PD-ksh, but heavily modified and maintained by +ksh: on the original PD-ksh, but heavily modified and maintained by ksh: OpenBSD developers. "Patched" means ported to Linux. ksh: ksh: |