summaryrefslogtreecommitdiffstats
path: root/usr.bin/kdump
diff options
context:
space:
mode:
authoroshogbo <oshogbo@FreeBSD.org>2016-02-25 18:23:40 +0000
committeroshogbo <oshogbo@FreeBSD.org>2016-02-25 18:23:40 +0000
commit023f14d65b31db71d1a4e6655205dd919bfeb5fb (patch)
treefaa5b7886c70249c03078cb4861e837c2d0f6582 /usr.bin/kdump
parent85f8ae969b95a5539c68ffb09c545b5023901f4e (diff)
downloadFreeBSD-src-023f14d65b31db71d1a4e6655205dd919bfeb5fb.zip
FreeBSD-src-023f14d65b31db71d1a4e6655205dd919bfeb5fb.tar.gz
Convert casperd(8) daemon to the libcasper.
After calling the cap_init(3) function Casper will fork from it's original process, using pdfork(2). Forking from a process has a lot of advantages: 1. We have the same cwd as the original process. 2. The same uid, gid and groups. 3. The same MAC labels. 4. The same descriptor table. 5. The same routing table. 6. The same umask. 7. The same cpuset(1). From now services are also in form of libraries. We also removed libcapsicum at all and converts existing program using Casper to new architecture. Discussed with: pjd, jonathan, ed, drysdale@google.com, emaste Partially reviewed by: drysdale@google.com, bdrewery Approved by: pjd (mentor) Differential Revision: https://reviews.freebsd.org/D4277
Diffstat (limited to 'usr.bin/kdump')
-rw-r--r--usr.bin/kdump/Makefile6
-rw-r--r--usr.bin/kdump/kdump.c31
2 files changed, 20 insertions, 17 deletions
diff --git a/usr.bin/kdump/Makefile b/usr.bin/kdump/Makefile
index 40109f0..f80f668 100644
--- a/usr.bin/kdump/Makefile
+++ b/usr.bin/kdump/Makefile
@@ -11,8 +11,10 @@ CFLAGS+= -I${.CURDIR}/../ktrace -I${.CURDIR} -I${.CURDIR}/../.. -I.
LIBADD= sysdecode
.if ${MK_CASPER} != "no"
-LIBADD+= capsicum
-CFLAGS+=-DHAVE_LIBCAPSICUM
+LIBADD+= casper
+LIBADD+= cap_grp
+LIBADD+= cap_pwd
+CFLAGS+=-DHAVE_LIBCASPER
.endif
NO_WERROR?= YES
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c
index 52001d2..e45a733 100644
--- a/usr.bin/kdump/kdump.c
+++ b/usr.bin/kdump/kdump.c
@@ -61,7 +61,7 @@ extern int errno;
#include <sys/un.h>
#include <sys/queue.h>
#include <sys/wait.h>
-#ifdef HAVE_LIBCAPSICUM
+#ifdef HAVE_LIBCASPER
#include <sys/nv.h>
#endif
#include <arpa/inet.h>
@@ -70,12 +70,6 @@ extern int errno;
#include <err.h>
#include <grp.h>
#include <inttypes.h>
-#ifdef HAVE_LIBCAPSICUM
-#include <libcapsicum.h>
-#include <libcapsicum_grp.h>
-#include <libcapsicum_pwd.h>
-#include <libcapsicum_service.h>
-#endif
#include <locale.h>
#include <netdb.h>
#include <nl_types.h>
@@ -91,6 +85,13 @@ extern int errno;
#include "ktrace.h"
#include "kdump_subr.h"
+#ifdef HAVE_LIBCASPER
+#include <libcasper.h>
+
+#include <casper/cap_grp.h>
+#include <casper/cap_pwd.h>
+#endif
+
u_int abidump(struct ktr_header *);
int fetchprocinfo(struct ktr_header *, u_int *);
int fread_tail(void *, int, int);
@@ -151,7 +152,7 @@ struct proc_info
static TAILQ_HEAD(trace_procs, proc_info) trace_procs;
-#ifdef HAVE_LIBCAPSICUM
+#ifdef HAVE_LIBCASPER
static cap_channel_t *cappwd, *capgrp;
#endif
@@ -180,7 +181,7 @@ localtime_init(void)
(void)localtime(&ltime);
}
-#ifdef HAVE_LIBCAPSICUM
+#ifdef HAVE_LIBCASPER
static int
cappwdgrp_setup(cap_channel_t **cappwdp, cap_channel_t **capgrpp)
{
@@ -189,8 +190,8 @@ cappwdgrp_setup(cap_channel_t **cappwdp, cap_channel_t **capgrpp)
capcas = cap_init();
if (capcas == NULL) {
- warn("unable to contact casperd");
- return (-1);
+ err(1, "unable to create casper process");
+ exit(1);
}
cappwdloc = cap_service_open(capcas, "system.pwd");
capgrploc = cap_service_open(capcas, "system.grp");
@@ -222,7 +223,7 @@ cappwdgrp_setup(cap_channel_t **cappwdp, cap_channel_t **capgrpp)
*capgrpp = capgrploc;
return (0);
}
-#endif /* HAVE_LIBCAPSICUM */
+#endif /* HAVE_LIBCASPER */
int
main(int argc, char *argv[])
@@ -302,7 +303,7 @@ main(int argc, char *argv[])
strerror_init();
localtime_init();
-#ifdef HAVE_LIBCAPSICUM
+#ifdef HAVE_LIBCASPER
if (resolv != 0) {
if (cappwdgrp_setup(&cappwd, &capgrp) < 0) {
cappwd = NULL;
@@ -1648,7 +1649,7 @@ ktrstat(struct stat *statp)
if (resolv == 0) {
pwd = NULL;
} else {
-#ifdef HAVE_LIBCAPSICUM
+#ifdef HAVE_LIBCASPER
if (cappwd != NULL)
pwd = cap_getpwuid(cappwd, statp->st_uid);
else
@@ -1662,7 +1663,7 @@ ktrstat(struct stat *statp)
if (resolv == 0) {
grp = NULL;
} else {
-#ifdef HAVE_LIBCAPSICUM
+#ifdef HAVE_LIBCASPER
if (capgrp != NULL)
grp = cap_getgrgid(capgrp, statp->st_gid);
else
OpenPOWER on IntegriCloud