tuid.c - plan9port - [fork] Plan 9 from user space
HTML git clone git://src.adamsgaard.dk/plan9port
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
tuid.c (519B)
---
1 #include <u.h>
2 #include <libc.h>
3 #include <fcall.h>
4 #include <thread.h>
5 #include <9p.h>
6
7 /*
8 * simplistic permission checking. assume that
9 * each user is the leader of her own group.
10 */
11 int
12 hasperm(File *f, char *uid, int p)
13 {
14 int m;
15
16 m = f->dir.mode & 7; /* other */
17 if((p & m) == p)
18 return 1;
19
20 if(strcmp(f->dir.uid, uid) == 0) {
21 m |= (f->dir.mode>>6) & 7;
22 if((p & m) == p)
23 return 1;
24 }
25
26 if(strcmp(f->dir.gid, uid) == 0) {
27 m |= (f->dir.mode>>3) & 7;
28 if((p & m) == p)
29 return 1;
30 }
31
32 return 0;
33 }