| * Absent other hints, it works reasonably well to use |
| * the X11 display name as the name space identifier. |
| * This is how sam's B has worked since the early days. |
| * Since most programs using name spaces are also using X, |
| * this still seems reasonable. Terminal-only sessions |
| if((disp = getenv("DISPLAY")) == nil){ |
| werrstr("$DISPLAY not set"); |
| /* canonicalize: xxx:0.0 => xxx:0 */ |
| while(isdigit((uchar)*p)) |
| p = smprint("/tmp/ns.%s.%s", getuser(), disp); |
| werrstr("out of memory"); |
| if((fd=create(p, OREAD, DMDIR|0700)) >= 0){ |
| if((d = dirstat(p)) == nil){ |
| werrstr("stat %s: %r", p); |
| if((d->mode&0777) != 0700 || strcmp(d->uid, getuser()) != 0){ |
| werrstr("bad name space dir %s", p); |
| ns = getenv("NAMESPACE"); |
| werrstr("$NAMESPACE not set, %r"); |