diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2022-01-20 22:52:55 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-02-01 07:31:48 +0000 |
commit | d77178e8df213160d0fe58c5942507f01e7af2bd (patch) | |
tree | 7cd60ea13922e5f105856fe8afbeaf8316e95867 | |
parent | 80bddd7c36412f758f1d43036c3f4845cbc87b6c (diff) | |
download | poky-d77178e8df213160d0fe58c5942507f01e7af2bd.tar.gz |
bitbake: bitbake: bitbake-worker: Preserve network non-local uid
The NIS can't work when network is dissable, so preserve network for it, the
error is like:
do_ypcall: clnt_call: RPC: Unable to send; errno = Network is unreachable
Note, enable nscd on the build machine might be a solution, but that isn't
reliable since it depends on whether the network function has been cached or
not.
(Bitbake rev: 4eafae7904bae6e5c6bc50356e8a9077f2e207fa)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-x | bitbake/bin/bitbake-worker | 7 | ||||
-rw-r--r-- | bitbake/lib/bb/utils.py | 16 |
2 files changed, 21 insertions, 2 deletions
diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker index 3aaf3c2444..063cf37926 100755 --- a/bitbake/bin/bitbake-worker +++ b/bitbake/bin/bitbake-worker | |||
@@ -262,8 +262,11 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, taskha | |||
262 | bb.utils.set_process_name("%s:%s" % (the_data.getVar("PN"), taskname.replace("do_", ""))) | 262 | bb.utils.set_process_name("%s:%s" % (the_data.getVar("PN"), taskname.replace("do_", ""))) |
263 | 263 | ||
264 | if not the_data.getVarFlag(taskname, 'network', False): | 264 | if not the_data.getVarFlag(taskname, 'network', False): |
265 | logger.debug("Attempting to disable network") | 265 | if bb.utils.is_local_uid(uid): |
266 | bb.utils.disable_network(uid, gid) | 266 | logger.debug("Attempting to disable network for %s" % taskname) |
267 | bb.utils.disable_network(uid, gid) | ||
268 | else: | ||
269 | logger.debug("Skipping disable network for %s since %s is not a local uid." % (taskname, uid)) | ||
267 | 270 | ||
268 | # exported_vars() returns a generator which *cannot* be passed to os.environ.update() | 271 | # exported_vars() returns a generator which *cannot* be passed to os.environ.update() |
269 | # successfully. We also need to unset anything from the environment which shouldn't be there | 272 | # successfully. We also need to unset anything from the environment which shouldn't be there |
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 0312231933..128b3ab570 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -1735,3 +1735,19 @@ def environment(**envvars): | |||
1735 | os.environ[var] = backup[var] | 1735 | os.environ[var] = backup[var] |
1736 | else: | 1736 | else: |
1737 | del os.environ[var] | 1737 | del os.environ[var] |
1738 | |||
1739 | def is_local_uid(uid=''): | ||
1740 | """ | ||
1741 | Check whether uid is a local one or not. | ||
1742 | Can't use pwd module since it gets all UIDs, not local ones only. | ||
1743 | """ | ||
1744 | if not uid: | ||
1745 | uid = os.getuid() | ||
1746 | with open('/etc/passwd', 'r') as f: | ||
1747 | for line in f: | ||
1748 | line_split = line.split(':') | ||
1749 | if len(line_split) < 3: | ||
1750 | continue | ||
1751 | if str(uid) == line_split[2]: | ||
1752 | return True | ||
1753 | return False | ||