aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2019-06-06 16:20:50 +0000
committerAlan Somers <asomers@FreeBSD.org>2019-06-06 16:20:50 +0000
commit0269ae4c19ad779b43b0d6e2416ac7386945d692 (patch)
treeab5e303c6cb3ded1f908fed5b0cd47780ddda696 /usr.bin
parentd10b757886cc63e5f5f5b6e798a20e339d5937bb (diff)
parentfbc27301ba4280886011dfb924c78402829b57cc (diff)
Notes
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/Makefile1
-rw-r--r--usr.bin/awk/Makefile2
-rw-r--r--usr.bin/calendar/calendars/calendar.freebsd10
-rw-r--r--usr.bin/clang/Makefile6
-rw-r--r--usr.bin/grep/grep.c16
-rw-r--r--usr.bin/login/Makefile5
-rw-r--r--usr.bin/login/login.access46
-rw-r--r--usr.bin/posixshmcontrol/Makefile7
-rw-r--r--usr.bin/posixshmcontrol/posixshmcontrol.1152
-rw-r--r--usr.bin/posixshmcontrol/posixshmcontrol.c480
-rw-r--r--usr.bin/tail/Makefile6
-rw-r--r--usr.bin/tail/tail.c25
-rw-r--r--usr.bin/tar/tests/Makefile1
-rw-r--r--usr.bin/vmstat/vmstat.c4
-rw-r--r--usr.bin/vtfontcvt/vtfontcvt.c41
15 files changed, 772 insertions, 30 deletions
diff --git a/usr.bin/Makefile b/usr.bin/Makefile
index c9620c7b87a12..75ea3b7426a41 100644
--- a/usr.bin/Makefile
+++ b/usr.bin/Makefile
@@ -114,6 +114,7 @@ SUBDIR= alias \
patch \
pathchk \
perror \
+ posixshmcontrol \
pr \
printenv \
printf \
diff --git a/usr.bin/awk/Makefile b/usr.bin/awk/Makefile
index a7c0442d57d56..4ea401b99cd7c 100644
--- a/usr.bin/awk/Makefile
+++ b/usr.bin/awk/Makefile
@@ -25,7 +25,7 @@ ytab.h: awkgram.c awkgram.h .NOMETA
ln -sf ${.ALLSRC:M*.h} ${.TARGET}
proctab.c: maketab
- ${BTOOLSPATH:U.}/maketab > proctab.c
+ ${BTOOLSPATH:U.}/maketab awkgram.h > proctab.c
build-tools: maketab
maketab: ytab.h maketab.c ${BUILD_TOOLS_META}
diff --git a/usr.bin/calendar/calendars/calendar.freebsd b/usr.bin/calendar/calendars/calendar.freebsd
index 40fd878e7a77c..9b6fd060b9d85 100644
--- a/usr.bin/calendar/calendars/calendar.freebsd
+++ b/usr.bin/calendar/calendars/calendar.freebsd
@@ -15,6 +15,8 @@
01/02 Patrick Li <pat@FreeBSD.org> born in Beijing, People's Republic of China, 1985
01/03 Tetsurou Okazaki <okazaki@FreeBSD.org> born in Mobara, Chiba, Japan, 1972
01/04 Hiroyuki Hanai <hanai@FreeBSD.org> born in Kagawa pre., Japan, 1969
+01/05 D Scott Phillips <scottph@FreeBSD.org> born in Anderson, Indiana, 1983
+01/06 Adriaan de Groot <adridg@FreeBSD.org> born in Calgary, Canada, 1973
01/06 Philippe Audeoud <jadawin@FreeBSD.org> born in Bretigny-Sur-Orge, France, 1980
01/08 Michael L. Hostbaek <mich@FreeBSD.org> born in Copenhagen, Denmark, 1977
01/10 Jean-Yves Lefort <jylefort@FreeBSD.org> born in Charleroi, Belgium, 1980
@@ -61,6 +63,7 @@
02/02 Yoichi Nakayama <yoichi@FreeBSD.org> born in Tsu, Mie, Japan, 1976
02/02 Yoshihiro Takahashi <nyan@FreeBSD.org> born in Yokohama, Kanagawa, Japan, 1976
02/03 Jason Helfman <jgh@FreeBSD.org> born in Royal Oak, Michigan, United States, 1972
+02/03 Mateusz Piotrowski <0mp@FreeBSD.org> born in Warsaw, Poland, 1995
02/04 Eitan Adler <eadler@FreeBSD.org> born in West Hempstead, New York, United States, 1991
02/05 Frank Laszlo <laszlof@FreeBSD.org> born in Howell, Michigan, United States, 1983
02/06 Julien Charbon <jch@FreeBSD.org> born in Saint Etienne, Loire, France, 1978
@@ -91,6 +94,7 @@
02/24 Johan Karlsson <johan@FreeBSD.org> born in Mariannelund, Sweden, 1974
02/24 Colin Percival <cperciva@FreeBSD.org> born in Burnaby, Canada, 1981
02/24 Kevin Bowling <kbowling@FreeBSD.org> born in Scottsdale, Arizona, United States, 1989
+02/24 Brandon Bergren <bdragon@FreeBSD.org> born in Edmond, Oklahoma, United States, 1984
02/26 Pietro Cerutti <gahr@FreeBSD.org> born in Faido, Switzerland, 1984
02/28 Daichi GOTO <daichi@FreeBSD.org> born in Shimizu Suntou, Shizuoka, Japan, 1980
02/28 Ruslan Makhmatkhanov <rm@FreeBSD.org> born in Rostov-on-Don, USSR, 1984
@@ -368,6 +372,7 @@
09/23 Michael Dexter <dexter@FreeBSD.org> born in Los Angeles, California, 1972
09/23 Martin Matuska <mm@FreeBSD.org> born in Bratislava, Slovakia, 1979
09/24 Larry Rosenman <ler@FreeBSD.org> born in Queens, New York, United States, 1957
+09/25 Piotr Kubaj <pkubaj@FreeBSD.org> born in Lubin, Poland, 1991
09/27 Kyle Evans <kevans@FreeBSD.org> born in Oklahoma City, Oklahoma, United States, 1991
09/27 Neil Blakey-Milner <nbm@FreeBSD.org> born in Port Elizabeth, South Africa, 1978
09/27 Renato Botelho <garga@FreeBSD.org> born in Araras, Sao Paulo, Brazil, 1979
@@ -382,6 +387,7 @@
10/05 Hiroki Sato <hrs@FreeBSD.org> born in Yamagata, Japan, 1977
10/05 Chris Costello <chris@FreeBSD.org> born in Houston, Texas, United States, 1985
10/09 Stefan Walter <stefan@FreeBSD.org> born in Werne, Nordrhein-Westfalen, Germany, 1978
+10/09 Vincenzo Maffione <vmaffione@FreeBSD.org> born in Foggia, Italy, 1988
10/11 Rick Macklem <rmacklem@FreeBSD.org> born in Ontario, Canada, 1955
10/12 Pawel Jakub Dawidek <pjd@FreeBSD.org> born in Radzyn Podlaski, Poland, 1980
10/15 Maxim Konovalov <maxim@FreeBSD.org> born in Khabarovsk, USSR, 1973
@@ -417,6 +423,7 @@
11/09 Antoine Brodin <antoine@FreeBSD.org> born in Bagnolet, France, 1981
11/10 Gregory Neil Shapiro <gshapiro@FreeBSD.org> born in Providence, Rhode Island, United States, 1970
11/11 Danilo E. Gondolfo <danilo@FreeBSD.org> born in Lobato, Parana, Brazil, 1987
+11/12 Gleb Popov <arrowd@FreeBSD.org> born in Volgograd, Russia, 1991
11/13 John Baldwin <jhb@FreeBSD.org> born in Stuart, Virginia, United States, 1977
11/14 Jeremie Le Hen <jlh@FreeBSD.org> born in Nancy, France, 1980
11/15 Lars Engels <lme@FreeBSD.org> born in Hilden, Nordrhein-Westfalen, Germany, 1980
@@ -439,6 +446,7 @@
11/25 Fedor Uporov <fsu@FreeBSD.org> born in Yalta, Crimea, USSR, 1988
11/28 Nik Clayton <nik@FreeBSD.org> born in Peterborough, United Kingdom, 1973
11/28 Stanislav Sedov <stas@FreeBSD.org> born in Chelyabinsk, USSR, 1985
+11/29 Doug Moore <dougm@FreeBSD.org> born in Arlington, Texas, United States, 1960
12/01 Hajimu Umemoto <ume@FreeBSD.org> born in Nara, Japan, 1961
12/01 Alexey Dokuchaev <danfe@FreeBSD.org> born in Magadan, USSR, 1980
12/02 Ermal Luçi <eri@FreeBSD.org> born in Tirane, Albania, 1980
@@ -448,6 +456,7 @@
12/06 Stefan Farfeleder <stefanf@FreeBSD.org> born in Wien, Austria, 1980
12/08 Michael Tuexen <tuexen@FreeBSD.org> born in Oldenburg, Germany, 1966
12/11 Ganael Laplanche <martymac@FreeBSD.org> born in Reims, France, 1980
+12/11 Koichiro Iwao <meta@FreeBSD.org> born in Oita, Japan, 1987
12/15 James FitzGibbon <jfitz@FreeBSD.org> born in Amersham, Buckinghamshire, United Kingdom, 1974
12/15 Timur I. Bakeyev <timur@FreeBSD.org> born in Kazan, Republic of Tatarstan, USSR, 1974
12/18 Chris Timmons <cwt@FreeBSD.org> born in Ellensburg, Washington, United States, 1964
@@ -468,6 +477,7 @@
12/28 Soren Schmidt <sos@FreeBSD.org> born in Maribo, Denmark, 1960
12/28 Ade Lovett <ade@FreeBSD.org> born in London, England, 1969
12/28 Marius Strobl <marius@FreeBSD.org> born in Cham, Bavaria, Germany, 1978
+12/30 Sean Eric Fagan <sef@FreeBSD.org> born in Los Angeles, California, United States, 1967
12/31 Edwin Groothuis <edwin@FreeBSD.org> born in Geldrop, the Netherlands, 1970
12/31 Fourth quarter status reports are due on 01/15
diff --git a/usr.bin/clang/Makefile b/usr.bin/clang/Makefile
index 4206ff977e687..37574381ad3de 100644
--- a/usr.bin/clang/Makefile
+++ b/usr.bin/clang/Makefile
@@ -7,14 +7,16 @@ SUBDIR+= clang-tblgen
SUBDIR+= llvm-tblgen
.if !defined(TOOLS_PREFIX)
+SUBDIR+= llvm-ar
+SUBDIR+= llvm-nm
SUBDIR+= llvm-objdump
+SUBDIR+= llvm-symbolizer
.if ${MK_CLANG_EXTRAS} != "no"
SUBDIR+= bugpoint
SUBDIR+= clang-format
SUBDIR+= llc
SUBDIR+= lli
-SUBDIR+= llvm-ar
SUBDIR+= llvm-as
SUBDIR+= llvm-bcanalyzer
SUBDIR+= llvm-cxxdump
@@ -29,11 +31,9 @@ SUBDIR+= llvm-lto2
SUBDIR+= llvm-mc
SUBDIR+= llvm-mca
SUBDIR+= llvm-modextract
-SUBDIR+= llvm-nm
SUBDIR+= llvm-objcopy
SUBDIR+= llvm-pdbutil
SUBDIR+= llvm-rtdyld
-SUBDIR+= llvm-symbolizer
SUBDIR+= llvm-xray
SUBDIR+= opt
.endif
diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c
index 542ee5f0e7dee..20911c2943436 100644
--- a/usr.bin/grep/grep.c
+++ b/usr.bin/grep/grep.c
@@ -343,14 +343,12 @@ main(int argc, char *argv[])
setlocale(LC_ALL, "");
- /* Check what is the program name of the binary. In this
- way we can have all the funcionalities in one binary
- without the need of scripting and using ugly hacks. */
+ /*
+ * Check how we've bene invoked to determine the behavior we should
+ * exhibit. In this way we can have all the functionalities in one
+ * binary without the need of scripting and using ugly hacks.
+ */
pn = getprogname();
- if (pn[0] == 'r') {
- dirbehave = DIR_RECURSE;
- Hflag = true;
- }
switch (pn[0]) {
case 'e':
grepbehave = GREP_EXTENDED;
@@ -358,6 +356,10 @@ main(int argc, char *argv[])
case 'f':
grepbehave = GREP_FIXED;
break;
+ case 'r':
+ dirbehave = DIR_RECURSE;
+ Hflag = true;
+ break;
}
lastc = '\0';
diff --git a/usr.bin/login/Makefile b/usr.bin/login/Makefile
index 6e88c2224b040..be29e8c05857d 100644
--- a/usr.bin/login/Makefile
+++ b/usr.bin/login/Makefile
@@ -3,11 +3,12 @@
.include <src.opts.mk>
-CONFS= fbtab login.conf motd
+CONFS= fbtab login.conf motd login.access
PROG= login
SRCS= login.c login_fbtab.c
CFLAGS+=-DLOGALL
LIBADD= util pam
+CAP_MKDB_CMD?= cap_mkdb
WARNS?= 5
@@ -25,7 +26,7 @@ PRECIOUSPROG=
.include <bsd.endian.mk>
afterinstallconfig:
- cap_mkdb ${CAP_MKDB_ENDIAN} ${DESTDIR}/etc/login.conf
+ ${CAP_MKDB_CMD} ${CAP_MKDB_ENDIAN} ${DESTDIR}/etc/login.conf
.if defined(NO_ROOT) && defined(METALOG)
echo "./etc/login.conf.db type=file mode=0644 uname=root gname=wheel" | \
cat -l >> ${METALOG}
diff --git a/usr.bin/login/login.access b/usr.bin/login/login.access
new file mode 100644
index 0000000000000..ffe5fff0abea7
--- /dev/null
+++ b/usr.bin/login/login.access
@@ -0,0 +1,46 @@
+# $FreeBSD$
+#
+# Login access control table.
+#
+# When someone logs in, the table is scanned for the first entry that
+# matches the (user, host) combination, or, in case of non-networked
+# logins, the first entry that matches the (user, tty) combination. The
+# permissions field of that table entry determines whether the login will
+# be accepted or refused.
+#
+# Format of the login access control table is three fields separated by a
+# ":" character:
+#
+# permission : users : origins
+#
+# The first field should be a "+" (access granted) or "-" (access denied)
+# character. The second field should be a list of one or more login names,
+# group names, or ALL (always matches). The third field should be a list
+# of one or more tty names (for non-networked logins), host names, domain
+# names (begin with "."), host addresses, internet network numbers (end
+# with "."), ALL (always matches) or LOCAL (matches any string that does
+# not contain a "." character). If you run NIS you can use @netgroupname
+# in host or user patterns.
+#
+# The EXCEPT operator makes it possible to write very compact rules.
+#
+# The group file is searched only when a name does not match that of the
+# logged-in user. Only groups are matched in which users are explicitly
+# listed: the program does not look at a user's primary group id value.
+#
+##############################################################################
+#
+# Disallow console logins to all but a few accounts.
+#
+#-:ALL EXCEPT wheel shutdown sync:console
+#
+# Disallow non-local logins to privileged accounts (group wheel).
+#
+#-:wheel:ALL EXCEPT LOCAL .win.tue.nl
+#
+# Some accounts are not allowed to login from anywhere:
+#
+#-:wsbscaro wsbsecr wsbspac wsbsym wscosor wstaiwde:ALL
+#
+# All other accounts are allowed to login from anywhere.
+#
diff --git a/usr.bin/posixshmcontrol/Makefile b/usr.bin/posixshmcontrol/Makefile
new file mode 100644
index 0000000000000..df8f6ce396875
--- /dev/null
+++ b/usr.bin/posixshmcontrol/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= posixshmcontrol
+LIBADD= util
+WARNS?= 6
+
+.include <bsd.prog.mk>
diff --git a/usr.bin/posixshmcontrol/posixshmcontrol.1 b/usr.bin/posixshmcontrol/posixshmcontrol.1
new file mode 100644
index 0000000000000..a0612a87d8a01
--- /dev/null
+++ b/usr.bin/posixshmcontrol/posixshmcontrol.1
@@ -0,0 +1,152 @@
+.\" Copyright (c) 2019 The FreeBSD Foundation, Inc.
+.\"
+.\" This documentation was written by
+.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" 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.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS 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 AUTHORS 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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd May 30, 2019
+.Dt POSIXSHMCONTROL 1
+.Os
+.Sh NAME
+.Nm posixshmcontrol
+.Nd Control POSIX shared memory segments
+.Sh SYNOPSIS
+.Nm
+.Ar create
+.Op Fl m Ar mode
+.Op Pa path \&...
+.Nm
+.Ar rm
+.Op Pa path \&...
+.Nm
+.Ar ls
+.Op Fl h
+.Op Fl n
+.Nm
+.Ar dump
+.Op Pa path \&...
+.Nm
+.Ar stat
+.Op Fl h
+.Op Fl n
+.Op Pa path \&...
+.Nm
+.Ar truncate
+.Op Fl s Ar length
+.Op Pa path \&...
+.Sh DESCRIPTION
+The
+.Nm
+command manipulates the named POSIX shared memory segments.
+It allows inspecting existing segments, dumping their metadata or contents,
+and unlinking them.
+.Pp
+Unlinking removes the name from the system and, when the last process
+unmaps the segment and closes file descriptor pointing to the segment,
+frees underlying memory.
+.Pp
+The number of hard links as displayed by the
+.Ic stat
+subcommand, is equal to the number of references to the underlying VM
+object.
+It is almost always equal to the number of mappings +1, except
+for transient references.
+.Pp
+The following subcommands are provided:
+.Bl -tag -width truncate
+.It Ic create
+Create segments with the specified paths, if not exist.
+The
+.Ar mode
+optional numerical argument specifies initial access mode.
+.It Ic rm
+Unlink the paths specified.
+.It Ic ls
+List all linked named shared memory segments visible to the caller.
+For each segment, the user and group owner, size, and path are displayed.
+.It Ic dump
+Output raw bytes values from the segment to standard output.
+.It Ic stat
+Print metadata for the specified path, in the format similar to the
+.Xr stat 1
+utility.
+.It Ic truncate
+Change the length of the segments.
+Argument to the
+.Fl s
+option specifies new length.
+The human-friendly 'k', 'm', 'g' suffixes can be used, see
+.Xr expand_number 3.
+If the option is not specified, assumed length is zero.
+.El
+.Pp
+For some commands, the following options may be provided:
+.Bl -tag -width XXX
+.It Fl h
+If specified, requests human-readable display of size, see
+.Xr humanize_number 3 .
+.It Fl n
+Prevent translation of owner and group into symbolic names
+using name-switch services, instead the raw numeric values are printed.
+.El
+.Sh EXIT STATUS
+.Ex -std
+.Sh EXAMPLES
+.Bl -bullet
+.It
+To show content of the shared memory segment with the path
+.Pa /1 ,
+use the command
+.Dl "posixshmcontrol dump /q | hexdump -C"
+.It
+To create a segment with the path
+.Pa /2
+and then enlarge it to 1M, use the sequence of commands
+.Dl "posixshmcontrol create /2"
+.Dl "posixshmcontrol truncate -s 1m /2"
+.El
+.Sh SEE ALSO
+.Xr hexdump 1 ,
+.Xr stat 1 ,
+.Xr ftruncate 2 ,
+.Xr read 2 ,
+.Xr shm_open 2 ,
+.Xr shm_unlink 2 ,
+.Xr stat 2 ,
+.Xr expand_number 3 ,
+.Xr humanize_number 3 ,
+.Xr sysctl 3
+.Sh HISTORY
+The
+.Nm
+command appeared in
+.Fx 13.0 .
+.Sh AUTHORS
+The
+.Nm
+command and this manual page were written by
+.An Konstantin Belousov Aq Mt kib@freebsd.org
+under sponsorship from The FreeBSD Foundation.
diff --git a/usr.bin/posixshmcontrol/posixshmcontrol.c b/usr.bin/posixshmcontrol/posixshmcontrol.c
new file mode 100644
index 0000000000000..50c78d0e0d7be
--- /dev/null
+++ b/usr.bin/posixshmcontrol/posixshmcontrol.c
@@ -0,0 +1,480 @@
+/*-
+ * Copyright (c) 2019 The FreeBSD Foundation
+ *
+ * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/sysctl.h>
+#include <sys/user.h>
+#include <err.h>
+#include <fcntl.h>
+#include <grp.h>
+#include <libutil.h>
+#include <pwd.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static void
+usage(void)
+{
+
+ fprintf(stderr, "Usage:\n"
+ "posixshmcontrol create [-m <mode>] <path> ...\n"
+ "posixshmcontrol rm <path> ...\n"
+ "posixshmcontrol ls [-h] [-n]\n"
+ "posixshmcontrol dump <path> ...\n"
+ "posixshmcontrol stat [-h] [-n] <path> ...\n"
+ "posixshmcontrol truncate [-s <newlen>] <path> ...\n");
+}
+
+static int
+create_one_shm(const char *path, long mode)
+{
+ int fd;
+
+ fd = shm_open(path, O_RDWR | O_CREAT, mode);
+ if (fd == -1) {
+ warn("create %s", path);
+ return (1);
+ }
+ close(fd);
+ return (0);
+}
+
+static int
+create_shm(int argc, char **argv)
+{
+ char *end;
+ long mode;
+ int c, i, ret, ret1;
+
+ mode = 0600;
+ while ((c = getopt(argc, argv, "m:")) != -1) {
+ switch (c) {
+ case 'm':
+ errno = 0;
+ mode = strtol(optarg, &end, 0);
+ if (mode == 0 && errno != 0)
+ err(1, "mode:");
+ if (*end != '\0')
+ errx(1, "non-integer mode");
+ break;
+ case '?':
+ default:
+ usage();
+ return (2);
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
+ ret = 0;
+ for (i = 0; i < argc; i++) {
+ ret1 = create_one_shm(argv[i], mode);
+ if (ret1 != 0 && ret == 0)
+ ret = ret1;
+ }
+ return (ret);
+}
+
+static int
+delete_one_shm(const char *path)
+{
+ int error, ret;
+
+ error = shm_unlink(path);
+ if (error != 0) {
+ warn("unlink of %s failed", path);
+ ret = 1;
+ } else {
+ ret = 0;
+ }
+ return (ret);
+}
+
+static int
+delete_shm(int argc, char **argv)
+{
+ int i, ret, ret1;
+
+ ret = 0;
+ for (i = 1; i < argc; i++) {
+ ret1 = delete_one_shm(argv[i]);
+ if (ret1 != 0 && ret == 0)
+ ret = ret1;
+ }
+ return (ret);
+}
+
+static const char listmib[] = "kern.ipc.posix_shm_list";
+
+static void
+shm_decode_mode(mode_t m, char *str)
+{
+ int i;
+
+ i = 0;
+ str[i++] = (m & S_IRUSR) != 0 ? 'r' : '-';
+ str[i++] = (m & S_IWUSR) != 0 ? 'w' : '-';
+ str[i++] = (m & S_IXUSR) != 0 ? 'x' : '-';
+ str[i++] = (m & S_IRGRP) != 0 ? 'r' : '-';
+ str[i++] = (m & S_IWGRP) != 0 ? 'w' : '-';
+ str[i++] = (m & S_IXGRP) != 0 ? 'x' : '-';
+ str[i++] = (m & S_IROTH) != 0 ? 'r' : '-';
+ str[i++] = (m & S_IWOTH) != 0 ? 'w' : '-';
+ str[i++] = (m & S_IXOTH) != 0 ? 'x' : '-';
+ str[i] = '\0';
+}
+
+static int
+list_shm(int argc, char **argv)
+{
+ char *buf, *bp, sizebuf[8], str[10];
+ const struct kinfo_file *kif;
+ struct stat st;
+ int c, error, fd, mib[3], ret;
+ size_t len, miblen;
+ bool hsize, uname;
+
+ hsize = false;
+ uname = true;
+
+ while ((c = getopt(argc, argv, "hn")) != -1) {
+ switch (c) {
+ case 'h':
+ hsize = true;
+ break;
+ case 'n':
+ uname = false;
+ break;
+ default:
+ usage();
+ return (2);
+ }
+ }
+ if (argc != optind) {
+ usage();
+ return (2);
+ }
+
+ miblen = nitems(mib);
+ error = sysctlnametomib(listmib, mib, &miblen);
+ if (error == -1) {
+ warn("cannot translate %s", listmib);
+ return (1);
+ }
+ len = 0;
+ error = sysctl(mib, miblen, NULL, &len, NULL, 0);
+ if (error == -1) {
+ warn("cannot get %s length", listmib);
+ return (1);
+ }
+ len = len * 4 / 3;
+ buf = malloc(len);
+ if (buf == NULL) {
+ warn("malloc");
+ return (1);
+ }
+ error = sysctl(mib, miblen, buf, &len, NULL, 0);
+ if (error != 0) {
+ warn("reading %s", listmib);
+ ret = 1;
+ goto out;
+ }
+ ret = 0;
+ printf("MODE \tOWNER\tGROUP\tSIZE\tPATH\n");
+ for (bp = buf; bp < buf + len; bp += kif->kf_structsize) {
+ kif = (const struct kinfo_file *)(void *)bp;
+ if (kif->kf_structsize == 0)
+ break;
+ fd = shm_open(kif->kf_path, O_RDONLY, 0);
+ if (fd == -1) {
+ warn("open %s", kif->kf_path);
+ ret = 1;
+ continue;
+ }
+ error = fstat(fd, &st);
+ close(fd);
+ if (error != 0) {
+ warn("stat %s", kif->kf_path);
+ ret = 1;
+ continue;
+ }
+ shm_decode_mode(kif->kf_un.kf_file.kf_file_mode, str);
+ printf("%s\t", str);
+ if (uname) {
+ printf("%s\t%s\t", user_from_uid(st.st_uid, 0),
+ group_from_gid(st.st_gid, 0));
+ } else {
+ printf("%d\t%d\t", st.st_uid, st.st_gid);
+ }
+ if (hsize) {
+ humanize_number(sizebuf, sizeof(sizebuf),
+ kif->kf_un.kf_file.kf_file_size, "", HN_AUTOSCALE,
+ HN_NOSPACE);
+ printf("%s\t", sizebuf);
+ } else {
+ printf("%jd\t",
+ (uintmax_t)kif->kf_un.kf_file.kf_file_size);
+ }
+ printf("%s\n", kif->kf_path);
+ }
+out:
+ free(buf);
+ return (ret);
+}
+
+static int
+read_one_shm(const char *path)
+{
+ char buf[4096];
+ ssize_t size, se;
+ int fd, ret;
+
+ ret = 1;
+ fd = shm_open(path, O_RDONLY, 0);
+ if (fd == -1) {
+ warn("open %s", path);
+ goto out;
+ }
+ for (;;) {
+ size = read(fd, buf, sizeof(buf));
+ if (size > 0) {
+ se = fwrite(buf, 1, size, stdout);
+ if (se < size) {
+ warnx("short write to stdout");
+ goto out;
+ }
+ }
+ if (size == (ssize_t)sizeof(buf))
+ continue;
+ if (size >= 0 && size < (ssize_t)sizeof(buf)) {
+ ret = 0;
+ goto out;
+ }
+ warn("read from %s", path);
+ goto out;
+ }
+out:
+ close(fd);
+ return (ret);
+}
+
+static int
+read_shm(int argc, char **argv)
+{
+ int i, ret, ret1;
+
+ ret = 0;
+ for (i = 1; i < argc; i++) {
+ ret1 = read_one_shm(argv[i]);
+ if (ret1 != 0 && ret == 0)
+ ret = ret1;
+ }
+ return (ret);
+}
+
+static int
+stat_one_shm(const char *path, bool hsize, bool uname)
+{
+ char sizebuf[8];
+ struct stat st;
+ int error, fd, ret;
+
+ fd = shm_open(path, O_RDONLY, 0);
+ if (fd == -1) {
+ warn("open %s", path);
+ return (1);
+ }
+ ret = 0;
+ error = fstat(fd, &st);
+ if (error == -1) {
+ warn("stat %s", path);
+ ret = 1;
+ } else {
+ printf("path\t%s\n", path);
+ printf("inode\t%jd\n", (uintmax_t)st.st_ino);
+ printf("mode\t%#o\n", st.st_mode);
+ printf("nlink\t%jd\n", (uintmax_t)st.st_nlink);
+ if (uname) {
+ printf("owner\t%s\n", user_from_uid(st.st_uid, 0));
+ printf("group\t%s\n", group_from_gid(st.st_gid, 0));
+ } else {
+ printf("uid\t%d\n", st.st_uid);
+ printf("gid\t%d\n", st.st_gid);
+ }
+ if (hsize) {
+ humanize_number(sizebuf, sizeof(sizebuf),
+ st.st_size, "", HN_AUTOSCALE, HN_NOSPACE);
+ printf("size\t%s\n", sizebuf);
+ } else {
+ printf("size\t%jd\n", (uintmax_t)st.st_size);
+ }
+ printf("atime\t%ld.%09ld\n", (long)st.st_atime,
+ (long)st.st_atim.tv_nsec);
+ printf("mtime\t%ld.%09ld\n", (long)st.st_mtime,
+ (long)st.st_mtim.tv_nsec);
+ printf("ctime\t%ld.%09ld\n", (long)st.st_ctime,
+ (long)st.st_ctim.tv_nsec);
+ printf("birth\t%ld.%09ld\n", (long)st.st_birthtim.tv_sec,
+ (long)st.st_birthtim.tv_nsec);
+ }
+ close(fd);
+ return (ret);
+}
+
+static int
+stat_shm(int argc, char **argv)
+{
+ int c, i, ret, ret1;
+ bool hsize, uname;
+
+ hsize = false;
+ uname = true;
+
+ while ((c = getopt(argc, argv, "hn")) != -1) {
+ switch (c) {
+ case 'h':
+ hsize = true;
+ break;
+ case 'n':
+ uname = false;
+ break;
+ default:
+ usage();
+ return (2);
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
+ ret = 0;
+ for (i = 0; i < argc; i++) {
+ ret1 = stat_one_shm(argv[i], hsize, uname);
+ if (ret1 != 0 && ret == 0)
+ ret = ret1;
+ }
+ return (ret);
+}
+
+static int
+truncate_one_shm(const char *path, uint64_t newsize)
+{
+ int error, fd, ret;
+
+ ret = 0;
+ fd = shm_open(path, O_RDWR, 0);
+ if (fd == -1) {
+ warn("open %s", path);
+ return (1);
+ }
+ error = ftruncate(fd, newsize);
+ if (error == -1) {
+ warn("truncate %s", path);
+ ret = 1;
+ }
+ close(fd);
+ return (ret);
+}
+
+static int
+truncate_shm(int argc, char **argv)
+{
+ uint64_t newsize;
+ int c, i, ret, ret1;
+
+ newsize = 0;
+ while ((c = getopt(argc, argv, "s:")) != -1) {
+ switch (c) {
+ case 's':
+ if (expand_number(optarg, &newsize) == -1)
+ err(1, "size:");
+ break;
+ case '?':
+ default:
+ return (2);
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
+ ret = 0;
+ for (i = 0; i < argc; i++) {
+ ret1 = truncate_one_shm(argv[i], newsize);
+ if (ret1 != 0 && ret == 0)
+ ret = ret1;
+ }
+ return (ret);
+}
+
+struct opmode {
+ const char *cmd;
+ int (*impl)(int argc, char **argv);
+};
+
+static const struct opmode opmodes[] = {
+ { .cmd = "create", .impl = create_shm},
+ { .cmd = "rm", .impl = delete_shm, },
+ { .cmd = "ls", .impl = list_shm },
+ { .cmd = "dump", .impl = read_shm, },
+ { .cmd = "stat", .impl = stat_shm, },
+ { .cmd = "truncate", .impl = truncate_shm, },
+};
+
+int
+main(int argc, char *argv[])
+{
+ const struct opmode *opmode;
+ int i, ret;
+
+ ret = 0;
+ opmode = NULL;
+
+ if (argc < 2) {
+ usage();
+ exit(2);
+ }
+ for (i = 0; i < (int)nitems(opmodes); i++) {
+ if (strcmp(argv[1], opmodes[i].cmd) == 0) {
+ opmode = &opmodes[i];
+ break;
+ }
+ }
+ if (opmode == NULL) {
+ usage();
+ exit(2);
+ }
+ ret = opmode->impl(argc - 1, argv + 1);
+ exit(ret);
+}
diff --git a/usr.bin/tail/Makefile b/usr.bin/tail/Makefile
index d586afe01c18a..5d53b23957a73 100644
--- a/usr.bin/tail/Makefile
+++ b/usr.bin/tail/Makefile
@@ -6,6 +6,12 @@
PROG= tail
SRCS= forward.c misc.c read.c reverse.c tail.c
+.if ${MK_CASPER} != "no" && !defined(RESCUE)
+LIBADD+= casper
+LIBADD+= cap_fileargs
+CFLAGS+= -DWITH_CASPER
+.endif
+
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
diff --git a/usr.bin/tail/tail.c b/usr.bin/tail/tail.c
index 2a9ab0222aa70..9cab33cef76f6 100644
--- a/usr.bin/tail/tail.c
+++ b/usr.bin/tail/tail.c
@@ -46,9 +46,11 @@ static const char copyright[] =
static const char sccsid[] = "@(#)tail.c 8.1 (Berkeley) 6/6/93";
#endif
+#include <sys/capsicum.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <capsicum_helpers.h>
#include <err.h>
#include <errno.h>
#include <getopt.h>
@@ -57,6 +59,9 @@ static const char sccsid[] = "@(#)tail.c 8.1 (Berkeley) 6/6/93";
#include <string.h>
#include <unistd.h>
+#include <libcasper.h>
+#include <casper/cap_fileargs.h>
+
#include "extern.h"
int Fflag, fflag, qflag, rflag, rval, no_files;
@@ -85,6 +90,13 @@ main(int argc, char *argv[])
int i, ch, first;
file_info_t *file;
char *p;
+ fileargs_t *fa;
+ cap_rights_t rights;
+
+ cap_rights_init(&rights, CAP_FSTAT, CAP_FCNTL, CAP_MMAP_RW);
+ if (caph_rights_limit(STDIN_FILENO, &rights) < 0 ||
+ caph_limit_stderr() < 0 || caph_limit_stdout() < 0)
+ err(1, "can't limit stdio rights");
/*
* Tail's options are weird. First, -n10 is the same as -n-10, not
@@ -155,6 +167,14 @@ main(int argc, char *argv[])
no_files = argc ? argc : 1;
+ fa = fileargs_init(argc, argv, O_RDONLY, 0, &rights, FA_OPEN);
+ if (fa == NULL)
+ errx(1, "unable to init casper");
+
+ caph_cache_catpages();
+ if (caph_enter_casper() < 0)
+ err(1, "unable to enter capability mode");
+
/*
* If displaying in reverse, don't permit follow option, and convert
* style values.
@@ -192,7 +212,7 @@ main(int argc, char *argv[])
file->file_name = strdup(fn);
if (! file->file_name)
errx(1, "Couldn't malloc space for file name.");
- if ((file->fp = fopen(file->file_name, "r")) == NULL ||
+ if ((file->fp = fileargs_fopen(fa, file->file_name, "r")) == NULL ||
fstat(fileno(file->fp), &file->st)) {
if (file->fp != NULL) {
fclose(file->fp);
@@ -209,7 +229,7 @@ main(int argc, char *argv[])
free(files);
} else if (*argv) {
for (first = 1; (fn = *argv++);) {
- if ((fp = fopen(fn, "r")) == NULL ||
+ if ((fp = fileargs_fopen(fa, fn, "r")) == NULL ||
fstat(fileno(fp), &sb)) {
ierr(fn);
continue;
@@ -247,6 +267,7 @@ main(int argc, char *argv[])
else
forward(stdin, fn, style, off, &sb);
}
+ fileargs_free(fa);
exit(rval);
}
diff --git a/usr.bin/tar/tests/Makefile b/usr.bin/tar/tests/Makefile
index 60344d8e10910..95fd0a470352d 100644
--- a/usr.bin/tar/tests/Makefile
+++ b/usr.bin/tar/tests/Makefile
@@ -53,6 +53,7 @@ TESTS_SRCS= \
test_option_b.c \
test_option_b64encode.c \
test_option_exclude.c \
+ test_option_exclude_vcs.c \
test_option_fflags.c \
test_option_gid_gname.c \
test_option_grzip.c \
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c
index 01b258bf668ef..e8cec07fd46b0 100644
--- a/usr.bin/vmstat/vmstat.c
+++ b/usr.bin/vmstat/vmstat.c
@@ -156,6 +156,7 @@ static struct __vmmeter {
u_int v_free_min;
u_int v_free_count;
u_int v_wire_count;
+ u_long v_user_wire_count;
u_int v_active_count;
u_int v_inactive_target;
u_int v_inactive_count;
@@ -566,6 +567,7 @@ fill_vmmeter(struct __vmmeter *vmmp)
GET_VM_STATS(vm, v_free_min);
GET_VM_STATS(vm, v_free_count);
GET_VM_STATS(vm, v_wire_count);
+ GET_VM_STATS(vm, v_user_wire_count);
GET_VM_STATS(vm, v_active_count);
GET_VM_STATS(vm, v_inactive_target);
GET_VM_STATS(vm, v_inactive_count);
@@ -1057,6 +1059,8 @@ dosum(void)
sum.v_laundry_count);
xo_emit("{:wired-pages/%9u} {N:pages wired down}\n",
sum.v_wire_count);
+ xo_emit("{:virtual-user-wired-pages/%9lu} {N:virtual user pages wired "
+ "down}\n", sum.v_user_wire_count);
xo_emit("{:free-pages/%9u} {N:pages free}\n",
sum.v_free_count);
xo_emit("{:bytes-per-page/%9u} {N:bytes per page}\n", sum.v_page_size);
diff --git a/usr.bin/vtfontcvt/vtfontcvt.c b/usr.bin/vtfontcvt/vtfontcvt.c
index e303d80b0eef0..58bc26938f447 100644
--- a/usr.bin/vtfontcvt/vtfontcvt.c
+++ b/usr.bin/vtfontcvt/vtfontcvt.c
@@ -49,6 +49,8 @@ __FBSDID("$FreeBSD$");
#define VFNT_MAP_NORMAL_RH 1
#define VFNT_MAP_BOLD 2
#define VFNT_MAP_BOLD_RH 3
+#define VFNT_MAXGLYPHS 131072
+#define VFNT_MAXDIMENSION 128
static unsigned int width = 8, wbytes, height = 16;
@@ -101,7 +103,7 @@ xmalloc(size_t size)
{
void *m;
- if ((m = malloc(size)) == NULL)
+ if ((m = calloc(1, size)) == NULL)
errx(1, "memory allocation failure");
return (m);
}
@@ -183,6 +185,8 @@ add_glyph(const uint8_t *bytes, unsigned int map_idx, int fallback)
SLIST_INSERT_HEAD(&glyph_hash[hash], gl, g_hash);
glyph_unique++;
+ if (glyph_unique > VFNT_MAXGLYPHS)
+ errx(1, "too many glyphs (%u)", glyph_unique);
return (gl);
}
@@ -201,8 +205,7 @@ add_char(unsigned curchar, unsigned map_idx, uint8_t *bytes, uint8_t *bytes_r)
return (1);
if (bytes_r != NULL) {
gl = add_glyph(bytes_r, map_idx + 1, 0);
- if (add_mapping(gl, curchar,
- map_idx + 1) != 0)
+ if (add_mapping(gl, curchar, map_idx + 1) != 0)
return (1);
}
}
@@ -298,10 +301,17 @@ parse_bdf(FILE *fp, unsigned int map_idx)
}
static void
-set_width(int w)
+set_height(int h)
{
+ if (h <= 0 || h > VFNT_MAXDIMENSION)
+ errx(1, "invalid height %d", h);
+ height = h;
+}
- if (w <= 0 || w > 128)
+static void
+set_width(int w)
+{
+ if (w <= 0 || w > VFNT_MAXDIMENSION)
errx(1, "invalid width %d", w);
width = w;
wbytes = howmany(width, 8);
@@ -323,7 +333,7 @@ parse_hex(FILE *fp, unsigned int map_idx)
if (strncmp(ln, "# Height: ", 10) == 0) {
if (bytes != NULL)
errx(1, "malformed input: Height tag after font data");
- height = atoi(ln + 10);
+ set_height(atoi(ln + 10));
} else if (strncmp(ln, "# Width: ", 9) == 0) {
if (bytes != NULL)
errx(1, "malformed input: Width tag after font data");
@@ -496,9 +506,9 @@ write_fnt(const char *filename)
if (write_glyphs(fp) != 0 ||
write_mappings(fp, VFNT_MAP_NORMAL) != 0 ||
- write_mappings(fp, 1) != 0 ||
+ write_mappings(fp, VFNT_MAP_NORMAL_RH) != 0 ||
write_mappings(fp, VFNT_MAP_BOLD) != 0 ||
- write_mappings(fp, 3) != 0) {
+ write_mappings(fp, VFNT_MAP_BOLD_RH) != 0) {
perror(filename);
fclose(fp);
return (1);
@@ -513,6 +523,8 @@ print_font_info(void)
{
printf(
"Statistics:\n"
+"- width: %6u\n"
+"- height: %6u\n"
"- glyph_total: %6u\n"
"- glyph_normal: %6u\n"
"- glyph_normal_right: %6u\n"
@@ -531,6 +543,7 @@ print_font_info(void)
"- mapping_bold_right_folded: %6u\n"
"- mapping_unique: %6u\n"
"- mapping_dupe: %6u\n",
+ width, height,
glyph_total,
glyph_count[0],
glyph_count[1],
@@ -548,7 +561,7 @@ print_font_info(void)
int
main(int argc, char *argv[])
{
- int ch, val, verbose = 0;
+ int ch, verbose = 0;
assert(sizeof(struct file_header) == 32);
assert(sizeof(struct file_mapping) == 8);
@@ -556,16 +569,13 @@ main(int argc, char *argv[])
while ((ch = getopt(argc, argv, "h:vw:")) != -1) {
switch (ch) {
case 'h':
- val = atoi(optarg);
- if (val <= 0 || val > 128)
- errx(1, "Invalid height %d", val);
- height = val;
+ height = atoi(optarg);
break;
case 'v':
verbose = 1;
break;
case 'w':
- set_width(atoi(optarg));
+ width = atoi(optarg);
break;
case '?':
default:
@@ -578,7 +588,8 @@ main(int argc, char *argv[])
if (argc < 2 || argc > 3)
usage();
- wbytes = howmany(width, 8);
+ set_width(width);
+ set_height(height);
if (parse_file(argv[0], VFNT_MAP_NORMAL) != 0)
return (1);