summaryrefslogtreecommitdiffstats
path: root/scripts/nativesdk-intercept/chgrp
blob: f8ae84b8b3f733ff3b0c64fa473a02217af7429f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3
#
# Wrapper around 'chgrp' that redirects to root in all cases

import os
import shutil
import sys

# calculate path to the real 'chgrp'
path = os.environ['PATH']
path = path.replace(os.path.dirname(sys.argv[0]), '')
real_chgrp = shutil.which('chgrp', path=path)

args = list()

found = False

args.append(real_chgrp)

for i in sys.argv[1:]:
    if i.startswith("-"):
        args.append(i)
        continue
    if not found:
        args.append("root")
        found = True
    else:
        args.append(i)

os.execv(real_chgrp, args)