summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorgjb <gjb@FreeBSD.org>2015-05-28 17:06:50 +0000
committergjb <gjb@FreeBSD.org>2015-05-28 17:06:50 +0000
commit03d84058c3a2a1f69cd43d180104c0cee5dc3920 (patch)
tree325b15bf87a318f4858724f04b5fd7a7970dee1a /usr.sbin
parentfff6c6a5b79cfb6b01358f15d19bf4d2ea200b96 (diff)
parent67b3bbe09c36f09dda55d0e010c9d1bf12cc6073 (diff)
downloadFreeBSD-src-03d84058c3a2a1f69cd43d180104c0cee5dc3920.zip
FreeBSD-src-03d84058c3a2a1f69cd43d180104c0cee5dc3920.tar.gz
MFH: r282615-r283655
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/acpi/acpidb/acpidb.c2
-rw-r--r--usr.sbin/acpi/iasl/Makefile4
-rw-r--r--usr.sbin/bhyve/bhyve.821
-rw-r--r--usr.sbin/bhyve/block_if.c74
-rw-r--r--usr.sbin/bhyve/pci_hostbridge.c2
-rw-r--r--usr.sbin/bhyve/pci_virtio_block.c1
-rw-r--r--usr.sbin/bhyve/pci_virtio_net.c1
-rw-r--r--usr.sbin/bhyve/pci_virtio_rnd.c1
-rw-r--r--usr.sbin/bhyve/virtio.c2
-rw-r--r--usr.sbin/bhyvectl/bhyvectl.c13
-rw-r--r--usr.sbin/bhyveload/bhyveload.c2
-rw-r--r--usr.sbin/bluetooth/bthidd/Makefile1
-rwxr-xr-xusr.sbin/bsdinstall/scripts/zfsboot4
-rw-r--r--usr.sbin/crunch/crunchide/exec_elf32.c6
-rw-r--r--usr.sbin/ctladm/ctladm.85
-rw-r--r--usr.sbin/ctld/ctld.85
-rw-r--r--usr.sbin/iostat/iostat.83
-rw-r--r--usr.sbin/kbdmap/kbdmap.c4
-rw-r--r--usr.sbin/mountd/mountd.c3
-rw-r--r--usr.sbin/ntp/Makefile.inc2
-rw-r--r--usr.sbin/ntp/config.h4
-rw-r--r--usr.sbin/ntp/ntp-keygen/Makefile2
-rw-r--r--usr.sbin/ntp/ntpd/Makefile4
-rw-r--r--usr.sbin/ntp/ntpdate/Makefile6
-rw-r--r--usr.sbin/ntp/ntpdc/Makefile6
-rw-r--r--usr.sbin/ntp/ntpq/Makefile6
-rw-r--r--usr.sbin/ntp/sntp/Makefile4
-rw-r--r--usr.sbin/pmcstat/pmcstat.811
-rw-r--r--usr.sbin/pmcstat/pmcstat.c100
-rw-r--r--usr.sbin/pmcstat/pmcstat_log.c7
-rw-r--r--usr.sbin/pw/Makefile2
-rw-r--r--usr.sbin/pw/fileupd.c21
-rw-r--r--usr.sbin/pw/grupd.c4
-rw-r--r--usr.sbin/pw/pw_conf.c266
-rw-r--r--usr.sbin/pw/pw_nis.c3
-rw-r--r--usr.sbin/pw/pw_user.c37
-rw-r--r--usr.sbin/pw/pwupd.c109
-rw-r--r--usr.sbin/pw/pwupd.h3
-rw-r--r--usr.sbin/syslogd/pathnames.h2
-rw-r--r--usr.sbin/uefisign/pe.c8
40 files changed, 399 insertions, 362 deletions
diff --git a/usr.sbin/acpi/acpidb/acpidb.c b/usr.sbin/acpi/acpidb/acpidb.c
index f49420f..b3d0021 100644
--- a/usr.sbin/acpi/acpidb/acpidb.c
+++ b/usr.sbin/acpi/acpidb/acpidb.c
@@ -478,7 +478,7 @@ load_dsdt(const char *dsdtfile)
return (-1);
}
- AcpiDbGetTableFromFile(filetmp, NULL);
+ AcpiDbGetTableFromFile(filetmp, NULL, TRUE);
AcpiDbInitialize();
AcpiGbl_DebuggerConfiguration = 0;
diff --git a/usr.sbin/acpi/iasl/Makefile b/usr.sbin/acpi/iasl/Makefile
index 7f6a1bd..e9faad2 100644
--- a/usr.sbin/acpi/iasl/Makefile
+++ b/usr.sbin/acpi/iasl/Makefile
@@ -4,8 +4,8 @@ PROG= iasl
# common
SRCS= adfile.c adisasm.c adwalk.c ahids.c ahpredef.c \
- ahuuids.c cmfsize.c dmextern.c dmrestag.c dmtable.c \
- dmtbdump.c dmtbinfo.c getopt.c
+ ahtable.c ahuuids.c cmfsize.c dmextern.c dmrestag.c \
+ dmtable.c dmtbdump.c dmtbinfo.c getopt.c
# compiler
SRCS+= aslanalyze.c aslascii.c aslbtypes.c aslcodegen.c \
diff --git a/usr.sbin/bhyve/bhyve.8 b/usr.sbin/bhyve/bhyve.8
index e3cf36b..ee0f2ca 100644
--- a/usr.sbin/bhyve/bhyve.8
+++ b/usr.sbin/bhyve/bhyve.8
@@ -193,8 +193,13 @@ format.
.Pp
Block storage devices:
.Bl -tag -width 10n
-.It Pa /filename Ns Oo , Ns Li nocache Oc Ns Oo , Ns Li direct Oc Ns Oo , Ns Li ro Oc
-.It Pa /dev/xxx Ns Oo , Ns Ar nocache Oc Ns Oo , Ns Ar direct Oc Ns Oo , Ns Ar ro Oc
+.It Pa /filename Ns Oo , Ns Ar block-device-options Oc
+.It Pa /dev/xxx Ns Oo , Ns Ar block-device-options Oc
+.El
+.Pp
+The
+.Ar block-device-options
+are:
.Bl -tag -width 8n
.It Li nocache
Open the file with
@@ -204,14 +209,10 @@ Open the file using
.Dv O_SYNC .
.It Li ro
Force the file to be opened read-only.
-.El
-.Pp
-The
-.Li nocache ,
-.Li direct ,
-and
-.Li ro
-options are not available for virtio block devices.
+.It Li sectorsize= Ns Ar logical Ns Oo / Ns Ar physical Oc
+Specify the logical and physical sector sizes of the emulated disk.
+The physical sector size is optional and is equal to the logical sector size
+if not explicitly specified.
.El
.Pp
TTY devices:
diff --git a/usr.sbin/bhyve/block_if.c b/usr.sbin/bhyve/block_if.c
index bcb1617..ef8e11e 100644
--- a/usr.sbin/bhyve/block_if.c
+++ b/usr.sbin/bhyve/block_if.c
@@ -392,16 +392,18 @@ blockif_open(const char *optstr, const char *ident)
{
char tname[MAXCOMLEN + 1];
char name[MAXPATHLEN];
- char *nopt, *xopts;
+ char *nopt, *xopts, *cp;
struct blockif_ctxt *bc;
struct stat sbuf;
struct diocgattr_arg arg;
off_t size, psectsz, psectoff;
int extra, fd, i, sectsz;
- int nocache, sync, ro, candelete, geom;
+ int nocache, sync, ro, candelete, geom, ssopt, pssopt;
pthread_once(&blockif_once, blockif_init);
+ fd = -1;
+ ssopt = 0;
nocache = 0;
sync = 0;
ro = 0;
@@ -410,16 +412,25 @@ blockif_open(const char *optstr, const char *ident)
* The first element in the optstring is always a pathname.
* Optional elements follow
*/
- nopt = strdup(optstr);
- for (xopts = strtok(nopt, ",");
- xopts != NULL;
- xopts = strtok(NULL, ",")) {
- if (!strcmp(xopts, "nocache"))
+ nopt = xopts = strdup(optstr);
+ while (xopts != NULL) {
+ cp = strsep(&xopts, ",");
+ if (cp == nopt) /* file or device pathname */
+ continue;
+ else if (!strcmp(cp, "nocache"))
nocache = 1;
- else if (!strcmp(xopts, "sync"))
+ else if (!strcmp(cp, "sync") || !strcmp(cp, "direct"))
sync = 1;
- else if (!strcmp(xopts, "ro"))
+ else if (!strcmp(cp, "ro"))
ro = 1;
+ else if (sscanf(cp, "sectorsize=%d/%d", &ssopt, &pssopt) == 2)
+ ;
+ else if (sscanf(cp, "sectorsize=%d", &ssopt) == 1)
+ pssopt = ssopt;
+ else {
+ fprintf(stderr, "Invalid device option \"%s\"\n", cp);
+ goto err;
+ }
}
extra = 0;
@@ -437,13 +448,12 @@ blockif_open(const char *optstr, const char *ident)
if (fd < 0) {
perror("Could not open backing file");
- return (NULL);
+ goto err;
}
if (fstat(fd, &sbuf) < 0) {
perror("Could not stat backing file");
- close(fd);
- return (NULL);
+ goto err;
}
/*
@@ -457,8 +467,7 @@ blockif_open(const char *optstr, const char *ident)
if (ioctl(fd, DIOCGMEDIASIZE, &size) < 0 ||
ioctl(fd, DIOCGSECTORSIZE, &sectsz)) {
perror("Could not fetch dev blk/sector size");
- close(fd);
- return (NULL);
+ goto err;
}
assert(size != 0);
assert(sectsz != 0);
@@ -473,10 +482,39 @@ blockif_open(const char *optstr, const char *ident)
} else
psectsz = sbuf.st_blksize;
+ if (ssopt != 0) {
+ if (!powerof2(ssopt) || !powerof2(pssopt) || ssopt < 512 ||
+ ssopt > pssopt) {
+ fprintf(stderr, "Invalid sector size %d/%d\n",
+ ssopt, pssopt);
+ goto err;
+ }
+
+ /*
+ * Some backend drivers (e.g. cd0, ada0) require that the I/O
+ * size be a multiple of the device's sector size.
+ *
+ * Validate that the emulated sector size complies with this
+ * requirement.
+ */
+ if (S_ISCHR(sbuf.st_mode)) {
+ if (ssopt < sectsz || (ssopt % sectsz) != 0) {
+ fprintf(stderr, "Sector size %d incompatible "
+ "with underlying device sector size %d\n",
+ ssopt, sectsz);
+ goto err;
+ }
+ }
+
+ sectsz = ssopt;
+ psectsz = pssopt;
+ psectoff = 0;
+ }
+
bc = calloc(1, sizeof(struct blockif_ctxt));
if (bc == NULL) {
- close(fd);
- return (NULL);
+ perror("calloc");
+ goto err;
}
bc->bc_magic = BLOCKIF_SIG;
@@ -506,6 +544,10 @@ blockif_open(const char *optstr, const char *ident)
}
return (bc);
+err:
+ if (fd >= 0)
+ close(fd);
+ return (NULL);
}
static int
diff --git a/usr.sbin/bhyve/pci_hostbridge.c b/usr.sbin/bhyve/pci_hostbridge.c
index 54a25ae..5c9ea28 100644
--- a/usr.sbin/bhyve/pci_hostbridge.c
+++ b/usr.sbin/bhyve/pci_hostbridge.c
@@ -38,7 +38,7 @@ pci_hostbridge_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
/* config space */
pci_set_cfgdata16(pi, PCIR_VENDOR, 0x1275); /* NetApp */
pci_set_cfgdata16(pi, PCIR_DEVICE, 0x1275); /* NetApp */
- pci_set_cfgdata8(pi, PCIR_HDRTYPE, PCIM_HDRTYPE_BRIDGE);
+ pci_set_cfgdata8(pi, PCIR_HDRTYPE, PCIM_HDRTYPE_NORMAL);
pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_BRIDGE);
pci_set_cfgdata8(pi, PCIR_SUBCLASS, PCIS_BRIDGE_HOST);
diff --git a/usr.sbin/bhyve/pci_virtio_block.c b/usr.sbin/bhyve/pci_virtio_block.c
index 35daa1f..8500be6 100644
--- a/usr.sbin/bhyve/pci_virtio_block.c
+++ b/usr.sbin/bhyve/pci_virtio_block.c
@@ -370,6 +370,7 @@ pci_vtblk_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
pci_set_cfgdata16(pi, PCIR_VENDOR, VIRTIO_VENDOR);
pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_STORAGE);
pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_TYPE_BLOCK);
+ pci_set_cfgdata16(pi, PCIR_SUBVEND_0, VIRTIO_VENDOR);
if (vi_intr_init(&sc->vbsc_vs, 1, fbsdrun_virtio_msix())) {
blockif_close(sc->bc);
diff --git a/usr.sbin/bhyve/pci_virtio_net.c b/usr.sbin/bhyve/pci_virtio_net.c
index 1a029d5..3781ea9 100644
--- a/usr.sbin/bhyve/pci_virtio_net.c
+++ b/usr.sbin/bhyve/pci_virtio_net.c
@@ -640,6 +640,7 @@ pci_vtnet_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
pci_set_cfgdata16(pi, PCIR_VENDOR, VIRTIO_VENDOR);
pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_NETWORK);
pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_TYPE_NET);
+ pci_set_cfgdata16(pi, PCIR_SUBVEND_0, VIRTIO_VENDOR);
/* Link is up if we managed to open tap device. */
sc->vsc_config.status = (opts == NULL || sc->vsc_tapfd >= 0);
diff --git a/usr.sbin/bhyve/pci_virtio_rnd.c b/usr.sbin/bhyve/pci_virtio_rnd.c
index 92d1d6f..78448f5 100644
--- a/usr.sbin/bhyve/pci_virtio_rnd.c
+++ b/usr.sbin/bhyve/pci_virtio_rnd.c
@@ -170,6 +170,7 @@ pci_vtrnd_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
pci_set_cfgdata16(pi, PCIR_VENDOR, VIRTIO_VENDOR);
pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_CRYPTO);
pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_TYPE_ENTROPY);
+ pci_set_cfgdata16(pi, PCIR_SUBVEND_0, VIRTIO_VENDOR);
if (vi_intr_init(&sc->vrsc_vs, 1, fbsdrun_virtio_msix()))
return (1);
diff --git a/usr.sbin/bhyve/virtio.c b/usr.sbin/bhyve/virtio.c
index 41a9e42..11b1e62 100644
--- a/usr.sbin/bhyve/virtio.c
+++ b/usr.sbin/bhyve/virtio.c
@@ -316,7 +316,7 @@ vq_getchain(struct vqueue_info *vq, uint16_t *pidx,
if ((vdir->vd_flags & VRING_DESC_F_INDIRECT) == 0) {
_vq_record(i, vdir, ctx, iov, n_iov, flags);
i++;
- } else if ((vs->vs_negotiated_caps &
+ } else if ((vs->vs_vc->vc_hv_caps &
VIRTIO_RING_F_INDIRECT_DESC) == 0) {
fprintf(stderr,
"%s: descriptor has forbidden INDIRECT flag, "
diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c
index 223ee25..7d3017f 100644
--- a/usr.sbin/bhyvectl/bhyvectl.c
+++ b/usr.sbin/bhyvectl/bhyvectl.c
@@ -293,6 +293,7 @@ static int get_guest_pat, get_host_pat;
static int get_guest_sysenter, get_vmcs_link;
static int get_exit_reason, get_vmcs_exit_qualification;
static int get_vmcs_exit_interruption_info, get_vmcs_exit_interruption_error;
+static int get_vmcs_exit_inst_length;
static uint64_t desc_base;
static uint32_t desc_limit, desc_access;
@@ -1145,7 +1146,15 @@ get_misc_vmcs(struct vmctx *ctx, int vcpu)
vcpu, u64);
}
}
-
+
+ if (!error && (get_vmcs_exit_inst_length || get_all)) {
+ error = vm_get_vmcs_field(ctx, vcpu,
+ VMCS_EXIT_INSTRUCTION_LENGTH, &u64);
+ if (error == 0)
+ printf("vmcs_exit_inst_length[%d]\t0x%08x\n", vcpu,
+ (uint32_t)u64);
+ }
+
if (!error && (get_vmcs_exit_qualification || get_all)) {
error = vm_get_vmcs_field(ctx, vcpu, VMCS_EXIT_QUALIFICATION,
&u64);
@@ -1405,6 +1414,8 @@ setup_options(bool cpu_intel)
REQ_ARG, 0, SET_VMCS_ENTRY_INTERRUPTION_INFO },
{ "get-vmcs-exit-qualification",
NO_ARG, &get_vmcs_exit_qualification, 1 },
+ { "get-vmcs-exit-inst-length",
+ NO_ARG, &get_vmcs_exit_inst_length, 1 },
{ "get-vmcs-interruptibility",
NO_ARG, &get_vmcs_interruptibility, 1 },
{ "get-vmcs-exit-interruption-error",
diff --git a/usr.sbin/bhyveload/bhyveload.c b/usr.sbin/bhyveload/bhyveload.c
index eaf71a8..8ebf116 100644
--- a/usr.sbin/bhyveload/bhyveload.c
+++ b/usr.sbin/bhyveload/bhyveload.c
@@ -609,7 +609,7 @@ disk_open(char *path)
{
int err, fd;
- if (ndisks > NDISKS)
+ if (ndisks >= NDISKS)
return (ERANGE);
err = 0;
diff --git a/usr.sbin/bluetooth/bthidd/Makefile b/usr.sbin/bluetooth/bthidd/Makefile
index 587189b..f36d216 100644
--- a/usr.sbin/bluetooth/bthidd/Makefile
+++ b/usr.sbin/bluetooth/bthidd/Makefile
@@ -8,7 +8,6 @@ SRCS= bthidd.c client.c hid.c kbd.c lexer.l parser.y server.c \
session.c
CFLAGS+= -I${.CURDIR}
-DEBUG_FLAGS= -g
LIBADD+= bluetooth usbhid
diff --git a/usr.sbin/bsdinstall/scripts/zfsboot b/usr.sbin/bsdinstall/scripts/zfsboot
index 7fa5cd3..c759e85 100755
--- a/usr.sbin/bsdinstall/scripts/zfsboot
+++ b/usr.sbin/bsdinstall/scripts/zfsboot
@@ -953,6 +953,8 @@ zfs_create_diskpart()
esac # $ZFSBOOT_PARTITION_SCHEME
# Update fstab(5)
+ local swapsize
+ f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize
if [ "$isswapmirror" ]; then
# This is not the first disk in the mirror, do nothing
elif [ "$ZFSBOOT_SWAP_ENCRYPTION" -a "$ZFSBOOT_SWAP_MIRROR" ]; then
@@ -972,6 +974,8 @@ zfs_create_diskpart()
/dev/$disk${swappart}.eli none swap sw 0 0 \
$BSDINSTALL_TMPETC/fstab ||
return $FAILURE
+ elif [ ${swapsize:-0} -eq 0 ]; then
+ # If swap is 0 sized, don't add it to fstab
else
f_eval_catch $funcname printf "$PRINTF_FSTAB" \
/dev/$disk$swappart none swap sw 0 0 \
diff --git a/usr.sbin/crunch/crunchide/exec_elf32.c b/usr.sbin/crunch/crunchide/exec_elf32.c
index 89080e9..fc9a959 100644
--- a/usr.sbin/crunch/crunchide/exec_elf32.c
+++ b/usr.sbin/crunch/crunchide/exec_elf32.c
@@ -35,7 +35,7 @@ __RCSID("$NetBSD: exec_elf32.c,v 1.6 1999/09/20 04:12:16 christos Exp $");
#endif
#endif
__FBSDID("$FreeBSD$");
-
+
#ifndef ELFSIZE
#define ELFSIZE 32
#endif
@@ -142,7 +142,7 @@ static void *
xrealloc(void *ptr, size_t size, const char *fn, const char *use)
{
void *rv;
-
+
rv = realloc(ptr, size);
if (rv == NULL) {
free(ptr);
@@ -150,7 +150,7 @@ xrealloc(void *ptr, size_t size, const char *fn, const char *use)
fn, use);
}
return (rv);
-}
+}
int
ELFNAMEEND(check)(int fd, const char *fn)
diff --git a/usr.sbin/ctladm/ctladm.8 b/usr.sbin/ctladm/ctladm.8
index 7616c24..c4508cc 100644
--- a/usr.sbin/ctladm/ctladm.8
+++ b/usr.sbin/ctladm/ctladm.8
@@ -34,7 +34,7 @@
.\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $
.\" $FreeBSD$
.\"
-.Dd February 1, 2015
+.Dd May 22, 2015
.Dt CTLADM 8
.Os
.Sh NAME
@@ -1160,7 +1160,8 @@ This will result in a sense key of NOT READY (0x02), and an ASC/ASCQ of
.Xr ctl 4 ,
.Xr xpt 4 ,
.Xr camcontrol 8 ,
-.Xr ctld 8
+.Xr ctld 8 ,
+.Xr ctlstat 8
.Sh HISTORY
The
.Nm
diff --git a/usr.sbin/ctld/ctld.8 b/usr.sbin/ctld/ctld.8
index aa9a414..b3bea16 100644
--- a/usr.sbin/ctld/ctld.8
+++ b/usr.sbin/ctld/ctld.8
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 9, 2014
+.Dd May 22, 2015
.Dt CTLD 8
.Os
.Sh NAME
@@ -104,7 +104,8 @@ utility exits 0 on success, and >0 if an error occurs.
.Sh SEE ALSO
.Xr ctl 4 ,
.Xr ctl.conf 5 ,
-.Xr ctladm 8
+.Xr ctladm 8 ,
+.Xr ctlstat 8
.Sh HISTORY
The
.Nm
diff --git a/usr.sbin/iostat/iostat.8 b/usr.sbin/iostat/iostat.8
index 5223b72..2073679 100644
--- a/usr.sbin/iostat/iostat.8
+++ b/usr.sbin/iostat/iostat.8
@@ -56,7 +56,7 @@
.\"
.\" @(#)iostat.8 8.1 (Berkeley) 6/6/93
.\"
-.Dd December 15, 2012
+.Dd May 22, 2015
.Dt IOSTAT 8
.Os
.Sh NAME
@@ -494,6 +494,7 @@ flags are given, the TTY and CPU displays will be displayed.
.Xr ps 1 ,
.Xr systat 1 ,
.Xr devstat 3 ,
+.Xr ctlstat 8 ,
.Xr gstat 8 ,
.Xr pstat 8 ,
.Xr vmstat 8
diff --git a/usr.sbin/kbdmap/kbdmap.c b/usr.sbin/kbdmap/kbdmap.c
index bf2aa81..08c0d77 100644
--- a/usr.sbin/kbdmap/kbdmap.c
+++ b/usr.sbin/kbdmap/kbdmap.c
@@ -571,7 +571,7 @@ menu_read(void)
char *p;
int mark, num_keymaps, items, i;
char buffer[256], filename[PATH_MAX];
- char keym[64], lng[64], desc[64];
+ char keym[64], lng[64], desc[256];
char dialect[64], lang_abk[64];
struct keymap *km;
struct keymap **km_sorted;
@@ -616,7 +616,7 @@ menu_read(void)
continue;
/* Parse input, removing newline */
- matches = sscanf(p, "%64[^:]:%64[^:]:%64[^:\n]",
+ matches = sscanf(p, "%64[^:]:%64[^:]:%256[^:\n]",
keym, lng, desc);
if (matches == 3) {
if (strcmp(keym, "FONT")
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index 3508f50..d916577 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -1410,6 +1410,9 @@ get_exportlist_one(void)
}
if (check_dirpath(cp) &&
statfs(cp, &fsb) >= 0) {
+ if ((fsb.f_flags & MNT_AUTOMOUNTED) != 0)
+ syslog(LOG_ERR, "Warning: exporting of "
+ "automounted fs %s not supported", cp);
if (got_nondir) {
syslog(LOG_ERR, "dirs must be first");
getexp_err(ep, tgrp);
diff --git a/usr.sbin/ntp/Makefile.inc b/usr.sbin/ntp/Makefile.inc
index 755fbee..274ec39 100644
--- a/usr.sbin/ntp/Makefile.inc
+++ b/usr.sbin/ntp/Makefile.inc
@@ -11,7 +11,7 @@ NTPDEFS= -DSYS_FREEBSD
CFLAGS+= ${NTPDEFS} ${DEFS_LOCAL} ${CLOCKDEFS}
.if ${MK_OPENSSL} != "no" && !defined(RELEASE_CRUNCH)
-CFLAGS+= -DOPENSSL
+CFLAGS+= -DOPENSSL -DUSE_OPENSSL_CRYPTO_RAND -DAUTOKEY
.endif
WARNS?= 0
diff --git a/usr.sbin/ntp/config.h b/usr.sbin/ntp/config.h
index 8bcf6e6..a5b5b43 100644
--- a/usr.sbin/ntp/config.h
+++ b/usr.sbin/ntp/config.h
@@ -9,7 +9,7 @@
/* #undef ADJTIME_IS_ACCURATE */
/* Support NTP Autokey protocol? */
-#define AUTOKEY 1
+/* #define AUTOKEY 1 */
/* why not HAVE_P_S? */
/* #undef CALL_PTHREAD_SETCONCURRENCY */
@@ -1578,7 +1578,7 @@ typedef unsigned int uintptr_t;
#define USE_FSETOWNCTTY 1
/* Use OpenSSL's crypto random functions */
-#define USE_OPENSSL_CRYPTO_RAND 1
+/* #define USE_OPENSSL_CRYPTO_RAND 1 */
/* OK to use snprintb()? */
/* #undef USE_SNPRINTB */
diff --git a/usr.sbin/ntp/ntp-keygen/Makefile b/usr.sbin/ntp/ntp-keygen/Makefile
index 3c29f9b..d3f10f3 100644
--- a/usr.sbin/ntp/ntp-keygen/Makefile
+++ b/usr.sbin/ntp/ntp-keygen/Makefile
@@ -23,7 +23,7 @@ CFLAGS+= -I${.CURDIR}/../../../contrib/ntp/include \
LIBADD+= ntp opts pthread
.if ${MK_OPENSSL} != "no"
-LIBADD+= md crypto
+LIBADD+= crypto
.endif
.include <bsd.prog.mk>
diff --git a/usr.sbin/ntp/ntpd/Makefile b/usr.sbin/ntp/ntpd/Makefile
index 8da2c68..9f80b15 100644
--- a/usr.sbin/ntp/ntpd/Makefile
+++ b/usr.sbin/ntp/ntpd/Makefile
@@ -35,10 +35,12 @@ CFLAGS+= -I${.CURDIR}/../../../contrib/ntp/ntpd \
-I${.CURDIR}/../ \
-I${.CURDIR}
-LIBADD= parse ntp m rt opts md pthread
+LIBADD= parse ntp m opts pthread
.if ${MK_OPENSSL} != "no"
LIBADD+= crypto
+.else
+LIBADD+= md
.endif
CLEANFILES+= .version version.c
diff --git a/usr.sbin/ntp/ntpdate/Makefile b/usr.sbin/ntp/ntpdate/Makefile
index 8fdd8f7..10352e8 100644
--- a/usr.sbin/ntp/ntpdate/Makefile
+++ b/usr.sbin/ntp/ntpdate/Makefile
@@ -14,10 +14,12 @@ CFLAGS+= -I${.CURDIR}/../../../contrib/ntp/include \
-I${.CURDIR}/../../../contrib/ntp/lib/isc/pthreads/include \
-I${.CURDIR}/../
-LIBADD= rt ntp m pthread
+LIBADD= ntp m pthread
.if ${MK_OPENSSL} != "no"
-LIBADD+= md ssl crypto
+LIBADD+= crypto
+.else
+LIBADD+= md
.endif
CLEANFILES+= .version version.c
diff --git a/usr.sbin/ntp/ntpdc/Makefile b/usr.sbin/ntp/ntpdc/Makefile
index 2129c20..f19211a 100644
--- a/usr.sbin/ntp/ntpdc/Makefile
+++ b/usr.sbin/ntp/ntpdc/Makefile
@@ -18,12 +18,14 @@ CFLAGS+= -I${.CURDIR}/../../../contrib/ntp/include \
-I${.CURDIR}/../../../lib/libc/${MACHINE_ARCH} \
-I${.CURDIR}/../ -I${.CURDIR}
-LIBADD= edit md ntp m readline opts ncurses pthread
+LIBADD= edit ntp m opts pthread
CFLAGS+= -DHAVE_LIBEDIT -DHAVE_READLINE_READLINE_H \
-I${DESTDIR}/${INCLUDEDIR}/edit
.if ${MK_OPENSSL} != "no"
-LIBADD+= ssl crypto
+LIBADD+= crypto
+.else
+LIBADD+= md
.endif
CLEANFILES+= .version version.c
diff --git a/usr.sbin/ntp/ntpq/Makefile b/usr.sbin/ntp/ntpq/Makefile
index d512cff..f9901a0 100644
--- a/usr.sbin/ntp/ntpq/Makefile
+++ b/usr.sbin/ntp/ntpq/Makefile
@@ -21,10 +21,12 @@ CFLAGS+= -I${.CURDIR}/../../../contrib/ntp/include \
-I${.CURDIR}/../../../contrib/ntp/sntp/libopts \
-I${.CURDIR}/../
-LIBADD+= edit md ntp opts m pthread
+LIBADD+= edit ntp opts m pthread
.if ${MK_OPENSSL} != "no"
-LIBADD+= ssl crypto
+LIBADD+= crypto
+.else
+LIBADD+= md
.endif
CFLAGS+= -DHAVE_LIBEDIT -DHAVE_READLINE_READLINE_H \
diff --git a/usr.sbin/ntp/sntp/Makefile b/usr.sbin/ntp/sntp/Makefile
index eba7b83..ce5c01d 100644
--- a/usr.sbin/ntp/sntp/Makefile
+++ b/usr.sbin/ntp/sntp/Makefile
@@ -23,7 +23,9 @@ CFLAGS+= -I${.CURDIR}/../../../contrib/ntp/include \
LIBADD= m opts ntp ntpevent pthread
.if ${MK_OPENSSL} != "no"
-LIBADD+= md ssl crypto
+LIBADD+= crypto
+.else
+LIBADD+= md
.endif
.include <bsd.prog.mk>
diff --git a/usr.sbin/pmcstat/pmcstat.8 b/usr.sbin/pmcstat/pmcstat.8
index 9a204a4..25ff7a6 100644
--- a/usr.sbin/pmcstat/pmcstat.8
+++ b/usr.sbin/pmcstat/pmcstat.8
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 27, 2015
+.Dd May 27, 2015
.Dt PMCSTAT 8
.Os
.Sh NAME
@@ -246,8 +246,8 @@ Argument
.Ar cpu-spec
is a comma separated list of CPU numbers, or the literal
.Sq *
-denoting all unhalted CPUs.
-The default is to allocate system mode PMCs on all unhalted
+denoting all available CPUs.
+The default is to allocate system mode PMCs on all available
CPUs.
.It Fl d
Toggle between process mode PMCs measuring events for the target
@@ -279,8 +279,9 @@ Set the pathname of the kernel directory to argument
This directory specifies where
.Nm
should look for the kernel and its modules.
-The default is
-.Pa /boot/kernel .
+The default is to use the path of the running kernel obtained from the
+.Va kern.bootfile
+sysctl.
.It Fl l Ar secs
Set system-wide performance measurement duration for
.Ar secs
diff --git a/usr.sbin/pmcstat/pmcstat.c b/usr.sbin/pmcstat/pmcstat.c
index 77613b4..c51c5fa 100644
--- a/usr.sbin/pmcstat/pmcstat.c
+++ b/usr.sbin/pmcstat/pmcstat.c
@@ -116,11 +116,10 @@ struct pmcstat_args args;
static void
pmcstat_clone_event_descriptor(struct pmcstat_ev *ev, const cpuset_t *cpumask)
{
- int cpu, mcpu;
+ int cpu;
struct pmcstat_ev *ev_clone;
- mcpu = sizeof(*cpumask) * NBBY;
- for (cpu = 0; cpu < mcpu; cpu++) {
+ for (cpu = 0; cpu < CPU_SETSIZE; cpu++) {
if (!CPU_ISSET(cpu, cpumask))
continue;
@@ -161,6 +160,7 @@ pmcstat_get_cpumask(const char *cpuspec, cpuset_t *cpumask)
CPU_SET(cpu, cpumask);
s = end + strspn(end, ", \t");
} while (*s);
+ assert(!CPU_EMPTY(cpumask));
}
void
@@ -550,14 +550,14 @@ pmcstat_topexit(void)
int
main(int argc, char **argv)
{
- cpuset_t cpumask;
+ cpuset_t cpumask, rootmask;
double interval;
double duration;
- int hcpu, option, npmc, ncpu;
+ int option, npmc;
int c, check_driver_stats, current_sampling_count;
int do_callchain, do_descendants, do_logproccsw, do_logprocexit;
int do_print, do_read;
- size_t dummy;
+ size_t len;
int graphdepth;
int pipefd[2], rfd;
int use_cumulative_counts;
@@ -586,7 +586,6 @@ main(int argc, char **argv)
args.pa_verbosity = 1;
args.pa_logfd = -1;
args.pa_fsroot = "";
- args.pa_kernel = strdup("/boot/kernel");
args.pa_samplesdir = ".";
args.pa_printfile = stderr;
args.pa_graphdepth = DEFAULT_CALLGRAPH_DEPTH;
@@ -610,15 +609,22 @@ main(int argc, char **argv)
ev = NULL;
CPU_ZERO(&cpumask);
+ /* Default to using the running system kernel. */
+ len = 0;
+ if (sysctlbyname("kern.bootfile", NULL, &len, NULL, 0) == -1)
+ err(EX_OSERR, "ERROR: Cannot determine path of running kernel");
+ args.pa_kernel = malloc(len + 1);
+ if (sysctlbyname("kern.bootfile", args.pa_kernel, &len, NULL, 0) == -1)
+ err(EX_OSERR, "ERROR: Cannot determine path of running kernel");
+
/*
- * The initial CPU mask specifies all non-halted CPUS in the
- * system.
+ * The initial CPU mask specifies the root mask of this process
+ * which is usually all CPUs in the system.
*/
- dummy = sizeof(int);
- if (sysctlbyname("hw.ncpu", &ncpu, &dummy, NULL, 0) < 0)
- err(EX_OSERR, "ERROR: Cannot determine the number of CPUs");
- for (hcpu = 0; hcpu < ncpu; hcpu++)
- CPU_SET(hcpu, &cpumask);
+ if (cpuset_getaffinity(CPU_LEVEL_ROOT, CPU_WHICH_PID, -1,
+ sizeof(rootmask), &rootmask) == -1)
+ err(EX_OSERR, "ERROR: Cannot determine the root set of CPUs");
+ CPU_COPY(&rootmask, &cpumask);
while ((option = getopt(argc, argv,
"CD:EF:G:M:NO:P:R:S:TWa:c:df:gk:l:m:n:o:p:qr:s:t:vw:z:")) != -1)
@@ -635,11 +641,9 @@ main(int argc, char **argv)
break;
case 'c': /* CPU */
-
- if (optarg[0] == '*' && optarg[1] == '\0') {
- for (hcpu = 0; hcpu < ncpu; hcpu++)
- CPU_SET(hcpu, &cpumask);
- } else
+ if (optarg[0] == '*' && optarg[1] == '\0')
+ CPU_COPY(&rootmask, &cpumask);
+ else
pmcstat_get_cpumask(optarg, &cpumask);
args.pa_flags |= FLAGS_HAS_CPUMASK;
@@ -764,13 +768,9 @@ main(int argc, char **argv)
else
ev->ev_count = -1;
- if (option == 'S' || option == 's') {
- hcpu = sizeof(cpumask) * NBBY;
- for (hcpu--; hcpu >= 0; hcpu--)
- if (CPU_ISSET(hcpu, &cpumask))
- break;
- ev->ev_cpu = hcpu;
- } else
+ if (option == 'S' || option == 's')
+ ev->ev_cpu = CPU_FFS(&cpumask);
+ else
ev->ev_cpu = PMC_CPU_ANY;
ev->ev_flags = 0;
@@ -797,11 +797,9 @@ main(int argc, char **argv)
STAILQ_INSERT_TAIL(&args.pa_events, ev, ev_next);
if (option == 's' || option == 'S') {
- hcpu = CPU_ISSET(ev->ev_cpu, &cpumask);
CPU_CLR(ev->ev_cpu, &cpumask);
pmcstat_clone_event_descriptor(ev, &cpumask);
- if (hcpu != 0)
- CPU_SET(ev->ev_cpu, &cpumask);
+ CPU_SET(ev->ev_cpu, &cpumask);
}
break;
@@ -1061,33 +1059,31 @@ main(int argc, char **argv)
);
/*
- * Check if "-k kerneldir" was specified, and if whether
- * 'kerneldir' actually refers to a file. If so, use
- * `dirname path` to determine the kernel directory.
+ * Check if 'kerneldir' refers to a file rather than a
+ * directory. If so, use `dirname path` to determine the
+ * kernel directory.
*/
- if (args.pa_flags & FLAG_HAS_KERNELPATH) {
- (void) snprintf(buffer, sizeof(buffer), "%s%s", args.pa_fsroot,
- args.pa_kernel);
+ (void) snprintf(buffer, sizeof(buffer), "%s%s", args.pa_fsroot,
+ args.pa_kernel);
+ if (stat(buffer, &sb) < 0)
+ err(EX_OSERR, "ERROR: Cannot locate kernel \"%s\"",
+ buffer);
+ if (!S_ISREG(sb.st_mode) && !S_ISDIR(sb.st_mode))
+ errx(EX_USAGE, "ERROR: \"%s\": Unsupported file type.",
+ buffer);
+ if (!S_ISDIR(sb.st_mode)) {
+ tmp = args.pa_kernel;
+ args.pa_kernel = strdup(dirname(args.pa_kernel));
+ free(tmp);
+ (void) snprintf(buffer, sizeof(buffer), "%s%s",
+ args.pa_fsroot, args.pa_kernel);
if (stat(buffer, &sb) < 0)
- err(EX_OSERR, "ERROR: Cannot locate kernel \"%s\"",
+ err(EX_OSERR, "ERROR: Cannot stat \"%s\"",
buffer);
- if (!S_ISREG(sb.st_mode) && !S_ISDIR(sb.st_mode))
- errx(EX_USAGE, "ERROR: \"%s\": Unsupported file type.",
+ if (!S_ISDIR(sb.st_mode))
+ errx(EX_USAGE,
+ "ERROR: \"%s\" is not a directory.",
buffer);
- if (!S_ISDIR(sb.st_mode)) {
- tmp = args.pa_kernel;
- args.pa_kernel = strdup(dirname(args.pa_kernel));
- free(tmp);
- (void) snprintf(buffer, sizeof(buffer), "%s%s",
- args.pa_fsroot, args.pa_kernel);
- if (stat(buffer, &sb) < 0)
- err(EX_OSERR, "ERROR: Cannot stat \"%s\"",
- buffer);
- if (!S_ISDIR(sb.st_mode))
- errx(EX_USAGE,
- "ERROR: \"%s\" is not a directory.",
- buffer);
- }
}
/*
diff --git a/usr.sbin/pmcstat/pmcstat_log.c b/usr.sbin/pmcstat/pmcstat_log.c
index 40de320..fbc358d 100644
--- a/usr.sbin/pmcstat/pmcstat_log.c
+++ b/usr.sbin/pmcstat/pmcstat_log.c
@@ -716,7 +716,8 @@ pmcstat_image_get_elf_params(struct pmcstat_image *image)
ph.p_offset);
break;
case PT_LOAD:
- if ((ph.p_offset & (-ph.p_align)) == 0)
+ if ((ph.p_flags & PF_X) != 0 &&
+ (ph.p_offset & (-ph.p_align)) == 0)
image->pi_vaddr = ph.p_vaddr & (-ph.p_align);
break;
}
@@ -1531,7 +1532,9 @@ pmcstat_analyze_log(void)
free(ppm);
}
- /* associate this process image */
+ /*
+ * Associate this process image.
+ */
image_path = pmcstat_string_intern(
ev.pl_u.pl_x.pl_pathname);
assert(image_path != NULL);
diff --git a/usr.sbin/pw/Makefile b/usr.sbin/pw/Makefile
index 269b145..69953da 100644
--- a/usr.sbin/pw/Makefile
+++ b/usr.sbin/pw/Makefile
@@ -8,7 +8,7 @@ SRCS= pw.c pw_conf.c pw_user.c pw_group.c pw_log.c pw_nis.c pw_vpw.c \
WARNS?= 2
-LIBADD= crypt util
+LIBADD= crypt util sbuf
.include <src.opts.mk>
diff --git a/usr.sbin/pw/fileupd.c b/usr.sbin/pw/fileupd.c
index 7df4bb1..dc32712 100644
--- a/usr.sbin/pw/fileupd.c
+++ b/usr.sbin/pw/fileupd.c
@@ -29,32 +29,11 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
-#include <stdio.h>
-#include <fcntl.h>
#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <errno.h>
-#include <unistd.h>
#include "pwupd.h"
int
-extendline(char **buf, int * buflen, int needed)
-{
- if (needed > *buflen) {
- char *tmp = realloc(*buf, needed);
- if (tmp == NULL)
- return -1;
- *buf = tmp;
- *buflen = needed;
- }
- return *buflen;
-}
-
-int
extendarray(char ***buf, int * buflen, int needed)
{
if (needed > *buflen) {
diff --git a/usr.sbin/pw/grupd.c b/usr.sbin/pw/grupd.c
index 3f78e95..74cc390 100644
--- a/usr.sbin/pw/grupd.c
+++ b/usr.sbin/pw/grupd.c
@@ -35,10 +35,6 @@ static const char rcsid[] =
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <sys/param.h>
#include "pwupd.h"
diff --git a/usr.sbin/pw/pw_conf.c b/usr.sbin/pw/pw_conf.c
index 1289b3e..99d3e8f 100644
--- a/usr.sbin/pw/pw_conf.c
+++ b/usr.sbin/pw/pw_conf.c
@@ -29,9 +29,12 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
+#include <sys/types.h>
+#include <sys/sbuf.h>
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
+#include <err.h>
#include "pw.h"
@@ -209,19 +212,16 @@ boolean_str(int val)
char *
newstr(char const * p)
{
- char *q = NULL;
+ char *q;
- if ((p = unquote(p)) != NULL) {
- int l = strlen(p) + 1;
+ if ((p = unquote(p)) == NULL)
+ return (NULL);
- if ((q = malloc(l)) != NULL)
- memcpy(q, p, l);
- }
- return q;
-}
-
-#define LNBUFSZ 1024
+ if ((q = strdup(p)) == NULL)
+ err(1, "strdup()");
+ return (q);
+}
struct userconf *
read_userconfig(char const * file)
@@ -234,8 +234,10 @@ read_userconfig(char const * file)
buf = NULL;
linecap = 0;
- extendarray(&config.groups, &config.numgroups, 200);
- memset(config.groups, 0, config.numgroups * sizeof(char *));
+ config.numgroups = 200;
+ config.groups = calloc(config.numgroups, sizeof(char *));
+ if (config.groups == NULL)
+ err(1, "calloc()");
if (file == NULL)
file = _PATH_PW_CONF;
@@ -366,138 +368,132 @@ int
write_userconfig(char const * file)
{
int fd;
+ int i, j;
+ struct sbuf *buf;
+ FILE *fp;
if (file == NULL)
file = _PATH_PW_CONF;
- if ((fd = open(file, O_CREAT | O_RDWR | O_TRUNC | O_EXLOCK, 0644)) != -1) {
- FILE *fp;
+ if ((fd = open(file, O_CREAT|O_RDWR|O_TRUNC|O_EXLOCK, 0644)) == -1)
+ return (0);
- if ((fp = fdopen(fd, "w")) == NULL)
- close(fd);
- else {
- int i, j, k;
- int len = LNBUFSZ;
- char *buf = malloc(len);
-
- for (i = _UC_NONE; i < _UC_FIELDS; i++) {
- int quote = 1;
- char const *val = buf;
-
- *buf = '\0';
- switch (i) {
- case _UC_DEFAULTPWD:
- val = boolean_str(config.default_password);
- break;
- case _UC_REUSEUID:
- val = boolean_str(config.reuse_uids);
- break;
- case _UC_REUSEGID:
- val = boolean_str(config.reuse_gids);
- break;
- case _UC_NISPASSWD:
- val = config.nispasswd ? config.nispasswd : "";
- quote = 0;
- break;
- case _UC_DOTDIR:
- val = config.dotdir ? config.dotdir : boolean_str(0);
- break;
- case _UC_NEWMAIL:
- val = config.newmail ? config.newmail : boolean_str(0);
- break;
- case _UC_LOGFILE:
- val = config.logfile ? config.logfile : boolean_str(0);
- break;
- case _UC_HOMEROOT:
- val = config.home;
- break;
- case _UC_HOMEMODE:
- sprintf(buf, "%04o", config.homemode);
- quote = 0;
- break;
- case _UC_SHELLPATH:
- val = config.shelldir;
- break;
- case _UC_SHELLS:
- for (j = k = 0; j < _UC_MAXSHELLS && system_shells[j] != NULL; j++) {
- char lbuf[64];
- int l = snprintf(lbuf, sizeof lbuf, "%s\"%s\"", k ? "," : "", system_shells[j]);
- if (l < 0)
- l = 0;
- if (l + k + 1 < len || extendline(&buf, &len, len + LNBUFSZ) != -1) {
- strcpy(buf + k, lbuf);
- k += l;
- }
- }
- quote = 0;
- break;
- case _UC_DEFAULTSHELL:
- val = config.shell_default ? config.shell_default : bourne_shell;
- break;
- case _UC_DEFAULTGROUP:
- val = config.default_group ? config.default_group : "";
- break;
- case _UC_EXTRAGROUPS:
- extendarray(&config.groups, &config.numgroups, 200);
- for (j = k = 0; j < config.numgroups && config.groups[j] != NULL; j++) {
- char lbuf[64];
- int l = snprintf(lbuf, sizeof lbuf, "%s\"%s\"", k ? "," : "", config.groups[j]);
- if (l < 0)
- l = 0;
- if (l + k + 1 < len || extendline(&buf, &len, len + 1024) != -1) {
- strcpy(buf + k, lbuf);
- k += l;
- }
- }
- quote = 0;
- break;
- case _UC_DEFAULTCLASS:
- val = config.default_class ? config.default_class : "";
- break;
- case _UC_MINUID:
- sprintf(buf, "%lu", (unsigned long) config.min_uid);
- quote = 0;
- break;
- case _UC_MAXUID:
- sprintf(buf, "%lu", (unsigned long) config.max_uid);
- quote = 0;
- break;
- case _UC_MINGID:
- sprintf(buf, "%lu", (unsigned long) config.min_gid);
- quote = 0;
- break;
- case _UC_MAXGID:
- sprintf(buf, "%lu", (unsigned long) config.max_gid);
- quote = 0;
- break;
- case _UC_EXPIRE:
- sprintf(buf, "%d", config.expire_days);
- quote = 0;
- break;
- case _UC_PASSWORD:
- sprintf(buf, "%d", config.password_days);
- quote = 0;
- break;
- case _UC_NONE:
- break;
- }
+ if ((fp = fdopen(fd, "w")) == NULL) {
+ close(fd);
+ return (0);
+ }
+
+ buf = sbuf_new_auto();
+ for (i = _UC_NONE; i < _UC_FIELDS; i++) {
+ int quote = 1;
+
+ sbuf_clear(buf);
+ switch (i) {
+ case _UC_DEFAULTPWD:
+ sbuf_cat(buf, boolean_str(config.default_password));
+ break;
+ case _UC_REUSEUID:
+ sbuf_cat(buf, boolean_str(config.reuse_uids));
+ break;
+ case _UC_REUSEGID:
+ sbuf_cat(buf, boolean_str(config.reuse_gids));
+ break;
+ case _UC_NISPASSWD:
+ sbuf_cat(buf, config.nispasswd ? config.nispasswd :
+ "");
+ quote = 0;
+ break;
+ case _UC_DOTDIR:
+ sbuf_cat(buf, config.dotdir ? config.dotdir :
+ boolean_str(0));
+ break;
+ case _UC_NEWMAIL:
+ sbuf_cat(buf, config.newmail ? config.newmail :
+ boolean_str(0));
+ break;
+ case _UC_LOGFILE:
+ sbuf_cat(buf, config.logfile ? config.logfile :
+ boolean_str(0));
+ break;
+ case _UC_HOMEROOT:
+ sbuf_cat(buf, config.home);
+ break;
+ case _UC_HOMEMODE:
+ sbuf_printf(buf, "%04o", config.homemode);
+ quote = 0;
+ break;
+ case _UC_SHELLPATH:
+ sbuf_cat(buf, config.shelldir);
+ break;
+ case _UC_SHELLS:
+ for (j = 0; j < _UC_MAXSHELLS &&
+ system_shells[j] != NULL; j++)
+ sbuf_printf(buf, "%s\"%s\"", j ?
+ "," : "", system_shells[j]);
+ quote = 0;
+ break;
+ case _UC_DEFAULTSHELL:
+ sbuf_cat(buf, config.shell_default ?
+ config.shell_default : bourne_shell);
+ break;
+ case _UC_DEFAULTGROUP:
+ sbuf_cat(buf, config.default_group ?
+ config.default_group : "");
+ break;
+ case _UC_EXTRAGROUPS:
+ for (j = 0; j < config.numgroups &&
+ config.groups[j] != NULL; j++)
+ sbuf_printf(buf, "%s\"%s\"", j ?
+ "," : "", config.groups[j]);
+ quote = 0;
+ break;
+ case _UC_DEFAULTCLASS:
+ sbuf_cat(buf, config.default_class ?
+ config.default_class : "");
+ break;
+ case _UC_MINUID:
+ sbuf_printf(buf, "%lu", (unsigned long) config.min_uid);
+ quote = 0;
+ break;
+ case _UC_MAXUID:
+ sbuf_printf(buf, "%lu", (unsigned long) config.max_uid);
+ quote = 0;
+ break;
+ case _UC_MINGID:
+ sbuf_printf(buf, "%lu", (unsigned long) config.min_gid);
+ quote = 0;
+ break;
+ case _UC_MAXGID:
+ sbuf_printf(buf, "%lu", (unsigned long) config.max_gid);
+ quote = 0;
+ break;
+ case _UC_EXPIRE:
+ sbuf_printf(buf, "%d", config.expire_days);
+ quote = 0;
+ break;
+ case _UC_PASSWORD:
+ sbuf_printf(buf, "%d", config.password_days);
+ quote = 0;
+ break;
+ case _UC_NONE:
+ break;
+ }
+ sbuf_finish(buf);
- if (comments[i])
- fputs(comments[i], fp);
+ if (comments[i])
+ fputs(comments[i], fp);
- if (*kwds[i]) {
- if (quote)
- fprintf(fp, "%s = \"%s\"\n", kwds[i], val);
- else
- fprintf(fp, "%s = %s\n", kwds[i], val);
+ if (*kwds[i]) {
+ if (quote)
+ fprintf(fp, "%s = \"%s\"\n", kwds[i],
+ sbuf_data(buf));
+ else
+ fprintf(fp, "%s = %s\n", kwds[i], sbuf_data(buf));
#if debugging
- printf("WROTE: %s = %s\n", kwds[i], val);
+ printf("WROTE: %s = %s\n", kwds[i], sbuf_data(buf));
#endif
- }
- }
- free(buf);
- return fclose(fp) != EOF;
}
}
- return 0;
+ sbuf_delete(buf);
+ return (fclose(fp) != EOF);
}
diff --git a/usr.sbin/pw/pw_nis.c b/usr.sbin/pw/pw_nis.c
index 918fc30..c786cc7 100644
--- a/usr.sbin/pw/pw_nis.c
+++ b/usr.sbin/pw/pw_nis.c
@@ -29,9 +29,6 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <sys/types.h>
#include <err.h>
#include <pwd.h>
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index 483148a..b058aab 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -40,7 +40,6 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
-#include <unistd.h>
#include <login_cap.h>
#include <pwd.h>
#include <grp.h>
@@ -185,8 +184,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
* But we create a symlink from cnf->home -> "/usr" -> cnf->home
*/
if (strchr(cnf->home+1, '/') == NULL) {
- strcpy(dbuf, "/usr");
- strncat(dbuf, cnf->home, MAXPATHLEN-5);
+ snprintf(dbuf, MAXPATHLEN, "/usr%s", cnf->home);
if (mkdir(dbuf, _DEF_DIRMODE) != -1 || errno == EEXIST) {
chown(dbuf, 0, 0);
/*
@@ -364,11 +362,9 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
if (mode == M_LOCK) {
if (strncmp(pwd->pw_passwd, locked_str, sizeof(locked_str)-1) == 0)
errx(EX_DATAERR, "user '%s' is already locked", pwd->pw_name);
- passtmp = malloc(strlen(pwd->pw_passwd) + sizeof(locked_str));
+ asprintf(&passtmp, "%s%s", locked_str, pwd->pw_passwd);
if (passtmp == NULL) /* disaster */
errx(EX_UNAVAILABLE, "out of memory");
- strcpy(passtmp, locked_str);
- strcat(passtmp, pwd->pw_passwd);
pwd->pw_passwd = passtmp;
edited = 1;
} else if (mode == M_UNLOCK) {
@@ -401,7 +397,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
*/
snprintf(file, sizeof(file), "/var/cron/tabs/%s", pwd->pw_name);
if (access(file, F_OK) == 0) {
- sprintf(file, "crontab -u %s -r", pwd->pw_name);
+ snprintf(file, sizeof(file), "crontab -u %s -r", pwd->pw_name);
system(file);
}
}
@@ -409,7 +405,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
* Save these for later, since contents of pwd may be
* invalidated by deletion
*/
- sprintf(file, "%s/%s", _PATH_MAILDIR, pwd->pw_name);
+ snprintf(file, sizeof(file), "%s/%s", _PATH_MAILDIR, pwd->pw_name);
strlcpy(home, pwd->pw_dir, sizeof(home));
gr = GETGRGID(pwd->pw_gid);
if (gr != NULL)
@@ -815,7 +811,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
*/
if (mode == M_ADD) {
if (!PWALTDIR()) {
- sprintf(line, "%s/%s", _PATH_MAILDIR, pwd->pw_name);
+ snprintf(line, sizeof(line), "%s/%s", _PATH_MAILDIR, pwd->pw_name);
close(open(line, O_RDWR | O_CREAT, 0600)); /* Preserve contents &
* mtime */
chown(line, pwd->pw_uid, pwd->pw_gid);
@@ -959,7 +955,7 @@ pw_gidpolicy(struct userconf * cnf, struct cargs * args, char *nam, gid_t prefer
* function will happily handle that case for us and exit.
*/
if (GETGRGID(prefer) == NULL) {
- sprintf(tmp, "%lu", (unsigned long) prefer);
+ snprintf(tmp, sizeof(tmp), "%u", prefer);
addarg(&grpargs, 'g', tmp);
}
if (getarg(args, 'N'))
@@ -1022,17 +1018,16 @@ static char *
pw_homepolicy(struct userconf * cnf, struct cargs * args, char const * user)
{
struct carg *arg = getarg(args, 'd');
+ static char home[128];
if (arg)
- return arg->val;
- else {
- static char home[128];
+ return (arg->val);
- if (cnf->home == NULL || *cnf->home == '\0')
- errx(EX_CONFIG, "no base home directory set");
- sprintf(home, "%s/%s", cnf->home, user);
- return home;
- }
+ if (cnf->home == NULL || *cnf->home == '\0')
+ errx(EX_CONFIG, "no base home directory set");
+ snprintf(home, sizeof(home), "%s/%s", cnf->home, user);
+
+ return (home);
}
static char *
@@ -1053,12 +1048,12 @@ shell_path(char const * path, char *shells[], char *sh)
static char shellpath[256];
if (sh != NULL) {
- sprintf(shellpath, "%s/%s", p, sh);
+ snprintf(shellpath, sizeof(shellpath), "%s/%s", p, sh);
if (access(shellpath, X_OK) == 0)
return shellpath;
} else
for (i = 0; i < _UC_MAXSHELLS && shells[i] != NULL; i++) {
- sprintf(shellpath, "%s/%s", p, shells[i]);
+ snprintf(shellpath, sizeof(shellpath), "%s/%s", p, shells[i]);
if (access(shellpath, X_OK) == 0)
return shellpath;
}
@@ -1308,7 +1303,7 @@ rmat(uid_t uid)
st.st_uid == uid) {
char tmp[MAXPATHLEN];
- sprintf(tmp, "/usr/bin/atrm %s", e->d_name);
+ snprintf(tmp, sizeof(tmp), "/usr/bin/atrm %s", e->d_name);
system(tmp);
}
}
diff --git a/usr.sbin/pw/pwupd.c b/usr.sbin/pw/pwupd.c
index c2a9a53..710e901 100644
--- a/usr.sbin/pw/pwupd.c
+++ b/usr.sbin/pw/pwupd.c
@@ -33,7 +33,6 @@ static const char rcsid[] =
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <stdarg.h>
#include <pwd.h>
#include <libutil.h>
#include <errno.h>
@@ -52,12 +51,13 @@ int
setpwdir(const char * dir)
{
if (dir == NULL)
- return -1;
+ return (-1);
else
pwpath = strdup(dir);
if (pwpath == NULL)
- return -1;
- return 0;
+ return (-1);
+
+ return (0);
}
char *
@@ -66,23 +66,20 @@ getpwpath(char const * file)
static char pathbuf[MAXPATHLEN];
snprintf(pathbuf, sizeof pathbuf, "%s/%s", pwpath, file);
- return pathbuf;
+
+ return (pathbuf);
}
static int
-pwdb(char *arg,...)
+pwdb_check(void)
{
int i = 0;
pid_t pid;
- va_list ap;
char *args[10];
args[i++] = _PATH_PWD_MKDB;
- va_start(ap, arg);
- while (i < 6 && arg != NULL) {
- args[i++] = arg;
- arg = va_arg(ap, char *);
- }
+ args[i++] = "-C";
+
if (pwpath != pathpwd) {
args[i++] = "-d";
args[i++] = pwpath;
@@ -100,65 +97,66 @@ pwdb(char *arg,...)
if (WEXITSTATUS(i))
i = EIO;
}
- va_end(ap);
- return i;
+
+ return (i);
}
static int
pw_update(struct passwd * pwd, char const * user)
{
- int rc = 0;
-
- rc = pwdb("-C", (char *)NULL); /* Check only */
- if (rc == 0) {
- int pfd, tfd;
- struct passwd *pw = NULL;
- struct passwd *old_pw = NULL;
-
- if (pwd != NULL)
- pw = pw_dup(pwd);
-
- if (user != NULL)
- old_pw = GETPWNAM(user);
-
- if (pw_init(pwpath, NULL))
- err(1, "pw_init()");
- if ((pfd = pw_lock()) == -1) {
- pw_fini();
- err(1, "pw_lock()");
- }
- if ((tfd = pw_tmp(-1)) == -1) {
- pw_fini();
- err(1, "pw_tmp()");
- }
- if (pw_copy(pfd, tfd, pw, old_pw) == -1) {
- pw_fini();
- err(1, "pw_copy()");
- }
- /*
- * in case of deletion of a user, the whole database
- * needs to be regenerated
- */
- if (pw_mkdb(pw != NULL ? pw->pw_name : NULL) == -1) {
- pw_fini();
- err(1, "pw_mkdb()");
- }
- free(pw);
+ struct passwd *pw = NULL;
+ struct passwd *old_pw = NULL;
+ int rc, pfd, tfd;
+
+ if ((rc = pwdb_check()) != 0)
+ return (rc);
+
+ if (pwd != NULL)
+ pw = pw_dup(pwd);
+
+ if (user != NULL)
+ old_pw = GETPWNAM(user);
+
+ if (pw_init(pwpath, NULL))
+ err(1, "pw_init()");
+ if ((pfd = pw_lock()) == -1) {
pw_fini();
+ err(1, "pw_lock()");
}
- return 0;
+ if ((tfd = pw_tmp(-1)) == -1) {
+ pw_fini();
+ err(1, "pw_tmp()");
+ }
+ if (pw_copy(pfd, tfd, pw, old_pw) == -1) {
+ pw_fini();
+ err(1, "pw_copy()");
+ }
+ /*
+ * in case of deletion of a user, the whole database
+ * needs to be regenerated
+ */
+ if (pw_mkdb(pw != NULL ? pw->pw_name : NULL) == -1) {
+ pw_fini();
+ err(1, "pw_mkdb()");
+ }
+ free(pw);
+ pw_fini();
+
+ return (0);
}
int
addpwent(struct passwd * pwd)
{
- return pw_update(pwd, NULL);
+
+ return (pw_update(pwd, NULL));
}
int
chgpwent(char const * login, struct passwd * pwd)
{
- return pw_update(pwd, login);
+
+ return (pw_update(pwd, login));
}
int
@@ -167,5 +165,6 @@ delpwent(struct passwd * pwd)
char login[MAXLOGNAME];
strlcpy(login, pwd->pw_name, MAXLOGNAME);
- return pw_update(NULL, login);
+
+ return (pw_update(NULL, login));
}
diff --git a/usr.sbin/pw/pwupd.h b/usr.sbin/pw/pwupd.h
index 200ffee..d6e39ce 100644
--- a/usr.sbin/pw/pwupd.h
+++ b/usr.sbin/pw/pwupd.h
@@ -112,10 +112,7 @@ void vendgrent(void);
void copymkdir(char const * dir, char const * skel, mode_t mode, uid_t uid, gid_t gid);
void rm_r(char const * dir, uid_t uid);
-int extendline(char **buf, int *buflen, int needed);
int extendarray(char ***buf, int *buflen, int needed);
__END_DECLS
-#define PWBUFSZ 1024
-
#endif /* !_PWUPD_H */
diff --git a/usr.sbin/syslogd/pathnames.h b/usr.sbin/syslogd/pathnames.h
index 24fbc4c..00631e0 100644
--- a/usr.sbin/syslogd/pathnames.h
+++ b/usr.sbin/syslogd/pathnames.h
@@ -30,8 +30,6 @@
* $FreeBSD$
*/
-#include <paths.h>
-
#define _PATH_KLOG "/dev/klog"
#define _PATH_LOGCONF "/etc/syslog.conf"
#define _PATH_LOGPID "/var/run/syslog.pid"
diff --git a/usr.sbin/uefisign/pe.c b/usr.sbin/uefisign/pe.c
index 26bb6d5..f4695b4 100644
--- a/usr.sbin/uefisign/pe.c
+++ b/usr.sbin/uefisign/pe.c
@@ -346,7 +346,9 @@ static void
parse_optional_32_plus(struct executable *x, off_t off,
int number_of_sections)
{
+#if 0
uint32_t computed_checksum;
+#endif
const struct pe_optional_header_32_plus *po;
range_check(x, off, sizeof(*po), "PE Optional Header");
@@ -373,13 +375,13 @@ parse_optional_32_plus(struct executable *x, off_t off,
#if 0
printf("checksum 0x%x at offset %zd, len %zd\n",
po->po_checksum, x->x_checksum_off, x->x_checksum_len);
-#endif
computed_checksum = compute_checksum(x);
if (computed_checksum != po->po_checksum) {
warnx("invalid PE+ checksum; is 0x%x, should be 0x%x",
po->po_checksum, computed_checksum);
}
+#endif
if (x->x_len < x->x_headers_len)
errx(1, "invalid SizeOfHeaders %d", po->po_size_of_headers);
@@ -393,7 +395,9 @@ parse_optional_32_plus(struct executable *x, off_t off,
static void
parse_optional_32(struct executable *x, off_t off, int number_of_sections)
{
+#if 0
uint32_t computed_checksum;
+#endif
const struct pe_optional_header_32 *po;
range_check(x, off, sizeof(*po), "PE Optional Header");
@@ -420,13 +424,13 @@ parse_optional_32(struct executable *x, off_t off, int number_of_sections)
#if 0
printf("checksum at offset %zd, len %zd\n",
x->x_checksum_off, x->x_checksum_len);
-#endif
computed_checksum = compute_checksum(x);
if (computed_checksum != po->po_checksum) {
warnx("invalid PE checksum; is 0x%x, should be 0x%x",
po->po_checksum, computed_checksum);
}
+#endif
if (x->x_len < x->x_headers_len)
errx(1, "invalid SizeOfHeaders %d", po->po_size_of_headers);
OpenPOWER on IntegriCloud