| 1 | // Package userns provides utilities to detect whether we are currently running |
| 2 | // in a Linux user namespace. |
| 3 | // |
| 4 | // This code was migrated from [libcontainer/runc], which based its implementation |
| 5 | // on code from [lcx/incus]. |
| 6 | // |
| 7 | // [libcontainer/runc]: https://github.com/opencontainers/runc/blob/3778ae603c706494fd1e2c2faf83b406e38d687d/libcontainer/userns/userns_linux.go#L12-L49 |
| 8 | // [lcx/incus]: https://github.com/lxc/incus/blob/e45085dd42f826b3c8c3228e9733c0b6f998eafe/shared/util.go#L678-L700 |
| 9 | package userns |
| 10 | |
| 11 | // RunningInUserNS detects whether we are currently running in a Linux |
| 12 | // user namespace and memoizes the result. It returns false on non-Linux |
| 13 | // platforms. |
| 14 | func RunningInUserNS() bool { |
| 15 | return inUserNS() |
| 16 | } |