Skip to contentSkip to conversation

bitbake-worker: remove the network flag

PATCH Superseded [email protected] 3 participants 5 messages Sep 10, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bitbake-worker: remove the network flag

From: Randolph Sapp <[email protected]>

The network flag does not respect proxies as the fetch stage does [1]. As such it only works for some users at the whim of the recipe writer.

This introduces an issue downstream as the build results are now dependent on the network architecture of the builder, the recipe in question, and the combination of proxy variables they choose to export in addition to the normal host variables that affect builds (host tool version, build environment, etc).

This is far more indeterminate than a build system that properly exports proxy variables. If abuse of the network tag is an issue, then the network tag should be removed in it's current state.

[1] https://lists.openembedded.org/g/bitbake-devel/topic/100924096

---

The logical followup to my last patch, even if it does seem a little extreme.

 bin/bitbake-worker                                    | 11 +++++------
 .../bitbake-user-manual-metadata.rst                  |  6 ------
 2 files changed, 5 insertions(+), 12 deletions(-)
bin/bitbake-worker +5 -6
index 451e6926..71ff0516 100755
@@ -270,12 +270,11 @@ def fork_off_task(cfg, data, databuilder, workerdata, extraconfigdata, runtask):
 
                 bb.utils.set_process_name("%s:%s" % (the_data.getVar("PN"), taskname.replace("do_", "")))
 
-                if not bb.utils.to_boolean(the_data.getVarFlag(taskname, 'network')):
-                    if bb.utils.is_local_uid(uid):
-                        logger.debug("Attempting to disable network for %s" % taskname)
-                        bb.utils.disable_network(uid, gid)
-                    else:
-                        logger.debug("Skipping disable network for %s since %s is not a local uid." % (taskname, uid))
+                if bb.utils.is_local_uid(uid):
+                    logger.debug("Attempting to disable network for %s" % taskname)
+                    bb.utils.disable_network(uid, gid)
+                else:
+                    logger.debug("Skipping disable network for %s since %s is not a local uid." % (taskname, uid))
 
                 # 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 
doc/bitbake-user-manual/bitbake-user-manual-metadata.rst +0 -6
index 58975f4c..b35c332c 100644
@@ -1519,12 +1519,6 @@ functionality of the task:
    released. You can use this variable flag to accomplish mutual
    exclusion.
 
--  ``[network]``: When set to "1", allows a task to access the network. By
-   default, only the ``do_fetch`` task is granted network access. Recipes
-   shouldn't access the network outside of ``do_fetch`` as it usually
-   undermines fetcher source mirroring, image and licence manifests, software
-   auditing and supply chain security.
-
 -  ``[noexec]``: When set to "1", marks the task as being empty, with
    no execution required. You can use the ``[noexec]`` flag to set up
    tasks as dependency placeholders, or to disable tasks defined
Signature · 1 line
2.42.0
#1 lore raw

doc/bitbake-user-manual/bitbake-user-manual-metadata.rst functionality of the task: · line 1526

Quoted 5 lines · On Sun, 10 Sept 2023 at 21:15, <[email protected]> wrote:

-- ``[network]``: When set to "1", allows a task to access the network. By

doc/bitbake-user-manual/bitbake-user-manual-metadata.rst +0 -4
-   default, only the ``do_fetch`` task is granted network access. Recipes
-   shouldn't access the network outside of ``do_fetch`` as it usually
-   undermines fetcher source mirroring, image and licence manifests, software
-   auditing and supply chain security.

These reasons still stand.

The only correct solution is to write a fetcher that can be used in SRC_URI. This was communicated to you previously. So please: lay out what is it exactly you're doing outside of do_fetch that needs the network, and we'll try to figure out how to engineer it with a fetcher.

Alex

#4 lore raw
In reply to [email protected]
Quoted 15 lines · On Sun, 2023-09-10 at 14:14 -0500, [email protected] wrote:

From: Randolph Sapp <[email protected]>

The network flag does not respect proxies as the fetch stage does [1]. As such it only works for some users at the whim of the recipe writer.

This introduces an issue downstream as the build results are now dependent on the network architecture of the builder, the recipe in question, and the combination of proxy variables they choose to export in addition to the normal host variables that affect builds (host tool version, build environment, etc).

This is far more indeterminate than a build system that properly exports proxy variables. If abuse of the network tag is an issue, then the network tag should be removed in it's current state.

Quoted 6 lines

[1] https://lists.openembedded.org/g/bitbake-devel/topic/100924096

---

The logical followup to my last patch, even if it does seem a little extreme.

My logical followup is to say no, I'm not merging this. The reason is self evident.

We should ensure custom fetch code correctly accounts for proxies.

Cheers,

Richard

#2 lore raw
In reply to Alexander Kanavin
Quoted 10 lines · Alexander Kanavin

doc/bitbake-user-manual/bitbake-user-manual-metadata.rst functionality of the task: · line 1526

Quoted 5 lines · On Sun, 10 Sept 2023 at 21:15, <[email protected]> wrote:

-- ``[network]``: When set to "1", allows a task to access the network. By

doc/bitbake-user-manual/bitbake-user-manual-metadata.rst +0 -4
-   default, only the ``do_fetch`` task is granted network access. Recipes
-   shouldn't access the network outside of ``do_fetch`` as it usually
-   undermines fetcher source mirroring, image and licence manifests, software
-   auditing and supply chain security.

These reasons still stand.

Quoted 7 lines

The only correct solution is to write a fetcher that can be used in SRC_URI. This was communicated to you previously. So please: lay out what is it exactly you're doing outside of do_fetch that needs the network, and we'll try to figure out how to engineer it with a fetcher.

Alex

I'm aware of the proper solution, but this will address the issues of network flag abuse that other layers are introducing.

My issue is that by exposing the network flag like this any layer can come along an introduce build complications. If that's the case, why expose this flag at all?

Randolph

#3 lore raw
Quoted 5 lines · Randolph Sapp

I'm aware of the proper solution, but this will address the issues of network flag abuse that other layers are introducing.
My issue is that by exposing the network flag like this any layer can come along an introduce build complications. If that's the case, why expose this flag at all?

Which other layers? Do tell us, so we can recommend everyone to avoid using them.

Poorly maintained layers do insane stuff all the time. This doesn't mean we shouldn't highlight bad practices in a very clear manner, and make them complicated or impossible whenever possible.

Alex