diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-12-21 17:38:30 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-01-12 21:09:39 +0000 |
commit | 0746b6a2a32fec4c18bf1a52b1454ca4c04bf543 (patch) | |
tree | 07719773221c075b49de52208e05bb3255897977 | |
parent | 9d6341df611a1725090444f6f8eb0244aed08213 (diff) | |
download | bitbake-0746b6a2a32fec4c18bf1a52b1454ca4c04bf543.tar.gz |
bitbake-worker: Add/support network task flag
This patch changes behaviour. After this change any task which does not
have the network flag set will have networking disabled on systems that
support that (kernel version dependent).
Add a "network" task specific flag which then triggers networking to
be enabled for this task, it is otherwise disabled.
This needs to happen before we enter the fakeroot environment of the task
due to the need for the real uid/gid which we save in the parent process.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-x | bin/bitbake-worker | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/bin/bitbake-worker b/bin/bitbake-worker index bf96207ed..3aaf3c244 100755 --- a/bin/bitbake-worker +++ b/bin/bitbake-worker @@ -152,6 +152,10 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, taskha fakeenv = {} umask = None + uid = os.getuid() + gid = os.getgid() + + taskdep = workerdata["taskdeps"][fn] if 'umask' in taskdep and taskname in taskdep['umask']: umask = taskdep['umask'][taskname] @@ -257,6 +261,10 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, taskha bb.utils.set_process_name("%s:%s" % (the_data.getVar("PN"), taskname.replace("do_", ""))) + if not the_data.getVarFlag(taskname, 'network', False): + logger.debug("Attempting to disable network") + bb.utils.disable_network(uid, gid) + # exported_vars() returns a generator which *cannot* be passed to os.environ.update() # successfully. We also need to unset anything from the environment which shouldn't be there exports = bb.data.exported_vars(the_data) |