on master help sign in
give directions on how to fix namespaces when they are disabled
commitf2fa3ec8e258fbeca1d0f40edbfe87b9192e3253 authorMichael Bishop <cleverca22@gmail.com> dateWed 4 Apr 2018, 13:26 (9 years ago) parent55c6a07
1 file changed+6−2
nix-user-chroot/main.cpp+6−2
nix-user-chroot/main.cpp+6−2
@@ -112,7 +112,6 @@ int main(int argc, char *argv[]) {
112112 switch (opt) {
113113 case 'c':
114114 clear_env = 1;
115− puts("clearing env");
116115 break;
117116 case 'n':
118117 // determine absolute directory for nix dir
@@ -167,7 +166,12 @@ int main(int argc, char *argv[]) {
167166
168167 // "unshare" into new namespace
169168 if (unshare(CLONE_NEWNS | CLONE_NEWUSER) < 0) {
170− err_exit("unshare()");
169+ if (errno == EPERM) {
170+ fputs("Run the following as root to enable unprivileged namespace use:\nsysctl -w kernel.unprivileged_userns_clone=1 ; echo kernel.unprivileged_userns_clone=1 > /etc/sysctl.d/nix-user-chroot.conf\n\n", stderr);
171+ exit(EXIT_FAILURE);
172+ } else {
173+ err_exit("unshare()");
174+ }
171175 }
172176
173177 // add necessary system stuff to rootdir namespace