aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-11-19 16:05:55 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-11-19 16:05:55 +0000
commit67bc8c8b9e69bc53221a9bd914e418d81d6cdc7d (patch)
tree7d222a83de8d7e5d1465e33f3c24660799770c92 /usr.bin
parent2828dafcf3e7b225b70cbb380eb8c7dae452493e (diff)
parent57b28934e964b15f1fcd91734c6dbef762222079 (diff)
Notes
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/basename/Makefile.depend1
-rw-r--r--usr.bin/cmp/Makefile.depend1
-rw-r--r--usr.bin/col/Makefile.depend1
-rw-r--r--usr.bin/dc/Makefile.depend1
-rw-r--r--usr.bin/dirname/Makefile.depend2
-rw-r--r--usr.bin/elfdump/Makefile.depend1
-rw-r--r--usr.bin/fold/Makefile.depend1
-rw-r--r--usr.bin/fold/fold.c4
-rw-r--r--usr.bin/gcore/gcore.c17
-rw-r--r--usr.bin/getopt/Makefile.depend2
-rw-r--r--usr.bin/jot/Makefile.depend1
-rw-r--r--usr.bin/kdump/Makefile.depend1
-rw-r--r--usr.bin/locale/locale.c36
-rw-r--r--usr.bin/locate/bigram/Makefile.depend2
-rw-r--r--usr.bin/logname/Makefile.depend2
-rw-r--r--usr.bin/netstat/mbuf.c3
-rw-r--r--usr.bin/printenv/Makefile.depend1
-rw-r--r--usr.bin/tee/Makefile.depend1
-rw-r--r--usr.bin/tr/Makefile.depend1
-rw-r--r--usr.bin/vmstat/vmstat.c2
-rw-r--r--usr.bin/whois/whois.c79
-rw-r--r--usr.bin/write/Makefile.depend1
-rw-r--r--usr.bin/yes/Makefile.depend2
23 files changed, 134 insertions, 29 deletions
diff --git a/usr.bin/basename/Makefile.depend b/usr.bin/basename/Makefile.depend
index 3646e2e2b1afa..4def626103cef 100644
--- a/usr.bin/basename/Makefile.depend
+++ b/usr.bin/basename/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/cmp/Makefile.depend b/usr.bin/cmp/Makefile.depend
index 3646e2e2b1afa..4def626103cef 100644
--- a/usr.bin/cmp/Makefile.depend
+++ b/usr.bin/cmp/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/col/Makefile.depend b/usr.bin/col/Makefile.depend
index 3646e2e2b1afa..4def626103cef 100644
--- a/usr.bin/col/Makefile.depend
+++ b/usr.bin/col/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/dc/Makefile.depend b/usr.bin/dc/Makefile.depend
index 9d5105e918de8..7e1b62db9b936 100644
--- a/usr.bin/dc/Makefile.depend
+++ b/usr.bin/dc/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
secure/lib/libcrypto \
secure/lib/libssl \
diff --git a/usr.bin/dirname/Makefile.depend b/usr.bin/dirname/Makefile.depend
index 9cb890b58360a..4def626103cef 100644
--- a/usr.bin/dirname/Makefile.depend
+++ b/usr.bin/dirname/Makefile.depend
@@ -5,8 +5,10 @@ DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \
include \
+ include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/elfdump/Makefile.depend b/usr.bin/elfdump/Makefile.depend
index 3646e2e2b1afa..4def626103cef 100644
--- a/usr.bin/elfdump/Makefile.depend
+++ b/usr.bin/elfdump/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/fold/Makefile.depend b/usr.bin/fold/Makefile.depend
index 3646e2e2b1afa..4def626103cef 100644
--- a/usr.bin/fold/Makefile.depend
+++ b/usr.bin/fold/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/fold/fold.c b/usr.bin/fold/fold.c
index 7eedfe252c0a5..1ce9b5eb3a929 100644
--- a/usr.bin/fold/fold.c
+++ b/usr.bin/fold/fold.c
@@ -45,7 +45,6 @@ static char sccsid[] = "@(#)fold.c 8.1 (Berkeley) 6/6/93";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <capsicum_helpers.h>
#include <err.h>
#include <limits.h>
#include <locale.h>
@@ -73,9 +72,6 @@ main(int argc, char **argv)
(void) setlocale(LC_CTYPE, "");
- if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno != ENOSYS))
- err(1, "capsicum");
-
width = -1;
previous_ch = 0;
while ((ch = getopt(argc, argv, "0123456789bsw:")) != -1) {
diff --git a/usr.bin/gcore/gcore.c b/usr.bin/gcore/gcore.c
index 3d4c5052eb7d0..6932cc3c6669d 100644
--- a/usr.bin/gcore/gcore.c
+++ b/usr.bin/gcore/gcore.c
@@ -143,21 +143,6 @@ main(int argc, char *argv[])
fd = open(corefile, O_RDWR|O_CREAT|O_TRUNC, DEFFILEMODE);
if (fd < 0)
err(1, "%s", corefile);
- /*
- * The semantics of the 's' flag is to stop the target process.
- * Previous versions of gcore would manage this by trapping SIGHUP,
- * SIGINT and SIGTERM (to be passed to the target pid), and then
- * signal the child to stop.
- *
- * However, this messes up if the selected dumper uses ptrace calls
- * that leave the child already stopped. The waitpid call in elfcore
- * never returns.
- *
- * The best thing to do here is to externalize the 's' flag and let
- * each dumper dispose of what that means, if anything. For the elfcore
- * dumper, the 's' flag is a no-op since the ptrace attach stops the
- * process in question already.
- */
dumper->dump(efd, fd, pid);
(void)close(fd);
@@ -169,6 +154,6 @@ void
usage(void)
{
- (void)fprintf(stderr, "usage: gcore [-s] [-c core] [executable] pid\n");
+ (void)fprintf(stderr, "usage: gcore [-c core] [executable] pid\n");
exit(1);
}
diff --git a/usr.bin/getopt/Makefile.depend b/usr.bin/getopt/Makefile.depend
index 9cb890b58360a..4def626103cef 100644
--- a/usr.bin/getopt/Makefile.depend
+++ b/usr.bin/getopt/Makefile.depend
@@ -5,8 +5,10 @@ DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \
include \
+ include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/jot/Makefile.depend b/usr.bin/jot/Makefile.depend
index 3646e2e2b1afa..4def626103cef 100644
--- a/usr.bin/jot/Makefile.depend
+++ b/usr.bin/jot/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/kdump/Makefile.depend b/usr.bin/kdump/Makefile.depend
index 71c8213639209..59ec51a9b1d71 100644
--- a/usr.bin/kdump/Makefile.depend
+++ b/usr.bin/kdump/Makefile.depend
@@ -9,6 +9,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcasper/libcasper \
lib/libcasper/services/cap_grp \
lib/libcasper/services/cap_pwd \
diff --git a/usr.bin/locale/locale.c b/usr.bin/locale/locale.c
index b295b176c883b..2c3e61eb529be 100644
--- a/usr.bin/locale/locale.c
+++ b/usr.bin/locale/locale.c
@@ -50,6 +50,7 @@
#include "setlocale.h"
/* Local prototypes */
+char *format_grouping(const char *);
void init_locales_list(void);
void list_charmaps(void);
void list_locales(void);
@@ -283,8 +284,9 @@ main(int argc, char *argv[])
/* process '-c', '-k', or command line arguments. */
if (prt_categories || prt_keywords || argc > 0) {
- if (argc > 0) {
+ if (prt_keywords || argc > 0)
setlocale(LC_ALL, "");
+ if (argc > 0) {
while (argc > 0) {
showdetails(*argv);
argv++;
@@ -487,6 +489,34 @@ showlocale(void)
printf("LC_ALL=%s\n", vval);
}
+char *
+format_grouping(const char *binary)
+{
+ static char rval[64];
+ const char *cp;
+ size_t len;
+
+ rval[0] = '\0';
+ for (cp = binary; *cp != '\0'; ++cp) {
+ char group[sizeof("127;")];
+ snprintf(group, sizeof(group), "%hhd;", *cp);
+ len = strlcat(rval, group, sizeof(rval));
+ if (len >= sizeof(rval)) {
+ len = sizeof(rval) - 1;
+ break;
+ }
+ if (*cp == CHAR_MAX) {
+ break;
+ }
+ }
+
+ /* Remove the trailing ';'. */
+ rval[len - 1] = '\0';
+
+ return (rval);
+}
+
+
/*
* keyword value lookup helper (via localeconv())
*/
@@ -500,7 +530,7 @@ kwval_lconv(int id)
lc = localeconv();
switch (id) {
case KW_GROUPING:
- rval = lc->grouping;
+ rval = format_grouping(lc->grouping);
break;
case KW_INT_CURR_SYMBOL:
rval = lc->int_curr_symbol;
@@ -515,7 +545,7 @@ kwval_lconv(int id)
rval = lc->mon_thousands_sep;
break;
case KW_MON_GROUPING:
- rval = lc->mon_grouping;
+ rval = format_grouping(lc->mon_grouping);
break;
case KW_POSITIVE_SIGN:
rval = lc->positive_sign;
diff --git a/usr.bin/locate/bigram/Makefile.depend b/usr.bin/locate/bigram/Makefile.depend
index 9cb890b58360a..4def626103cef 100644
--- a/usr.bin/locate/bigram/Makefile.depend
+++ b/usr.bin/locate/bigram/Makefile.depend
@@ -5,8 +5,10 @@ DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \
include \
+ include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/logname/Makefile.depend b/usr.bin/logname/Makefile.depend
index 9cb890b58360a..4def626103cef 100644
--- a/usr.bin/logname/Makefile.depend
+++ b/usr.bin/logname/Makefile.depend
@@ -5,8 +5,10 @@ DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \
include \
+ include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/netstat/mbuf.c b/usr.bin/netstat/mbuf.c
index 8b95ddddd04b6..c1d0dd35376f3 100644
--- a/usr.bin/netstat/mbuf.c
+++ b/usr.bin/netstat/mbuf.c
@@ -340,6 +340,9 @@ mbpr(void *kvmd, u_long mbaddr)
xo_emit("{:sendfile-pages-valid/%ju} "
"{N:pages were valid at time of a sendfile request}\n",
(uintmax_t)sfstat.sf_pages_valid);
+ xo_emit("{:sendfile-pages-bogus/%ju} "
+ "{N:pages were valid and substituted to bogus page}\n",
+ (uintmax_t)sfstat.sf_pages_bogus);
xo_emit("{:sendfile-requested-readahead/%ju} "
"{N:pages were requested for read ahead by applications}\n",
(uintmax_t)sfstat.sf_rhpages_requested);
diff --git a/usr.bin/printenv/Makefile.depend b/usr.bin/printenv/Makefile.depend
index 3646e2e2b1afa..4def626103cef 100644
--- a/usr.bin/printenv/Makefile.depend
+++ b/usr.bin/printenv/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/tee/Makefile.depend b/usr.bin/tee/Makefile.depend
index 3646e2e2b1afa..4def626103cef 100644
--- a/usr.bin/tee/Makefile.depend
+++ b/usr.bin/tee/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/tr/Makefile.depend b/usr.bin/tr/Makefile.depend
index 3646e2e2b1afa..4def626103cef 100644
--- a/usr.bin/tr/Makefile.depend
+++ b/usr.bin/tr/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c
index 14fad8ca392f4..40c6f54451bdd 100644
--- a/usr.bin/vmstat/vmstat.c
+++ b/usr.bin/vmstat/vmstat.c
@@ -1085,8 +1085,6 @@ dosum(void)
sum.v_vforkpages);
xo_emit("{:pages-rfork/%9u} {N:pages affected by rfork}()\n",
sum.v_rforkpages);
- xo_emit("{:pages-total-cached/%9u} {N:pages cached}\n",
- sum.v_tcached);
xo_emit("{:pages-freed/%9u} {N:pages freed}\n",
sum.v_tfree);
xo_emit("{:pages-freed-by-daemon/%9u} {N:pages freed by daemon}\n",
diff --git a/usr.bin/whois/whois.c b/usr.bin/whois/whois.c
index 4f4062b7c7f1d..de3b946def408 100644
--- a/usr.bin/whois/whois.c
+++ b/usr.bin/whois/whois.c
@@ -119,12 +119,38 @@ static struct {
{ NULL, 0 }
};
+/*
+ * We have a list of patterns for RIRs that assert ignorance rather than
+ * providing referrals. If that happens, we guess that ARIN will be more
+ * helpful. But, before following a referral to an RIR, we check if we have
+ * asked that RIR already, and if so we make another guess.
+ */
static const char *actually_arin[] = {
"netname: ERX-NETBLOCK\n", /* APNIC */
"netname: NON-RIPE-NCC-MANAGED-ADDRESS-BLOCK\n",
NULL
};
+static struct {
+ int loop;
+ const char *host;
+} try_rir[] = {
+ { 0, ANICHOST },
+ { 0, RNICHOST },
+ { 0, PNICHOST },
+ { 0, FNICHOST },
+ { 0, LNICHOST },
+ { 0, NULL }
+};
+
+static void
+reset_rir(void) {
+ int i;
+
+ for (i = 0; try_rir[i].host != NULL; i++)
+ try_rir[i].loop = 0;
+}
+
static const char *port = DEFAULT_PORT;
static const char *choose_server(char *);
@@ -232,6 +258,7 @@ main(int argc, char *argv[])
} else
whois(*argv, host != NULL ? host :
choose_server(*argv), flags);
+ reset_rir();
argv++;
}
exit(0);
@@ -420,7 +447,7 @@ whois(const char *query, const char *hostname, int flags)
FILE *fp;
struct addrinfo *hostres;
char *buf, *host, *nhost, *p;
- int s, f;
+ int comment, s, f;
size_t len, i;
hostres = gethostinfo(hostname, 1);
@@ -467,12 +494,28 @@ whois(const char *query, const char *hostname, int flags)
fprintf(fp, "%s\r\n", query);
fflush(fp);
+ comment = 0;
+ if (!(flags & WHOIS_SPAM_ME) &&
+ (strcasecmp(hostname, ANICHOST) == 0 ||
+ strcasecmp(hostname, RNICHOST) == 0)) {
+ comment = 2;
+ }
+
nhost = NULL;
while ((buf = fgetln(fp, &len)) != NULL) {
/* Nominet */
if (!(flags & WHOIS_SPAM_ME) &&
len == 5 && strncmp(buf, "-- \r\n", 5) == 0)
break;
+ /* RIRs */
+ if (comment == 1 && buf[0] == '#')
+ break;
+ else if (comment == 2) {
+ if (strchr("#%\r\n", buf[0]) != NULL)
+ continue;
+ else
+ comment = 1;
+ }
printf("%.*s", (int)len, buf);
@@ -487,8 +530,7 @@ whois(const char *query, const char *hostname, int flags)
SCAN(p, buf+len, *p == ' ');
host = p;
SCAN(p, buf+len, ishost(*p));
- /* avoid loops */
- if (strncmp(hostname, host, p - host) != 0)
+ if (p > host)
s_asprintf(&nhost, "%.*s",
(int)(p - host), host);
break;
@@ -511,8 +553,37 @@ whois(const char *query, const char *hostname, int flags)
}
fclose(fp);
freeaddrinfo(hostres);
+
+ f = 0;
+ for (i = 0; try_rir[i].host != NULL; i++) {
+ /* Remember visits to RIRs */
+ if (try_rir[i].loop == 0 &&
+ strcasecmp(try_rir[i].host, hostname) == 0)
+ try_rir[i].loop = 1;
+ /* Do we need to find an alternative RIR? */
+ if (try_rir[i].loop != 0 && nhost != NULL &&
+ strcasecmp(try_rir[i].host, nhost) == 0) {
+ free(nhost);
+ nhost = NULL;
+ f = 1;
+ }
+ }
+ if (f) {
+ /* Find a replacement RIR */
+ for (i = 0; try_rir[i].host != NULL; i++) {
+ if (try_rir[i].loop == 0) {
+ s_asprintf(&nhost, "%s",
+ try_rir[i].host);
+ break;
+ }
+ }
+ }
if (nhost != NULL) {
- whois(query, nhost, flags);
+ /* Ignore self-referrals */
+ if (strcasecmp(hostname, nhost) != 0) {
+ printf("# %s\n\n", nhost);
+ whois(query, nhost, flags);
+ }
free(nhost);
}
}
diff --git a/usr.bin/write/Makefile.depend b/usr.bin/write/Makefile.depend
index 3646e2e2b1afa..4def626103cef 100644
--- a/usr.bin/write/Makefile.depend
+++ b/usr.bin/write/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/yes/Makefile.depend b/usr.bin/yes/Makefile.depend
index 9cb890b58360a..4def626103cef 100644
--- a/usr.bin/yes/Makefile.depend
+++ b/usr.bin/yes/Makefile.depend
@@ -5,8 +5,10 @@ DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \
include \
+ include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \