summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/arp/arp.c114
-rw-r--r--usr.sbin/bhyve/virtio.h2
-rwxr-xr-xusr.sbin/bsdinstall/scripts/auto7
-rw-r--r--usr.sbin/etcupdate/tests/Makefile2
-rw-r--r--usr.sbin/fstyp/tests/Makefile2
-rw-r--r--usr.sbin/kldxref/ef.c4
-rw-r--r--usr.sbin/newsyslog/tests/Makefile2
-rw-r--r--usr.sbin/nmtree/tests/Makefile4
-rw-r--r--usr.sbin/pw/tests/Makefile2
-rw-r--r--usr.sbin/sa/tests/Makefile2
-rw-r--r--usr.sbin/syslogd/syslogd.c14
-rw-r--r--usr.sbin/tests/Makefile4
-rw-r--r--usr.sbin/vidcontrol/vidcontrol.c44
-rw-r--r--usr.sbin/watchdogd/watchdogd.82
-rw-r--r--usr.sbin/watchdogd/watchdogd.c2
15 files changed, 99 insertions, 108 deletions
diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c
index eefde75..60079d4 100644
--- a/usr.sbin/arp/arp.c
+++ b/usr.sbin/arp/arp.c
@@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
* arp - display, set, and delete arp table entries
*/
-
#include <sys/param.h>
#include <sys/file.h>
#include <sys/socket.h>
@@ -80,8 +79,8 @@ __FBSDID("$FreeBSD$");
#include <strings.h>
#include <unistd.h>
-typedef void (action_fn)(struct sockaddr_dl *sdl,
- struct sockaddr_in *s_in, struct rt_msghdr *rtm);
+typedef void (action_fn)(struct sockaddr_dl *sdl, struct sockaddr_in *s_in,
+ struct rt_msghdr *rtm);
static int search(u_long addr, action_fn *action);
static action_fn print_entry;
@@ -320,7 +319,7 @@ set(int argc, char **argv)
return (1);
doing_proxy = flags = expire_time = 0;
while (argc-- > 0) {
- if (strncmp(argv[0], "temp", 4) == 0) {
+ if (strcmp(argv[0], "temp") == 0) {
struct timespec tp;
int max_age;
size_t len = sizeof(max_age);
@@ -330,10 +329,10 @@ set(int argc, char **argv)
&max_age, &len, NULL, 0) != 0)
err(1, "sysctlbyname");
expire_time = tp.tv_sec + max_age;
- } else if (strncmp(argv[0], "pub", 3) == 0) {
+ } else if (strcmp(argv[0], "pub") == 0) {
flags |= RTF_ANNOUNCE;
doing_proxy = 1;
- if (argc && strncmp(argv[1], "only", 3) == 0) {
+ if (argc && strcmp(argv[1], "only") == 0) {
/*
* Compatibility: in pre FreeBSD 8 times
* the "only" keyword used to mean that
@@ -342,27 +341,28 @@ set(int argc, char **argv)
*/
argc--; argv++;
}
- } else if (strncmp(argv[0], "blackhole", 9) == 0) {
+ } else if (strcmp(argv[0], "blackhole") == 0) {
if (flags & RTF_REJECT) {
- printf("Choose one of blackhole or reject, not both.\n");
+ errx(1, "Choose one of blackhole or reject, "
+ "not both.");
}
flags |= RTF_BLACKHOLE;
- } else if (strncmp(argv[0], "reject", 6) == 0) {
+ } else if (strcmp(argv[0], "reject") == 0) {
if (flags & RTF_BLACKHOLE) {
- printf("Choose one of blackhole or reject, not both.\n");
+ errx(1, "Choose one of blackhole or reject, "
+ "not both.");
}
flags |= RTF_REJECT;
- } else if (strncmp(argv[0], "trail", 5) == 0) {
- /* XXX deprecated and undocumented feature */
- printf("%s: Sending trailers is no longer supported\n",
- host);
+ } else {
+ warnx("Invalid parameter '%s'", argv[0]);
+ usage();
}
argv++;
}
ea = (struct ether_addr *)LLADDR(&sdl_m);
if (doing_proxy && !strcmp(eaddr, "auto")) {
if (!get_ether_addr(dst->sin_addr.s_addr, ea)) {
- printf("no interface found for %s\n",
+ warnx("no interface found for %s",
inet_ntoa(dst->sin_addr));
return (1);
}
@@ -381,7 +381,7 @@ set(int argc, char **argv)
/*
* In the case a proxy-arp entry is being added for
- * a remote end point, the RTF_ANNOUNCE flag in the
+ * a remote end point, the RTF_ANNOUNCE flag in the
* RTM_GET command is an indication to the kernel
* routing code that the interface associated with
* the prefix route covering the local end of the
@@ -398,7 +398,7 @@ set(int argc, char **argv)
if ((sdl->sdl_family != AF_LINK) ||
(rtm->rtm_flags & RTF_GATEWAY) ||
!valid_type(sdl->sdl_type)) {
- printf("cannot intuit interface index and type for %s\n", host);
+ warnx("cannot intuit interface index and type for %s", host);
return (1);
}
sdl_m.sdl_type = sdl->sdl_type;
@@ -467,7 +467,7 @@ delete(char *host)
sdl = (struct sockaddr_dl *)(SA_SIZE(addr) + (char *)addr);
/*
- * With the new L2/L3 restructure, the route
+ * With the new L2/L3 restructure, the route
* returned is a prefix route. The important
* piece of information from the previous
* RTM_GET is the interface index. In the
@@ -486,7 +486,7 @@ delete(char *host)
* is a proxy-arp entry to remove.
*/
if (flags & RTF_ANNOUNCE) {
- fprintf(stderr, "delete: cannot locate %s\n",host);
+ warnx("delete: cannot locate %s", host);
return (1);
}
@@ -525,7 +525,7 @@ search(u_long addr, action_fn *action)
mib[5] = RTF_LLINFO;
#else
mib[5] = 0;
-#endif
+#endif
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
err(1, "route-sysctl-estimate");
if (needed == 0) /* empty table */
@@ -575,7 +575,7 @@ print_entry(struct sockaddr_dl *sdl,
struct if_nameindex *p;
int seg;
- if (ifnameindex == NULL)
+ if (ifnameindex == NULL)
if ((ifnameindex = if_nameindex()) == NULL)
err(1, "cannot retrieve interface names");
@@ -597,7 +597,8 @@ print_entry(struct sockaddr_dl *sdl,
sdl->sdl_type == IFT_L2VLAN ||
sdl->sdl_type == IFT_BRIDGE) &&
sdl->sdl_alen == ETHER_ADDR_LEN)
- printf("%s", ether_ntoa((struct ether_addr *)LLADDR(sdl)));
+ printf("%s",
+ ether_ntoa((struct ether_addr *)LLADDR(sdl)));
else {
int n = sdl->sdl_nlen > 0 ? sdl->sdl_nlen + 1 : 0;
@@ -607,7 +608,7 @@ print_entry(struct sockaddr_dl *sdl,
printf("(incomplete)");
for (p = ifnameindex; p && ifnameindex->if_index &&
- ifnameindex->if_name; p++) {
+ ifnameindex->if_name; p++) {
if (p->if_index == sdl->sdl_index) {
printf(" on %s", p->if_name);
break;
@@ -629,31 +630,31 @@ print_entry(struct sockaddr_dl *sdl,
printf(" published");
switch(sdl->sdl_type) {
case IFT_ETHER:
- printf(" [ethernet]");
- break;
+ printf(" [ethernet]");
+ break;
case IFT_ISO88025:
- printf(" [token-ring]");
+ printf(" [token-ring]");
trld = SDL_ISO88025(sdl);
if (trld->trld_rcf != 0) {
printf(" rt=%x", ntohs(trld->trld_rcf));
for (seg = 0;
seg < ((TR_RCF_RIFLEN(trld->trld_rcf) - 2 ) / 2);
- seg++)
+ seg++)
printf(":%x", ntohs(*(trld->trld_route[seg])));
}
break;
case IFT_FDDI:
- printf(" [fddi]");
- break;
+ printf(" [fddi]");
+ break;
case IFT_ATM:
- printf(" [atm]");
- break;
+ printf(" [atm]");
+ break;
case IFT_L2VLAN:
printf(" [vlan]");
break;
case IFT_IEEE1394:
- printf(" [firewire]");
- break;
+ printf(" [firewire]");
+ break;
case IFT_BRIDGE:
printf(" [bridge]");
break;
@@ -662,8 +663,8 @@ print_entry(struct sockaddr_dl *sdl,
break;
default:
break;
- }
-
+ }
+
printf("\n");
}
@@ -688,13 +689,13 @@ static void
usage(void)
{
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
- "usage: arp [-n] [-i interface] hostname",
- " arp [-n] [-i interface] -a",
- " arp -d hostname [pub]",
- " arp -d [-i interface] -a",
- " arp -s hostname ether_addr [temp] [reject | blackhole] [pub [only]]",
- " arp -S hostname ether_addr [temp] [reject | blackhole] [pub [only]]",
- " arp -f filename");
+ "usage: arp [-n] [-i interface] hostname",
+ " arp [-n] [-i interface] -a",
+ " arp -d hostname [pub]",
+ " arp -d [-i interface] -a",
+ " arp -s hostname ether_addr [temp] [reject | blackhole] [pub [only]]",
+ " arp -S hostname ether_addr [temp] [reject | blackhole] [pub [only]]",
+ " arp -f filename");
exit(1);
}
@@ -753,12 +754,12 @@ rtmsg(int cmd, struct sockaddr_in *dst, struct sockaddr_dl *sdl)
case RTM_GET:
rtm->rtm_addrs |= RTA_DST;
}
-#define NEXTADDR(w, s) \
- do { \
- if ((s) != NULL && rtm->rtm_addrs & (w)) { \
- bcopy((s), cp, sizeof(*(s))); \
- cp += SA_SIZE(s); \
- } \
+#define NEXTADDR(w, s) \
+ do { \
+ if ((s) != NULL && rtm->rtm_addrs & (w)) { \
+ bcopy((s), cp, sizeof(*(s))); \
+ cp += SA_SIZE(s); \
+ } \
} while (0)
NEXTADDR(RTA_DST, dst);
@@ -814,7 +815,7 @@ get_ether_addr(in_addr_t ipaddr, struct ether_addr *hwaddr)
}
#define NEXTIFR(i) \
- ((struct ifreq *)((char *)&(i)->ifr_addr \
+ ((struct ifreq *)((char *)&(i)->ifr_addr \
+ MAX((i)->ifr_addr.sa_len, sizeof((i)->ifr_addr))) )
/*
@@ -835,14 +836,10 @@ get_ether_addr(in_addr_t ipaddr, struct ether_addr *hwaddr)
if (ioctl(sock, SIOCGIFFLAGS, &ifreq) < 0)
continue;
if ((ifreq.ifr_flags &
- (IFF_UP|IFF_BROADCAST|IFF_POINTOPOINT|
- IFF_LOOPBACK|IFF_NOARP))
- != (IFF_UP|IFF_BROADCAST))
+ (IFF_UP|IFF_BROADCAST|IFF_POINTOPOINT|
+ IFF_LOOPBACK|IFF_NOARP)) != (IFF_UP|IFF_BROADCAST))
continue;
- /*
- * Get its netmask and check that it's on
- * the right subnet.
- */
+ /* Get its netmask and check that it's on the right subnet. */
if (ioctl(sock, SIOCGIFNETMASK, &ifreq) < 0)
continue;
mask = ((struct sockaddr_in *)
@@ -872,9 +869,8 @@ get_ether_addr(in_addr_t ipaddr, struct ether_addr *hwaddr)
*/
dla = (struct sockaddr_dl *) &ifr->ifr_addr;
memcpy(hwaddr, LLADDR(dla), dla->sdl_alen);
- printf("using interface %s for proxy with address ",
- ifp->ifr_name);
- printf("%s\n", ether_ntoa(hwaddr));
+ printf("using interface %s for proxy with address %s\n", ifp->ifr_name,
+ ether_ntoa(hwaddr));
retval = dla->sdl_alen;
done:
close(sock);
diff --git a/usr.sbin/bhyve/virtio.h b/usr.sbin/bhyve/virtio.h
index 0e96a1d..28eecc7 100644
--- a/usr.sbin/bhyve/virtio.h
+++ b/usr.sbin/bhyve/virtio.h
@@ -209,7 +209,7 @@ struct vring_used {
#define VIRTIO_VENDOR 0x1AF4
#define VIRTIO_DEV_NET 0x1000
#define VIRTIO_DEV_BLOCK 0x1001
-#define VIRTIO_DEV_RANDOM 0x1002
+#define VIRTIO_DEV_RANDOM 0x1005
/*
* PCI config space constants.
diff --git a/usr.sbin/bsdinstall/scripts/auto b/usr.sbin/bsdinstall/scripts/auto
index b7ce48b..fd88c84 100755
--- a/usr.sbin/bsdinstall/scripts/auto
+++ b/usr.sbin/bsdinstall/scripts/auto
@@ -387,9 +387,11 @@ finalconfig
trap error SIGINT # SIGINT is bad again
bsdinstall config || error "Failed to save config"
+if [ -n "$DISTDIR_IS_UNIONFS" ]; then
+ umount -f $BSDINSTALL_DISTDIR
+fi
+
if [ ! -z "$BSDINSTALL_FETCHDEST" ]; then
- [ "$BSDINSTALL_FETCHDEST" != "$BSDINSTALL_DISTDIR" ] && \
- umount "$BSDINSTALL_DISTDIR"
rm -rf "$BSDINSTALL_FETCHDEST"
fi
@@ -398,7 +400,6 @@ dialog --backtitle "FreeBSD Installer" --title "Manual Configuration" \
"The installation is now finished. Before exiting the installer, would you like to open a shell in the new system to make any final manual modifications?" 0 0
if [ $? -eq 0 ]; then
clear
- mount -t devfs devfs "$BSDINSTALL_CHROOT/dev"
echo This shell is operating in a chroot in the new system. \
When finished making configuration changes, type \"exit\".
chroot "$BSDINSTALL_CHROOT" /bin/sh 2>&1
diff --git a/usr.sbin/etcupdate/tests/Makefile b/usr.sbin/etcupdate/tests/Makefile
index da83397..45b12b7 100644
--- a/usr.sbin/etcupdate/tests/Makefile
+++ b/usr.sbin/etcupdate/tests/Makefile
@@ -1,7 +1,5 @@
# $FreeBSD$
-TESTSDIR= ${TESTSBASE}/usr.sbin/etcupdate
-
PLAIN_TESTS_SH=
.for test in always_test \
conflicts_test \
diff --git a/usr.sbin/fstyp/tests/Makefile b/usr.sbin/fstyp/tests/Makefile
index db686b59..01c9869 100644
--- a/usr.sbin/fstyp/tests/Makefile
+++ b/usr.sbin/fstyp/tests/Makefile
@@ -1,7 +1,5 @@
# $FreeBSD$
-TESTSDIR= ${TESTSBASE}/usr.sbin/fstyp
-
ATF_TESTS_SH= fstyp_test
FILES= ext2.img.bz2
diff --git a/usr.sbin/kldxref/ef.c b/usr.sbin/kldxref/ef.c
index 88fbc34..d700b2a 100644
--- a/usr.sbin/kldxref/ef.c
+++ b/usr.sbin/kldxref/ef.c
@@ -47,7 +47,7 @@
#include "ef.h"
-#define MAXSEGS 2
+#define MAXSEGS 3
struct ef_file {
char* ef_name;
struct elf_file *ef_efile;
@@ -600,7 +600,7 @@ ef_open(const char *filename, struct elf_file *efile, int verbose)
filename);
break;
} else if (nsegs > MAXSEGS) {
- warnx("%s: too many sections", filename);
+ warnx("%s: too many segments", filename);
break;
}
ef->ef_nsegs = nsegs;
diff --git a/usr.sbin/newsyslog/tests/Makefile b/usr.sbin/newsyslog/tests/Makefile
index f8ad273..802a44c 100644
--- a/usr.sbin/newsyslog/tests/Makefile
+++ b/usr.sbin/newsyslog/tests/Makefile
@@ -1,7 +1,5 @@
# $FreeBSD$
-TESTSDIR= ${TESTSBASE}/usr.sbin/newsyslog
-
TAP_TESTS_SH= legacy_test
.include <bsd.test.mk>
diff --git a/usr.sbin/nmtree/tests/Makefile b/usr.sbin/nmtree/tests/Makefile
index 1df81d0..0b63127 100644
--- a/usr.sbin/nmtree/tests/Makefile
+++ b/usr.sbin/nmtree/tests/Makefile
@@ -1,10 +1,8 @@
# $FreeBSD$
-TESTSRC= ${.CURDIR}/../../../contrib/netbsd-tests/usr.sbin/mtree
+TESTSRC= ${SRCTOP}/contrib/netbsd-tests/usr.sbin/mtree
.PATH: ${TESTSRC}
-TESTSDIR= ${TESTSBASE}/usr.sbin/nmtree
-
ATF_TESTS_SH= nmtree_test
ATF_TESTS_SH_SRC_nmtree_test= t_mtree.sh
diff --git a/usr.sbin/pw/tests/Makefile b/usr.sbin/pw/tests/Makefile
index 07a8069..613d8b5 100644
--- a/usr.sbin/pw/tests/Makefile
+++ b/usr.sbin/pw/tests/Makefile
@@ -1,7 +1,5 @@
# $FreeBSD$
-TESTSDIR= ${TESTSBASE}/usr.sbin/pw
-
BINDIR= ${TESTSDIR}
PROGS+= crypt
diff --git a/usr.sbin/sa/tests/Makefile b/usr.sbin/sa/tests/Makefile
index 2fdbbea..399d7d1 100644
--- a/usr.sbin/sa/tests/Makefile
+++ b/usr.sbin/sa/tests/Makefile
@@ -1,7 +1,5 @@
# $FreeBSD$
-TESTSDIR= ${TESTSBASE}/usr.sbin/sa
-
TAP_TESTS_SH= legacy_test
TEST_METADATA.legacy_test+= allowed_architectures="amd64 i386 sparc64"
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index 4fcd6d9..24d1cea 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -79,15 +79,15 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <sys/socket.h>
#include <sys/queue.h>
-#include <sys/uio.h>
-#include <sys/un.h>
-#include <sys/time.h>
#include <sys/resource.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
#include <sys/syslimits.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/un.h>
+#include <sys/wait.h>
#include <sys/types.h>
#include <sys/mman.h>
@@ -2204,7 +2204,7 @@ markit(void)
/*
* fork off and become a daemon, but wait for the child to come online
- * before returing to the parent, or we get disk thrashing at boot etc.
+ * before returning to the parent, or we get disk thrashing at boot etc.
* Set a timer so we don't hang forever if it wedges.
*/
static int
diff --git a/usr.sbin/tests/Makefile b/usr.sbin/tests/Makefile
index a7e9c71..a0e63e5 100644
--- a/usr.sbin/tests/Makefile
+++ b/usr.sbin/tests/Makefile
@@ -2,9 +2,7 @@
.include <bsd.own.mk>
-TESTSDIR= ${TESTSBASE}/usr.sbin
-
-.PATH: ${.CURDIR:H:H}/tests
+.PATH: ${SRCTOP}/tests
KYUAFILE= yes
.include <bsd.test.mk>
diff --git a/usr.sbin/vidcontrol/vidcontrol.c b/usr.sbin/vidcontrol/vidcontrol.c
index e1981f3..5933dcd 100644
--- a/usr.sbin/vidcontrol/vidcontrol.c
+++ b/usr.sbin/vidcontrol/vidcontrol.c
@@ -393,11 +393,15 @@ load_vt4mappingtable(unsigned int nmappings, FILE *f)
if (nmappings == 0)
return (NULL);
- t = malloc(sizeof *t * nmappings);
+ if ((t = malloc(sizeof *t * nmappings)) == NULL) {
+ warn("malloc");
+ return (NULL);
+ }
if (fread(t, sizeof *t * nmappings, 1, f) != 1) {
- perror("mappings");
- exit(1);
+ warn("read mappings");
+ free(t);
+ return (NULL);
}
for (i = 0; i < nmappings; i++) {
@@ -422,7 +426,7 @@ load_default_vt4font(void)
}
}
-static int
+static void
load_vt4font(FILE *f)
{
struct vt4font_header fh;
@@ -431,13 +435,13 @@ load_vt4font(FILE *f)
unsigned int i;
if (fread(&fh, sizeof fh, 1, f) != 1) {
- perror("file_header");
- return (1);
+ warn("read file_header");
+ return;
}
if (memcmp(fh.magic, "VFNT0002", 8) != 0) {
- fprintf(stderr, "Bad magic\n");
- return (1);
+ warnx("bad magic in font file\n");
+ return;
}
for (i = 0; i < VFNT_MAPS; i++)
@@ -447,21 +451,26 @@ load_vt4font(FILE *f)
vfnt.height = fh.height;
glyphsize = howmany(vfnt.width, 8) * vfnt.height * vfnt.glyph_count;
- vfnt.glyphs = malloc(glyphsize);
+ if ((vfnt.glyphs = malloc(glyphsize)) == NULL) {
+ warn("malloc");
+ return;
+ }
if (fread(vfnt.glyphs, glyphsize, 1, f) != 1) {
- perror("glyphs");
- return (1);
+ warn("read glyphs");
+ free(vfnt.glyphs);
+ return;
}
for (i = 0; i < VFNT_MAPS; i++)
vfnt.map[i] = load_vt4mappingtable(vfnt.map_count[i], f);
- if (ioctl(STDIN_FILENO, PIO_VFONT, &vfnt) == -1) {
- perror("PIO_VFONT");
- return (1);
- }
- return (0);
+ if (ioctl(STDIN_FILENO, PIO_VFONT, &vfnt) == -1)
+ warn("PIO_VFONT");
+
+ for (i = 0; i < VFNT_MAPS; i++)
+ free(vfnt.map[i]);
+ free(vfnt.glyphs);
}
/*
@@ -511,8 +520,7 @@ load_font(const char *type, const char *filename)
}
if (vt4_mode) {
- if(load_vt4font(fd))
- warn("failed to load font \"%s\"", filename);
+ load_vt4font(fd);
fclose(fd);
return;
}
diff --git a/usr.sbin/watchdogd/watchdogd.8 b/usr.sbin/watchdogd/watchdogd.8
index 5f4b68a..cdf5778 100644
--- a/usr.sbin/watchdogd/watchdogd.8
+++ b/usr.sbin/watchdogd/watchdogd.8
@@ -80,7 +80,7 @@ reboot if there are problems with the script.
The
.Fl s Ar sleep
argument can be used to control the sleep period between each execution
-of the check and defaults to one second.
+of the check and defaults to 10 seconds.
.Pp
The
.Fl t Ar timeout
diff --git a/usr.sbin/watchdogd/watchdogd.c b/usr.sbin/watchdogd/watchdogd.c
index 3bad9ac..1271bbf 100644
--- a/usr.sbin/watchdogd/watchdogd.c
+++ b/usr.sbin/watchdogd/watchdogd.c
@@ -80,7 +80,7 @@ static u_int timeout = WD_TO_128SEC;
static u_int exit_timeout = WD_TO_NEVER;
static u_int pretimeout = 0;
static u_int timeout_sec;
-static u_int nap = 1;
+static u_int nap = 10;
static int passive = 0;
static int is_daemon = 0;
static int is_dry_run = 0; /* do not arm the watchdog, only
OpenPOWER on IntegriCloud