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){
33 // Might be running native GUI on OS X.
34 disp = strdup(":0.0");
38 werrstr("$DISPLAY not set");
43 /* canonicalize: xxx:0.0 => xxx:0 */
44 p = strrchr(disp, ':');
47 while(isdigit((uchar)*p))
49 if(strcmp(p, ".0") == 0)
53 /* turn /tmp/launch/:0 into _tmp_launch_:0 (OS X 10.5) */
58 p = smprint("/tmp/ns.%s.%s", getuser(), disp);
61 werrstr("out of memory");
64 if((fd=create(p, OREAD, DMDIR|0700)) >= 0){
68 if((d = dirstat(p)) == nil){
70 werrstr("stat %s: %r", p);
74 if((d->mode&0777) != 0700 || !isme(d->uid)){
75 werrstr("bad name space dir %s", p);
89 ns = getenv("NAMESPACE");
93 werrstr("$NAMESPACE not set, %r");