diff options
author | 2002-10-09 03:51:49 +0000 | |
---|---|---|
committer | 2002-10-09 03:51:49 +0000 | |
commit | a238d3f7986254c18ecce3f6fc8a863df415b8a7 (patch) | |
tree | 2e781023f3cefaf817b6e01547de920ff15c6e40 /sys/dev/systrace.c | |
parent | clean-up. check that SA_RESETHAND does the right thing, too. (diff) | |
download | wireguard-openbsd-a238d3f7986254c18ecce3f6fc8a863df415b8a7.tar.xz wireguard-openbsd-a238d3f7986254c18ecce3f6fc8a863df415b8a7.zip |
new message to track uid/gid changes
from provos
Diffstat (limited to 'sys/dev/systrace.c')
-rw-r--r-- | sys/dev/systrace.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sys/dev/systrace.c b/sys/dev/systrace.c index 666355785cc..a2a51f42c17 100644 --- a/sys/dev/systrace.c +++ b/sys/dev/systrace.c @@ -134,6 +134,7 @@ int systrace_msg_ask(struct fsystrace *, struct str_process *, int systrace_msg_result(struct fsystrace *, struct str_process *, int, int, size_t, register_t [], register_t []); int systrace_msg_emul(struct fsystrace *, struct str_process *); +int systrace_msg_ugid(struct fsystrace *, struct str_process *); int systrace_make_msg(struct str_process *, int); static struct fileops systracefops = { @@ -730,6 +731,8 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval) if (!error) { struct emul *oldemul = p->p_emul; + uid_t olduid = p->p_cred->p_ruid; + gid_t oldgid = p->p_cred->p_rgid; error = (*callp->sy_call)(p, v, retval); @@ -766,6 +769,23 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval) } else systrace_unlock(); + /* Report if effective uid or gid changed */ + if (olduid != p->p_cred->p_ruid || + oldgid != p->p_cred->p_rgid) { + systrace_lock(); + if ((strp = p->p_systrace) == NULL) { + systrace_unlock(); + goto nougid; + } + + fst = strp->parent; + lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, p); + systrace_unlock(); + + systrace_msg_ugid(fst, strp); + nougid: + } + /* Report result from system call */ systrace_lock(); if (report && (strp = p->p_systrace) != NULL) { @@ -1322,6 +1342,18 @@ systrace_msg_emul(struct fsystrace *fst, struct str_process *strp) } int +systrace_msg_ugid(struct fsystrace *fst, struct str_process *strp) +{ + struct str_msg_ugid *msg_ugid = &strp->msg.msg_data.msg_ugid; + struct proc *p = strp->proc; + + msg_ugid->uid = p->p_cred->p_ruid; + msg_ugid->gid = p->p_cred->p_rgid; + + return (systrace_make_msg(strp, SYSTR_MSG_UGID)); +} + +int systrace_make_msg(struct str_process *strp, int type) { struct str_message *msg = &strp->msg; |