mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 21:09:03 +02:00

Running either of these ends up corrupting the os.execv args. If we run: ./scripts/nativesdk-intercept/chown -R foo:foo bar The loop here ends up missing the conversion of foo:foo to root:root because it sees sys.argv[0] and assumes that it's the user:group argument and that we should convert that. We end up a os.execv(path, args) that have the following args: ['root:root', '-R', 'foo:foo', 'bar'] As os.execv ignores args[0], we can just populate it with sys.argv[0] and then loop through sys.argv[1:]. As both chgrp and chown would have either flags and USER[:GROUP] next, this fixes the issue. (From OE-Core rev: 2a75f647ec7696d353f4b09099d777ba53f34d36) Signed-off-by: Eilís 'pidge' Ní Fhlannagáin <pidge@baylibre.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
559 B
Executable File
559 B
Executable File
#!/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)