summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2014-04-28 07:50:45 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2014-04-28 07:50:45 +0000
commit3b8f08459569bf0faa21473e5cec2491e95c9349 (patch)
tree80f45dd81ca716bcd7ca9674581e1fc40b93cd34 /libexec
parent9d2ab4a62d6733c45958627ac113bdbd818d1e2a (diff)
parentb2ba55951383498f252746f618d513139da06e8e (diff)
downloadsrc-test2-3b8f08459569bf0faa21473e5cec2491e95c9349.tar.gz
src-test2-3b8f08459569bf0faa21473e5cec2491e95c9349.zip
Notes
Diffstat (limited to 'libexec')
-rw-r--r--libexec/Makefile22
-rw-r--r--libexec/atf/Makefile2
-rw-r--r--libexec/atf/Makefile.inc2
-rw-r--r--libexec/atf/atf-check/Makefile5
-rw-r--r--libexec/atf/atf-check/Makefile.inc3
-rw-r--r--libexec/atf/atf-check/tests/Makefile12
-rw-r--r--libexec/atf/tests/Makefile10
-rw-r--r--libexec/atrun/atrun.c6
-rw-r--r--libexec/bootpd/bootpgw/Makefile2
-rw-r--r--libexec/bootpd/rtmsg.c6
-rw-r--r--libexec/bootpd/tools/bootptest/print-bootp.c25
-rw-r--r--libexec/casper/Makefile11
-rw-r--r--libexec/casper/dns/Makefile22
-rw-r--r--libexec/casper/dns/dns.c425
-rw-r--r--libexec/casper/grp/Makefile22
-rw-r--r--libexec/casper/grp/grp.c384
-rw-r--r--libexec/casper/pwd/Makefile22
-rw-r--r--libexec/casper/pwd/pwd.c429
-rw-r--r--libexec/casper/random/Makefile22
-rw-r--r--libexec/casper/random/random.c81
-rw-r--r--libexec/casper/sysctl/Makefile22
-rw-r--r--libexec/casper/sysctl/sysctl.c249
-rw-r--r--libexec/comsat/comsat.86
-rw-r--r--libexec/comsat/comsat.c6
-rw-r--r--libexec/dma-mbox-create/Makefile18
-rw-r--r--libexec/dma/Makefile40
-rw-r--r--libexec/fingerd/fingerd.86
-rw-r--r--libexec/fingerd/fingerd.c6
-rw-r--r--libexec/fingerd/pathnames.h8
-rw-r--r--libexec/ftpd/extern.h6
-rw-r--r--libexec/ftpd/ftpcmd.y6
-rw-r--r--libexec/ftpd/ftpd.86
-rw-r--r--libexec/ftpd/ftpd.c8
-rw-r--r--libexec/ftpd/logwtmp.c6
-rw-r--r--libexec/ftpd/pathnames.h6
-rw-r--r--libexec/ftpd/popen.c6
-rw-r--r--libexec/getty/extern.h6
-rw-r--r--libexec/getty/getty.86
-rw-r--r--libexec/getty/gettytab.56
-rw-r--r--libexec/getty/gettytab.h6
-rw-r--r--libexec/getty/init.c6
-rw-r--r--libexec/getty/main.c6
-rw-r--r--libexec/getty/pathnames.h6
-rw-r--r--libexec/getty/subr.c6
-rw-r--r--libexec/getty/ttys.524
-rw-r--r--libexec/lukemftpd/Makefile60
-rw-r--r--libexec/lukemftpd/config.h303
-rw-r--r--libexec/lukemftpd/nbsd2fbsd.h35
-rw-r--r--libexec/lukemftpd/nbsd_pidfile.h30
-rw-r--r--libexec/lukemftpd/util.h3
-rw-r--r--libexec/mknetid/parse_group.c6
-rw-r--r--libexec/rbootd/bpf.c14
-rw-r--r--libexec/rbootd/conf.c6
-rw-r--r--libexec/rbootd/defs.h6
-rw-r--r--libexec/rbootd/parseconf.c6
-rw-r--r--libexec/rbootd/pathnames.h8
-rw-r--r--libexec/rbootd/rbootd.86
-rw-r--r--libexec/rbootd/rbootd.c6
-rw-r--r--libexec/rbootd/rmp.h8
-rw-r--r--libexec/rbootd/rmp_var.h8
-rw-r--r--libexec/rbootd/rmpproto.c6
-rw-r--r--libexec/rbootd/utils.c6
-rw-r--r--libexec/revnetgroup/parse_netgroup.c6
-rw-r--r--libexec/rlogind/rlogind.86
-rw-r--r--libexec/rlogind/rlogind.c6
-rw-r--r--libexec/rpc.rstatd/rpc.rstatd.86
-rw-r--r--libexec/rpc.rstatd/rstatd.c6
-rw-r--r--libexec/rpc.rusersd/extern.h6
-rw-r--r--libexec/rpc.rusersd/rpc.rusersd.86
-rw-r--r--libexec/rpc.rusersd/rusers_proc.c6
-rw-r--r--libexec/rpc.rusersd/rusersd.c6
-rw-r--r--libexec/rpc.rwalld/rpc.rwalld.86
-rw-r--r--libexec/rshd/rshd.86
-rw-r--r--libexec/rshd/rshd.c6
-rw-r--r--libexec/rtld-elf/Makefile11
-rw-r--r--libexec/rtld-elf/amd64/rtld_start.S43
-rw-r--r--libexec/rtld-elf/malloc.c35
-rw-r--r--libexec/rtld-elf/map_object.c7
-rw-r--r--libexec/rtld-elf/rtld.c93
-rw-r--r--libexec/rtld-elf/rtld.h5
-rw-r--r--libexec/rtld-elf/xmalloc.c28
-rw-r--r--libexec/talkd/announce.c6
-rw-r--r--libexec/talkd/print.c6
-rw-r--r--libexec/talkd/process.c6
-rw-r--r--libexec/talkd/table.c6
-rw-r--r--libexec/talkd/talkd.86
-rw-r--r--libexec/talkd/talkd.c6
-rw-r--r--libexec/tests/Makefile10
-rw-r--r--libexec/tftpd/tftpd.86
-rw-r--r--libexec/tftpd/tftpd.c6
-rw-r--r--libexec/ulog-helper/Makefile2
91 files changed, 2072 insertions, 789 deletions
diff --git a/libexec/Makefile b/libexec/Makefile
index 0b9c9618a1b7..e087a8a8ffe7 100644
--- a/libexec/Makefile
+++ b/libexec/Makefile
@@ -6,7 +6,10 @@
SUBDIR= ${_atf} \
${_atrun} \
bootpd \
+ ${_casper} \
${_comsat} \
+ ${_dma} \
+ ${_dma-mbox-create} \
fingerd \
ftpd \
getty \
@@ -28,23 +31,29 @@ SUBDIR= ${_atf} \
talkd \
tcpd \
${_telnetd} \
+ ${_tests} \
tftpd \
${_tftp-proxy} \
ulog-helper \
${_ypxfr}
-.if ${MK_ATF} != "no"
-_atf= atf
-.endif
-
.if ${MK_AT} != "no"
_atrun= atrun
.endif
+.if ${MK_CASPER} != "no"
+_casper= casper
+.endif
+
.if ${MK_MAIL} != "no"
_comsat= comsat
.endif
+.if ${MK_DMAGENT} != "no"
+_dma= dma
+_dma-mbox-create= dma-mbox-create
+.endif
+
.if ${MK_NIS} != "no"
_mknetid= mknetid
_ypxfr= ypxfr
@@ -76,4 +85,9 @@ _smrsh= smrsh
_telnetd= telnetd
.endif
+.if ${MK_TESTS} != "no"
+_atf= atf
+_tests= tests
+.endif
+
.include <bsd.subdir.mk>
diff --git a/libexec/atf/Makefile b/libexec/atf/Makefile
index dc222c393329..6749db5fce9f 100644
--- a/libexec/atf/Makefile
+++ b/libexec/atf/Makefile
@@ -25,6 +25,6 @@
#
# $FreeBSD$
-SUBDIR= atf-check
+SUBDIR= atf-check tests
.include <bsd.subdir.mk>
diff --git a/libexec/atf/Makefile.inc b/libexec/atf/Makefile.inc
index a28f54645572..392bbb23b236 100644
--- a/libexec/atf/Makefile.inc
+++ b/libexec/atf/Makefile.inc
@@ -25,8 +25,6 @@
#
# $FreeBSD$
-ATF = ${.CURDIR}/../../../contrib/atf
-
CFLAGS+= -DHAVE_CONFIG_H
WARNS?= 3
diff --git a/libexec/atf/atf-check/Makefile b/libexec/atf/atf-check/Makefile
index fafb1e40d653..0cfa8636491b 100644
--- a/libexec/atf/atf-check/Makefile
+++ b/libexec/atf/atf-check/Makefile
@@ -27,6 +27,7 @@
.include <bsd.init.mk>
+ATF= ${.CURDIR:H:H:H}/contrib/atf
.PATH: ${ATF}/atf-sh
BINDIR= /usr/libexec
@@ -42,4 +43,8 @@ LDFLAGS+= -L${.OBJDIR}/../../../lib/atf/libatf-c++
LDFLAGS+= -L${.OBJDIR}/../../../lib/atf/libatf-c
LDADD+= -latf-c++ -latf-c
+.if ${MK_TESTS} != "no"
+SUBDIR+= tests
+.endif
+
.include <bsd.prog.mk>
diff --git a/libexec/atf/atf-check/Makefile.inc b/libexec/atf/atf-check/Makefile.inc
new file mode 100644
index 000000000000..265f86d1ed55
--- /dev/null
+++ b/libexec/atf/atf-check/Makefile.inc
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+.include "../Makefile.inc"
diff --git a/libexec/atf/atf-check/tests/Makefile b/libexec/atf/atf-check/tests/Makefile
new file mode 100644
index 000000000000..43a74988a27b
--- /dev/null
+++ b/libexec/atf/atf-check/tests/Makefile
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+.include <bsd.init.mk>
+
+TESTSDIR= ${TESTSBASE}/libexec/atf/atf-check
+
+ATF= ${.CURDIR:H:H:H:H}/contrib/atf
+.PATH: ${ATF}/atf-sh
+
+ATF_TESTS_SH= atf-check_test
+
+.include <bsd.test.mk>
diff --git a/libexec/atf/tests/Makefile b/libexec/atf/tests/Makefile
new file mode 100644
index 000000000000..7aa96019367e
--- /dev/null
+++ b/libexec/atf/tests/Makefile
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+.include <bsd.own.mk>
+
+TESTSDIR= ${TESTSBASE}/libexec/atf
+
+.PATH: ${.CURDIR:H:H:H}/tests
+KYUAFILE= yes
+
+.include <bsd.test.mk>
diff --git a/libexec/atrun/atrun.c b/libexec/atrun/atrun.c
index 594107e3d2c1..1e25766c41b1 100644
--- a/libexec/atrun/atrun.c
+++ b/libexec/atrun/atrun.c
@@ -567,6 +567,12 @@ main(int argc, char *argv[])
if (run_batch && (gloadavg() < load_avg))
run_file(batch_name, batch_uid, batch_gid);
+ if (flock(dirfd(spool), LOCK_UN) == -1)
+ perr("cannot unlock %s", ATJOB_DIR);
+
+ if (closedir(spool) == -1)
+ perr("cannot closedir %s", ATJOB_DIR);
+
closelog();
exit(EXIT_SUCCESS);
}
diff --git a/libexec/bootpd/bootpgw/Makefile b/libexec/bootpd/bootpgw/Makefile
index 93a982c2d384..b7adadf3d514 100644
--- a/libexec/bootpd/bootpgw/Makefile
+++ b/libexec/bootpd/bootpgw/Makefile
@@ -2,7 +2,7 @@
# $FreeBSD$
PROG= bootpgw
-NO_MAN=
+MAN=
SRCS= bootpgw.c getif.c hwaddr.c report.c rtmsg.c
SRCDIR= ${.CURDIR}/..
diff --git a/libexec/bootpd/rtmsg.c b/libexec/bootpd/rtmsg.c
index c075bc5dae06..09886fd217f2 100644
--- a/libexec/bootpd/rtmsg.c
+++ b/libexec/bootpd/rtmsg.c
@@ -16,11 +16,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/bootpd/tools/bootptest/print-bootp.c b/libexec/bootpd/tools/bootptest/print-bootp.c
index eb474d3bd215..3cdb65abd01a 100644
--- a/libexec/bootpd/tools/bootptest/print-bootp.c
+++ b/libexec/bootpd/tools/bootptest/print-bootp.c
@@ -1,19 +1,18 @@
/*
- * Copyright (c) 1988-1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988-1990
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
+ * modification, are permitted provided that:
+ * 1. Source code distributions retain the above copyright
+ * notice and this paragraph in its entirety
+ * 2. Distributions including binary code include the above copyright
+ * notice and this paragraph in its entirety in the documentation
+ * or other materials provided with the distribution, and
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/libexec/casper/Makefile b/libexec/casper/Makefile
new file mode 100644
index 000000000000..ed6bd7b42aa6
--- /dev/null
+++ b/libexec/casper/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+.include <bsd.own.mk>
+
+SUBDIR= dns
+SUBDIR+=grp
+SUBDIR+=pwd
+SUBDIR+=random
+SUBDIR+=sysctl
+
+.include <bsd.subdir.mk>
diff --git a/libexec/casper/dns/Makefile b/libexec/casper/dns/Makefile
new file mode 100644
index 000000000000..245493e9c6f0
--- /dev/null
+++ b/libexec/casper/dns/Makefile
@@ -0,0 +1,22 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR} ${.CURDIR}/../../../sbin/casper
+
+PROG= dns
+
+SRCS= dns.c
+
+DPADD= ${LIBCAPSICUM} ${LIBCASPER} ${LIBNV} ${LIBPJDLOG} ${LIBUTIL}
+LDADD= -lcapsicum -lcasper -lnv -lpjdlog -lutil
+
+BINDIR= /libexec/casper
+
+CFLAGS+=-I${.CURDIR}
+CFLAGS+=-I${.CURDIR}/../../../lib/libcapsicum
+CFLAGS+=-I${.CURDIR}/../../../lib/libcasper
+CFLAGS+=-I${.CURDIR}/../../../lib/libpjdlog
+CFLAGS+=-I${.CURDIR}/../../../sbin/casper
+
+MAN=
+
+.include <bsd.prog.mk>
diff --git a/libexec/casper/dns/dns.c b/libexec/casper/dns/dns.c
new file mode 100644
index 000000000000..6be022ab6566
--- /dev/null
+++ b/libexec/casper/dns/dns.c
@@ -0,0 +1,425 @@
+/*-
+ * Copyright (c) 2012-2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 AUTHORS OR CONTRIBUTORS 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <netinet/in.h>
+
+#include <errno.h>
+#include <netdb.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <libcapsicum.h>
+#include <libcapsicum_dns.h>
+#include <libcasper.h>
+#include <nv.h>
+#include <pjdlog.h>
+
+static bool
+dns_allowed_type(const nvlist_t *limits, const char *type)
+{
+ const char *name;
+ bool notypes;
+ void *cookie;
+
+ if (limits == NULL)
+ return (true);
+
+ notypes = true;
+ cookie = NULL;
+ while ((name = nvlist_next(limits, NULL, &cookie)) != NULL) {
+ if (strncmp(name, "type", sizeof("type") - 1) != 0)
+ continue;
+ notypes = false;
+ if (strcmp(nvlist_get_string(limits, name), type) == 0)
+ return (true);
+ }
+
+ /* If there are no types at all, allow any type. */
+ if (notypes)
+ return (true);
+
+ return (false);
+}
+
+static bool
+dns_allowed_family(const nvlist_t *limits, int family)
+{
+ const char *name;
+ bool nofamilies;
+ void *cookie;
+
+ if (limits == NULL)
+ return (true);
+
+ nofamilies = true;
+ cookie = NULL;
+ while ((name = nvlist_next(limits, NULL, &cookie)) != NULL) {
+ if (strncmp(name, "family", sizeof("family") - 1) != 0)
+ continue;
+ nofamilies = false;
+ if (family == AF_UNSPEC)
+ continue;
+ if (nvlist_get_number(limits, name) == (uint64_t)family)
+ return (true);
+ }
+
+ /* If there are no families at all, allow any family. */
+ if (nofamilies)
+ return (true);
+
+ return (false);
+}
+
+static void
+hostent_pack(const struct hostent *hp, nvlist_t *nvl)
+{
+ unsigned int ii;
+
+ nvlist_add_string(nvl, "name", hp->h_name);
+ nvlist_add_number(nvl, "addrtype", (uint64_t)hp->h_addrtype);
+ nvlist_add_number(nvl, "length", (uint64_t)hp->h_length);
+
+ if (hp->h_aliases == NULL) {
+ nvlist_add_number(nvl, "naliases", 0);
+ } else {
+ for (ii = 0; hp->h_aliases[ii] != NULL; ii++) {
+ nvlist_addf_string(nvl, hp->h_aliases[ii], "alias%u",
+ ii);
+ }
+ nvlist_add_number(nvl, "naliases", (uint64_t)ii);
+ }
+
+ if (hp->h_addr_list == NULL) {
+ nvlist_add_number(nvl, "naddrs", 0);
+ } else {
+ for (ii = 0; hp->h_addr_list[ii] != NULL; ii++) {
+ nvlist_addf_binary(nvl, hp->h_addr_list[ii],
+ (size_t)hp->h_length, "addr%u", ii);
+ }
+ nvlist_add_number(nvl, "naddrs", (uint64_t)ii);
+ }
+}
+
+static int
+dns_gethostbyname(const nvlist_t *limits, const nvlist_t *nvlin,
+ nvlist_t *nvlout)
+{
+ struct hostent *hp;
+ int family;
+
+ if (!dns_allowed_type(limits, "NAME"))
+ return (NO_RECOVERY);
+
+ family = (int)nvlist_get_number(nvlin, "family");
+
+ if (!dns_allowed_family(limits, family))
+ return (NO_RECOVERY);
+
+ hp = gethostbyname2(nvlist_get_string(nvlin, "name"), family);
+ if (hp == NULL)
+ return (h_errno);
+ hostent_pack(hp, nvlout);
+ return (0);
+}
+
+static int
+dns_gethostbyaddr(const nvlist_t *limits, const nvlist_t *nvlin,
+ nvlist_t *nvlout)
+{
+ struct hostent *hp;
+ const void *addr;
+ size_t addrsize;
+ int family;
+
+ if (!dns_allowed_type(limits, "ADDR"))
+ return (NO_RECOVERY);
+
+ family = (int)nvlist_get_number(nvlin, "family");
+
+ if (!dns_allowed_family(limits, family))
+ return (NO_RECOVERY);
+
+ addr = nvlist_get_binary(nvlin, "addr", &addrsize);
+ hp = gethostbyaddr(addr, (socklen_t)addrsize, family);
+ if (hp == NULL)
+ return (h_errno);
+ hostent_pack(hp, nvlout);
+ return (0);
+}
+
+static int
+dns_getnameinfo(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ struct sockaddr_storage sast;
+ const void *sabin;
+ char *host, *serv;
+ size_t sabinsize, hostlen, servlen;
+ socklen_t salen;
+ int error, flags;
+
+ if (!dns_allowed_type(limits, "NAME"))
+ return (NO_RECOVERY);
+
+ error = 0;
+ host = serv = NULL;
+ memset(&sast, 0, sizeof(sast));
+
+ hostlen = (size_t)nvlist_get_number(nvlin, "hostlen");
+ servlen = (size_t)nvlist_get_number(nvlin, "servlen");
+
+ if (hostlen > 0) {
+ host = calloc(1, hostlen + 1);
+ if (host == NULL) {
+ error = EAI_MEMORY;
+ goto out;
+ }
+ }
+ if (servlen > 0) {
+ serv = calloc(1, servlen + 1);
+ if (serv == NULL) {
+ error = EAI_MEMORY;
+ goto out;
+ }
+ }
+
+ sabin = nvlist_get_binary(nvlin, "sa", &sabinsize);
+ if (sabinsize > sizeof(sast)) {
+ error = EAI_FAIL;
+ goto out;
+ }
+
+ memcpy(&sast, sabin, sabinsize);
+ salen = (socklen_t)sabinsize;
+
+ if ((sast.ss_family != AF_INET ||
+ salen != sizeof(struct sockaddr_in)) &&
+ (sast.ss_family != AF_INET6 ||
+ salen != sizeof(struct sockaddr_in6))) {
+ error = EAI_FAIL;
+ goto out;
+ }
+
+ if (!dns_allowed_family(limits, (int)sast.ss_family))
+ return (NO_RECOVERY);
+
+ flags = (int)nvlist_get_number(nvlin, "flags");
+
+ error = getnameinfo((struct sockaddr *)&sast, salen, host, hostlen,
+ serv, servlen, flags);
+ if (error != 0)
+ goto out;
+
+ nvlist_move_string(nvlout, "host", host);
+ nvlist_move_string(nvlout, "serv", serv);
+out:
+ if (error != 0) {
+ free(host);
+ free(serv);
+ }
+ return (error);
+}
+
+static nvlist_t *
+addrinfo_pack(const struct addrinfo *ai)
+{
+ nvlist_t *nvl;
+
+ nvl = nvlist_create(0);
+ nvlist_add_number(nvl, "ai_flags", (uint64_t)ai->ai_flags);
+ nvlist_add_number(nvl, "ai_family", (uint64_t)ai->ai_family);
+ nvlist_add_number(nvl, "ai_socktype", (uint64_t)ai->ai_socktype);
+ nvlist_add_number(nvl, "ai_protocol", (uint64_t)ai->ai_protocol);
+ nvlist_add_binary(nvl, "ai_addr", ai->ai_addr, (size_t)ai->ai_addrlen);
+ nvlist_add_string(nvl, "ai_canonname", ai->ai_canonname);
+
+ return (nvl);
+}
+
+static int
+dns_getaddrinfo(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ struct addrinfo hints, *hintsp, *res, *cur;
+ const char *hostname, *servname;
+ nvlist_t *elem;
+ unsigned int ii;
+ int error, family;
+
+ if (!dns_allowed_type(limits, "ADDR"))
+ return (NO_RECOVERY);
+
+ hostname = nvlist_get_string(nvlin, "hostname");
+ servname = nvlist_get_string(nvlin, "servname");
+ if (nvlist_exists_number(nvlin, "hints.ai_flags")) {
+ size_t addrlen;
+
+ hints.ai_flags = (int)nvlist_get_number(nvlin,
+ "hints.ai_flags");
+ hints.ai_family = (int)nvlist_get_number(nvlin,
+ "hints.ai_family");
+ hints.ai_socktype = (int)nvlist_get_number(nvlin,
+ "hints.ai_socktype");
+ hints.ai_protocol = (int)nvlist_get_number(nvlin,
+ "hints.ai_protocol");
+ hints.ai_addrlen = 0;
+ hints.ai_addr = NULL;
+ hints.ai_canonname = NULL;
+ hintsp = &hints;
+ family = hints.ai_family;
+ } else {
+ hintsp = NULL;
+ family = AF_UNSPEC;
+ }
+
+ if (!dns_allowed_family(limits, family))
+ return (NO_RECOVERY);
+
+ error = getaddrinfo(hostname, servname, hintsp, &res);
+ if (error != 0)
+ goto out;
+
+ for (cur = res, ii = 0; cur != NULL; cur = cur->ai_next, ii++) {
+ elem = addrinfo_pack(cur);
+ nvlist_movef_nvlist(nvlout, elem, "res%u", ii);
+ }
+
+ freeaddrinfo(res);
+ error = 0;
+out:
+ return (error);
+}
+
+static bool
+limit_has_entry(const nvlist_t *limits, const char *prefix)
+{
+ const char *name;
+ size_t prefixlen;
+ void *cookie;
+
+ if (limits == NULL)
+ return (false);
+
+ prefixlen = strlen(prefix);
+
+ cookie = NULL;
+ while ((name = nvlist_next(limits, NULL, &cookie)) != NULL) {
+ if (strncmp(name, prefix, prefixlen) == 0)
+ return (true);
+ }
+
+ return (false);
+}
+
+static int
+dns_limit(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const char *name;
+ void *cookie;
+ int nvtype;
+ bool hastype, hasfamily;
+
+ hastype = false;
+ hasfamily = false;
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &nvtype, &cookie)) != NULL) {
+ if (nvtype == NV_TYPE_STRING) {
+ const char *type;
+
+ if (strncmp(name, "type", sizeof("type") - 1) != 0)
+ return (EINVAL);
+ type = nvlist_get_string(newlimits, name);
+ if (strcmp(type, "ADDR") != 0 &&
+ strcmp(type, "NAME") != 0) {
+ return (EINVAL);
+ }
+ if (!dns_allowed_type(oldlimits, type))
+ return (ENOTCAPABLE);
+ hastype = true;
+ } else if (nvtype == NV_TYPE_NUMBER) {
+ int family;
+
+ if (strncmp(name, "family", sizeof("family") - 1) != 0)
+ return (EINVAL);
+ family = (int)nvlist_get_number(newlimits, name);
+ if (!dns_allowed_family(oldlimits, family))
+ return (ENOTCAPABLE);
+ hasfamily = true;
+ } else {
+ return (EINVAL);
+ }
+ }
+
+ /*
+ * If the new limit doesn't mention type or family we have to
+ * check if the current limit does have those. Missing type or
+ * family in the limit means that all types or families are
+ * allowed.
+ */
+ if (!hastype) {
+ if (limit_has_entry(oldlimits, "type"))
+ return (ENOTCAPABLE);
+ }
+ if (!hasfamily) {
+ if (limit_has_entry(oldlimits, "family"))
+ return (ENOTCAPABLE);
+ }
+
+ return (0);
+}
+
+static int
+dns_command(const char *cmd, const nvlist_t *limits, nvlist_t *nvlin,
+ nvlist_t *nvlout)
+{
+ int error;
+
+ if (strcmp(cmd, "gethostbyname") == 0)
+ error = dns_gethostbyname(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "gethostbyaddr") == 0)
+ error = dns_gethostbyaddr(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "getnameinfo") == 0)
+ error = dns_getnameinfo(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "getaddrinfo") == 0)
+ error = dns_getaddrinfo(limits, nvlin, nvlout);
+ else
+ error = NO_RECOVERY;
+
+ return (error);
+}
+
+int
+main(int argc, char *argv[])
+{
+
+ return (service_start("system.dns", PARENT_FILENO, dns_limit,
+ dns_command, argc, argv));
+}
diff --git a/libexec/casper/grp/Makefile b/libexec/casper/grp/Makefile
new file mode 100644
index 000000000000..502cd261f595
--- /dev/null
+++ b/libexec/casper/grp/Makefile
@@ -0,0 +1,22 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR} ${.CURDIR}/../../../sbin/casper
+
+PROG= grp
+
+SRCS= grp.c
+
+DPADD= ${LIBCAPSICUM} ${LIBCASPER} ${LIBNV} ${LIBPJDLOG} ${LIBUTIL}
+LDADD= -lcapsicum -lcasper -lnv -lpjdlog -lutil
+
+BINDIR= /libexec/casper
+
+CFLAGS+=-I${.CURDIR}
+CFLAGS+=-I${.CURDIR}/../../../lib/libcapsicum
+CFLAGS+=-I${.CURDIR}/../../../lib/libcasper
+CFLAGS+=-I${.CURDIR}/../../../lib/libpjdlog
+CFLAGS+=-I${.CURDIR}/../../../sbin/casper
+
+MAN=
+
+.include <bsd.prog.mk>
diff --git a/libexec/casper/grp/grp.c b/libexec/casper/grp/grp.c
new file mode 100644
index 000000000000..ba22f62e59c7
--- /dev/null
+++ b/libexec/casper/grp/grp.c
@@ -0,0 +1,384 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 AUTHORS OR CONTRIBUTORS 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <errno.h>
+#include <grp.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <libcapsicum.h>
+#include <libcasper.h>
+#include <nv.h>
+#include <pjdlog.h>
+
+static bool
+grp_allowed_cmd(const nvlist_t *limits, const char *cmd)
+{
+
+ if (limits == NULL)
+ return (true);
+
+ /*
+ * If no limit was set on allowed commands, then all commands
+ * are allowed.
+ */
+ if (!nvlist_exists_nvlist(limits, "cmds"))
+ return (true);
+
+ limits = nvlist_get_nvlist(limits, "cmds");
+ return (nvlist_exists_null(limits, cmd));
+}
+
+static int
+grp_allowed_cmds(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const char *name;
+ void *cookie;
+ int type;
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) {
+ if (type != NV_TYPE_NULL)
+ return (EINVAL);
+ if (!grp_allowed_cmd(oldlimits, name))
+ return (ENOTCAPABLE);
+ }
+
+ return (0);
+}
+
+static bool
+grp_allowed_group(const nvlist_t *limits, const char *gname, gid_t gid)
+{
+ const char *name;
+ void *cookie;
+ int type;
+
+ if (limits == NULL)
+ return (true);
+
+ /*
+ * If no limit was set on allowed groups, then all groups are allowed.
+ */
+ if (!nvlist_exists_nvlist(limits, "groups"))
+ return (true);
+
+ limits = nvlist_get_nvlist(limits, "groups");
+ cookie = NULL;
+ while ((name = nvlist_next(limits, &type, &cookie)) != NULL) {
+ switch (type) {
+ case NV_TYPE_NUMBER:
+ if (gid != (gid_t)-1 &&
+ nvlist_get_number(limits, name) == (uint64_t)gid) {
+ return (true);
+ }
+ break;
+ case NV_TYPE_STRING:
+ if (gname != NULL &&
+ strcmp(nvlist_get_string(limits, name),
+ gname) == 0) {
+ return (true);
+ }
+ break;
+ default:
+ PJDLOG_ABORT("Unexpected type %d.", type);
+ }
+ }
+
+ return (false);
+}
+
+static int
+grp_allowed_groups(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const char *name, *gname;
+ void *cookie;
+ gid_t gid;
+ int type;
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) {
+ switch (type) {
+ case NV_TYPE_NUMBER:
+ gid = (gid_t)nvlist_get_number(newlimits, name);
+ gname = NULL;
+ break;
+ case NV_TYPE_STRING:
+ gid = (gid_t)-1;
+ gname = nvlist_get_string(newlimits, name);
+ break;
+ default:
+ return (EINVAL);
+ }
+ if (!grp_allowed_group(oldlimits, gname, gid))
+ return (ENOTCAPABLE);
+ }
+
+ return (0);
+}
+
+static bool
+grp_allowed_field(const nvlist_t *limits, const char *field)
+{
+
+ if (limits == NULL)
+ return (true);
+
+ /*
+ * If no limit was set on allowed fields, then all fields are allowed.
+ */
+ if (!nvlist_exists_nvlist(limits, "fields"))
+ return (true);
+
+ limits = nvlist_get_nvlist(limits, "fields");
+ return (nvlist_exists_null(limits, field));
+}
+
+static int
+grp_allowed_fields(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const char *name;
+ void *cookie;
+ int type;
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) {
+ if (type != NV_TYPE_NULL)
+ return (EINVAL);
+ if (!grp_allowed_field(oldlimits, name))
+ return (ENOTCAPABLE);
+ }
+
+ return (0);
+}
+
+static bool
+grp_pack(const nvlist_t *limits, const struct group *grp, nvlist_t *nvl)
+{
+
+ if (grp == NULL)
+ return (true);
+
+ /*
+ * If either name or GID is allowed, we allow it.
+ */
+ if (!grp_allowed_group(limits, grp->gr_name, grp->gr_gid))
+ return (false);
+
+ if (grp_allowed_field(limits, "gr_name"))
+ nvlist_add_string(nvl, "gr_name", grp->gr_name);
+ else
+ nvlist_add_string(nvl, "gr_name", "");
+ if (grp_allowed_field(limits, "gr_passwd"))
+ nvlist_add_string(nvl, "gr_passwd", grp->gr_passwd);
+ else
+ nvlist_add_string(nvl, "gr_passwd", "");
+ if (grp_allowed_field(limits, "gr_gid"))
+ nvlist_add_number(nvl, "gr_gid", (uint64_t)grp->gr_gid);
+ else
+ nvlist_add_number(nvl, "gr_gid", (uint64_t)-1);
+ if (grp_allowed_field(limits, "gr_mem") && grp->gr_mem[0] != NULL) {
+ unsigned int ngroups;
+
+ for (ngroups = 0; grp->gr_mem[ngroups] != NULL; ngroups++) {
+ nvlist_addf_string(nvl, grp->gr_mem[ngroups],
+ "gr_mem[%u]", ngroups);
+ }
+ nvlist_add_number(nvl, "gr_nmem", (uint64_t)ngroups);
+ }
+
+ return (true);
+}
+
+static int
+grp_getgrent(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ struct group *grp;
+
+ for (;;) {
+ errno = 0;
+ grp = getgrent();
+ if (errno != 0)
+ return (errno);
+ if (grp_pack(limits, grp, nvlout))
+ return (0);
+ }
+
+ /* NOTREACHED */
+}
+
+static int
+grp_getgrnam(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ struct group *grp;
+ const char *name;
+
+ if (!nvlist_exists_string(nvlin, "name"))
+ return (EINVAL);
+ name = nvlist_get_string(nvlin, "name");
+ PJDLOG_ASSERT(name != NULL);
+
+ errno = 0;
+ grp = getgrnam(name);
+ if (errno != 0)
+ return (errno);
+
+ (void)grp_pack(limits, grp, nvlout);
+
+ return (0);
+}
+
+static int
+grp_getgrgid(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ struct group *grp;
+ gid_t gid;
+
+ if (!nvlist_exists_number(nvlin, "gid"))
+ return (EINVAL);
+
+ gid = (gid_t)nvlist_get_number(nvlin, "gid");
+
+ errno = 0;
+ grp = getgrgid(gid);
+ if (errno != 0)
+ return (errno);
+
+ (void)grp_pack(limits, grp, nvlout);
+
+ return (0);
+}
+
+static int
+grp_setgroupent(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ int stayopen;
+
+ if (!nvlist_exists_bool(nvlin, "stayopen"))
+ return (EINVAL);
+
+ stayopen = nvlist_get_bool(nvlin, "stayopen") ? 1 : 0;
+
+ return (setgroupent(stayopen) == 0 ? EFAULT : 0);
+}
+
+static int
+grp_setgrent(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+
+ return (setgrent() == 0 ? EFAULT : 0);
+}
+
+static int
+grp_endgrent(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+
+ endgrent();
+
+ return (0);
+}
+
+static int
+grp_limit(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const nvlist_t *limits;
+ const char *name;
+ void *cookie;
+ int error, type;
+
+ if (oldlimits != NULL && nvlist_exists_nvlist(oldlimits, "cmds") &&
+ !nvlist_exists_nvlist(newlimits, "cmds")) {
+ return (ENOTCAPABLE);
+ }
+ if (oldlimits != NULL && nvlist_exists_nvlist(oldlimits, "fields") &&
+ !nvlist_exists_nvlist(newlimits, "fields")) {
+ return (ENOTCAPABLE);
+ }
+ if (oldlimits != NULL && nvlist_exists_nvlist(oldlimits, "groups") &&
+ !nvlist_exists_nvlist(newlimits, "groups")) {
+ return (ENOTCAPABLE);
+ }
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) {
+ if (type != NV_TYPE_NVLIST)
+ return (EINVAL);
+ limits = nvlist_get_nvlist(newlimits, name);
+ if (strcmp(name, "cmds") == 0)
+ error = grp_allowed_cmds(oldlimits, limits);
+ else if (strcmp(name, "fields") == 0)
+ error = grp_allowed_fields(oldlimits, limits);
+ else if (strcmp(name, "groups") == 0)
+ error = grp_allowed_groups(oldlimits, limits);
+ else
+ error = EINVAL;
+ if (error != 0)
+ return (error);
+ }
+
+ return (0);
+}
+
+static int
+grp_command(const char *cmd, const nvlist_t *limits, nvlist_t *nvlin,
+ nvlist_t *nvlout)
+{
+ int error;
+
+ if (!grp_allowed_cmd(limits, cmd))
+ return (ENOTCAPABLE);
+
+ if (strcmp(cmd, "getgrent") == 0 || strcmp(cmd, "getgrent_r") == 0)
+ error = grp_getgrent(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "getgrnam") == 0 || strcmp(cmd, "getgrnam_r") == 0)
+ error = grp_getgrnam(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "getgrgid") == 0 || strcmp(cmd, "getgrgid_r") == 0)
+ error = grp_getgrgid(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "setgroupent") == 0)
+ error = grp_setgroupent(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "setgrent") == 0)
+ error = grp_setgrent(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "endgrent") == 0)
+ error = grp_endgrent(limits, nvlin, nvlout);
+ else
+ error = EINVAL;
+
+ return (error);
+}
+
+int
+main(int argc, char *argv[])
+{
+
+ return (service_start("system.grp", PARENT_FILENO, grp_limit,
+ grp_command, argc, argv));
+}
diff --git a/libexec/casper/pwd/Makefile b/libexec/casper/pwd/Makefile
new file mode 100644
index 000000000000..ebf6cac9e121
--- /dev/null
+++ b/libexec/casper/pwd/Makefile
@@ -0,0 +1,22 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR} ${.CURDIR}/../../../sbin/casper
+
+PROG= pwd
+
+SRCS= pwd.c
+
+DPADD= ${LIBCAPSICUM} ${LIBCASPER} ${LIBNV} ${LIBPJDLOG} ${LIBUTIL}
+LDADD= -lcapsicum -lcasper -lnv -lpjdlog -lutil
+
+BINDIR= /libexec/casper
+
+CFLAGS+=-I${.CURDIR}
+CFLAGS+=-I${.CURDIR}/../../../lib/libcapsicum
+CFLAGS+=-I${.CURDIR}/../../../lib/libcasper
+CFLAGS+=-I${.CURDIR}/../../../lib/libpjdlog
+CFLAGS+=-I${.CURDIR}/../../../sbin/casper
+
+MAN=
+
+.include <bsd.prog.mk>
diff --git a/libexec/casper/pwd/pwd.c b/libexec/casper/pwd/pwd.c
new file mode 100644
index 000000000000..be51ad0c2217
--- /dev/null
+++ b/libexec/casper/pwd/pwd.c
@@ -0,0 +1,429 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 AUTHORS OR CONTRIBUTORS 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <errno.h>
+#include <pwd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <libcapsicum.h>
+#include <libcasper.h>
+#include <nv.h>
+#include <pjdlog.h>
+
+static bool
+pwd_allowed_cmd(const nvlist_t *limits, const char *cmd)
+{
+
+ if (limits == NULL)
+ return (true);
+
+ /*
+ * If no limit was set on allowed commands, then all commands
+ * are allowed.
+ */
+ if (!nvlist_exists_nvlist(limits, "cmds"))
+ return (true);
+
+ limits = nvlist_get_nvlist(limits, "cmds");
+ return (nvlist_exists_null(limits, cmd));
+}
+
+static int
+pwd_allowed_cmds(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const char *name;
+ void *cookie;
+ int type;
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) {
+ if (type != NV_TYPE_NULL)
+ return (EINVAL);
+ if (!pwd_allowed_cmd(oldlimits, name))
+ return (ENOTCAPABLE);
+ }
+
+ return (0);
+}
+
+static bool
+pwd_allowed_user(const nvlist_t *limits, const char *uname, uid_t uid)
+{
+ const char *name;
+ void *cookie;
+ int type;
+
+ if (limits == NULL)
+ return (true);
+
+ /*
+ * If no limit was set on allowed users, then all users are allowed.
+ */
+ if (!nvlist_exists_nvlist(limits, "users"))
+ return (true);
+
+ limits = nvlist_get_nvlist(limits, "users");
+ cookie = NULL;
+ while ((name = nvlist_next(limits, &type, &cookie)) != NULL) {
+ switch (type) {
+ case NV_TYPE_NUMBER:
+ if (uid != (uid_t)-1 &&
+ nvlist_get_number(limits, name) == (uint64_t)uid) {
+ return (true);
+ }
+ break;
+ case NV_TYPE_STRING:
+ if (uname != NULL &&
+ strcmp(nvlist_get_string(limits, name),
+ uname) == 0) {
+ return (true);
+ }
+ break;
+ default:
+ PJDLOG_ABORT("Unexpected type %d.", type);
+ }
+ }
+
+ return (false);
+}
+
+static int
+pwd_allowed_users(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const char *name, *uname;
+ void *cookie;
+ uid_t uid;
+ int type;
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) {
+ switch (type) {
+ case NV_TYPE_NUMBER:
+ uid = (uid_t)nvlist_get_number(newlimits, name);
+ uname = NULL;
+ break;
+ case NV_TYPE_STRING:
+ uid = (uid_t)-1;
+ uname = nvlist_get_string(newlimits, name);
+ break;
+ default:
+ return (EINVAL);
+ }
+ if (!pwd_allowed_user(oldlimits, uname, uid))
+ return (ENOTCAPABLE);
+ }
+
+ return (0);
+}
+
+static bool
+pwd_allowed_field(const nvlist_t *limits, const char *field)
+{
+
+ if (limits == NULL)
+ return (true);
+
+ /*
+ * If no limit was set on allowed fields, then all fields are allowed.
+ */
+ if (!nvlist_exists_nvlist(limits, "fields"))
+ return (true);
+
+ limits = nvlist_get_nvlist(limits, "fields");
+ return (nvlist_exists_null(limits, field));
+}
+
+static int
+pwd_allowed_fields(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const char *name;
+ void *cookie;
+ int type;
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) {
+ if (type != NV_TYPE_NULL)
+ return (EINVAL);
+ if (!pwd_allowed_field(oldlimits, name))
+ return (ENOTCAPABLE);
+ }
+
+ return (0);
+}
+
+static bool
+pwd_pack(const nvlist_t *limits, const struct passwd *pwd, nvlist_t *nvl)
+{
+ int fields;
+
+ if (pwd == NULL)
+ return (true);
+
+ /*
+ * If either name or UID is allowed, we allow it.
+ */
+ if (!pwd_allowed_user(limits, pwd->pw_name, pwd->pw_uid))
+ return (false);
+
+ fields = pwd->pw_fields;
+
+ if (pwd_allowed_field(limits, "pw_name")) {
+ nvlist_add_string(nvl, "pw_name", pwd->pw_name);
+ } else {
+ nvlist_add_string(nvl, "pw_name", "");
+ fields &= ~_PWF_NAME;
+ }
+ if (pwd_allowed_field(limits, "pw_uid")) {
+ nvlist_add_number(nvl, "pw_uid", (uint64_t)pwd->pw_uid);
+ } else {
+ nvlist_add_number(nvl, "pw_uid", (uint64_t)-1);
+ fields &= ~_PWF_UID;
+ }
+ if (pwd_allowed_field(limits, "pw_gid")) {
+ nvlist_add_number(nvl, "pw_gid", (uint64_t)pwd->pw_gid);
+ } else {
+ nvlist_add_number(nvl, "pw_gid", (uint64_t)-1);
+ fields &= ~_PWF_GID;
+ }
+ if (pwd_allowed_field(limits, "pw_change")) {
+ nvlist_add_number(nvl, "pw_change", (uint64_t)pwd->pw_change);
+ } else {
+ nvlist_add_number(nvl, "pw_change", (uint64_t)0);
+ fields &= ~_PWF_CHANGE;
+ }
+ if (pwd_allowed_field(limits, "pw_passwd")) {
+ nvlist_add_string(nvl, "pw_passwd", pwd->pw_passwd);
+ } else {
+ nvlist_add_string(nvl, "pw_passwd", "");
+ fields &= ~_PWF_PASSWD;
+ }
+ if (pwd_allowed_field(limits, "pw_class")) {
+ nvlist_add_string(nvl, "pw_class", pwd->pw_class);
+ } else {
+ nvlist_add_string(nvl, "pw_class", "");
+ fields &= ~_PWF_CLASS;
+ }
+ if (pwd_allowed_field(limits, "pw_gecos")) {
+ nvlist_add_string(nvl, "pw_gecos", pwd->pw_gecos);
+ } else {
+ nvlist_add_string(nvl, "pw_gecos", "");
+ fields &= ~_PWF_GECOS;
+ }
+ if (pwd_allowed_field(limits, "pw_dir")) {
+ nvlist_add_string(nvl, "pw_dir", pwd->pw_dir);
+ } else {
+ nvlist_add_string(nvl, "pw_dir", "");
+ fields &= ~_PWF_DIR;
+ }
+ if (pwd_allowed_field(limits, "pw_shell")) {
+ nvlist_add_string(nvl, "pw_shell", pwd->pw_shell);
+ } else {
+ nvlist_add_string(nvl, "pw_shell", "");
+ fields &= ~_PWF_SHELL;
+ }
+ if (pwd_allowed_field(limits, "pw_expire")) {
+ nvlist_add_number(nvl, "pw_expire", (uint64_t)pwd->pw_expire);
+ } else {
+ nvlist_add_number(nvl, "pw_expire", (uint64_t)0);
+ fields &= ~_PWF_EXPIRE;
+ }
+ nvlist_add_number(nvl, "pw_fields", (uint64_t)fields);
+
+ return (true);
+}
+
+static int
+pwd_getpwent(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ struct passwd *pwd;
+
+ for (;;) {
+ errno = 0;
+ pwd = getpwent();
+ if (errno != 0)
+ return (errno);
+ if (pwd_pack(limits, pwd, nvlout))
+ return (0);
+ }
+
+ /* NOTREACHED */
+}
+
+static int
+pwd_getpwnam(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ struct passwd *pwd;
+ const char *name;
+
+ if (!nvlist_exists_string(nvlin, "name"))
+ return (EINVAL);
+ name = nvlist_get_string(nvlin, "name");
+ PJDLOG_ASSERT(name != NULL);
+
+ errno = 0;
+ pwd = getpwnam(name);
+ if (errno != 0)
+ return (errno);
+
+ (void)pwd_pack(limits, pwd, nvlout);
+
+ return (0);
+}
+
+static int
+pwd_getpwuid(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ struct passwd *pwd;
+ uid_t uid;
+
+ if (!nvlist_exists_number(nvlin, "uid"))
+ return (EINVAL);
+
+ uid = (uid_t)nvlist_get_number(nvlin, "uid");
+
+ errno = 0;
+ pwd = getpwuid(uid);
+ if (errno != 0)
+ return (errno);
+
+ (void)pwd_pack(limits, pwd, nvlout);
+
+ return (0);
+}
+
+static int
+pwd_setpassent(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+ int stayopen;
+
+ if (!nvlist_exists_bool(nvlin, "stayopen"))
+ return (EINVAL);
+
+ stayopen = nvlist_get_bool(nvlin, "stayopen") ? 1 : 0;
+
+ return (setpassent(stayopen) == 0 ? EFAULT : 0);
+}
+
+static int
+pwd_setpwent(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+
+ setpwent();
+
+ return (0);
+}
+
+static int
+pwd_endpwent(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
+{
+
+ endpwent();
+
+ return (0);
+}
+
+static int
+pwd_limit(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const nvlist_t *limits;
+ const char *name;
+ void *cookie;
+ int error, type;
+
+ if (oldlimits != NULL && nvlist_exists_nvlist(oldlimits, "cmds") &&
+ !nvlist_exists_nvlist(newlimits, "cmds")) {
+ return (ENOTCAPABLE);
+ }
+ if (oldlimits != NULL && nvlist_exists_nvlist(oldlimits, "fields") &&
+ !nvlist_exists_nvlist(newlimits, "fields")) {
+ return (ENOTCAPABLE);
+ }
+ if (oldlimits != NULL && nvlist_exists_nvlist(oldlimits, "users") &&
+ !nvlist_exists_nvlist(newlimits, "users")) {
+ return (ENOTCAPABLE);
+ }
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) {
+ if (type != NV_TYPE_NVLIST)
+ return (EINVAL);
+ limits = nvlist_get_nvlist(newlimits, name);
+ if (strcmp(name, "cmds") == 0)
+ error = pwd_allowed_cmds(oldlimits, limits);
+ else if (strcmp(name, "fields") == 0)
+ error = pwd_allowed_fields(oldlimits, limits);
+ else if (strcmp(name, "users") == 0)
+ error = pwd_allowed_users(oldlimits, limits);
+ else
+ error = EINVAL;
+ if (error != 0)
+ return (error);
+ }
+
+ return (0);
+}
+
+static int
+pwd_command(const char *cmd, const nvlist_t *limits, nvlist_t *nvlin,
+ nvlist_t *nvlout)
+{
+ int error;
+
+ if (!pwd_allowed_cmd(limits, cmd))
+ return (ENOTCAPABLE);
+
+ if (strcmp(cmd, "getpwent") == 0 || strcmp(cmd, "getpwent_r") == 0)
+ error = pwd_getpwent(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "getpwnam") == 0 || strcmp(cmd, "getpwnam_r") == 0)
+ error = pwd_getpwnam(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "getpwuid") == 0 || strcmp(cmd, "getpwuid_r") == 0)
+ error = pwd_getpwuid(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "setpassent") == 0)
+ error = pwd_setpassent(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "setpwent") == 0)
+ error = pwd_setpwent(limits, nvlin, nvlout);
+ else if (strcmp(cmd, "endpwent") == 0)
+ error = pwd_endpwent(limits, nvlin, nvlout);
+ else
+ error = EINVAL;
+
+ return (error);
+}
+
+int
+main(int argc, char *argv[])
+{
+
+ return (service_start("system.pwd", PARENT_FILENO, pwd_limit,
+ pwd_command, argc, argv));
+}
diff --git a/libexec/casper/random/Makefile b/libexec/casper/random/Makefile
new file mode 100644
index 000000000000..46c97393335b
--- /dev/null
+++ b/libexec/casper/random/Makefile
@@ -0,0 +1,22 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR} ${.CURDIR}/../../../sbin/casper
+
+PROG= random
+
+SRCS= random.c
+
+DPADD= ${LIBCAPSICUM} ${LIBCASPER} ${LIBNV} ${LIBPJDLOG} ${LIBUTIL}
+LDADD= -lcapsicum -lcasper -lnv -lpjdlog -lutil
+
+BINDIR= /libexec/casper
+
+CFLAGS+=-I${.CURDIR}
+CFLAGS+=-I${.CURDIR}/../../../lib/libcapsicum
+CFLAGS+=-I${.CURDIR}/../../../lib/libcasper
+CFLAGS+=-I${.CURDIR}/../../../lib/libpjdlog
+CFLAGS+=-I${.CURDIR}/../../../sbin/casper
+
+MAN=
+
+.include <bsd.prog.mk>
diff --git a/libexec/casper/random/random.c b/libexec/casper/random/random.c
new file mode 100644
index 000000000000..56f1afbf0354
--- /dev/null
+++ b/libexec/casper/random/random.c
@@ -0,0 +1,81 @@
+/*-
+ * Copyright (c) 2012-2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 AUTHORS OR CONTRIBUTORS 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <libcapsicum.h>
+#include <libcasper.h>
+#include <nv.h>
+#include <pjdlog.h>
+
+#define MAXSIZE (1024 * 1024)
+
+static int
+random_command(const char *cmd, const nvlist_t *limits, nvlist_t *nvlin,
+ nvlist_t *nvlout)
+{
+ void *data;
+ size_t size;
+
+ if (strcmp(cmd, "generate") != 0)
+ return (EINVAL);
+ if (!nvlist_exists_number(nvlin, "size"))
+ return (EINVAL);
+
+ size = (size_t)nvlist_get_number(nvlin, "size");
+ if (size == 0 || size > MAXSIZE)
+ return (EINVAL);
+
+ data = malloc(size);
+ if (data == NULL)
+ return (ENOMEM);
+
+ arc4random_buf(data, size);
+
+ nvlist_move_binary(nvlout, "data", data, size);
+
+ return (0);
+}
+
+int
+main(int argc, char *argv[])
+{
+
+ /*
+ * TODO: Sandbox this.
+ */
+
+ return (service_start("system.random", PARENT_FILENO, NULL,
+ random_command, argc, argv));
+}
diff --git a/libexec/casper/sysctl/Makefile b/libexec/casper/sysctl/Makefile
new file mode 100644
index 000000000000..432008e01e75
--- /dev/null
+++ b/libexec/casper/sysctl/Makefile
@@ -0,0 +1,22 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR} ${.CURDIR}/../../../sbin/casper
+
+PROG= sysctl
+
+SRCS= sysctl.c
+
+DPADD= ${LIBCAPSICUM} ${LIBCASPER} ${LIBNV} ${LIBPJDLOG} ${LIBUTIL}
+LDADD= -lcapsicum -lcasper -lnv -lpjdlog -lutil
+
+BINDIR= /libexec/casper
+
+CFLAGS+=-I${.CURDIR}
+CFLAGS+=-I${.CURDIR}/../../../lib/libcapsicum
+CFLAGS+=-I${.CURDIR}/../../../lib/libcasper
+CFLAGS+=-I${.CURDIR}/../../../lib/libpjdlog
+CFLAGS+=-I${.CURDIR}/../../../sbin/casper
+
+MAN=
+
+.include <bsd.prog.mk>
diff --git a/libexec/casper/sysctl/sysctl.c b/libexec/casper/sysctl/sysctl.c
new file mode 100644
index 000000000000..8bb43b6b8bd1
--- /dev/null
+++ b/libexec/casper/sysctl/sysctl.c
@@ -0,0 +1,249 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 AUTHORS OR CONTRIBUTORS 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <libcapsicum.h>
+#include <libcapsicum_sysctl.h>
+#include <libcasper.h>
+#include <nv.h>
+#include <pjdlog.h>
+
+static int
+sysctl_check_one(const nvlist_t *nvl, bool islimit)
+{
+ const char *name;
+ void *cookie;
+ int type;
+ unsigned int fields;
+
+ /* NULL nvl is of course invalid. */
+ if (nvl == NULL)
+ return (EINVAL);
+ if (nvlist_error(nvl) != 0)
+ return (nvlist_error(nvl));
+
+#define HAS_NAME 0x01
+#define HAS_OPERATION 0x02
+
+ fields = 0;
+ cookie = NULL;
+ while ((name = nvlist_next(nvl, &type, &cookie)) != NULL) {
+ /* We accept only one 'name' and one 'operation' in nvl. */
+ if (strcmp(name, "name") == 0) {
+ if (type != NV_TYPE_STRING)
+ return (EINVAL);
+ /* Only one 'name' can be present. */
+ if ((fields & HAS_NAME) != 0)
+ return (EINVAL);
+ fields |= HAS_NAME;
+ } else if (strcmp(name, "operation") == 0) {
+ uint64_t operation;
+
+ if (type != NV_TYPE_NUMBER)
+ return (EINVAL);
+ /*
+ * We accept only CAP_SYSCTL_READ and
+ * CAP_SYSCTL_WRITE flags.
+ */
+ operation = nvlist_get_number(nvl, name);
+ if ((operation & ~(CAP_SYSCTL_RDWR)) != 0)
+ return (EINVAL);
+ /* ...but there has to be at least one of them. */
+ if ((operation & (CAP_SYSCTL_RDWR)) == 0)
+ return (EINVAL);
+ /* Only one 'operation' can be present. */
+ if ((fields & HAS_OPERATION) != 0)
+ return (EINVAL);
+ fields |= HAS_OPERATION;
+ } else if (islimit) {
+ /* If this is limit, there can be no other fields. */
+ return (EINVAL);
+ }
+ }
+
+ /* Both fields has to be there. */
+ if (fields != (HAS_NAME | HAS_OPERATION))
+ return (EINVAL);
+
+#undef HAS_OPERATION
+#undef HAS_NAME
+
+ return (0);
+}
+
+static bool
+sysctl_allowed(const nvlist_t *limits, const char *chname, uint64_t choperation)
+{
+ uint64_t operation;
+ const char *name;
+ void *cookie;
+ int type;
+
+ if (limits == NULL)
+ return (true);
+
+ cookie = NULL;
+ while ((name = nvlist_next(limits, &type, &cookie)) != NULL) {
+ PJDLOG_ASSERT(type == NV_TYPE_NUMBER);
+
+ operation = nvlist_get_number(limits, name);
+ if ((operation & choperation) != choperation)
+ continue;
+
+ if ((operation & CAP_SYSCTL_RECURSIVE) == 0) {
+ if (strcmp(name, chname) != 0)
+ continue;
+ } else {
+ size_t namelen;
+
+ namelen = strlen(name);
+ if (strncmp(name, chname, namelen) != 0)
+ continue;
+ if (chname[namelen] != '.' && chname[namelen] != '\0')
+ continue;
+ }
+
+ return (true);
+ }
+
+ return (false);
+}
+
+static int
+sysctl_limit(const nvlist_t *oldlimits, const nvlist_t *newlimits)
+{
+ const nvlist_t *nvl;
+ const char *name;
+ void *cookie;
+ uint64_t operation;
+ int error, type;
+
+ cookie = NULL;
+ while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) {
+ if (type != NV_TYPE_NUMBER)
+ return (EINVAL);
+ operation = nvlist_get_number(newlimits, name);
+ if ((operation & ~(CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE)) != 0)
+ return (EINVAL);
+ if ((operation & (CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE)) == 0)
+ return (EINVAL);
+ if (!sysctl_allowed(oldlimits, name, operation))
+ return (ENOTCAPABLE);
+ }
+
+ return (0);
+}
+
+static int
+sysctl_command(const char *cmd, const nvlist_t *limits, nvlist_t *nvlin,
+ nvlist_t *nvlout)
+{
+ const char *name;
+ const void *newp;
+ void *oldp;
+ uint64_t operation;
+ size_t oldlen, newlen;
+ size_t *oldlenp;
+ int error;
+
+ if (strcmp(cmd, "sysctl") != 0)
+ return (EINVAL);
+ error = sysctl_check_one(nvlin, false);
+ if (error != 0)
+ return (error);
+
+ name = nvlist_get_string(nvlin, "name");
+ operation = nvlist_get_number(nvlin, "operation");
+ if (!sysctl_allowed(limits, name, operation))
+ return (ENOTCAPABLE);
+
+ if ((operation & CAP_SYSCTL_WRITE) != 0) {
+ if (!nvlist_exists_binary(nvlin, "newp"))
+ return (EINVAL);
+ newp = nvlist_get_binary(nvlin, "newp", &newlen);
+ PJDLOG_ASSERT(newp != NULL && newlen > 0);
+ } else {
+ newp = NULL;
+ newlen = 0;
+ }
+
+ if ((operation & CAP_SYSCTL_READ) != 0) {
+ if (nvlist_exists_null(nvlin, "justsize")) {
+ oldp = NULL;
+ oldlen = 0;
+ oldlenp = &oldlen;
+ } else {
+ if (!nvlist_exists_number(nvlin, "oldlen"))
+ return (EINVAL);
+ oldlen = (size_t)nvlist_get_number(nvlin, "oldlen");
+ if (oldlen == 0)
+ return (EINVAL);
+ oldp = calloc(1, oldlen);
+ if (oldp == NULL)
+ return (ENOMEM);
+ oldlenp = &oldlen;
+ }
+ } else {
+ oldp = NULL;
+ oldlen = 0;
+ oldlenp = NULL;
+ }
+
+ if (sysctlbyname(name, oldp, oldlenp, newp, newlen) == -1) {
+ error = errno;
+ free(oldp);
+ return (error);
+ }
+
+ if ((operation & CAP_SYSCTL_READ) != 0) {
+ if (nvlist_exists_null(nvlin, "justsize"))
+ nvlist_add_number(nvlout, "oldlen", (uint64_t)oldlen);
+ else
+ nvlist_move_binary(nvlout, "oldp", oldp, oldlen);
+ }
+
+ return (0);
+}
+
+int
+main(int argc, char *argv[])
+{
+
+ return (service_start("system.sysctl", PARENT_FILENO, sysctl_limit,
+ sysctl_command, argc, argv));
+}
diff --git a/libexec/comsat/comsat.8 b/libexec/comsat/comsat.8
index 55976025b6ad..5a58ad0ca9c0 100644
--- a/libexec/comsat/comsat.8
+++ b/libexec/comsat/comsat.8
@@ -9,11 +9,7 @@
.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
diff --git a/libexec/comsat/comsat.c b/libexec/comsat/comsat.c
index d15c2a4c57ff..4420f00f7a12 100644
--- a/libexec/comsat/comsat.c
+++ b/libexec/comsat/comsat.c
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/dma-mbox-create/Makefile b/libexec/dma-mbox-create/Makefile
new file mode 100644
index 000000000000..f0a2341a916a
--- /dev/null
+++ b/libexec/dma-mbox-create/Makefile
@@ -0,0 +1,18 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../contrib/dma
+
+CFLAGS= -I${.CURDIR}/../../contrib/dma \
+ -DHAVE_REALLOCF -DHAVE_STRLCPY -DHAVE_GETPROGNAME \
+ -DCONF_PATH='"/etc/dma"' \
+ -DLIBEXEC_PATH='"/usr/libexec"' -DDMA_VERSION='"v0.9+"'
+
+MAN=
+
+WARNS= 2
+
+PROG= dma-mbox-create
+BINGRP= mail
+BINMODE= 4554
+
+.include <bsd.prog.mk>
diff --git a/libexec/dma/Makefile b/libexec/dma/Makefile
new file mode 100644
index 000000000000..757faf4a3c34
--- /dev/null
+++ b/libexec/dma/Makefile
@@ -0,0 +1,40 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../contrib/dma
+
+CFLAGS= -I${.CURDIR}/../../contrib/dma \
+ -DHAVE_REALLOCF -DHAVE_STRLCPY -DHAVE_GETPROGNAME \
+ -DCONF_PATH='"/etc/dma"' \
+ -DLIBEXEC_PATH='"/usr/libexec"' -DDMA_VERSION='"v0.9+"' \
+ -DDMA_ROOT_USER='"mailnull"' \
+ -DDMA_GROUP='"mail"'
+DPADD= ${LIBSSL} ${LIBCRYPTO}
+LDADD= -lssl -lcrypto
+
+PROG= dma
+SRCS= aliases_parse.y \
+ aliases_scan.l \
+ base64.c \
+ conf.c \
+ crypto.c \
+ dma.c \
+ dns.c \
+ local.c \
+ mail.c \
+ net.c \
+ spool.c \
+ util.c
+MAN8= dma.8
+YFLAGS+= -i
+CLEANFILES= aliases_parse.i
+
+BINGRP= mail
+BINMODE= 2555
+
+.include <bsd.compiler.mk>
+
+.if ${COMPILER_TYPE} == gcc
+WARNS= 5
+.endif
+
+.include <bsd.prog.mk>
diff --git a/libexec/fingerd/fingerd.8 b/libexec/fingerd/fingerd.8
index e28164c4e785..304479f1caac 100644
--- a/libexec/fingerd/fingerd.8
+++ b/libexec/fingerd/fingerd.8
@@ -9,11 +9,7 @@
.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
diff --git a/libexec/fingerd/fingerd.c b/libexec/fingerd/fingerd.c
index 0225d94ae8ea..be344d4693b7 100644
--- a/libexec/fingerd/fingerd.c
+++ b/libexec/fingerd/fingerd.c
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/fingerd/pathnames.h b/libexec/fingerd/pathnames.h
index 864a8f6c20d4..0a9154112eca 100644
--- a/libexec/fingerd/pathnames.h
+++ b/libexec/fingerd/pathnames.h
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -31,6 +27,8 @@
* SUCH DAMAGE.
*
* @(#)pathnames.h 8.1 (Berkeley) 6/4/93
+ *
+ * $FreeBSD$
*/
#define _PATH_FINGER "/usr/bin/finger"
diff --git a/libexec/ftpd/extern.h b/libexec/ftpd/extern.h
index 895f8ae2c75c..4f16f7b7d5d4 100644
--- a/libexec/ftpd/extern.h
+++ b/libexec/ftpd/extern.h
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/ftpd/ftpcmd.y b/libexec/ftpd/ftpcmd.y
index f3718eaa167d..94475ece0d15 100644
--- a/libexec/ftpd/ftpcmd.y
+++ b/libexec/ftpd/ftpcmd.y
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/ftpd/ftpd.8 b/libexec/ftpd/ftpd.8
index f7dbc88af48e..50565e9cd5e1 100644
--- a/libexec/ftpd/ftpd.8
+++ b/libexec/ftpd/ftpd.8
@@ -9,11 +9,7 @@
.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index 00570d6e56c1..b3c78f677a46 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -965,6 +961,7 @@ sgetpwnam(char *name)
if (save.pw_name) {
free(save.pw_name);
free(save.pw_passwd);
+ free(save.pw_class);
free(save.pw_gecos);
free(save.pw_dir);
free(save.pw_shell);
@@ -972,6 +969,7 @@ sgetpwnam(char *name)
save = *p;
save.pw_name = sgetsave(p->pw_name);
save.pw_passwd = sgetsave(p->pw_passwd);
+ save.pw_class = sgetsave(p->pw_class);
save.pw_gecos = sgetsave(p->pw_gecos);
save.pw_dir = sgetsave(p->pw_dir);
save.pw_shell = sgetsave(p->pw_shell);
diff --git a/libexec/ftpd/logwtmp.c b/libexec/ftpd/logwtmp.c
index 711234f7d448..9beade307044 100644
--- a/libexec/ftpd/logwtmp.c
+++ b/libexec/ftpd/logwtmp.c
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/ftpd/pathnames.h b/libexec/ftpd/pathnames.h
index a8837a90c446..208303498654 100644
--- a/libexec/ftpd/pathnames.h
+++ b/libexec/ftpd/pathnames.h
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/ftpd/popen.c b/libexec/ftpd/popen.c
index 9f80507a839f..03b8f7ab5f18 100644
--- a/libexec/ftpd/popen.c
+++ b/libexec/ftpd/popen.c
@@ -13,11 +13,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/getty/extern.h b/libexec/getty/extern.h
index 04f3287c9bb9..c7b73a87236e 100644
--- a/libexec/getty/extern.h
+++ b/libexec/getty/extern.h
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/getty/getty.8 b/libexec/getty/getty.8
index 4ab5501b3f9a..0f3bca745bbb 100644
--- a/libexec/getty/getty.8
+++ b/libexec/getty/getty.8
@@ -9,11 +9,7 @@
.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
diff --git a/libexec/getty/gettytab.5 b/libexec/getty/gettytab.5
index 8c6d90727d1e..16cd15ac68bf 100644
--- a/libexec/getty/gettytab.5
+++ b/libexec/getty/gettytab.5
@@ -9,11 +9,7 @@
.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
diff --git a/libexec/getty/gettytab.h b/libexec/getty/gettytab.h
index e8b4143af645..67ad95fa1768 100644
--- a/libexec/getty/gettytab.h
+++ b/libexec/getty/gettytab.h
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/getty/init.c b/libexec/getty/init.c
index 81384d94b835..6959e8d56235 100644
--- a/libexec/getty/init.c
+++ b/libexec/getty/init.c
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/getty/main.c b/libexec/getty/main.c
index d61802575df3..c9d2093602a5 100644
--- a/libexec/getty/main.c
+++ b/libexec/getty/main.c
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/getty/pathnames.h b/libexec/getty/pathnames.h
index 035e8b6c14b3..df59a2ca85cf 100644
--- a/libexec/getty/pathnames.h
+++ b/libexec/getty/pathnames.h
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/getty/subr.c b/libexec/getty/subr.c
index 4938d7386dbf..26d2173aa144 100644
--- a/libexec/getty/subr.c
+++ b/libexec/getty/subr.c
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/getty/ttys.5 b/libexec/getty/ttys.5
index 18151c9855fe..d4c7f1d1a249 100644
--- a/libexec/getty/ttys.5
+++ b/libexec/getty/ttys.5
@@ -9,11 +9,7 @@
.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
@@ -32,7 +28,7 @@
.\" from: @(#)ttys.5 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\" "
-.Dd May 27, 2005
+.Dd March 9, 2014
.Dt TTYS 5
.Os
.Sh NAME
@@ -43,6 +39,9 @@ The file
.Nm
contains information that is used by various routines to initialize
and control the use of terminal special files.
+Pseudo-terminals (see
+.Xr pts 4 )
+are not listed.
This information is read with the
.Xr getttyent 3
library routines.
@@ -102,13 +101,15 @@ ttys as a group.
.Pp
As flag values, the strings ``on'' and ``off'' specify that
.Xr init 8
-should (should not) execute the command given in the second field,
-while ``secure'' (if ``on'' is also specified) allows users with a
+should (should not) execute the command given in the second field.
+``onifconsole'' will cause this line to be enabled if and only if it is
+an active kernel console device (it is equivalent to ``on'' in this
+case).
+The flag ``secure'' (if the console is enabled) allows users with a
uid of 0 to login on
this line.
The flag ``dialin'' indicates that a tty entry describes a dialin
-line, and ``network'' indicates that a tty entry provides a
-network connection.
+line, and ``network'' is obsolete and does nothing.
Either of these strings may also be specified in the terminal type
field.
The string ``window='' may be followed by a quoted command
@@ -151,9 +152,6 @@ ttyh0 "/usr/libexec/getty std.9600" hp2621-nl on group=dialup # 457 Evans
ttyh1 "/usr/libexec/getty std.9600" vt100 on group=dialup # 459 Evans
# terminal emulate/window system
ttyv0 "/usr/local/bin/xterm -display :0" xterm on window="/usr/local/bin/X :0"
-# Network pseudo ttys -- don't enable getty
-ttyp0 none network group=pty
-ttyp1 none network off group=pty
.Ed
.Sh SEE ALSO
.Xr login 1 ,
diff --git a/libexec/lukemftpd/Makefile b/libexec/lukemftpd/Makefile
deleted file mode 100644
index 8ef420d9fcb4..000000000000
--- a/libexec/lukemftpd/Makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-# @(#)Makefile 8.2 (Berkeley) 4/4/94
-# $FreeBSD$
-
-.include <bsd.own.mk>
-
-LUKEMFTPD= ${.CURDIR}/../../contrib/lukemftpd
-.PATH: ${LUKEMFTPD}/src ${LUKEMFTPD}/libnetbsd
-
-PROG= lukemftpd
-MAN= lukemftpd.8 ftpd.conf.5 ftpusers.5
-MLINKS= ftpusers.5 ftpchroot.5
-SRCS= cmds.c conf.c ftpd.c ftpcmd.y popen.c
-SRCS+= strsuftoll.c
-
-WFORMAT= 0
-
-.if ${MK_INET6_SUPPORT} != "no"
-CFLAGS+= -DINET6
-.endif
-
-CFLAGS+= -include nbsd2fbsd.h
-CFLAGS+= -I${.CURDIR} -I${LUKEMFTPD} -I${LUKEMFTPD}/src
-CFLAGS+= -I${.CURDIR}/../../lib/libc/stdtime
-YFLAGS=
-
-LDADD= -lcrypt -lutil
-DPADD= ${LIBCRYPT} ${LIBUTIL}
-
-LSDIR= ../../bin/ls
-.PATH: ${.CURDIR}/${LSDIR}
-SRCS+= ls-unmain.c cmp.c print.c util.c
-CFLAGS+=-I${.CURDIR}/${LSDIR}
-DPADD+= ${LIBM}
-LDADD+= -lm
-
-CFLAGS+= -DUSE_OPIE -DLOGIN_CAP
-DPADD+= ${LIBOPIE} ${LIBMD}
-LDADD+= -lopie -lmd
-
-.if ${MK_PAM_SUPPORT} != "no"
-CFLAGS+= -DUSE_PAM
-DPADD+= ${LIBPAM}
-LDADD+= ${MINUSLPAM}
-.endif
-
-CLEANFILES+= ls-unmain.c
-ls-unmain.c: ls.c
- sed -e 's/^main(/ls_main(/g' -e 's,extern.h,${LSDIR}/extern.h,' \
- ${.ALLSRC} > ${.TARGET}
-
-ftpd.o ftpcmd.o: version.h
-
-lukemftpd.8: ftpd.8
- ln -sf ${.ALLSRC} ${.TARGET}
-
-CLEANFILES+= lukemftpd.8
-
-.include <bsd.prog.mk>
-
-${OBJS}: ${.CURDIR}/nbsd2fbsd.h
diff --git a/libexec/lukemftpd/config.h b/libexec/lukemftpd/config.h
deleted file mode 100644
index 0d4566a924c0..000000000000
--- a/libexec/lukemftpd/config.h
+++ /dev/null
@@ -1,303 +0,0 @@
-/* $FreeBSD$ */
-
-
-/* config.h. Generated automatically by configure. */
-/* config.h.in. Generated automatically from configure.in by autoheader. */
-/* $Id: config.h.in,v 1.6 2004/08/10 00:40:22 lukem Exp $ */
-
-
-/* Define if the closedir function returns void instead of int. */
-/* #undef CLOSEDIR_VOID */
-
-/* Define to empty if the keyword does not work. */
-/* #undef const */
-
-/* Define if your C compiler doesn't accept -c and -o together. */
-/* #undef NO_MINUS_C_MINUS_O */
-
-/* Define if your Fortran 77 compiler doesn't accept -c and -o together. */
-/* #undef F77_NO_MINUS_C_MINUS_O */
-
-/* Define to `long' if <sys/types.h> doesn't define. */
-/* #undef off_t */
-
-/* Define to the type of arg1 for select(). */
-/* #undef SELECT_TYPE_ARG1 */
-
-/* Define to the type of args 2, 3 and 4 for select(). */
-/* #undef SELECT_TYPE_ARG234 */
-
-/* Define to the type of arg5 for select(). */
-/* #undef SELECT_TYPE_ARG5 */
-
-/* Define if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define if you can safely include both <sys/time.h> and <time.h>. */
-#define TIME_WITH_SYS_TIME 1
-
-/* Define if the closedir function returns void instead of int. */
-/* #undef VOID_CLOSEDIR */
-
-/* The number of bytes in a off_t. */
-#define SIZEOF_OFF_T 0
-
-/* Define if you have the err function. */
-#define HAVE_ERR 1
-
-/* Define if you have the fgetln function. */
-#define HAVE_FGETLN 1
-
-/* Define if you have the flock function. */
-#define HAVE_FLOCK 1
-
-/* Define if you have the fparseln function. */
-#define HAVE_FPARSELN 1
-
-/* Define if you have the fts_open function. */
-#define HAVE_FTS_OPEN 1
-
-/* Define if you have the getaddrinfo function. */
-#define HAVE_GETADDRINFO 1
-
-/* Define if you have the getgrouplist function. */
-#define HAVE_GETGROUPLIST 1
-
-/* Define if you have the getnameinfo function. */
-#define HAVE_GETNAMEINFO 1
-
-/* Define if you have the getspnam function. */
-/* #undef HAVE_GETSPNAM */
-
-/* Define if you have the getusershell function. */
-#define HAVE_GETUSERSHELL 1
-
-/* Define if you have the inet_net_pton function. */
-#define HAVE_INET_NET_PTON 1
-
-/* Define if you have the inet_ntop function. */
-#define HAVE_INET_NTOP 1
-
-/* Define if you have the inet_pton function. */
-#define HAVE_INET_PTON 1
-
-/* Define if you have the lockf function. */
-#define HAVE_LOCKF 1
-
-/* Define if you have the mkstemp function. */
-#define HAVE_MKSTEMP 1
-
-/* Define if you have the setegid function. */
-#define HAVE_SETEGID 1
-
-/* Define if you have the seteuid function. */
-#define HAVE_SETEUID 1
-
-/* Define if you have the setlogin function. */
-#define HAVE_SETLOGIN 1
-
-/* Define if you have the setproctitle function. */
-#define HAVE_SETPROCTITLE 1
-
-/* Define if you have the setresgid function. */
-#define HAVE_SETRESGID 1
-
-/* Define if you have the setresuid function. */
-#define HAVE_SETRESUID 1
-
-/* Define if you have the sl_init function. */
-#define HAVE_SL_INIT 1
-
-/* Define if you have the snprintf function. */
-#define HAVE_SNPRINTF 1
-
-/* Define if you have the strdup function. */
-#define HAVE_STRDUP 1
-
-/* Define if you have the strerror function. */
-#define HAVE_STRERROR 1
-
-/* Define if you have the strlcat function. */
-#define HAVE_STRLCAT 1
-
-/* Define if you have the strlcpy function. */
-#define HAVE_STRLCPY 1
-
-/* Define if you have the strmode function. */
-#define HAVE_STRMODE 1
-
-/* Define if you have the strsep function. */
-#define HAVE_STRSEP 1
-
-/* Define if you have the strsuftollx function. */
-/* #undef HAVE_STRSUFTOLLX */
-
-/* Define if you have the strtoll function. */
-#define HAVE_STRTOLL 1
-
-/* Define if you have the user_from_uid function. */
-#define HAVE_USER_FROM_UID 1
-
-/* Define if you have the usleep function. */
-#define HAVE_USLEEP 1
-
-/* Define if you have the vfork function. */
-#define HAVE_VFORK 1
-
-/* Define if you have the vsyslog function. */
-#define HAVE_VSYSLOG 1
-
-/* Define if you have the <arpa/nameser.h> header file. */
-#define HAVE_ARPA_NAMESER_H 1
-
-/* Define if you have the <dirent.h> header file. */
-#define HAVE_DIRENT_H 1
-
-/* Define if you have the <err.h> header file. */
-#define HAVE_ERR_H 1
-
-/* Define if you have the <fts.h> header file. */
-#define HAVE_FTS_H 1
-
-/* Define if you have the <libutil.h> header file. */
-#define HAVE_LIBUTIL_H 1
-
-/* Define if you have the <ndir.h> header file. */
-/* #undef HAVE_NDIR_H */
-
-/* Define if you have the <paths.h> header file. */
-#define HAVE_PATHS_H 1
-
-/* Define if you have the <sys/dir.h> header file. */
-#define HAVE_SYS_DIR_H 1
-
-/* Define if you have the <sys/ndir.h> header file. */
-/* #undef HAVE_SYS_NDIR_H */
-
-/* Define if you have the <sys/sysmacros.h> header file. */
-/* #undef HAVE_SYS_SYSMACROS_H */
-
-/* Define if you have the <util.h> header file. */
-/* #undef HAVE_UTIL_H */
-
-/* Define if you have the crypt library (-lcrypt). */
-#define HAVE_LIBCRYPT 1
-
-/* Define if you have the nsl library (-lnsl). */
-/* #undef HAVE_LIBNSL */
-
-/* Define if you have the skey library (-lskey). */
-/* #undef HAVE_LIBSKEY */
-
-/* Define if you have the socket library (-lsocket). */
-/* #undef HAVE_LIBSOCKET */
-
-/* Define if you have the util library (-lutil). */
-#define HAVE_LIBUTIL 1
-
-/* Define if your compiler supports `long long' */
-#define HAVE_LONG_LONG 1
-
-/* Define if *printf() uses %qd to print `long long' (otherwise uses %lld) */
-#define HAVE_PRINTF_QD 1
-
-/* Define if in_port_t exists */
-#define HAVE_IN_PORT_T 1
-
-/* Define if struct sockaddr.sa_len exists (implies sockaddr_in.sin_len, etc) */
-#define HAVE_SOCKADDR_SA_LEN 1
-
-/* Define if socklen_t exists */
-#define HAVE_SOCKLEN_T 1
-
-/* Define if AF_INET6 exists in <sys/socket.h> */
-#define HAVE_AF_INET6 1
-
-/* Define if `struct sockaddr_in6' exists in <netinet/in.h> */
-#define HAVE_SOCKADDR_IN6 1
-
-/* Define if `struct addrinfo' exists in <netdb.h> */
-#define HAVE_ADDRINFO 1
-
-/*
- * Define if <netdb.h> contains AI_NUMERICHOST et al.
- * Systems which only implement RFC2133 will need this.
- */
-#define HAVE_RFC2553_NETDB 1
-
-/* Define if `struct direct' has a d_namlen element */
-#define HAVE_D_NAMLEN 1
-
-/* Define if struct passwd.pw_expire exists. */
-#define HAVE_PW_EXPIRE 1
-
-/* Define if GLOB_BRACE, gl_path and gl_match exist in <glob.h> */
-#define HAVE_WORKING_GLOB 1
-
-/* Define if crypt() is declared in <unistd.h> */
-#define HAVE_CRYPT_D 1
-
-/* Define if fclose() is declared in <stdio.h> */
-#define HAVE_FCLOSE_D 1
-
-/* Define if FNM_CASEFOLD is declared in <fnmatch.h> */
-#define HAVE_FNM_CASEFOLD 1
-
-/* Define if optarg is declared in <stdlib.h> or <unistd.h> */
-#define HAVE_OPTARG_D 1
-
-/* Define if optind is declared in <stdlib.h> or <unistd.h> */
-#define HAVE_OPTIND_D 1
-
-/* Define if optreset exists */
-#define HAVE_OPTRESET 1
-
-/* Define if pclose() is declared in <stdio.h> */
-#define HAVE_PCLOSE_D 1
-
-/* Define if getusershell() is declared in <unistd.h> */
-#define HAVE_GETUSERSHELL_D 1
-
-/* Define if `long long' is supported and sizeof(off_t) >= 8 */
-/* #undef HAVE_WORKING_LONG_LONG */
-#define HAVE_QUAD_SUPPORT 1
-
-/* Define if not using in-built /bin/ls code */
-/* #undef NO_INTERNAL_LS */
-
-#include <sys/param.h>
-#if __FreeBSD_version <= 500020
-/* Define if using S/Key */
-#define SKEY 1
-#endif
-
-/*
- * Define this if compiling with SOCKS (the firewall traversal library).
- * Also, you must define connect, getsockname, bind, accept, listen, and
- * select to their R-versions.
- */
-/* #undef SOCKS */
-/* #undef SOCKS4 */
-/* #undef SOCKS5 */
-/* #undef connect */
-/* #undef getsockname */
-/* #undef bind */
-/* #undef accept */
-/* #undef listen */
-/* #undef select */
-/* #undef dup */
-/* #undef dup2 */
-/* #undef fclose */
-/* #undef gethostbyname */
-/* #undef getpeername */
-/* #undef read */
-/* #undef recv */
-/* #undef recvfrom */
-/* #undef rresvport */
-/* #undef send */
-/* #undef sendto */
-/* #undef shutdown */
-/* #undef write */
-
-/* Define if you have the <arpa/ftp.h> header file. */
-#define HAVE_FTP_NAMES 1
diff --git a/libexec/lukemftpd/nbsd2fbsd.h b/libexec/lukemftpd/nbsd2fbsd.h
deleted file mode 100644
index ac09bdfda57c..000000000000
--- a/libexec/lukemftpd/nbsd2fbsd.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* $FreeBSD$ */
-
-/* XXX: Depend on our system headers protecting against multiple includes. */
-#include <paths.h>
-#undef _PATH_FTPUSERS
-
-#include <pwd.h>
-
-#define _DIAGASSERT(x)
-
-#include <sys/_types.h>
-#ifndef _SIZE_T_DECLARED
-typedef __size_t size_t;
-#define _SIZE_T_DECLARED
-#endif
-long long strsuftollx(const char *, const char *,
- long long, long long, char *, size_t);
-
-/*
- * IEEE Std 1003.1c-95, adopted in X/Open CAE Specification Issue 5 Version 2
- */
-#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500
-#define LOGIN_NAME_MAX MAXLOGNAME /* max login name length (incl. NUL) */
-#endif
-
-/* NetBSD pwd.h */
-#define _PASSWORD_CHGNOW -1 /* special day to force password
- * change at next login */
-
-/* Need this for some LOGIN_CAP functionality NetBSD has doesn't have
- the infastructure for. */
-#define notyet
-/* Need this for some USE_PAM functionality NetBSD has doesn't have
- the infastructure for. */
-#define notdef
diff --git a/libexec/lukemftpd/nbsd_pidfile.h b/libexec/lukemftpd/nbsd_pidfile.h
deleted file mode 100644
index 53487709afc9..000000000000
--- a/libexec/lukemftpd/nbsd_pidfile.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* $FreeBSD$ */
-
-#include <sys/stdint.h>
-#include <sysexits.h>
-
-static int
-pidfile(const char *basename)
-{
- struct pidfh *pfh;
- pid_t otherpid, childpid;
-
- if (basename != NULL) {
- errx(EX_USAGE, "Need to implement NetBSD semantics.");
- }
-
- pfh = pidfile_open(basename, 0644, &otherpid);
- if (pfh == NULL) {
- if (errno == EEXIST) {
- errx(EXIT_FAILURE, "Daemon already running, pid: %jd.",
- (intmax_t)otherpid);
- }
- /* If we cannot create pidfile from other reasons, only warn. */
- warn("Cannot open or create pidfile");
- return -1;
- }
-
- pidfile_write(pfh);
- pidfile_close(pfh);
- return 0;
-}
diff --git a/libexec/lukemftpd/util.h b/libexec/lukemftpd/util.h
deleted file mode 100644
index 91ce241953ea..000000000000
--- a/libexec/lukemftpd/util.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/* $FreeBSD$ */
-
-#include <libutil.h>
diff --git a/libexec/mknetid/parse_group.c b/libexec/mknetid/parse_group.c
index 75665dc4fe23..6244a8c6847e 100644
--- a/libexec/mknetid/parse_group.c
+++ b/libexec/mknetid/parse_group.c
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/rbootd/bpf.c b/libexec/rbootd/bpf.c
index ddd9cfbc2ae6..6291f1e31dd7 100644
--- a/libexec/rbootd/bpf.c
+++ b/libexec/rbootd/bpf.c
@@ -18,11 +18,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -237,19 +233,11 @@ BpfGetIntfName(char **errmsg)
ifc.ifc_len = sizeof ibuf;
ifc.ifc_buf = (caddr_t)ibuf;
-#ifdef OSIOCGIFCONF
- if (ioctl(fd, OSIOCGIFCONF, (char *)&ifc) < 0 ||
- ifc.ifc_len < sizeof(struct ifreq)) {
- (void) strcpy(errbuf, "bpf: ioctl(OSIOCGIFCONF): %m");
- return(NULL);
- }
-#else
if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0 ||
ifc.ifc_len < sizeof(struct ifreq)) {
(void) strcpy(errbuf, "bpf: ioctl(SIOCGIFCONF): %m");
return(NULL);
}
-#endif
ifrp = ibuf;
ifend = (struct ifreq *)((char *)ibuf + ifc.ifc_len);
diff --git a/libexec/rbootd/conf.c b/libexec/rbootd/conf.c
index 74ff341095f9..32b878274548 100644
--- a/libexec/rbootd/conf.c
+++ b/libexec/rbootd/conf.c
@@ -18,11 +18,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/rbootd/defs.h b/libexec/rbootd/defs.h
index ff640c1629b5..ebf82439cf76 100644
--- a/libexec/rbootd/defs.h
+++ b/libexec/rbootd/defs.h
@@ -18,11 +18,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/rbootd/parseconf.c b/libexec/rbootd/parseconf.c
index 7151dae9ef13..58b9ac5d6a4b 100644
--- a/libexec/rbootd/parseconf.c
+++ b/libexec/rbootd/parseconf.c
@@ -18,11 +18,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/rbootd/pathnames.h b/libexec/rbootd/pathnames.h
index 56b9deb39fc3..54f8c67bf3a3 100644
--- a/libexec/rbootd/pathnames.h
+++ b/libexec/rbootd/pathnames.h
@@ -18,11 +18,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -42,6 +38,8 @@
*
* From: Utah Hdr: pathnames.h 3.1 92/07/06
* Author: Jeff Forys, University of Utah CSS
+ *
+ * $FreeBSD$
*/
#define _PATH_BPF "/dev/bpf%d"
diff --git a/libexec/rbootd/rbootd.8 b/libexec/rbootd/rbootd.8
index 79c528dca923..6baf9f2491fa 100644
--- a/libexec/rbootd/rbootd.8
+++ b/libexec/rbootd/rbootd.8
@@ -17,11 +17,7 @@
.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
diff --git a/libexec/rbootd/rbootd.c b/libexec/rbootd/rbootd.c
index 1d35bd1e2eeb..de142f17fbec 100644
--- a/libexec/rbootd/rbootd.c
+++ b/libexec/rbootd/rbootd.c
@@ -18,11 +18,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/rbootd/rmp.h b/libexec/rbootd/rmp.h
index c4285c9b37cc..09b67eedce01 100644
--- a/libexec/rbootd/rmp.h
+++ b/libexec/rbootd/rmp.h
@@ -18,11 +18,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -42,6 +38,8 @@
*
* From: Utah Hdr: rmp.h 3.1 92/07/06
* Author: Jeff Forys, University of Utah CSS
+ *
+ * $FreeBSD$
*/
/*
diff --git a/libexec/rbootd/rmp_var.h b/libexec/rbootd/rmp_var.h
index 3a9c7f4e20c4..fdaacf7c7c51 100644
--- a/libexec/rbootd/rmp_var.h
+++ b/libexec/rbootd/rmp_var.h
@@ -18,11 +18,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -42,6 +38,8 @@
*
* from: Utah Hdr: rmp_var.h 3.1 92/07/06
* Author: Jeff Forys, University of Utah CSS
+ *
+ * $FreeBSD$
*/
/*
diff --git a/libexec/rbootd/rmpproto.c b/libexec/rbootd/rmpproto.c
index d37ef852415a..aa4be5647222 100644
--- a/libexec/rbootd/rmpproto.c
+++ b/libexec/rbootd/rmpproto.c
@@ -18,11 +18,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/rbootd/utils.c b/libexec/rbootd/utils.c
index d13f123df236..81ef584813bc 100644
--- a/libexec/rbootd/utils.c
+++ b/libexec/rbootd/utils.c
@@ -18,11 +18,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/revnetgroup/parse_netgroup.c b/libexec/revnetgroup/parse_netgroup.c
index a962e726d97d..b89148143894 100644
--- a/libexec/revnetgroup/parse_netgroup.c
+++ b/libexec/revnetgroup/parse_netgroup.c
@@ -13,11 +13,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/rlogind/rlogind.8 b/libexec/rlogind/rlogind.8
index d861da538394..209cec94b433 100644
--- a/libexec/rlogind/rlogind.8
+++ b/libexec/rlogind/rlogind.8
@@ -9,11 +9,7 @@
.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
diff --git a/libexec/rlogind/rlogind.c b/libexec/rlogind/rlogind.c
index be92f0f6baa9..d64d7bf93ec1 100644
--- a/libexec/rlogind/rlogind.c
+++ b/libexec/rlogind/rlogind.c
@@ -17,11 +17,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/rpc.rstatd/rpc.rstatd.8 b/libexec/rpc.rstatd/rpc.rstatd.8
index ebaa766efd88..87512ca3a703 100644
--- a/libexec/rpc.rstatd/rpc.rstatd.8
+++ b/libexec/rpc.rstatd/rpc.rstatd.8
@@ -11,11 +11,7 @@
.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
diff --git a/libexec/rpc.rstatd/rstatd.c b/libexec/rpc.rstatd/rstatd.c
index 362cdc486683..bb74eb806024 100644
--- a/libexec/rpc.rstatd/rstatd.c
+++ b/libexec/rpc.rstatd/rstatd.c
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/rpc.rusersd/extern.h b/libexec/rpc.rusersd/extern.h
index b1a8309bf85f..ac91526318ed 100644
--- a/libexec/rpc.rusersd/extern.h
+++ b/libexec/rpc.rusersd/extern.h
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/rpc.rusersd/rpc.rusersd.8 b/libexec/rpc.rusersd/rpc.rusersd.8
index 6efd47de9ede..f9f1a1de888a 100644
--- a/libexec/rpc.rusersd/rpc.rusersd.8
+++ b/libexec/rpc.rusersd/rpc.rusersd.8
@@ -11,11 +11,7 @@
.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
diff --git a/libexec/rpc.rusersd/rusers_proc.c b/libexec/rpc.rusersd/rusers_proc.c
index ff2ebc4c63ed..51e9a4dc0faf 100644
--- a/libexec/rpc.rusersd/rusers_proc.c
+++ b/libexec/rpc.rusersd/rusers_proc.c
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/rpc.rusersd/rusersd.c b/libexec/rpc.rusersd/rusersd.c
index 0ad468650a9f..2a1e7bdadb31 100644
--- a/libexec/rpc.rusersd/rusersd.c
+++ b/libexec/rpc.rusersd/rusersd.c
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/rpc.rwalld/rpc.rwalld.8 b/libexec/rpc.rwalld/rpc.rwalld.8
index d5e1472732a6..6b2d206ddadc 100644
--- a/libexec/rpc.rwalld/rpc.rwalld.8
+++ b/libexec/rpc.rwalld/rpc.rwalld.8
@@ -11,11 +11,7 @@
.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
diff --git a/libexec/rshd/rshd.8 b/libexec/rshd/rshd.8
index 27f39db078e1..6c6e57ce8e5d 100644
--- a/libexec/rshd/rshd.8
+++ b/libexec/rshd/rshd.8
@@ -9,11 +9,7 @@
.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
diff --git a/libexec/rshd/rshd.c b/libexec/rshd/rshd.c
index 82af6a46f5db..7cdacae74247 100644
--- a/libexec/rshd/rshd.c
+++ b/libexec/rshd/rshd.c
@@ -17,11 +17,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile
index 31cbfdd449d7..2a0953c96dfa 100644
--- a/libexec/rtld-elf/Makefile
+++ b/libexec/rtld-elf/Makefile
@@ -43,11 +43,12 @@ DPADD= ${LIBC_PIC}
LDADD= -lc_pic
.if ${MACHINE_CPUARCH} == "arm" && ${MK_ARM_EABI} != "no"
-# Some of the required math functions (div & mod) are implemented in libgcc
-# on ARM. The library also needs to be placed first to be correctly linked.
-# As some of the functions are used before we have shared libraries.
-DPADD+= ${LIBGCC}
-LDADD+= -lgcc
+# Some of the required math functions (div & mod) are implemented in
+# libcompiler_rt on ARM. The library also needs to be placed first to be
+# correctly linked. As some of the functions are used before we have
+# shared libraries.
+DPADD+= ${LIBCOMPILER_RT}
+LDADD+= -lcompiler_rt
.endif
diff --git a/libexec/rtld-elf/amd64/rtld_start.S b/libexec/rtld-elf/amd64/rtld_start.S
index da3d156e00f7..2481f09417dc 100644
--- a/libexec/rtld-elf/amd64/rtld_start.S
+++ b/libexec/rtld-elf/amd64/rtld_start.S
@@ -79,17 +79,39 @@
.globl _rtld_bind_start
.type _rtld_bind_start,@function
_rtld_bind_start:
+ .cfi_startproc
+ .cfi_adjust_cfa_offset 16
subq $8,%rsp
+ .cfi_adjust_cfa_offset 8
pushfq # Save rflags
+ .cfi_adjust_cfa_offset 8
pushq %rax # Save %rax
+ .cfi_adjust_cfa_offset 8
+ .cfi_offset %rax,-32
pushq %rdx # Save %rdx
+ .cfi_adjust_cfa_offset 8
+ .cfi_offset %rdx,-40
pushq %rcx # Save %rcx
+ .cfi_adjust_cfa_offset 8
+ .cfi_offset %rcx,-48
pushq %rsi # Save %rsi
+ .cfi_adjust_cfa_offset 8
+ .cfi_offset %rsi,-56
pushq %rdi # Save %rdi
+ .cfi_adjust_cfa_offset 8
+ .cfi_offset %rdi,-64
pushq %r8 # Save %r8
+ .cfi_adjust_cfa_offset 8
+ .cfi_offset %r8,-72
pushq %r9 # Save %r9
+ .cfi_adjust_cfa_offset 8
+ .cfi_offset %r9,-80
pushq %r10 # Save %r10
+ .cfi_adjust_cfa_offset 8
+ .cfi_offset %r10,-88
pushq %r11 # Save %r11
+ .cfi_adjust_cfa_offset 8
+ .cfi_offset %r11,-96
movq 0x58(%rsp),%rdi # Fetch obj argument
movq 0x60(%rsp),%rsi # Fetch reloff argument
@@ -101,16 +123,37 @@ _rtld_bind_start:
movq %rax,0x60(%rsp) # Store target over reloff argument
popq %r11 # Restore %r11
+ .cfi_adjust_cfa_offset -8
+ .cfi_restore %r11
popq %r10 # Restore %r10
+ .cfi_adjust_cfa_offset -8
+ .cfi_restore %r10
popq %r9 # Restore %r9
+ .cfi_adjust_cfa_offset -8
+ .cfi_restore %r9
popq %r8 # Restore %r8
+ .cfi_adjust_cfa_offset -8
+ .cfi_restore %r8
popq %rdi # Restore %rdi
+ .cfi_adjust_cfa_offset -8
+ .cfi_restore %rdi
popq %rsi # Restore %rsi
+ .cfi_adjust_cfa_offset -8
+ .cfi_restore %rsi
popq %rcx # Restore %rcx
+ .cfi_adjust_cfa_offset -8
+ .cfi_restore %rcx
popq %rdx # Restore %rdx
+ .cfi_adjust_cfa_offset -8
+ .cfi_restore %rdx
popq %rax # Restore %rax
+ .cfi_adjust_cfa_offset -8
+ .cfi_restore %rax
popfq # Restore rflags
+ .cfi_adjust_cfa_offset -8
leaq 16(%rsp),%rsp # Discard spare, obj, do not change rflags
ret # "Return" to target address
+ .cfi_endproc
+ .size _rtld_bind_start, . - _rtld_bind_start
.section .note.GNU-stack,"",%progbits
diff --git a/libexec/rtld-elf/malloc.c b/libexec/rtld-elf/malloc.c
index 901ffcb44200..9f7dbe0ec176 100644
--- a/libexec/rtld-elf/malloc.c
+++ b/libexec/rtld-elf/malloc.c
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -143,25 +139,14 @@ botch(s)
/* Debugging stuff */
#define TRACE() rtld_printf("TRACE %s:%d\n", __FILE__, __LINE__)
-extern int pagesize;
-
-static int
-rtld_getpagesize(void)
-{
- int mib[2];
- size_t size;
-
- if (pagesize != 0)
- return (pagesize);
-
- mib[0] = CTL_HW;
- mib[1] = HW_PAGESIZE;
- size = sizeof(pagesize);
- if (sysctl(mib, 2, &pagesize, &size, NULL, 0) == -1)
- return (-1);
- return (pagesize);
-
-}
+/*
+ * The array of supported page sizes is provided by the user, i.e., the
+ * program that calls this storage allocator. That program must initialize
+ * the array before making its first call to allocate storage. The array
+ * must contain at least one page size. The page sizes must be stored in
+ * increasing order.
+ */
+extern size_t *pagesizes;
void *
malloc(nbytes)
@@ -177,7 +162,7 @@ malloc(nbytes)
* align break pointer so all data will be page aligned.
*/
if (pagesz == 0) {
- pagesz = n = rtld_getpagesize();
+ pagesz = n = pagesizes[0];
if (morepages(NPOOLPAGES) == 0)
return NULL;
op = (union overhead *)(pagepool_start);
diff --git a/libexec/rtld-elf/map_object.c b/libexec/rtld-elf/map_object.c
index 0f75cca31cc1..2e17fbf06b78 100644
--- a/libexec/rtld-elf/map_object.c
+++ b/libexec/rtld-elf/map_object.c
@@ -68,6 +68,7 @@ map_object(int fd, const char *path, const struct stat *sb)
Elf_Addr base_vaddr;
Elf_Addr base_vlimit;
caddr_t base_addr;
+ int base_flags;
Elf_Off data_offset;
Elf_Addr data_vaddr;
Elf_Addr data_vlimit;
@@ -176,9 +177,11 @@ map_object(int fd, const char *path, const struct stat *sb)
base_vlimit = round_page(segs[nsegs]->p_vaddr + segs[nsegs]->p_memsz);
mapsize = base_vlimit - base_vaddr;
base_addr = (caddr_t) base_vaddr;
+ base_flags = MAP_PRIVATE | MAP_ANON | MAP_NOCORE;
+ if (npagesizes > 1 && round_page(segs[0]->p_filesz) >= pagesizes[1])
+ base_flags |= MAP_ALIGNED_SUPER;
- mapbase = mmap(base_addr, mapsize, PROT_NONE, MAP_ANON | MAP_PRIVATE |
- MAP_NOCORE, -1, 0);
+ mapbase = mmap(base_addr, mapsize, PROT_NONE, base_flags, -1, 0);
if (mapbase == (caddr_t) -1) {
_rtld_error("%s: mmap of entire address space failed: %s",
path, rtld_strerror(errno));
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index fa6dc2a0c2c9..f96b8e7189f7 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -97,6 +97,7 @@ static void *fill_search_info(const char *, size_t, void *);
static char *find_library(const char *, const Obj_Entry *);
static const char *gethints(bool);
static void init_dag(Obj_Entry *);
+static void init_pagesizes(Elf_Auxinfo **aux_info);
static void init_rtld(caddr_t, Elf_Auxinfo **);
static void initlist_add_neededs(Needed_Entry *, Objlist *);
static void initlist_add_objects(Obj_Entry *, Obj_Entry **, Objlist *);
@@ -205,7 +206,8 @@ extern Elf_Dyn _DYNAMIC;
#define RTLD_IS_DYNAMIC() (&_DYNAMIC != NULL)
#endif
-int osreldate, pagesize;
+int npagesizes, osreldate;
+size_t *pagesizes;
long __stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0};
@@ -231,6 +233,7 @@ char **main_argv;
size_t tls_last_offset; /* Static TLS offset of last module */
size_t tls_last_size; /* Static TLS size of last module */
size_t tls_static_space; /* Static TLS space allocated */
+size_t tls_static_max_align;
int tls_dtv_generation = 1; /* Used to detect when dtv size changes */
int tls_max_index = 1; /* Largest module index allocated */
@@ -1821,8 +1824,9 @@ init_rtld(caddr_t mapbase, Elf_Auxinfo **aux_info)
/* Now that non-local variables can be accesses, copy out obj_rtld. */
memcpy(&obj_rtld, &objtmp, sizeof(obj_rtld));
- if (aux_info[AT_PAGESZ] != NULL)
- pagesize = aux_info[AT_PAGESZ]->a_un.a_val;
+ /* The page size is required by the dynamic memory allocator. */
+ init_pagesizes(aux_info);
+
if (aux_info[AT_OSRELDATE] != NULL)
osreldate = aux_info[AT_OSRELDATE]->a_un.a_val;
@@ -1836,6 +1840,50 @@ init_rtld(caddr_t mapbase, Elf_Auxinfo **aux_info)
}
/*
+ * Retrieve the array of supported page sizes. The kernel provides the page
+ * sizes in increasing order.
+ */
+static void
+init_pagesizes(Elf_Auxinfo **aux_info)
+{
+ static size_t psa[MAXPAGESIZES];
+ int mib[2];
+ size_t len, size;
+
+ if (aux_info[AT_PAGESIZES] != NULL && aux_info[AT_PAGESIZESLEN] !=
+ NULL) {
+ size = aux_info[AT_PAGESIZESLEN]->a_un.a_val;
+ pagesizes = aux_info[AT_PAGESIZES]->a_un.a_ptr;
+ } else {
+ len = 2;
+ if (sysctlnametomib("hw.pagesizes", mib, &len) == 0)
+ size = sizeof(psa);
+ else {
+ /* As a fallback, retrieve the base page size. */
+ size = sizeof(psa[0]);
+ if (aux_info[AT_PAGESZ] != NULL) {
+ psa[0] = aux_info[AT_PAGESZ]->a_un.a_val;
+ goto psa_filled;
+ } else {
+ mib[0] = CTL_HW;
+ mib[1] = HW_PAGESIZE;
+ len = 2;
+ }
+ }
+ if (sysctl(mib, len, psa, &size, NULL, 0) == -1) {
+ _rtld_error("sysctl for hw.pagesize(s) failed");
+ die();
+ }
+psa_filled:
+ pagesizes = psa;
+ }
+ npagesizes = size / sizeof(pagesizes[0]);
+ /* Discard any invalid entries at the end of the array. */
+ while (npagesizes > 0 && pagesizes[npagesizes - 1] == 0)
+ npagesizes--;
+}
+
+/*
* Add the init functions from a needed object list (and its recursive
* needed objects) to "list". This is not used directly; it is a helper
* function for initlist_add_objects(). The write lock must be held
@@ -3269,6 +3317,11 @@ dl_iterate_phdr(__dl_iterate_hdr_callback callback, void *param)
break;
}
+ if (error == 0) {
+ rtld_fill_dl_phdr_info(&obj_rtld, &phdr_info);
+ error = callback(&phdr_info, sizeof(phdr_info), param);
+ }
+
lock_release(rtld_bind_lock, &bind_lockstate);
lock_release(rtld_phdr_lock, &phdr_lockstate);
@@ -4276,19 +4329,22 @@ void *
allocate_tls(Obj_Entry *objs, void *oldtls, size_t tcbsize, size_t tcbalign)
{
Obj_Entry *obj;
- size_t size;
+ size_t size, ralign;
char *tls;
Elf_Addr *dtv, *olddtv;
Elf_Addr segbase, oldsegbase, addr;
int i;
- size = round(tls_static_space, tcbalign);
+ ralign = tcbalign;
+ if (tls_static_max_align > ralign)
+ ralign = tls_static_max_align;
+ size = round(tls_static_space, ralign) + round(tcbsize, ralign);
assert(tcbsize >= 2*sizeof(Elf_Addr));
- tls = xcalloc(1, size + tcbsize);
+ tls = malloc_aligned(size, ralign);
dtv = xcalloc(tls_max_index + 2, sizeof(Elf_Addr));
- segbase = (Elf_Addr)(tls + size);
+ segbase = (Elf_Addr)(tls + round(tls_static_space, ralign));
((Elf_Addr*)segbase)[0] = segbase;
((Elf_Addr*)segbase)[1] = (Elf_Addr) dtv;
@@ -4340,8 +4396,8 @@ allocate_tls(Obj_Entry *objs, void *oldtls, size_t tcbsize, size_t tcbalign)
void
free_tls(void *tls, size_t tcbsize, size_t tcbalign)
{
- size_t size;
Elf_Addr* dtv;
+ size_t size, ralign;
int dtvsize, i;
Elf_Addr tlsstart, tlsend;
@@ -4349,19 +4405,22 @@ free_tls(void *tls, size_t tcbsize, size_t tcbalign)
* Figure out the size of the initial TLS block so that we can
* find stuff which ___tls_get_addr() allocated dynamically.
*/
- size = round(tls_static_space, tcbalign);
+ ralign = tcbalign;
+ if (tls_static_max_align > ralign)
+ ralign = tls_static_max_align;
+ size = round(tls_static_space, ralign);
dtv = ((Elf_Addr**)tls)[1];
dtvsize = dtv[1];
tlsend = (Elf_Addr) tls;
tlsstart = tlsend - size;
for (i = 0; i < dtvsize; i++) {
- if (dtv[i+2] && (dtv[i+2] < tlsstart || dtv[i+2] > tlsend)) {
- free((void*) dtv[i+2]);
+ if (dtv[i + 2] != 0 && (dtv[i + 2] < tlsstart || dtv[i + 2] > tlsend)) {
+ free_aligned((void *)dtv[i + 2]);
}
}
- free((void*) tlsstart);
+ free_aligned((void *)tlsstart);
free((void*) dtv);
}
@@ -4385,11 +4444,7 @@ allocate_module_tls(int index)
die();
}
- p = malloc(obj->tlssize);
- if (p == NULL) {
- _rtld_error("Cannot allocate TLS block for index %d", index);
- die();
- }
+ p = malloc_aligned(obj->tlssize, obj->tlsalign);
memcpy(p, obj->tlsinit, obj->tlsinitsize);
memset(p + obj->tlsinitsize, 0, obj->tlssize - obj->tlsinitsize);
@@ -4421,9 +4476,11 @@ allocate_tls_offset(Obj_Entry *obj)
* leave a small amount of space spare to be used for dynamically
* loading modules which use static TLS.
*/
- if (tls_static_space) {
+ if (tls_static_space != 0) {
if (calculate_tls_end(off, obj->tlssize) > tls_static_space)
return false;
+ } else if (obj->tlsalign > tls_static_max_align) {
+ tls_static_max_align = obj->tlsalign;
}
tls_last_offset = obj->tlsoffset = off;
diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h
index 083f5a4f673e..cbeff668ba48 100644
--- a/libexec/rtld-elf/rtld.h
+++ b/libexec/rtld-elf/rtld.h
@@ -71,6 +71,9 @@ extern size_t tls_static_space;
extern int tls_dtv_generation;
extern int tls_max_index;
+extern int npagesizes;
+extern size_t *pagesizes;
+
extern int main_argc;
extern char **main_argv;
extern char **environ;
@@ -352,6 +355,8 @@ Obj_Entry *map_object(int, const char *, const struct stat *);
void *xcalloc(size_t, size_t);
void *xmalloc(size_t);
char *xstrdup(const char *);
+void *malloc_aligned(size_t size, size_t align);
+void free_aligned(void *ptr);
extern Elf_Addr _GLOBAL_OFFSET_TABLE_[];
extern Elf_Sym sym_zero; /* For resolving undefined weak refs. */
diff --git a/libexec/rtld-elf/xmalloc.c b/libexec/rtld-elf/xmalloc.c
index 178f49bda0df..ed195dfb8312 100644
--- a/libexec/rtld-elf/xmalloc.c
+++ b/libexec/rtld-elf/xmalloc.c
@@ -67,3 +67,31 @@ xstrdup(const char *str)
memcpy(copy, str, len);
return (copy);
}
+
+void *
+malloc_aligned(size_t size, size_t align)
+{
+ void *mem, *res;
+
+ if (align < sizeof(void *))
+ align = sizeof(void *);
+
+ mem = xmalloc(size + sizeof(void *) + align - 1);
+ res = (void *)round((uintptr_t)mem + sizeof(void *), align);
+ *(void **)((uintptr_t)res - sizeof(void *)) = mem;
+ return (res);
+}
+
+void
+free_aligned(void *ptr)
+{
+ void *mem;
+ uintptr_t x;
+
+ if (ptr == NULL)
+ return;
+ x = (uintptr_t)ptr;
+ x -= sizeof(void *);
+ mem = *(void **)x;
+ free(mem);
+}
diff --git a/libexec/talkd/announce.c b/libexec/talkd/announce.c
index 83c96b724c01..00c01ac6d735 100644
--- a/libexec/talkd/announce.c
+++ b/libexec/talkd/announce.c
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/talkd/print.c b/libexec/talkd/print.c
index 6c39d8da72cc..9a749618ff70 100644
--- a/libexec/talkd/print.c
+++ b/libexec/talkd/print.c
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/talkd/process.c b/libexec/talkd/process.c
index 1c5108fc7d59..742043f8ceb0 100644
--- a/libexec/talkd/process.c
+++ b/libexec/talkd/process.c
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/talkd/table.c b/libexec/talkd/table.c
index 5ad7b61bdf7a..70b71b2c9be5 100644
--- a/libexec/talkd/table.c
+++ b/libexec/talkd/table.c
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/talkd/talkd.8 b/libexec/talkd/talkd.8
index b1944b7b5600..27f3a4eaf0c9 100644
--- a/libexec/talkd/talkd.8
+++ b/libexec/talkd/talkd.8
@@ -9,11 +9,7 @@
.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
diff --git a/libexec/talkd/talkd.c b/libexec/talkd/talkd.c
index 56ce4414c106..a444fe7c9ed3 100644
--- a/libexec/talkd/talkd.c
+++ b/libexec/talkd/talkd.c
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/tests/Makefile b/libexec/tests/Makefile
new file mode 100644
index 000000000000..665efab4275e
--- /dev/null
+++ b/libexec/tests/Makefile
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+.include <bsd.own.mk>
+
+TESTSDIR= ${TESTSBASE}/libexec
+
+.PATH: ${.CURDIR:H:H}/tests
+KYUAFILE= yes
+
+.include <bsd.test.mk>
diff --git a/libexec/tftpd/tftpd.8 b/libexec/tftpd/tftpd.8
index c06cc61b4ad4..0071264ef338 100644
--- a/libexec/tftpd/tftpd.8
+++ b/libexec/tftpd/tftpd.8
@@ -9,11 +9,7 @@
.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c
index 87f80f0ca7c4..571fa5970db2 100644
--- a/libexec/tftpd/tftpd.c
+++ b/libexec/tftpd/tftpd.c
@@ -10,11 +10,7 @@
* 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/libexec/ulog-helper/Makefile b/libexec/ulog-helper/Makefile
index c1697c8fd12c..764f0dece164 100644
--- a/libexec/ulog-helper/Makefile
+++ b/libexec/ulog-helper/Makefile
@@ -3,7 +3,7 @@
PROG= ulog-helper
BINOWN= root
BINMODE=4555
-NO_MAN=
+MAN=
DPADD= ${LIBULOG}
LDADD= -lulog