Files
poky/scripts/nativesdk-intercept/chgrp
Richard Purdie e22da98e79 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: a05c116c517e0700837c335d0691c3fcc4462dda)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit e1f40670c438e33cae87678425de72ca03566888)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-02-24 16:41:42 +00:00

28 lines
529 B
Python
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
for i in sys.argv:
if i.startswith("-"):
args.append(i)
continue
if not found:
args.append("root")
found = True
else:
args.append(i)
os.execv(real_chgrp, args)