<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>14848</bug_id>
          
          <creation_ts>2022-06-28 19:48:02 +0000</creation_ts>
          <short_desc>regression: sudo command in recipe not working anymore in kirkstone</short_desc>
          <delta_ts>2022-06-30 16:16:32 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>BitBake</product>
          <component>bitbake</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Undecided</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Marc Haesen">marc.haesen</reporter>
          <assigned_to name="Richard Purdie">richard.purdie</assigned_to>
          <cc>marc.haesen</cc>
    
    <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>93603</commentid>
    <comment_count>0</comment_count>
    <who name="Marc Haesen">marc.haesen</who>
    <bug_when>2022-06-28 19:48:02 +0000</bug_when>
    <thetext>I have a recipe calling sudo which is working in yocto honister. When switched to kirkstone, the recipe gives errors executing the sudo command inside a task.
After some debugging, I found it is caused by the addition of calling the disable_network (bitbake/lib/bb/utils.py) function.

Applying the following patch solves the problem:

diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index d11da978d7..7410e040bb 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -1608,8 +1608,6 @@ def disable_network(uid=None, gid=None):
     libc = ctypes.CDLL(&apos;libc.so.6&apos;)

     # From sched.h
-    # New user namespace
-    CLONE_NEWUSER = 0x10000000
     # New network namespace
     CLONE_NEWNET = 0x40000000

@@ -1618,7 +1616,7 @@ def disable_network(uid=None, gid=None):
     if gid is None:
         gid = os.getgid()

-    ret = libc.unshare(CLONE_NEWNET | CLONE_NEWUSER)
+    ret = libc.unshare(CLONE_NEWNET)
     if ret != 0:
         logger.debug(&quot;System doesn&apos;t suport disabling network without admin privs&quot;)
         return</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93614</commentid>
    <comment_count>1</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2022-06-30 14:36:41 +0000</bug_when>
    <thetext>
Firstly, using sudo in a recipe is horrible. I&apos;d suggest you just disable the network isolation if you really want/have to do this with:

do_mytask[network] = &quot;1&quot;

See the migration notes for kirkstone for info on that:

https://docs.yoctoproject.org/migration-guides/migration-4.0.html#fetching-ch

From memory we need the namespace piece to have this work with normal user privileges so we can&apos;t/won&apos;t change this as mentioned.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93627</commentid>
    <comment_count>2</comment_count>
    <who name="Marc Haesen">marc.haesen</who>
    <bug_when>2022-06-30 16:16:32 +0000</bug_when>
    <thetext>I agree that sudo should not be used in a recipe, but I am creating an encrypted disc-image with cryptsetup using a loop device. For this you need sudo rights.
If you known another way of creating an encrypted disc image without the need of root rights, I would be very glad.

But the workaround with do_mytask[network] = &quot;1&quot; works for me to.

Thanks anyhow.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>