From 0572408d0f87aa2483c427545c5f52cd08cce1a3 Mon Sep 17 00:00:00 2001 From: Darren Reed Date: Fri, 12 Mar 2010 09:14:15 -0800 Subject: 6932760 dlmgmtd leaks contracts --- usr/src/cmd/dlmgmtd/dlmgmt_db.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'usr/src/cmd/dlmgmtd') diff --git a/usr/src/cmd/dlmgmtd/dlmgmt_db.c b/usr/src/cmd/dlmgmtd/dlmgmt_db.c index 9f1a3406ef..05741d09f7 100644 --- a/usr/src/cmd/dlmgmtd/dlmgmt_db.c +++ b/usr/src/cmd/dlmgmtd/dlmgmt_db.c @@ -198,6 +198,7 @@ dlmgmt_zfop(const char *filename, zoneid_t zoneid, zfcb_t *zfcb, pid_t childpid; siginfo_t info; zfarg_t zfarg; + ctid_t ct; if (zoneid != GLOBAL_ZONEID) { /* @@ -220,15 +221,18 @@ dlmgmt_zfop(const char *filename, zoneid_t zoneid, zfcb_t *zfcb, (err = ct_pr_tmpl_set_fatal(ctfd, CT_PR_EV_HWERR)) != 0 || (err = ct_pr_tmpl_set_param(ctfd, CT_PR_PGRPONLY)) != 0 || (err = ct_tmpl_activate(ctfd)) != 0) { + (void) close(ctfd); return (err); } childpid = fork(); - (void) ct_tmpl_clear(ctfd); - (void) close(ctfd); switch (childpid) { case -1: + (void) ct_tmpl_clear(ctfd); + (void) close(ctfd); return (err); case 0: + (void) ct_tmpl_clear(ctfd); + (void) close(ctfd); /* * Elevate our privileges as zone_enter() requires all * privileges. @@ -241,8 +245,15 @@ dlmgmt_zfop(const char *filename, zoneid_t zoneid, zfcb_t *zfcb, _exit(err); break; default: - if (waitid(P_PID, childpid, &info, WEXITED) == -1) + if (contract_latest(&ct) == -1) + ct = -1; + (void) ct_tmpl_clear(ctfd); + (void) close(ctfd); + if (waitid(P_PID, childpid, &info, WEXITED) == -1) { + (void) contract_abandon_id(ct); return (errno); + } + (void) contract_abandon_id(ct); if (info.si_status != 0) return (info.si_status); } -- cgit v1.2.3