]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
nativesdk-intercept: Fix bad intercept chgrp/chown logic
authorEilís 'pidge' Ní Fhlannagáin <pidge@baylibre.com>
Thu, 7 Sep 2023 11:38:03 +0000 (11:38 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 8 Sep 2023 21:59:29 +0000 (22:59 +0100)
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.

Signed-off-by: Eilís 'pidge' Ní Fhlannagáin <pidge@baylibre.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/nativesdk-intercept/chgrp
scripts/nativesdk-intercept/chown

index 30cc417d3ac2f0350d976d54fd634f0e38d17ce9..f8ae84b8b3f733ff3b0c64fa473a02217af7429f 100755 (executable)
@@ -14,7 +14,10 @@ real_chgrp = shutil.which('chgrp', path=path)
 args = list()
 
 found = False
-for i in sys.argv:
+
+args.append(real_chgrp)
+
+for i in sys.argv[1:]:
     if i.startswith("-"):
         args.append(i)
         continue
index 3914b3e38418a8bffc6b56eacbff5011211f1bb1..0805ceb70a89b6e5c1a29bdb3ec5eb911e407294 100755 (executable)
@@ -14,7 +14,10 @@ real_chown = shutil.which('chown', path=path)
 args = list()
 
 found = False
-for i in sys.argv:
+
+args.append(real_chown)
+
+for i in sys.argv[1:]:
     if i.startswith("-"):
         args.append(i)
         continue