summaryrefslogtreecommitdiffstats
path: root/scripts/nativesdk-intercept/chgrp
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/nativesdk-intercept/chgrp')
-rwxr-xr-xscripts/nativesdk-intercept/chgrp27
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/nativesdk-intercept/chgrp b/scripts/nativesdk-intercept/chgrp
new file mode 100755
index 0000000000..30cc417d3a
--- /dev/null
+++ b/scripts/nativesdk-intercept/chgrp
@@ -0,0 +1,27 @@
1#!/usr/bin/env python3
2#
3# Wrapper around 'chgrp' that redirects to root in all cases
4
5import os
6import shutil
7import sys
8
9# calculate path to the real 'chgrp'
10path = os.environ['PATH']
11path = path.replace(os.path.dirname(sys.argv[0]), '')
12real_chgrp = shutil.which('chgrp', path=path)
13
14args = list()
15
16found = False
17for i in sys.argv:
18 if i.startswith("-"):
19 args.append(i)
20 continue
21 if not found:
22 args.append("root")
23 found = True
24 else:
25 args.append(i)
26
27os.execv(real_chgrp, args)