From d77178e8df213160d0fe58c5942507f01e7af2bd Mon Sep 17 00:00:00 2001 From: Robert Yang Date: Thu, 20 Jan 2022 22:52:55 -0800 Subject: 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 Signed-off-by: Richard Purdie --- bitbake/lib/bb/utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'bitbake/lib/bb/utils.py') 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): os.environ[var] = backup[var] else: del os.environ[var] + +def is_local_uid(uid=''): + """ + Check whether uid is a local one or not. + Can't use pwd module since it gets all UIDs, not local ones only. + """ + if not uid: + uid = os.getuid() + with open('/etc/passwd', 'r') as f: + for line in f: + line_split = line.split(':') + if len(line_split) < 3: + continue + if str(uid) == line_split[2]: + return True + return False -- cgit v1.2.3-54-g00ecf