Lines Matching defs:ctp

124 #define	EVSENDP(ctp, flag) \
125 ((ctp->conp_contract.ct_ev_info | ctp->conp_contract.ct_ev_crit) & flag)
127 #define EVINFOP(ctp, flag) \
128 ((ctp->conp_contract.ct_ev_crit & flag) == 0)
130 #define EVFATALP(ctp, flag) \
131 (ctp->conp_ev_fatal & flag)
182 ctmpl_process_t *ctp = template->ctmpl_data;
184 if (ctp->ctp_subsume)
185 contract_rele(ctp->ctp_subsume);
186 if (ctp->ctp_svc_fmri != NULL) {
187 refstr_rele(ctp->ctp_svc_fmri);
189 if (ctp->ctp_svc_aux != NULL) {
190 refstr_rele(ctp->ctp_svc_aux);
199 * additional privilege given the template "ctp".
202 #define EXCESS(ctp, value) \
203 (((value) & ~((ctp)->ctp_ev_fatal | SAFE_EV)) || \
204 (((value) & ~SAFE_EV) && (ctp->ctp_params & CT_PR_PGRPONLY)))
227 ctmpl_process_t *ctp = tmpl->ctmpl_data;
273 if (ctp->ctp_subsume)
274 contract_rele(ctp->ctp_subsume);
275 ctp->ctp_subsume = ct;
280 ctp->ctp_params = param_value;
287 if ((ctp->ctp_params & CT_PR_PGRPONLY) &&
288 EXCESS(ctp, tmpl->ctmpl_ev_crit) &&
298 if (ctp->ctp_svc_fmri != NULL)
299 refstr_rele(ctp->ctp_svc_fmri);
301 ctp->ctp_svc_fmri = NULL;
303 ctp->ctp_svc_fmri =
307 if (ctp->ctp_svc_aux != NULL)
308 refstr_rele(ctp->ctp_svc_aux);
310 ctp->ctp_svc_aux = NULL;
312 ctp->ctp_svc_aux =
321 if (EXCESS(ctp, param_value) &&
329 ctp->ctp_ev_fatal = param_value;
335 if (EXCESS(ctp, tmpl->ctmpl_ev_crit) &&
338 SAFE_EV | (ctp->ctp_params & CT_PR_PGRPONLY) ?
339 0 : ctp->ctp_ev_fatal;
360 ctmpl_process_t *ctp = template->ctmpl_data;
374 *param_value = ctp->ctp_subsume ?
375 ctp->ctp_subsume->ct_id : 0;
378 *param_value = ctp->ctp_params;
381 if (ctp->ctp_svc_fmri == NULL) {
388 refstr_value(ctp->ctp_svc_fmri), param->ctpm_size);
393 if (ctp->ctp_svc_aux == NULL) {
401 refstr_value(ctp->ctp_svc_aux), param->ctpm_size);
406 *param_value = ctp->ctp_ev_fatal;
464 cont_process_t *ctp = ct->ct_data;
465 crfree(ctp->conp_cred);
466 list_destroy(&ctp->conp_members);
467 list_destroy(&ctp->conp_inherited);
468 if (ctp->conp_svc_fmri != NULL) {
469 refstr_rele(ctp->conp_svc_fmri);
471 if (ctp->conp_svc_aux != NULL) {
472 refstr_rele(ctp->conp_svc_aux);
474 if (ctp->conp_svc_creator != NULL) {
475 refstr_rele(ctp->conp_svc_creator);
477 kmem_free(ctp, sizeof (cont_process_t));
487 contract_process_cankill(proc_t *tp, proc_t *sp, cont_process_t *ctp)
492 cankill = hasprocperm(tp->p_cred, ctp->conp_cred);
512 cont_process_t *ctp = ct->ct_data;
518 if (ex && (ctp->conp_params & CT_PR_PGRPONLY)) {
523 for (p = list_head(&ctp->conp_members); p != NULL;
524 p = list_next(&ctp->conp_members, p)) {
527 (checkpriv && !contract_process_cankill(p, ex, ctp)))
549 cont_process_t *ctp = parent->ct_data;
553 return (ctp->conp_params & CT_PR_REGENT);
564 cont_process_t *ctp = parent->ct_data;
569 ASSERT(ctp->conp_params & CT_PR_REGENT);
571 list_insert_head(&ctp->conp_inherited, child);
572 ctp->conp_ninherited++;
607 cont_process_t *ctp = ct->ct_data;
614 if (list_head(&ctp->conp_members) == NULL) {
622 if (ctp->conp_params & CT_PR_NOORPHAN)
638 cont_process_t *ctp = ct->ct_data;
646 while (cct = list_head(&ctp->conp_inherited)) {
651 list_remove(&ctp->conp_inherited, cct);
652 ctp->conp_ninherited--;
667 cont_process_t *ctp = ct->ct_data;
676 local_svc_zone_enter = ctp->conp_svc_zone_enter;
686 spids = ctp->conp_nmembers + 5;
687 sctids = ctp->conp_ninherited + 5;
695 npids = ctp->conp_nmembers;
696 nctids = ctp->conp_ninherited;
704 for (loc = 0, cnext = list_head(&ctp->conp_inherited); cnext;
705 cnext = list_next(&ctp->conp_inherited, cnext))
708 for (loc = 0, pnext = list_head(&ctp->conp_members); pnext;
709 pnext = list_next(&ctp->conp_members, pnext))
712 local_svc_zone_enter = ctp->conp_svc_zone_enter;
720 VERIFY(nvlist_add_uint32(nvl, CTPS_PARAMS, ctp->conp_params) == 0);
721 VERIFY(nvlist_add_uint32(nvl, CTPS_EV_FATAL, ctp->conp_ev_fatal) == 0);
728 refstr_value(ctp->conp_svc_aux)) == 0);
730 refstr_value(ctp->conp_svc_creator)) == 0);
743 ctp->conp_svc_ctid) == 0);
747 refstr_value(ctp->conp_svc_fmri)) == 0);
819 cont_process_t *ctp;
825 ctp = kmem_zalloc(sizeof (cont_process_t), KM_SLEEP);
827 list_create(&ctp->conp_members, sizeof (proc_t),
829 list_create(&ctp->conp_inherited, sizeof (contract_t),
832 ctp->conp_params = tmpl->ctp_params;
833 ctp->conp_ev_fatal = tmpl->ctp_ev_fatal;
834 crhold(ctp->conp_cred = CRED());
836 if (contract_ctor(&ctp->conp_contract, process_type, &tmpl->ctp_ctmpl,
837 ctp, (ctp->conp_params & CT_PR_INHERIT) ? CTF_INHERIT : 0,
840 contract_process_free(&ctp->conp_contract);
850 ctp->conp_svc_fmri = parent->p_ct_process->conp_svc_fmri;
851 ctp->conp_svc_ctid = parent->p_ct_process->conp_svc_ctid;
852 ctp->conp_svc_zone_enter =
855 ctp->conp_svc_fmri = tmpl->ctp_svc_fmri;
856 ctp->conp_svc_ctid = ctp->conp_contract.ct_id;
858 ctp->conp_svc_zone_enter = 0;
860 refstr_hold(ctp->conp_svc_fmri);
863 ctp->conp_svc_aux = conp_svc_aux_default;
865 ctp->conp_svc_aux = tmpl->ctp_svc_aux;
867 refstr_hold(ctp->conp_svc_aux);
875 ctp->conp_svc_creator = refstr_alloc("sched");
877 ctp->conp_svc_creator = refstr_alloc(parent->p_user.u_comm);
889 mutex_enter(&ctp->conp_contract.ct_lock);
893 list_insert_tail(&ctp->conp_inherited, ct);
894 ct->ct_regent = &ctp->conp_contract;
897 ctp->conp_ninherited += sct->conp_ninherited;
899 mutex_exit(&ctp->conp_contract.ct_lock);
910 return (ctp);
917 * ctp. Generates an exit event, if requested. Generates an empty
922 contract_process_exit(cont_process_t *ctp, proc_t *p, int exitstatus)
924 contract_t *ct = &ctp->conp_contract;
932 list_remove(&ctp->conp_members, p);
933 ctp->conp_nmembers--;
943 empty = (list_head(&ctp->conp_members) == NULL);
944 if (EVSENDP(ctp, CT_PR_EV_EXIT)) {
953 event->cte_flags = EVINFOP(ctp, CT_PR_EV_EXIT) ? CTE_INFO : 0;
962 if (EVSENDP(ctp, CT_PR_EV_EMPTY)) {
971 event->cte_flags = EVINFOP(ctp, CT_PR_EV_EMPTY) ?
1014 cont_process_t *ctp;
1023 ctp = curproc->p_ct_process;
1024 else if ((ctp = contract_process_create(rtmpl, pp, canfail)) == NULL)
1027 ct = &ctp->conp_contract;
1031 * It's not worth hoisting the ctp test since contract creation
1036 if (ctp == curproc->p_ct_process && (pp->p_flag & SKILLED) != 0 &&
1042 cp->p_ct_process = ctp;
1045 list_insert_head(&ctp->conp_members, cp);
1046 ctp->conp_nmembers++;
1048 if (EVSENDP(ctp, CT_PR_EV_FORK)) {
1056 event->cte_flags = EVINFOP(ctp, CT_PR_EV_FORK) ? CTE_INFO : 0;
1060 return (ctp);
1072 contract_process_core(cont_process_t *ctp, proc_t *p, int sig,
1075 contract_t *ct = &ctp->conp_contract;
1077 if (EVSENDP(ctp, CT_PR_EV_CORE)) {
1103 event->cte_flags = EVINFOP(ctp, CT_PR_EV_CORE) ? CTE_INFO : 0;
1108 if (EVFATALP(ctp, CT_PR_EV_CORE)) {
1123 contract_process_hwerr(cont_process_t *ctp, proc_t *p)
1125 contract_t *ct = &ctp->conp_contract;
1127 if (EVSENDP(ctp, CT_PR_EV_HWERR)) {
1135 event->cte_flags = EVINFOP(ctp, CT_PR_EV_HWERR) ? CTE_INFO : 0;
1140 if (EVFATALP(ctp, CT_PR_EV_HWERR)) {
1158 contract_process_sig(cont_process_t *ctp, proc_t *p, int sig, pid_t pid,
1161 contract_t *ct = &ctp->conp_contract;
1163 if (EVSENDP(ctp, CT_PR_EV_SIGNAL)) {
1185 event->cte_flags = EVINFOP(ctp, CT_PR_EV_SIGNAL) ? CTE_INFO : 0;
1190 if (EVFATALP(ctp, CT_PR_EV_SIGNAL)) {