summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2016-01-22 20:41:56 +0000
committerdim <dim@FreeBSD.org>2016-01-22 20:41:56 +0000
commit7cf07624a0c8bc9de65a351f13206cea487afb48 (patch)
tree10bd7a9c1abe1f278df85958745a2a09074c1dda /usr.bin
parentf011e361d3e821edf47ec30d69116ed25a05b696 (diff)
parent66dd616ca8c4d3779be38f549e7e793674dbfd03 (diff)
downloadFreeBSD-src-7cf07624a0c8bc9de65a351f13206cea487afb48.zip
FreeBSD-src-7cf07624a0c8bc9de65a351f13206cea487afb48.tar.gz
Merge ^/head r294169 through r294598.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/finger/net.c13
-rw-r--r--usr.bin/iscsictl/iscsictl.86
-rw-r--r--usr.bin/m4/misc.c4
-rw-r--r--usr.bin/truncate/tests/truncate_test.sh11
-rw-r--r--usr.bin/whois/whois.150
-rw-r--r--usr.bin/whois/whois.c92
-rw-r--r--usr.bin/xlint/arch/riscv/targparam.h53
-rw-r--r--usr.bin/xlint/lint1/param.h3
8 files changed, 156 insertions, 76 deletions
diff --git a/usr.bin/finger/net.c b/usr.bin/finger/net.c
index 2b18b0f..da3a4e1 100644
--- a/usr.bin/finger/net.c
+++ b/usr.bin/finger/net.c
@@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/uio.h>
-#include <ctype.h>
+#include <wctype.h>
#include <db.h>
#include <err.h>
#include <netdb.h>
@@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
#include <utmpx.h>
+#include <wchar.h>
#include "finger.h"
static void cleanup(int sig);
@@ -108,7 +109,7 @@ do_protocol(const char *name, const struct addrinfo *ai)
{
int cnt, line_len, s;
FILE *fp;
- int c, lastc;
+ wint_t c, lastc;
struct iovec iov[3];
struct msghdr msg;
static char slash_w[] = "/W ";
@@ -168,7 +169,7 @@ do_protocol(const char *name, const struct addrinfo *ai)
if ((fp = fdopen(s, "r")) != NULL) {
cnt = 0;
line_len = 0;
- while ((c = getc(fp)) != EOF) {
+ while ((c = getwc(fp)) != EOF) {
if (++cnt > OUTPUT_MAX) {
printf("\n\n Output truncated at %d bytes...\n",
cnt - 1);
@@ -180,7 +181,7 @@ do_protocol(const char *name, const struct addrinfo *ai)
c = '\n';
lastc = '\r';
} else {
- if (!isprint(c) && !isspace(c)) {
+ if (!iswprint(c) && !iswspace(c)) {
c &= 0x7f;
c |= 0x40;
}
@@ -191,7 +192,7 @@ do_protocol(const char *name, const struct addrinfo *ai)
continue;
}
}
- putchar(c);
+ putwchar(c);
if (c != '\n' && ++line_len > _POSIX2_LINE_MAX) {
putchar('\\');
putchar('\n');
@@ -206,7 +207,7 @@ do_protocol(const char *name, const struct addrinfo *ai)
*/
warn("reading from network");
}
- if (lastc != '\n')
+ if (lastc != L'\n')
putchar('\n');
fclose(fp);
diff --git a/usr.bin/iscsictl/iscsictl.8 b/usr.bin/iscsictl/iscsictl.8
index d31e1703..be3762f 100644
--- a/usr.bin/iscsictl/iscsictl.8
+++ b/usr.bin/iscsictl/iscsictl.8
@@ -187,11 +187,11 @@ Attach to target iqn.2012-06.com.example:target0, served by 192.168.1.1:
Disconnect all iSCSI sessions:
.Dl Nm Fl Ra
.Sh SEE ALSO
+.Xr libxo 3 ,
+.Xr xo_parse_args 3 ,
.Xr iscsi 4 ,
.Xr iscsi.conf 5 ,
-.Xr iscsid 8 ,
-.Xr libxo 3 ,
-.Xr xo_parse_args 3
+.Xr iscsid 8
.Sh HISTORY
The
.Nm
diff --git a/usr.bin/m4/misc.c b/usr.bin/m4/misc.c
index eeca68e..aeafea9 100644
--- a/usr.bin/m4/misc.c
+++ b/usr.bin/m4/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.45 2014/12/21 09:33:12 espie Exp $ */
+/* $OpenBSD: misc.c,v 1.46 2015/12/07 14:12:46 espie Exp $ */
/* $NetBSD: misc.c,v 1.6 1995/09/28 05:37:41 tls Exp $ */
/*
@@ -424,6 +424,8 @@ do_emit_synchline(void)
void
release_input(struct input_file *f)
{
+ if (ferror(f->file))
+ errx(1, "Fatal error reading from %s\n", f->name);
if (f->file != stdin)
fclose(f->file);
f->c = EOF;
diff --git a/usr.bin/truncate/tests/truncate_test.sh b/usr.bin/truncate/tests/truncate_test.sh
index e66f48a..369deba 100644
--- a/usr.bin/truncate/tests/truncate_test.sh
+++ b/usr.bin/truncate/tests/truncate_test.sh
@@ -173,26 +173,23 @@ bad_refer_body()
[ ! -e afile ] || atf_fail "afile should not exist"
}
-atf_test_case bad_truncate cleanup
+atf_test_case bad_truncate
bad_truncate_head()
{
atf_set "descr" "Verifies that truncate reports an error during" \
"truncation"
+ atf_set "require.user" "unprivileged"
}
bad_truncate_body()
{
- create_stderr_file "truncate: exists.txt: Operation not permitted"
+ create_stderr_file "truncate: exists.txt: Permission denied"
# Trying to get the ftruncate() call to return -1.
> exists.txt
- atf_check chflags uimmutable exists.txt
+ atf_check chmod 444 exists.txt
atf_check -s not-exit:0 -e file:stderr.txt truncate -s1 exists.txt
}
-bad_truncate_cleanup()
-{
- chflags 0 exists.txt
-}
atf_test_case new_absolute_grow
new_absolute_grow_head()
diff --git a/usr.bin/whois/whois.1 b/usr.bin/whois/whois.1
index a9ed50a..bcc770c 100644
--- a/usr.bin/whois/whois.1
+++ b/usr.bin/whois/whois.1
@@ -28,7 +28,7 @@
.\" From: @(#)whois.1 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
-.Dd May 14, 2015
+.Dd January 22, 2016
.Dt WHOIS 1
.Os
.Sh NAME
@@ -36,7 +36,7 @@
.Nd "Internet domain name and network number directory service"
.Sh SYNOPSIS
.Nm
-.Op Fl aAbfgiIklmPQr
+.Op Fl aAbfgiIklmPQrRS
.Op Fl c Ar country-code | Fl h Ar host
.Op Fl p Ar port
.Ar name ...
@@ -59,18 +59,10 @@ and
.Qq Li whois.nic. Ns Va TLD
and if neither host exists it falls back to its default server.
.Pp
-If an IP address is specified, the whois server will default to
+If an IP address or AS number is specified,
+the whois server will default to
the American Registry for Internet Numbers
.Pq Tn ARIN .
-If a query to
-.Tn ARIN
-references
-.Tn APNIC , AfriNIC , LACNIC ,
-or
-.Tn RIPE ,
-that server will be queried also, provided that the
-.Fl Q
-option is not specified.
.Pp
If
.Nm
@@ -164,18 +156,42 @@ Use the PeeringDB database of AS numbers.
It contains details about presence at internet peering points
for many network operators.
.It Fl Q
-Do a quick lookup.
-This means that
+Do a quick lookup;
.Nm
-will not attempt to lookup the name in the authoritative whois
-server (if one is listed).
-This option has no effect when combined with any other options.
+will not attempt to follow referrals to other whois servers.
+This is the default if a server is explicitly specified
+using one of the other options.
+See also the
+.Fl R
+option.
.It Fl r
Use the R\(aaeseaux IP Europ\(aaeens
.Pq Tn RIPE
database.
It contains network numbers and domain contact information
for Europe.
+.It Fl R
+Do a recursive lookup;
+.Nm
+will attempt to follow referrals to other whois servers.
+This is the default if no server is explicitly specified.
+See also the
+.Fl Q
+option.
+.It Fl S
+By default, if the whois server is
+.Pa whois.verisign-grs.com
+(or a CNAME alias pointing at that name)
+then
+.Nm
+will query for
+.Dl domain Ar name
+The
+.Fl S
+option suppresses this behaviour,
+allowing you to make a loose-matching query,
+or query for host objects using the syntax
+.Dl nameserver Ar name
.El
.Pp
The operands specified to
diff --git a/usr.bin/whois/whois.c b/usr.bin/whois/whois.c
index 278b50c..6be6c40 100644
--- a/usr.bin/whois/whois.c
+++ b/usr.bin/whois/whois.c
@@ -63,7 +63,7 @@ __FBSDID("$FreeBSD$");
#define ANICHOST "whois.arin.net"
#define BNICHOST "whois.registro.br"
#define FNICHOST "whois.afrinic.net"
-#define GERMNICHOST "de.whois-servers.net"
+#define GERMNICHOST "de" QNICHOST_TAIL
#define GNICHOST "whois.nic.gov"
#define IANAHOST "whois.iana.org"
#define INICHOST "whois.networksolutions.com"
@@ -76,14 +76,13 @@ __FBSDID("$FreeBSD$");
#define QNICHOST_HEAD "whois.nic."
#define QNICHOST_TAIL ".whois-servers.net"
#define RNICHOST "whois.ripe.net"
+#define VNICHOST "whois.verisign-grs.com"
#define DEFAULT_PORT "whois"
-#define WHOIS_SERVER_ID "Whois Server: "
-#define WHOIS_ORG_SERVER_ID "Registrant Street1:Whois Server:"
-
#define WHOIS_RECURSE 0x01
#define WHOIS_QUICK 0x02
+#define WHOIS_SPAM_ME 0x04
#define ishost(h) (isalnum((unsigned char)h) || h == '.' || h == '-')
@@ -100,8 +99,20 @@ static struct {
{ NULL, NULL }
};
-static const char *ip_whois[] = { LNICHOST, RNICHOST, PNICHOST, BNICHOST,
- FNICHOST, NULL };
+#define WHOIS_REFERRAL(s) { s, sizeof(s) - 1 }
+static struct {
+ const char *prefix;
+ size_t len;
+} whois_referral[] = {
+ WHOIS_REFERRAL("Whois Server: "),
+ WHOIS_REFERRAL("WHOIS Server: "),
+ WHOIS_REFERRAL(" Whois Server: "),
+ WHOIS_REFERRAL("refer: "),
+ WHOIS_REFERRAL("Registrant Street1:Whois Server:"),
+ WHOIS_REFERRAL("ReferralServer: whois://"),
+ { NULL, 0 }
+};
+
static const char *port = DEFAULT_PORT;
static char *choose_server(char *);
@@ -123,7 +134,7 @@ main(int argc, char *argv[])
country = host = qnichost = NULL;
flags = use_qnichost = 0;
- while ((ch = getopt(argc, argv, "aAbc:fgh:iIklmp:PQr")) != -1) {
+ while ((ch = getopt(argc, argv, "aAbc:fgh:iIklmp:PQrRS")) != -1) {
switch (ch) {
case 'a':
host = ANICHOST;
@@ -173,6 +184,12 @@ main(int argc, char *argv[])
case 'r':
host = RNICHOST;
break;
+ case 'R':
+ flags |= WHOIS_RECURSE;
+ break;
+ case 'S':
+ flags |= WHOIS_SPAM_ME;
+ break;
case '?':
default:
usage();
@@ -235,6 +252,13 @@ choose_server(char *domain)
s_asprintf(&retval, "%s", ANICHOST);
return (retval);
}
+ if (strncasecmp(domain, "AS", 2) == 0) {
+ size_t len = strspn(domain + 2, "0123456789");
+ if (domain[len + 2] == '\0') {
+ s_asprintf(&retval, "%s", ANICHOST);
+ return (retval);
+ }
+ }
for (pos = strchr(domain, '\0'); pos > domain && pos[-1] == '.';)
*--pos = '\0';
if (*domain == '\0')
@@ -285,7 +309,7 @@ gethostinfo(char const *host, int exit_on_noname)
int error;
memset(&hints, 0, sizeof(hints));
- hints.ai_flags = 0;
+ hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
res = NULL;
@@ -317,9 +341,9 @@ whois(const char *query, const char *hostname, int flags)
FILE *fp;
struct addrinfo *hostres, *res;
char *buf, *host, *nhost, *p;
- int s = -1, f;
+ int s = -1, f, antispam;
nfds_t i, j;
- size_t c, len, count;
+ size_t len, count;
struct pollfd *fds;
int timeout = 180;
@@ -327,6 +351,9 @@ whois(const char *query, const char *hostname, int flags)
for (res = hostres, count = 0; res; res = res->ai_next)
count++;
+ antispam = (flags & WHOIS_SPAM_ME) == 0 &&
+ strcmp(hostres->ai_canonname, VNICHOST) == 0;
+
fds = calloc(count, sizeof(*fds));
if (fds == NULL)
err(EX_OSERR, "calloc()");
@@ -457,6 +484,8 @@ done:
fprintf(fp, "-T dn,ace -C ISO-8859-1 %s\r\n", query);
} else if (strcmp(hostname, "dk" QNICHOST_TAIL) == 0) {
fprintf(fp, "--show-handles %s\r\n", query);
+ } else if (antispam) {
+ fprintf(fp, "domain %s\r\n", query);
} else {
fprintf(fp, "%s\r\n", query);
}
@@ -468,39 +497,18 @@ done:
printf("%.*s\n", (int)len, buf);
if ((flags & WHOIS_RECURSE) && nhost == NULL) {
- host = strnstr(buf, WHOIS_SERVER_ID, len);
- if (host != NULL) {
- host += sizeof(WHOIS_SERVER_ID) - 1;
- for (p = host; p < buf + len; p++) {
- if (!ishost(*p)) {
- *p = '\0';
+ for (i = 0; whois_referral[i].prefix != NULL; i++) {
+ if (strncmp(buf,
+ whois_referral[i].prefix,
+ whois_referral[i].len) != 0)
+ continue;
+ host = buf + whois_referral[i].len;
+ for (p = host; p < buf + len; p++)
+ if (!ishost(*p))
break;
- }
- }
s_asprintf(&nhost, "%.*s",
- (int)(buf + len - host), host);
- } else if ((host =
- strnstr(buf, WHOIS_ORG_SERVER_ID, len)) != NULL) {
- host += sizeof(WHOIS_ORG_SERVER_ID) - 1;
- for (p = host; p < buf + len; p++) {
- if (!ishost(*p)) {
- *p = '\0';
- break;
- }
- }
- s_asprintf(&nhost, "%.*s",
- (int)(buf + len - host), host);
- } else if (strcmp(hostname, ANICHOST) == 0) {
- for (c = 0; c <= len; c++)
- buf[c] = tolower((unsigned char)buf[c]);
- for (i = 0; ip_whois[i] != NULL; i++) {
- if (strnstr(buf, ip_whois[i], len) !=
- NULL) {
- s_asprintf(&nhost, "%s",
- ip_whois[i]);
- break;
- }
- }
+ (int)(p - host), host);
+ break;
}
}
}
@@ -515,7 +523,7 @@ static void
usage(void)
{
fprintf(stderr,
- "usage: whois [-aAbfgiIklmPQr] [-c country-code | -h hostname] "
+ "usage: whois [-aAbfgiIklmPQrRS] [-c country-code | -h hostname] "
"[-p port] name ...\n");
exit(EX_USAGE);
}
diff --git a/usr.bin/xlint/arch/riscv/targparam.h b/usr.bin/xlint/arch/riscv/targparam.h
new file mode 100644
index 0000000..8d57fbd
--- /dev/null
+++ b/usr.bin/xlint/arch/riscv/targparam.h
@@ -0,0 +1,53 @@
+/* $NetBSD: targparam.h,v 1.2 2002/01/30 06:55:00 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Jochen Pohl
+ * 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 Jochen Pohl for
+ * The NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/*
+ * Machine-dependent target parameters for lint1.
+ */
+
+#include "lp64.h"
+
+/*
+ * Should be set to 1 if the difference of two pointers is of type long
+ * or the value of sizeof is of type unsigned long. Note this MUST be
+ * kept in sync with the compiler!
+ */
+
+#define PTRDIFF_IS_LONG 1
+#define SIZEOF_IS_ULONG 1
+
+#define FLOAT_SIZE (4 * CHAR_BIT)
+#define DOUBLE_SIZE (8 * CHAR_BIT)
+#define LDOUBLE_SIZE (16 * CHAR_BIT)
+
+#define ENUM_SIZE (4 * CHAR_BIT)
diff --git a/usr.bin/xlint/lint1/param.h b/usr.bin/xlint/lint1/param.h
index 7d31373..1e15fbd 100644
--- a/usr.bin/xlint/lint1/param.h
+++ b/usr.bin/xlint/lint1/param.h
@@ -80,6 +80,9 @@
#elif __powerpc__
#define PTRDIFF_IS_LONG 0
#define SIZEOF_IS_ULONG 0
+#elif __riscv__
+#define PTRDIFF_IS_LONG 1
+#define SIZEOF_IS_ULONG 1
#elif __sparc__
#define PTRDIFF_IS_LONG 0
#define SIZEOF_IS_ULONG 0
OpenPOWER on IntegriCloud