diff options
| author | Darren Reed <Darren.Reed@Sun.COM> | 2010-03-12 09:14:15 -0800 |
|---|---|---|
| committer | Darren Reed <Darren.Reed@Sun.COM> | 2010-03-12 09:14:15 -0800 |
| commit | 0572408d0f87aa2483c427545c5f52cd08cce1a3 (patch) | |
| tree | e85f3b31db67cb7b4c8f9ddc56c102d589449649 /usr/src/cmd/dlmgmtd | |
| parent | 86b7dbefda771542da92c8e031c0153fd809ff01 (diff) | |
| download | illumos-joyent-0572408d0f87aa2483c427545c5f52cd08cce1a3.tar.gz | |
6932760 dlmgmtd leaks contracts
Diffstat (limited to 'usr/src/cmd/dlmgmtd')
| -rw-r--r-- | usr/src/cmd/dlmgmtd/dlmgmt_db.c | 17 |
1 files changed, 14 insertions, 3 deletions
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); } |
