diff options
-rw-r--r-- | bin/ksh/Makefile | 5 | ||||
-rw-r--r-- | bin/ksh/c_sh.c | 61 | ||||
-rw-r--r-- | bin/ksh/ksh.1 | 43 | ||||
-rw-r--r-- | bin/ksh/main.c | 4 | ||||
-rw-r--r-- | bin/ksh/mknod.c | 94 | ||||
-rw-r--r-- | bin/ksh/sh.h | 5 | ||||
-rw-r--r-- | distrib/special/ksh/Makefile | 6 |
7 files changed, 11 insertions, 207 deletions
diff --git a/bin/ksh/Makefile b/bin/ksh/Makefile index b330267b628..b468996de27 100644 --- a/bin/ksh/Makefile +++ b/bin/ksh/Makefile @@ -1,12 +1,11 @@ -# $OpenBSD: Makefile,v 1.31 2015/10/22 02:29:20 mmcc Exp $ +# $OpenBSD: Makefile,v 1.32 2016/03/04 15:11:06 deraadt Exp $ 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 \ + exec.c expr.c history.c io.c jobs.c lex.c mail.c main.c \ misc.c path.c shf.c syn.c table.c trap.c tree.c tty.c var.c \ version.c vi.c -# -DMKNOD - enable builtin mknod; conflicts with pledge(2) DEFS= -Wall CFLAGS+=${DEFS} -I. -I${.CURDIR} -I${.CURDIR}/../../lib/libc/gen MAN= ksh.1 sh.1 diff --git a/bin/ksh/c_sh.c b/bin/ksh/c_sh.c index a5cc99282f9..4e40c464ecb 100644 --- a/bin/ksh/c_sh.c +++ b/bin/ksh/c_sh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_sh.c,v 1.58 2015/12/30 09:07:00 tedu Exp $ */ +/* $OpenBSD: c_sh.c,v 1.59 2016/03/04 15:11:06 deraadt Exp $ */ /* * built-in Bourne commands @@ -826,62 +826,6 @@ c_exec(char **wp) return 0; } -#ifdef MKNOD -static int -c_mknod(char **wp) -{ - int argc, optc, ismkfifo = 0, ret; - char **argv; - void *set = NULL; - mode_t mode = 0, oldmode = 0; - - 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); - break; - default: - goto usage; - } - } - argv = &wp[builtin_opt.optind]; - if (argv[0] == NULL) - goto usage; - for (argc = 0; argv[argc]; argc++) - ; - if (argc == 2 && argv[1][0] == 'p') { - ismkfifo = 1; - argc--; - } else if (argc != 4) - goto usage; - - if (set) - oldmode = umask(0); - else - mode = DEFFILEMODE; - - if (ismkfifo) - ret = domkfifo(argc, argv, mode); - else - ret = domknod(argc, argv, mode); - - if (set) - umask(oldmode); - return ret; -usage: - builtin_argv0 = NULL; - bi_errorf("usage: mknod [-m mode] name b|c major minor"); - bi_errorf("usage: mknod [-m mode] name p"); - return 1; -} -#endif /* MKNOD */ - static int c_suspend(char **wp) { @@ -940,9 +884,6 @@ const struct builtin shbuiltins [] = { {"ulimit", c_ulimit}, {"+umask", c_umask}, {"*=unset", c_unset}, -#ifdef MKNOD - {"mknod", c_mknod}, -#endif {"suspend", c_suspend}, {NULL, NULL} }; diff --git a/bin/ksh/ksh.1 b/bin/ksh/ksh.1 index 164fe2f4b9e..bfe5c812876 100644 --- a/bin/ksh/ksh.1 +++ b/bin/ksh/ksh.1 @@ -1,8 +1,8 @@ -.\" $OpenBSD: ksh.1,v 1.173 2015/12/29 01:02:34 mmcc Exp $ +.\" $OpenBSD: ksh.1,v 1.174 2016/03/04 15:11:06 deraadt Exp $ .\" .\" Public Domain .\" -.Dd $Mdocdate: December 29 2015 $ +.Dd $Mdocdate: March 4 2016 $ .Dt KSH 1 .Os .Sh NAME @@ -2717,7 +2717,7 @@ Additional .Nm regular commands .Pp -.Ic \&[ , echo , let , mknod , +.Ic \&[ , echo , let , .Ic print , suspend , test , .Ic ulimit , whence .Pp @@ -3321,43 +3321,6 @@ is syntactic sugar for .No let \&" Ns Ar expr Ns \&" . .Pp .It Xo -.Ic mknod -.Op Fl m Ar mode -.Ar name -.Cm b Ns Pf | Cm c -.Ar major minor -.Xc -.It Xo -.Ic mknod -.Op Fl m Ar mode -.Ar name -.Cm p -.Xc -Create a device special file. -The file type may be -.Cm b -(block type device), -.Cm c -(character type device), -or -.Cm p -(named pipe). -The file created may be modified according to its -.Ar mode -(via the -.Fl m -option), -.Ar major -(major device number), -and -.Ar minor -(minor device number). -.Pp -See -.Xr mknod 8 -for further information. -.Pp -.It Xo .Ic print .Oo .Fl nprsu Ns Oo Ar n Oc | diff --git a/bin/ksh/main.c b/bin/ksh/main.c index e0fb38fcfa7..c0e5f67a18a 100644 --- a/bin/ksh/main.c +++ b/bin/ksh/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.78 2015/12/30 09:07:00 tedu Exp $ */ +/* $OpenBSD: main.c,v 1.79 2016/03/04 15:11:06 deraadt Exp $ */ /* * startup, main loop, environments and error handling @@ -152,13 +152,11 @@ main(int argc, char *argv[]) kshname = argv[0]; -#ifndef MKNOD if (pledge("stdio rpath wpath cpath fattr flock getpw proc exec tty", NULL) == -1) { perror("pledge"); exit(1); } -#endif ainit(&aperm); /* initialize permanent Area */ diff --git a/bin/ksh/mknod.c b/bin/ksh/mknod.c deleted file mode 100644 index 1c849ba1a00..00000000000 --- a/bin/ksh/mknod.c +++ /dev/null @@ -1,94 +0,0 @@ -/* $OpenBSD: mknod.c,v 1.5 2015/12/14 13:59:42 tb Exp $ */ -/* $NetBSD: mknod.c,v 1.8 1995/08/11 00:08:18 jtc Exp $ */ - -/* - * Copyright (c) 1989, 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Kevin Fall. - * - * 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. 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. - */ - -#include <sys/types.h> -#include <sys/stat.h> - -#include <errno.h> -#include <stdlib.h> -#include <string.h> - -#include "sh.h" - -int -domknod(int argc, char **argv, mode_t mode) -{ - dev_t dev; - char *endp; - u_int major, minor; - - if (argv[1][0] == 'c') - mode |= S_IFCHR; - else if (argv[1][0] == 'b') - mode |= S_IFBLK; - else { - bi_errorf("node must be type 'b' or 'c'."); - return 1; - } - - major = (long)strtoul(argv[2], &endp, 0); - if (endp == argv[2] || *endp != '\0') { - bi_errorf("non-numeric major number."); - return 1; - } - minor = (long)strtoul(argv[3], &endp, 0); - if (endp == argv[3] || *endp != '\0') { - bi_errorf("non-numeric minor number."); - return 1; - } - dev = makedev(major, minor); - if (major(dev) != major || minor(dev) != minor) { - bi_errorf("major or minor number too large"); - return 1; - } - if (mknod(argv[0], mode, dev) < 0) { - bi_errorf("%s: %s", argv[0], strerror(errno)); - return 1; - } - return 0; -} - -int -domkfifo(int argc, char **argv, mode_t mode) -{ - int rv = 0; - - if (mkfifo(argv[0], mode) < 0) { - bi_errorf("%s: %s", argv[0], strerror(errno)); - rv = 1; - } - return(rv); -} - diff --git a/bin/ksh/sh.h b/bin/ksh/sh.h index 298fc4454a4..16f609d0699 100644 --- a/bin/ksh/sh.h +++ b/bin/ksh/sh.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sh.h,v 1.56 2015/12/30 09:07:00 tedu Exp $ */ +/* $OpenBSD: sh.h,v 1.57 2016/03/04 15:11:06 deraadt Exp $ */ /* * Public Domain Bourne/Korn shell @@ -557,9 +557,6 @@ int strip_nuls(char *, int); int blocking_read(int, char *, int); int reset_nonblock(int); char *ksh_get_wd(char *, int); -/* mknod.c */ -int domknod(int, char **, mode_t); -int domkfifo(int, char **, mode_t); /* path.c */ int make_path(const char *, const char *, char **, XString *, int *); void simplify_path(char *); diff --git a/distrib/special/ksh/Makefile b/distrib/special/ksh/Makefile index 00cd33dc112..0ac9d479f3e 100644 --- a/distrib/special/ksh/Makefile +++ b/distrib/special/ksh/Makefile @@ -1,12 +1,12 @@ -# $OpenBSD: Makefile,v 1.2 2015/10/10 00:10:07 deraadt Exp $ +# $OpenBSD: Makefile,v 1.3 2016/03/04 15:11:07 deraadt Exp $ 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 \ + exec.c expr.c history.c io.c jobs.c lex.c mail.c main.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 -DMKNOD +DEFS= -Wall CFLAGS+=${DEFS} -I. -I${.CURDIR}/../../../bin/ksh -I${.CURDIR}/../../../lib/libc/gen MAN= ksh.1 sh.1 |