11 n = strtol(uid, &p, 10);
12 if(*p == 0 && p > uid)
14 return strcmp(getuser(), uid) == 0;
17 * Absent other hints, it works reasonably well to use
18 * the X11 display name as the name space identifier.
19 * This is how sam's B has worked since the early days.
20 * Since most programs using name spaces are also using X,
21 * this still seems reasonable. Terminal-only sessions
31 if((disp = getenv("DISPLAY")) == nil){
32 werrstr("$DISPLAY not set");
36 /* canonicalize: xxx:0.0 => xxx:0 */
37 p = strrchr(disp, ':');
40 while(isdigit((uchar)*p))
42 if(strcmp(p, ".0") == 0)
46 p = smprint("/tmp/ns.%s.%s", getuser(), disp);
49 werrstr("out of memory");
52 if((fd=create(p, OREAD, DMDIR|0700)) >= 0){
56 if((d = dirstat(p)) == nil){
58 werrstr("stat %s: %r", p);
62 if((d->mode&0777) != 0700 || !isme(d->uid)){
63 werrstr("bad name space dir %s", p);
77 ns = getenv("NAMESPACE");
81 werrstr("$NAMESPACE not set, %r");