summaryrefslogtreecommitdiffstats
path: root/sbin/hastd/secondary.c
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2011-02-03 11:39:49 +0000
committerpjd <pjd@FreeBSD.org>2011-02-03 11:39:49 +0000
commitd2daebca5a3e66dcf1823aec44dcbeb61f5fe78e (patch)
tree5376bd4ffaada59dd0f6a2e59253765cf24b14a6 /sbin/hastd/secondary.c
parent0c525303bdcbdd0f85b8805ec7efe0fa389bc7ed (diff)
downloadFreeBSD-src-d2daebca5a3e66dcf1823aec44dcbeb61f5fe78e.zip
FreeBSD-src-d2daebca5a3e66dcf1823aec44dcbeb61f5fe78e.tar.gz
Setup another socketpair between parent and child, so that primary sandboxed
worker can ask the main privileged process to connect in worker's behalf and then we can migrate descriptor using this socketpair to worker. This is not really needed now, but will be needed once we start to use capsicum for sandboxing. MFC after: 1 week
Diffstat (limited to 'sbin/hastd/secondary.c')
-rw-r--r--sbin/hastd/secondary.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sbin/hastd/secondary.c b/sbin/hastd/secondary.c
index 12a68de..9c859e0 100644
--- a/sbin/hastd/secondary.c
+++ b/sbin/hastd/secondary.c
@@ -364,6 +364,16 @@ hastd_secondary(struct hast_resource *res, struct nv *nvin)
pjdlog_exit(EX_OSERR,
"Unable to create event sockets between child and parent");
}
+ /*
+ * Create communication channel for sending connection requests from
+ * parent to child.
+ */
+ if (proto_client("socketpair://", &res->hr_conn) < 0) {
+ /* TODO: There's no need for this to be fatal error. */
+ KEEP_ERRNO((void)pidfile_remove(pfh));
+ pjdlog_exit(EX_OSERR,
+ "Unable to create connection sockets between parent and child");
+ }
pid = fork();
if (pid < 0) {
@@ -381,6 +391,7 @@ hastd_secondary(struct hast_resource *res, struct nv *nvin)
proto_recv(res->hr_event, NULL, 0);
/* Declare that we are sender. */
proto_send(res->hr_ctrl, NULL, 0);
+ proto_send(res->hr_conn, NULL, 0);
res->hr_workerpid = pid;
return;
}
@@ -392,6 +403,7 @@ hastd_secondary(struct hast_resource *res, struct nv *nvin)
proto_send(res->hr_event, NULL, 0);
/* Declare that we are receiver. */
proto_recv(res->hr_ctrl, NULL, 0);
+ proto_recv(res->hr_conn, NULL, 0);
descriptors_cleanup(res);
descriptors_assert(res, mode);
OpenPOWER on IntegriCloud