1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

Use the proc lock to protect p_ucred while we read a few items from it.

This commit is contained in:
John Baldwin 2002-04-11 21:17:45 +00:00
parent 3aa68913bc
commit 59cfd37dd4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=94460

View File

@ -37,6 +37,8 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/module.h>
#include <sys/sysctl.h>
#include <sys/syslog.h>
@ -129,9 +131,14 @@ log_append_int(lomac_log_t *s, int data) {
void
log_append_subject_id(lomac_log_t *s, const lomac_subject_t *p_subject) {
uid_t uid;
pid_t pgid;
(void)sbuf_printf(s, "p%dg%du%d:%s", p_subject->p_pid,
p_subject->p_pgrp->pg_id, p_subject->p_ucred->cr_uid,
PROC_LOCK(p_subject);
uid = p_subject->p_ucred->cr_uid;
pgid = p_subject->p_pgrp->pg_id;
PROC_UNLOCK(p_subject);
(void)sbuf_printf(s, "p%dg%du%d:%s", p_subject->p_pid, pgid, uid,
p_subject->p_comm);
} /* log_append_subject_id() */