❯ command bat /etc/sub{uid,gid}
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: /etc/subuid
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ joerg:100000:65536
2 │ nix:165536:65536
───────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: /etc/subgid
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ joerg:100000:65536
2 │ nix:165536:65536
───────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Last active
January 28, 2025 13:39
-
-
Save Mic92/3846bb589a84061b38ada9f5a309726b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eux -o pipefail | |
# Create mount point if it doesn't exist | |
mkdir -p /run/testmount | |
# Clean up on exit | |
trap 'umount /run/testmount; rmdir /run/testmount' EXIT | |
# Enter new namespace with same mapping and mount tmpfs inside it | |
sudo -u joerg unshare --map-auto --map-root-user \ | |
--user \ | |
--mount \ | |
--uts \ | |
--ipc \ | |
--pid \ | |
--fork \ | |
/bin/bash -c " | |
mount -t tmpfs tmpfs /run/testmount; | |
touch /run/testmount/testfile; | |
chmod u+s /run/testmount/testfile; | |
ls -la /run/testmount/testfile" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment