summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTill Höppner2017-10-01 22:34:59 +0200
committerTill Höppner2017-10-01 22:34:59 +0200
commita940236215b234a2aa37e26ecf5a14acd2e7f539 (patch)
tree8bbb1e17790b186b1020bf6642a0d91c2842e138
parenta275e595d3e945eaf1ac8e0f0ff73db72d16e453 (diff)
downloadserver-a940236215b234a2aa37e26ecf5a14acd2e7f539.tar.gz
server-a940236215b234a2aa37e26ecf5a14acd2e7f539.tar.xz
server-a940236215b234a2aa37e26ecf5a14acd2e7f539.zip
Add utility script to fix uid volumes for uid namespaces
-rwxr-xr-xbin/offset_ids28
1 files changed, 28 insertions, 0 deletions
diff --git a/bin/offset_ids b/bin/offset_ids
new file mode 100755
index 0000000..e5e1a47
--- /dev/null
+++ b/bin/offset_ids
@@ -0,0 +1,28 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i python3 -p python36
+
+import pwd
+import grp
+import os
+import sys
+
+if len(sys.argv) != 3:
+ print(f"USAGE: {sys.argv[0]} TARGET OFFSET")
+ sys.exit(1)
+
+target = sys.argv[1]
+offset = int(sys.argv[2])
+
+def adjust(path):
+ stat = os.stat(path, follow_symlinks=False)
+ uid = stat.st_uid
+ gid = stat.st_gid
+
+ print(f"{path} {uid}:{gid} => {uid + offset}:{gid + offset}")
+ os.chown(path, uid + offset, gid + offset, follow_symlinks=False)
+
+for root, dirs, files in os.walk(target):
+ for d in dirs:
+ adjust(root + os.sep + d)
+ for f in files:
+ adjust(root + os.sep + f)