diff options
author | helg <helg@cvs.openbsd.org> | 2018-06-19 11:27:55 +0000 |
---|---|---|
committer | helg <helg@cvs.openbsd.org> | 2018-06-19 11:27:55 +0000 |
commit | 57436230755cc8f123e77d7f7ac1a438cba5e871 (patch) | |
tree | 64871dbb7aef157778e2b65d75d7007f344e5c7c /sys | |
parent | 776ddb05eea331f13e13a11cd92e783bbfbc0a91 (diff) |
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@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/miscfs/fuse/fusebuf.c | 12 | ||||
-rw-r--r-- | sys/sys/fusebuf.h | 10 |
2 files changed, 20 insertions, 2 deletions
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 |