aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/Makefile3
-rw-r--r--usr.sbin/acpi/acpidump/acpi.c8
-rw-r--r--usr.sbin/ancontrol/ancontrol.c4
-rw-r--r--usr.sbin/autofs/common.c1
-rw-r--r--usr.sbin/bhyve/pci_fbuf.c48
-rw-r--r--usr.sbin/bhyve/pci_xhci.c3
-rw-r--r--usr.sbin/bsdinstall/partedit/gpart_ops.c26
-rwxr-xr-xusr.sbin/bsdinstall/scripts/hardening7
-rwxr-xr-xusr.sbin/etcupdate/etcupdate.sh16
-rw-r--r--usr.sbin/kgzip/kgzip.817
-rw-r--r--usr.sbin/newsyslog/newsyslog.c28
-rw-r--r--usr.sbin/pciconf/cap.c5
-rw-r--r--usr.sbin/pkg/pkg.c1
-rw-r--r--usr.sbin/pmcstudy/pmcstudy.c6
-rw-r--r--usr.sbin/pw/pw.h1
-rw-r--r--usr.sbin/pw/pw_vpw.c6
-rw-r--r--usr.sbin/pw/pwupd.h10
-rw-r--r--usr.sbin/services_mkdb/services_mkdb.c1
-rw-r--r--usr.sbin/uathload/uathload.c36
19 files changed, 140 insertions, 87 deletions
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile
index b08a65a28c88..67499a10b5c6 100644
--- a/usr.sbin/Makefile
+++ b/usr.sbin/Makefile
@@ -25,6 +25,7 @@ SUBDIR= adduser \
digictl \
diskinfo \
dumpcis \
+ etcupdate \
extattr \
extattrctl \
fifolog \
@@ -181,13 +182,13 @@ SUBDIR.${MK_PKGBOOTSTRAP}+= pkg
SUBDIR.${MK_PMC}+= pmcannotate
SUBDIR.${MK_PMC}+= pmccontrol
SUBDIR.${MK_PMC}+= pmcstat
+SUBDIR.${MK_PMC}+= pmcstudy
SUBDIR.${MK_PORTSNAP}+= portsnap
SUBDIR.${MK_PPP}+= ppp
SUBDIR.${MK_QUOTAS}+= edquota
SUBDIR.${MK_QUOTAS}+= quotaon
SUBDIR.${MK_QUOTAS}+= repquota
SUBDIR.${MK_RCMDS}+= rwhod
-SUBDIR.${MK_RCS}+= etcupdate
SUBDIR.${MK_SENDMAIL}+= editmap
SUBDIR.${MK_SENDMAIL}+= mailstats
SUBDIR.${MK_SENDMAIL}+= makemap
diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c
index e790ef118b74..6d3f31a1938c 100644
--- a/usr.sbin/acpi/acpidump/acpi.c
+++ b/usr.sbin/acpi/acpidump/acpi.c
@@ -1494,8 +1494,8 @@ aml_disassemble(ACPI_TABLE_HEADER *rsdt, ACPI_TABLE_HEADER *dsdp)
perror("mkdtemp tmp working dir");
return;
}
- assert((size_t)snprintf(tmpstr, sizeof(tmpstr), "%s%s", wrkdir, iname)
- <= sizeof(tmpstr) - 1);
+ len = (size_t)snprintf(tmpstr, sizeof(tmpstr), "%s%s", wrkdir, iname);
+ assert(len <= sizeof(tmpstr) - 1);
fd = open(tmpstr, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
if (fd < 0) {
perror("iasl tmp file");
@@ -1527,8 +1527,8 @@ aml_disassemble(ACPI_TABLE_HEADER *rsdt, ACPI_TABLE_HEADER *dsdp)
}
/* Dump iasl's output to stdout */
- assert((size_t)snprintf(tmpstr, sizeof(tmpstr), "%s%s", wrkdir, oname)
- <= sizeof(tmpstr) -1);
+ len = (size_t)snprintf(tmpstr, sizeof(tmpstr), "%s%s", wrkdir, oname);
+ assert(len <= sizeof(tmpstr) - 1);
fp = fopen(tmpstr, "r");
if (unlink(tmpstr) < 0) {
perror("unlink");
diff --git a/usr.sbin/ancontrol/ancontrol.c b/usr.sbin/ancontrol/ancontrol.c
index 4ff32ff19098..ba2419a7f90e 100644
--- a/usr.sbin/ancontrol/ancontrol.c
+++ b/usr.sbin/ancontrol/ancontrol.c
@@ -573,9 +573,9 @@ an_dumpstats(const char *iface)
printf("Management frames transmitted:\t\t\t[ %u ]\n",
stats->an_tx_mgmt_pkts);
printf("Refresh frames received:\t\t\t[ %u ]\n",
- stats->an_rx_refresh_pkts),
+ stats->an_rx_refresh_pkts);
printf("Refresh frames transmitted:\t\t\t[ %u ]\n",
- stats->an_tx_refresh_pkts),
+ stats->an_tx_refresh_pkts);
printf("Poll frames received:\t\t\t\t[ %u ]\n",
stats->an_rx_poll_pkts);
printf("Poll frames transmitted:\t\t\t[ %u ]\n",
diff --git a/usr.sbin/autofs/common.c b/usr.sbin/autofs/common.c
index 584c10b46961..42b64f84bdda 100644
--- a/usr.sbin/autofs/common.c
+++ b/usr.sbin/autofs/common.c
@@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$");
#include <signal.h>
#include <stdbool.h>
#include <stdint.h>
-#define _WITH_GETLINE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/usr.sbin/bhyve/pci_fbuf.c b/usr.sbin/bhyve/pci_fbuf.c
index 22ec86c5bd3b..c2de6221afbb 100644
--- a/usr.sbin/bhyve/pci_fbuf.c
+++ b/usr.sbin/bhyve/pci_fbuf.c
@@ -95,7 +95,8 @@ struct pci_fbuf_softc {
char *rfb_host;
int rfb_port;
int rfb_wait;
- int use_vga;
+ int vga_enabled;
+ int vga_full;
uint32_t fbaddr;
char *fb_base;
@@ -114,7 +115,7 @@ pci_fbuf_usage(char *opt)
{
fprintf(stderr, "Invalid fbuf emulation \"%s\"\r\n", opt);
- fprintf(stderr, "fbuf: {wait,}tcp=<ip>:port\r\n");
+ fprintf(stderr, "fbuf: {wait,}{vga=on|io|off,}rfb=<ip>:port\r\n");
}
static void
@@ -234,13 +235,6 @@ pci_fbuf_parse_opts(struct pci_fbuf_softc *sc, char *opts)
continue;
}
-#if 0 /* notyet */
- if (strcmp(xopts, "vga") == 0) {
- sc->use_vga = 1;
- continue;
- }
-#endif
-
if ((config = strchr(xopts, '=')) == NULL) {
pci_fbuf_usage(xopts);
ret = -1;
@@ -252,17 +246,31 @@ pci_fbuf_parse_opts(struct pci_fbuf_softc *sc, char *opts)
DPRINTF(DEBUG_VERBOSE, ("pci_fbuf option %s = %s\r\n",
xopts, config));
- if (!strcmp(xopts, "tcp")) {
+ if (!strcmp(xopts, "tcp") || !strcmp(xopts, "rfb")) {
/* parse host-ip:port */
- tmpstr = strsep(&config, ":");
+ tmpstr = strsep(&config, ":");
if (!config)
sc->rfb_port = atoi(tmpstr);
else {
sc->rfb_port = atoi(config);
sc->rfb_host = tmpstr;
}
- } else if (!strcmp(xopts, "w")) {
- sc->memregs.width = atoi(config);
+ } else if (!strcmp(xopts, "vga")) {
+ if (!strcmp(config, "off")) {
+ sc->vga_enabled = 0;
+ } else if (!strcmp(config, "io")) {
+ sc->vga_enabled = 1;
+ sc->vga_full = 0;
+ } else if (!strcmp(config, "on")) {
+ sc->vga_enabled = 1;
+ sc->vga_full = 1;
+ } else {
+ pci_fbuf_usage(opts);
+ ret = -1;
+ goto done;
+ }
+ } else if (!strcmp(xopts, "w")) {
+ sc->memregs.width = atoi(config);
if (sc->memregs.width > COLS_MAX) {
pci_fbuf_usage(xopts);
ret = -1;
@@ -299,7 +307,7 @@ pci_fbuf_render(struct bhyvegc *gc, void *arg)
sc = arg;
- if (sc->use_vga && sc->gc_image->vgamode) {
+ if (sc->vga_full && sc->gc_image->vgamode) {
/* TODO: mode switching to vga and vesa should use the special
* EFI-bhyve protocol port.
*/
@@ -352,12 +360,21 @@ pci_fbuf_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
sc->memregs.height = ROWS_DEFAULT;
sc->memregs.depth = 32;
+ sc->vga_enabled = 1;
+ sc->vga_full = 0;
+
sc->fsc_pi = pi;
error = pci_fbuf_parse_opts(sc, opts);
if (error != 0)
goto done;
+ /* XXX until VGA rendering is enabled */
+ if (sc->vga_full != 0) {
+ fprintf(stderr, "pci_fbuf: VGA rendering not enabled");
+ goto done;
+ }
+
sc->fb_base = vm_create_devmem(ctx, VM_FRAMEBUFFER, "framebuffer", FB_SIZE);
if (sc->fb_base == MAP_FAILED) {
error = -1;
@@ -382,7 +399,8 @@ pci_fbuf_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
console_init(sc->memregs.width, sc->memregs.height, sc->fb_base);
console_fb_register(pci_fbuf_render, sc);
- sc->vgasc = vga_init(!sc->use_vga);
+ if (sc->vga_enabled)
+ sc->vgasc = vga_init(!sc->vga_full);
sc->gc_image = console_get_image();
fbuf_sc = sc;
diff --git a/usr.sbin/bhyve/pci_xhci.c b/usr.sbin/bhyve/pci_xhci.c
index 025b40e25d5b..d28a3e698c4c 100644
--- a/usr.sbin/bhyve/pci_xhci.c
+++ b/usr.sbin/bhyve/pci_xhci.c
@@ -2559,7 +2559,8 @@ pci_xhci_dev_intr(struct usb_hci *hci, int epctx)
/* check if device is ready; OS has to initialise it */
if (sc->rtsregs.erstba_p == NULL ||
- (sc->opregs.usbcmd & XHCI_CMD_RS) == 0)
+ (sc->opregs.usbcmd & XHCI_CMD_RS) == 0 ||
+ dev->dev_ctx == NULL)
return (0);
p = XHCI_PORTREG_PTR(sc, hci->hci_port);
diff --git a/usr.sbin/bsdinstall/partedit/gpart_ops.c b/usr.sbin/bsdinstall/partedit/gpart_ops.c
index 04c8ceac994f..89d75294e2a3 100644
--- a/usr.sbin/bsdinstall/partedit/gpart_ops.c
+++ b/usr.sbin/bsdinstall/partedit/gpart_ops.c
@@ -795,6 +795,7 @@ gpart_max_free(struct ggeom *geom, intmax_t *npartstart)
{
struct gconfig *gc;
struct gprovider *pp, **providers;
+ intmax_t sectorsize, stripesize, offset;
intmax_t lastend;
intmax_t start, end;
intmax_t maxsize, maxstart;
@@ -845,12 +846,25 @@ gpart_max_free(struct ggeom *geom, intmax_t *npartstart)
pp = LIST_FIRST(&geom->lg_consumer)->lg_provider;
- /* Compute beginning of new partition and maximum available space */
- if (pp->lg_stripesize > 0 &&
- (maxstart*pp->lg_sectorsize % pp->lg_stripesize) != 0) {
- intmax_t offset = (pp->lg_stripesize -
- ((maxstart*pp->lg_sectorsize) % pp->lg_stripesize)) /
- pp->lg_sectorsize;
+ /*
+ * Round the start and size of the largest available space up to
+ * the nearest multiple of the adjusted stripe size.
+ *
+ * The adjusted stripe size is the least common multiple of the
+ * actual stripe size, or the sector size if no stripe size was
+ * reported, and 4096. The reason for this is that contemporary
+ * disks often have 4096-byte physical sectors but report 512
+ * bytes instead for compatibility with older / broken operating
+ * systems and BIOSes. For the same reasons, virtualized storage
+ * may also report a 512-byte stripe size, or none at all.
+ */
+ sectorsize = pp->lg_sectorsize;
+ if ((stripesize = pp->lg_stripesize) == 0)
+ stripesize = sectorsize;
+ while (stripesize % 4096 != 0)
+ stripesize *= 2;
+ if ((offset = maxstart * sectorsize % stripesize) != 0) {
+ offset = (stripesize - offset) / sectorsize;
maxstart += offset;
maxsize -= offset;
}
diff --git a/usr.sbin/bsdinstall/scripts/hardening b/usr.sbin/bsdinstall/scripts/hardening
index 7a3195e43fdd..130a9f73347c 100755
--- a/usr.sbin/bsdinstall/scripts/hardening
+++ b/usr.sbin/bsdinstall/scripts/hardening
@@ -28,7 +28,8 @@
: ${DIALOG_OK=0}
-echo -n > $BSDINSTALL_TMPETC/rc.conf.services
+echo -n > $BSDINSTALL_TMPETC/rc.conf.hardening
+echo -n > $BSDINSTALL_TMPETC/sysctl.conf.hardening
exec 3>&1
FEATURES=$( dialog --backtitle "FreeBSD Installer" \
@@ -39,7 +40,7 @@ FEATURES=$( dialog --backtitle "FreeBSD Installer" \
"hide_gids" "Hide processes running as other groups" ${hide_gids:-off} \
"read_msgbuf" "Disable reading kernel message buffer for unprivileged users" ${read_msgbuf:-off} \
"proc_debug" "Disable process debugging facilities for unprivileged users" ${proc_debug:-off} \
- "random_pid" "Randomize the PID of newly created processes" ${random_id:-off} \
+ "random_pid" "Randomize the PID of newly created processes" ${random_pid:-off} \
"stack_guard" "Insert stack guard page ahead of the growable segments" ${stack_guard:-off} \
"clear_tmp" "Clean the /tmp filesystem on system startup" ${clear_tmp:-off} \
"disable_syslogd" "Disable opening Syslogd network socket (disables remote logging)" ${disable_syslogd:-off} \
@@ -60,7 +61,7 @@ for feature in $FEATURES; do
if [ "$feature" = "proc_debug" ]; then
echo security.bsd.unprivileged_proc_debug=0 >> $BSDINSTALL_TMPETC/sysctl.conf.hardening
fi
- if [ "$feature" = "random_id" ]; then
+ if [ "$feature" = "random_pid" ]; then
echo kern.randompid=$(jot -r 1 9999) >> $BSDINSTALL_TMPETC/sysctl.conf.hardening
fi
if [ "$feature" = "stack_guard" ]; then
diff --git a/usr.sbin/etcupdate/etcupdate.sh b/usr.sbin/etcupdate/etcupdate.sh
index bb12d3669126..6330c60da854 100755
--- a/usr.sbin/etcupdate/etcupdate.sh
+++ b/usr.sbin/etcupdate/etcupdate.sh
@@ -814,15 +814,17 @@ merge_file()
local res
# Try the merge to see if there is a conflict.
- merge -q -p ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1 >/dev/null 2>&3
+ diff3 -E -m ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1 > /dev/null 2>&3
res=$?
case $res in
0)
# No conflicts, so just redo the merge to the
# real file.
- log "merge ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1"
+ log "diff3 -E -m ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1"
if [ -z "$dryrun" ]; then
- merge ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1
+ temp=$(mktemp -t etcupdate)
+ diff3 -E -m ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1 > ${temp}
+ mv -f ${temp} ${DESTDIR}$1
fi
post_install_file $1
echo " M $1"
@@ -832,10 +834,10 @@ merge_file()
# the conflicts directory.
if [ -z "$dryrun" ]; then
install_dirs $NEWTREE $CONFLICTS $1
- log "cp -Rp ${DESTDIR}$1 ${CONFLICTS}$1"
- cp -Rp ${DESTDIR}$1 ${CONFLICTS}$1 >&3 2>&1
- merge -A -q -L "yours" -L "original" -L "new" \
- ${CONFLICTS}$1 ${OLDTREE}$1 ${NEWTREE}$1
+ log "diff3 -m -A ${DESTDIR}$1 ${CONFLICTS}$1"
+ diff3 -m -A -L "yours" -L "original" -L "new" \
+ ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1 > \
+ ${CONFLICTS}$1
fi
echo " C $1"
;;
diff --git a/usr.sbin/kgzip/kgzip.8 b/usr.sbin/kgzip/kgzip.8
index 72d0bf5cfe86..bcf395735a98 100644
--- a/usr.sbin/kgzip/kgzip.8
+++ b/usr.sbin/kgzip/kgzip.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 19, 1999
+.Dd August 2, 2016
.Dt KGZIP 8
.Os
.Sh NAME
@@ -38,6 +38,14 @@
.Op Fl o Ar output
.Ar file
.Sh DESCRIPTION
+.Bf -symbolic
+This utility is deprecated.
+Users are advised to use
+.Xr loader 8
+and compress the kernel with
+.Xr gzip 1 .
+.Ef
+.Pp
The
.Nm
utility compresses a kernel or some other bootable binary.
@@ -137,7 +145,12 @@ The default loader
As symbols are lost, the usefulness of this utility for compressing
kernels is limited to situations where
.Xr loader 8
-cannot be used; otherwise the preferred method of compressing a kernel
+cannot be used.
+.Pp
+.Pa kgzldr.o
+is only available for the i386 and pc98 architectures.
+.Pp
+The preferred method of compressing a kernel
is simply to
.Xr gzip 1
it.
diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c
index 4108ac988c44..766c756e2e7b 100644
--- a/usr.sbin/newsyslog/newsyslog.c
+++ b/usr.sbin/newsyslog/newsyslog.c
@@ -2286,26 +2286,29 @@ mtime_old_timelog(const char *file)
time_t t;
struct dirent *dp;
DIR *dirp;
- char *s, *logfname, *dir;
+ char *logfname, *logfnamebuf, *dir, *dirbuf;
t = -1;
- if ((dir = dirname(file)) == NULL) {
- warn("dirname() of '%s'", file);
+ if ((dirbuf = strdup(file)) == NULL) {
+ warn("strdup() of '%s'", file);
return (t);
}
- if ((s = basename(file)) == NULL) {
- warn("basename() of '%s'", file);
+ dir = dirname(dirbuf);
+ if ((logfnamebuf = strdup(file)) == NULL) {
+ warn("strdup() of '%s'", file);
+ free(dirbuf);
return (t);
- } else if (s[0] == '/') {
- warnx("Invalid log filename '%s'", s);
- return (t);
- } else if ((logfname = strdup(s)) == NULL)
- err(1, "strdup()");
+ }
+ logfname = basename(logfnamebuf);
+ if (logfname[0] == '/') {
+ warnx("Invalid log filename '%s'", logfname);
+ goto out;
+ }
if ((dirp = opendir(dir)) == NULL) {
warn("Cannot open log directory '%s'", dir);
- return (t);
+ goto out;
}
dir_fd = dirfd(dirp);
/* Open the archive dir and find the most recent archive of logfname. */
@@ -2322,6 +2325,9 @@ mtime_old_timelog(const char *file)
}
closedir(dirp);
+out:
+ free(dirbuf);
+ free(logfnamebuf);
return (t);
}
diff --git a/usr.sbin/pciconf/cap.c b/usr.sbin/pciconf/cap.c
index cd5ae2697c9a..4d0738896816 100644
--- a/usr.sbin/pciconf/cap.c
+++ b/usr.sbin/pciconf/cap.c
@@ -529,10 +529,13 @@ cap_express(int fd, struct pci_conf *p, uint8_t ptr)
if (cap & PCIEM_SLOT_CAP_APB)
printf(" Attn Button");
if (cap & PCIEM_SLOT_CAP_PCP)
- printf(" PC(%s)", ctl & PCIEM_SLOT_CTL_PCC ? "on" : "off");
+ printf(" PC(%s)", ctl & PCIEM_SLOT_CTL_PCC ? "off" : "on");
if (cap & PCIEM_SLOT_CAP_MRLSP)
printf(" MRL(%s)", sta & PCIEM_SLOT_STA_MRLSS ? "open" :
"closed");
+ if (cap & PCIEM_SLOT_CAP_EIP)
+ printf(" EI(%s)", sta & PCIEM_SLOT_STA_EIS ? "engaged" :
+ "disengaged");
}
static void
diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c
index bd3076cc9ea8..13d02da56655 100644
--- a/usr.sbin/pkg/pkg.c
+++ b/usr.sbin/pkg/pkg.c
@@ -34,7 +34,6 @@ __FBSDID("$FreeBSD$");
#include <sys/sbuf.h>
#include <sys/wait.h>
-#define _WITH_GETLINE
#include <archive.h>
#include <archive_entry.h>
#include <dirent.h>
diff --git a/usr.sbin/pmcstudy/pmcstudy.c b/usr.sbin/pmcstudy/pmcstudy.c
index e94addfb5700..3cf1f8e328a8 100644
--- a/usr.sbin/pmcstudy/pmcstudy.c
+++ b/usr.sbin/pmcstudy/pmcstudy.c
@@ -2322,11 +2322,7 @@ do_cpuid(u_int ax, u_int cx, u_int *p)
#else
#define cpuid(in, a, b, c, d)
-static __inline void
-do_cpuid(u_int ax, u_int cx, u_int *p)
-{
-}
-
+#define do_cpuid(ax, cx, p)
#endif
static void
diff --git a/usr.sbin/pw/pw.h b/usr.sbin/pw/pw.h
index 05a51c220723..592d5921556f 100644
--- a/usr.sbin/pw/pw.h
+++ b/usr.sbin/pw/pw.h
@@ -28,7 +28,6 @@
#include <sys/stat.h>
-#define _WITH_GETLINE
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/usr.sbin/pw/pw_vpw.c b/usr.sbin/pw/pw_vpw.c
index 08c8bd5336d8..58e52946f146 100644
--- a/usr.sbin/pw/pw_vpw.c
+++ b/usr.sbin/pw/pw_vpw.c
@@ -33,7 +33,6 @@ static const char rcsid[] =
#include <pwd.h>
#include <grp.h>
#include <libutil.h>
-#define _WITH_GETLINE
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -131,13 +130,10 @@ vendgrent(void)
}
}
-RET_SETGRENT
+void
vsetgrent(void)
{
vendgrent();
-#if defined(__FreeBSD__)
- return 0;
-#endif
}
static struct group *
diff --git a/usr.sbin/pw/pwupd.h b/usr.sbin/pw/pwupd.h
index 7fecffb7da4b..daca487835f1 100644
--- a/usr.sbin/pw/pwupd.h
+++ b/usr.sbin/pw/pwupd.h
@@ -38,12 +38,6 @@
#include <stdbool.h>
#include <stringlist.h>
-#if defined(__FreeBSD__)
-#define RET_SETGRENT int
-#else
-#define RET_SETGRENT void
-#endif
-
struct pwf {
int _altdir;
void (*_setpwent)(void);
@@ -51,7 +45,7 @@ struct pwf {
struct passwd * (*_getpwent)(void);
struct passwd * (*_getpwuid)(uid_t uid);
struct passwd * (*_getpwnam)(const char * nam);
- RET_SETGRENT (*_setgrent)(void);
+ void (*_setgrent)(void);
void (*_endgrent)(void);
struct group * (*_getgrent)(void);
struct group * (*_getgrgid)(gid_t gid);
@@ -141,7 +135,7 @@ struct passwd * vgetpwnam(const char * nam);
struct group * vgetgrent(void);
struct group * vgetgrgid(gid_t gid);
struct group * vgetgrnam(const char * nam);
-RET_SETGRENT vsetgrent(void);
+void vsetgrent(void);
void vendgrent(void);
void copymkdir(int rootfd, char const * dir, int skelfd, mode_t mode, uid_t uid,
diff --git a/usr.sbin/services_mkdb/services_mkdb.c b/usr.sbin/services_mkdb/services_mkdb.c
index 7a992c3eb72c..92dd5e43367a 100644
--- a/usr.sbin/services_mkdb/services_mkdb.c
+++ b/usr.sbin/services_mkdb/services_mkdb.c
@@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <fcntl.h>
#include <netdb.h>
-#define _WITH_GETLINE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/usr.sbin/uathload/uathload.c b/usr.sbin/uathload/uathload.c
index 50e9eb64d757..8479f17c88e6 100644
--- a/usr.sbin/uathload/uathload.c
+++ b/usr.sbin/uathload/uathload.c
@@ -50,6 +50,7 @@
#include <libgen.h>
#include <paths.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
@@ -82,21 +83,32 @@ extern uint8_t _binary_ar5523_bin_start;
extern uint8_t _binary_ar5523_bin_end;
static int
-getdevname(const char *devname, char *msgdev, char *datadev)
+getdevname(const char *udevname, char *msgdev, char *datadev)
{
- char *bn, *dn;
+ char *bn, *bnbuf, *dn, *dnbuf;
- dn = dirname(devname);
- if (dn == NULL)
+ dnbuf = strdup(udevname);
+ if (dnbuf == NULL)
return (-1);
- bn = basename(devname);
- if (bn == NULL || strncmp(bn, "ugen", 4))
+ dn = dirname(dnbuf);
+ bnbuf = strdup(udevname);
+ if (bnbuf == NULL) {
+ free(dnbuf);
return (-1);
+ }
+ bn = basename(bnbuf);
+ if (strncmp(bn, "ugen", 4) != 0) {
+ free(dnbuf);
+ free(bnbuf);
+ return (-1);
+ }
bn += 4;
/* NB: pipes are hardcoded */
snprintf(msgdev, 256, "%s/usb/%s.1", dn, bn);
snprintf(datadev, 256, "%s/usb/%s.2", dn, bn);
+ free(dnbuf);
+ free(bnbuf);
return (0);
}
@@ -109,7 +121,7 @@ usage(void)
int
main(int argc, char *argv[])
{
- const char *fwname, *devname;
+ const char *fwname, *udevname;
char msgdev[256], datadev[256];
struct uath_fwmsg txmsg, rxmsg;
char *txdata;
@@ -118,11 +130,11 @@ main(int argc, char *argv[])
int bufsize = 512, verbose = 0;
ssize_t len;
- devname = NULL;
+ udevname = NULL;
while ((c = getopt(argc, argv, "d:v")) != -1) {
switch (c) {
case 'd':
- devname = optarg;
+ udevname = optarg;
break;
case 'v':
verbose = 1;
@@ -135,7 +147,7 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
- if (devname == NULL)
+ if (udevname == NULL)
errx(-1, "No device name; use -d to specify the ugen device");
if (argc > 1)
usage();
@@ -154,7 +166,7 @@ main(int argc, char *argv[])
err(-1, "mmap(%s)", fwname);
len = sb.st_size;
/* XXX verify device is an AR5005 part */
- if (getdevname(devname, msgdev, datadev))
+ if (getdevname(udevname, msgdev, datadev))
err(-1, "getdevname error");
msg = open(msgdev, O_RDWR, 0);
@@ -174,7 +186,7 @@ main(int argc, char *argv[])
err(-1, "%s: USB_SET_TX_TIMEOUT(%u)", datadev,
UATH_DATA_TIMEOUT);
- VERBOSE("Load firmware %s to %s\n", fwname, devname);
+ VERBOSE("Load firmware %s to %s\n", fwname, udevname);
bzero(&txmsg, sizeof (struct uath_fwmsg));
txmsg.flags = htobe32(UATH_WRITE_BLOCK);