aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2001-12-20 15:38:05 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2001-12-20 15:38:05 +0000
commitfe25def3344095825738deba119e1400b8e2315f (patch)
treea277304923d54e0495558c1e4e6720c2c114d78d /lib
parent2e50d4376f3124a87d5723ae66c09fa71c7ecf88 (diff)
downloadlibfuse-fe25def3344095825738deba119e1400b8e2315f.tar.gz
permission checking implemented
Diffstat (limited to 'lib')
-rw-r--r--lib/fuse.c4
-rw-r--r--lib/fuse_i.h1
-rw-r--r--lib/fuse_mt.c25
3 files changed, 30 insertions, 0 deletions
diff --git a/lib/fuse.c b/lib/fuse.c
index 0a0b40a..541014f 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
@@ -781,6 +781,7 @@ void __fuse_process_cmd(struct fuse *f, struct fuse_cmd *cmd)
struct fuse_in_header *in = (struct fuse_in_header *) cmd->buf;
void *inarg = cmd->buf + sizeof(struct fuse_in_header);
size_t argsize;
+ struct fuse_context *ctx = fuse_get_context(f);
dec_avail(f);
@@ -789,6 +790,9 @@ void __fuse_process_cmd(struct fuse *f, struct fuse_cmd *cmd)
in->opcode, in->ino, cmd->buflen);
fflush(stdout);
}
+
+ ctx->uid = in->uid;
+ ctx->gid = in->gid;
argsize = cmd->buflen - sizeof(struct fuse_in_header);
diff --git a/lib/fuse_i.h b/lib/fuse_i.h
index 604c297..d587af1 100644
--- a/lib/fuse_i.h
+++ b/lib/fuse_i.h
@@ -37,6 +37,7 @@ struct fuse {
int numavail;
struct fuse_context *(*getcontext)(struct fuse *);
struct fuse_context context;
+ pthread_key_t context_key;
};
struct fuse_dirhandle {
diff --git a/lib/fuse_mt.c b/lib/fuse_mt.c
index 4534d0f..b8756ac 100644
--- a/lib/fuse_mt.c
+++ b/lib/fuse_mt.c
@@ -69,9 +69,28 @@ static void start_thread(struct fuse_worker *w)
pthread_detach(thrid);
}
+static struct fuse_context *mt_getcontext(struct fuse *f)
+{
+ struct fuse_context *ctx;
+
+ ctx = (struct fuse_context *) pthread_getspecific(f->context_key);
+ if(ctx == NULL) {
+ ctx = (struct fuse_context *) malloc(sizeof(struct fuse_context));
+ pthread_setspecific(f->context_key, ctx);
+ }
+
+ return ctx;
+}
+
+static void mt_freecontext(void *data)
+{
+ free(data);
+}
+
void __fuse_loop_mt(struct fuse *f, fuse_processor_t proc, void *data)
{
struct fuse_worker *w;
+ int res;
w = malloc(sizeof(struct fuse_worker));
w->f = f;
@@ -79,6 +98,12 @@ void __fuse_loop_mt(struct fuse *f, fuse_processor_t proc, void *data)
w->proc = proc;
f->numworker = 1;
+ res = pthread_key_create(&f->context_key, mt_freecontext);
+ if(res != 0) {
+ fprintf(stderr, "Failed to create thread specific key\n");
+ exit(1);
+ }
+ f->getcontext = mt_getcontext;
do_work(w);
}