diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
commit | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch) | |
tree | d8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/lib9p/uid.c |
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/lib9p/uid.c')
-rwxr-xr-x | sys/src/lib9p/uid.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sys/src/lib9p/uid.c b/sys/src/lib9p/uid.c new file mode 100755 index 000000000..4b7ee64eb --- /dev/null +++ b/sys/src/lib9p/uid.c @@ -0,0 +1,34 @@ +#include <u.h> +#include <libc.h> +#include <auth.h> +#include <fcall.h> +#include <thread.h> +#include <9p.h> + +/* + * simplistic permission checking. assume that + * each user is the leader of her own group. + */ +int +hasperm(File *f, char *uid, int p) +{ + int m; + + m = f->mode & 7; /* other */ + if((p & m) == p) + return 1; + + if(strcmp(f->uid, uid) == 0) { + m |= (f->mode>>6) & 7; + if((p & m) == p) + return 1; + } + + if(strcmp(f->gid, uid) == 0) { + m |= (f->mode>>3) & 7; + if((p & m) == p) + return 1; + } + + return 0; +} |