diff options
author | 2018-06-19 11:27:54 +0000 | |
---|---|---|
committer | 2018-06-19 11:27:54 +0000 | |
commit | 413ec31c49a681fcd185c34be06e8b17074efb80 (patch) | |
tree | 00024a07b506cfbfe5fca9a12fded7b340ebe828 | |
parent | describe more supported hardware (diff) | |
download | wireguard-openbsd-413ec31c49a681fcd185c34be06e8b17074efb80.tar.xz wireguard-openbsd-413ec31c49a681fcd185c34be06e8b17074efb80.zip |
Send the calling thread id, effective uid and gid, and umask to the
FUSE file system. fuse_get_context(3) will now return the correct
values.
ok mpi@
-rw-r--r-- | lib/libfuse/fuse.c | 10 | ||||
-rw-r--r-- | sys/miscfs/fuse/fusebuf.c | 12 | ||||
-rw-r--r-- | sys/sys/fusebuf.h | 10 |
3 files changed, 25 insertions, 7 deletions
diff --git a/lib/libfuse/fuse.c b/lib/libfuse/fuse.c index d0551a84f0d..9ed4079c5ba 100644 --- a/lib/libfuse/fuse.c +++ b/lib/libfuse/fuse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse.c,v 1.45 2018/05/22 12:52:14 helg Exp $ */ +/* $OpenBSD: fuse.c,v 1.46 2018/06/19 11:27:54 helg Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -228,10 +228,10 @@ fuse_loop(struct fuse *fuse) } ctx.fuse = fuse; - ctx.uid = fuse->conf.uid; - ctx.gid = fuse->conf.gid; - ctx.pid = fuse->conf.pid; - ctx.umask = fuse->conf.umask; + ctx.uid = fbuf.fb_uid; + ctx.gid = fbuf.fb_gid; + ctx.pid = fbuf.fb_tid; + ctx.umask = fbuf.fb_umask; ctx.private_data = fuse->private_data; ictx = &ctx; diff --git a/sys/miscfs/fuse/fusebuf.c b/sys/miscfs/fuse/fusebuf.c index 869889f84d4..edc5a9ca3d2 100644 --- a/sys/miscfs/fuse/fusebuf.c +++ b/sys/miscfs/fuse/fusebuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fusebuf.c,v 1.14 2018/05/23 13:09:37 helg Exp $ */ +/* $OpenBSD: fusebuf.c,v 1.15 2018/06/19 11:27:54 helg Exp $ */ /* * Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -16,9 +16,11 @@ */ #include <sys/param.h> +#include <sys/filedesc.h> #include <sys/kernel.h> #include <sys/malloc.h> #include <sys/pool.h> +#include <sys/proc.h> #include <sys/stat.h> #include <sys/statvfs.h> #include <sys/systm.h> @@ -39,6 +41,14 @@ fb_setup(size_t len, ino_t ino, int op, struct proc *p) arc4random_buf(&fbuf->fb_uuid, sizeof fbuf->fb_uuid); fbuf->fb_type = op; fbuf->fb_ino = ino; + /* + * When exposed to userspace, thread IDs have THREAD_PID_OFFSET added + * to keep them from overlapping the PID range. + */ + fbuf->fb_tid = p->p_tid + THREAD_PID_OFFSET; + fbuf->fb_uid = p->p_ucred->cr_uid; + fbuf->fb_gid = p->p_ucred->cr_gid; + fbuf->fb_umask = p->p_p->ps_fd->fd_cmask; if (len == 0) fbuf->fb_dat = NULL; else diff --git a/sys/sys/fusebuf.h b/sys/sys/fusebuf.h index 76bb73e559b..87066051f44 100644 --- a/sys/sys/fusebuf.h +++ b/sys/sys/fusebuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fusebuf.h,v 1.12 2017/11/30 11:29:03 helg Exp $ */ +/* $OpenBSD: fusebuf.h,v 1.13 2018/06/19 11:27:54 helg Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon * Copyright (c) 2013 Martin Pieuchot @@ -33,6 +33,10 @@ struct fb_hdr { int fh_type; /* type of data */ ino_t fh_ino; /* Inode of this fusebuf */ uint64_t fh_uuid; /* Uuid to track the answer */ + pid_t fh_tid; /* calling proc thread id */ + uid_t fh_uid; /* calling proc uid */ + gid_t fh_gid; /* calling proc gid */ + mode_t fh_umask; /* calling proc umask */ }; /* header for fuse file operations (like read/write/mkdir): */ @@ -74,6 +78,10 @@ struct fusebuf { #define fb_type fb_hdr.fh_type #define fb_ino fb_hdr.fh_ino #define fb_uuid fb_hdr.fh_uuid +#define fb_tid fb_hdr.fh_tid +#define fb_uid fb_hdr.fh_uid +#define fb_gid fb_hdr.fh_gid +#define fb_umask fb_hdr.fh_umask #define fb_stat FD.FD_stat #define fb_attr FD.FD_attr |