| 82 | struct mac *mac_p, int follow); |
| 83 | |
| 84 | int |
| 85 | sys___mac_get_pid(struct thread *td, struct __mac_get_pid_args *uap) |
| 86 | { |
| 87 | char *elements, *buffer; |
| 88 | struct mac mac; |
| 89 | struct proc *tproc; |
| 90 | struct ucred *tcred; |
| 91 | int error; |
| 92 | |
| 93 | error = copyin(uap->mac_p, &mac, sizeof(mac)); |
| 94 | if (error) |
| 95 | return (error); |
| 96 | |
| 97 | error = mac_check_structmac_consistent(&mac); |
| 98 | if (error) |
| 99 | return (error); |
| 100 | |
| 101 | tproc = pfind(uap->pid); |
| 102 | if (tproc == NULL) |
| 103 | return (ESRCH); |
| 104 | |
| 105 | tcred = NULL; /* Satisfy gcc. */ |
| 106 | error = p_cansee(td, tproc); |
| 107 | if (error == 0) |
| 108 | tcred = crhold(tproc->p_ucred); |
| 109 | PROC_UNLOCK(tproc); |
| 110 | if (error) |
| 111 | return (error); |
| 112 | |
| 113 | elements = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK); |
| 114 | error = copyinstr(mac.m_string, elements, mac.m_buflen, NULL); |
| 115 | if (error) { |
| 116 | free(elements, M_MACTEMP); |
| 117 | crfree(tcred); |
| 118 | return (error); |
| 119 | } |
| 120 | |
| 121 | buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK | M_ZERO); |
| 122 | error = mac_cred_externalize_label(tcred->cr_label, elements, |
| 123 | buffer, mac.m_buflen); |
| 124 | if (error == 0) |
| 125 | error = copyout(buffer, mac.m_string, strlen(buffer)+1); |
| 126 | |
| 127 | free(buffer, M_MACTEMP); |
| 128 | free(elements, M_MACTEMP); |
| 129 | crfree(tcred); |
| 130 | return (error); |
| 131 | } |
| 132 | |
| 133 | int |
| 134 | sys___mac_get_proc(struct thread *td, struct __mac_get_proc_args *uap) |
nothing calls this directly
no test coverage detected