diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-11-22 16:11:45 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-11-26 17:01:08 +0000 |
commit | 8dd0a45c858290288e1a1fef046b5cfcf7ff6257 (patch) | |
tree | f6010033f1e8b3b7a7b943e00057dacbabf8d306 /scripts/nativesdk-intercept | |
parent | 44a3909bf61a29d279a5a0a23d62cb9b0fdd3b52 (diff) | |
download | poky-8dd0a45c858290288e1a1fef046b5cfcf7ff6257.tar.gz |
nativesdk: Handle chown/chgrp calls in nativesdk do_install tasks
We disable the useradd code for nativesdk targets since we don't support
postinstalls or multiple users in those cases. This means any usage
of chown/chgrp inside do_install tasks won't work and would have to be
conditional. Rather than require all recipes to do that, add intercepts
of the calls and map those to root/root user/groups. We can't just ignore
them as some calls are used to remove host contamination from the host
user ID so they need to be made, just as root.
(From OE-Core rev: e1f40670c438e33cae87678425de72ca03566888)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/nativesdk-intercept')
-rwxr-xr-x | scripts/nativesdk-intercept/chgrp | 27 | ||||
-rwxr-xr-x | scripts/nativesdk-intercept/chown | 27 |
2 files changed, 54 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 | |||
5 | import os | ||
6 | import shutil | ||
7 | import sys | ||
8 | |||
9 | # calculate path to the real 'chgrp' | ||
10 | path = os.environ['PATH'] | ||
11 | path = path.replace(os.path.dirname(sys.argv[0]), '') | ||
12 | real_chgrp = shutil.which('chgrp', path=path) | ||
13 | |||
14 | args = list() | ||
15 | |||
16 | found = False | ||
17 | for 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 | |||
27 | os.execv(real_chgrp, args) | ||
diff --git a/scripts/nativesdk-intercept/chown b/scripts/nativesdk-intercept/chown new file mode 100755 index 0000000000..3914b3e384 --- /dev/null +++ b/scripts/nativesdk-intercept/chown | |||
@@ -0,0 +1,27 @@ | |||
1 | #!/usr/bin/env python3 | ||
2 | # | ||
3 | # Wrapper around 'chown' that redirects to root in all cases | ||
4 | |||
5 | import os | ||
6 | import shutil | ||
7 | import sys | ||
8 | |||
9 | # calculate path to the real 'chown' | ||
10 | path = os.environ['PATH'] | ||
11 | path = path.replace(os.path.dirname(sys.argv[0]), '') | ||
12 | real_chown = shutil.which('chown', path=path) | ||
13 | |||
14 | args = list() | ||
15 | |||
16 | found = False | ||
17 | for i in sys.argv: | ||
18 | if i.startswith("-"): | ||
19 | args.append(i) | ||
20 | continue | ||
21 | if not found: | ||
22 | args.append("root:root") | ||
23 | found = True | ||
24 | else: | ||
25 | args.append(i) | ||
26 | |||
27 | os.execv(real_chown, args) | ||