<?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>11053</bug_id>
          
          <creation_ts>2017-02-14 17:44:22 +0000</creation_ts>
          <short_desc>insane.bbclass: Verify shebang line length valid</short_desc>
          <delta_ts>2022-07-04 16:17:22 +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>OE-Core</product>
          <component>core</component>
          <version>2.3</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>NEWCOMER</status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>Future</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Juro Bystricky">juro.bystricky</reporter>
          <assigned_to name="Paulo Neves">ptsneves</assigned_to>
          <cc>dorindabassey</cc>
    
    <cc>markus.lehtonen</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>ptsneves</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>sakib.sajal</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>70698</commentid>
    <comment_count>0</comment_count>
    <who name="Juro Bystricky">juro.bystricky</who>
    <bug_when>2017-02-14 17:44:22 +0000</bug_when>
    <thetext>The valid &quot;shebang&quot; line length is determined by linux kernel, in particular
BINPRM_BUF_SIZE in include/uapi/linux/binfmts.h:

#define BINPRM_BUF_SIZE 128


Which means that any shebang line should be shorter.
If it is not, we get all kinds of permission errors trying to run the script.
So it would make sense for sanity checks to verify the line length.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>70898</commentid>
    <comment_count>1</comment_count>
    <who name="Markus Lehtonen">markus.lehtonen</who>
    <bug_when>2017-02-23 12:19:39 +0000</bug_when>
    <thetext>Could you elaborate a bit more, what scripts are you thinking of? Any scripts bitbake runs, anything that gets installed into the image or something else?

In which kind of situation have you hit this problem? If shebang is too long your should get &quot;bad interpreter&quot; error, not a permission error, right?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>70899</commentid>
    <comment_count>2</comment_count>
    <who name="Markus Lehtonen">markus.lehtonen</who>
    <bug_when>2017-02-23 12:23:14 +0000</bug_when>
    <thetext>I should&apos;ve read the bug heading a bit better. Answering to myself: you&apos;re obviously referring to files getting installed into the image (or packaged) :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>70933</commentid>
    <comment_count>3</comment_count>
    <who name="Juro Bystricky">juro.bystricky</who>
    <bug_when>2017-02-24 17:13:12 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; I should&apos;ve read the bug heading a bit better. Answering to myself: you&apos;re
&gt; obviously referring to files getting installed into the image (or packaged)
&gt; :)

I ran into this when trying to use native easy_install. The shebang line was:

#!/data/master-multi/poky/build-pip3-native/tmp/work/x86_64-linux/python3-setuptools-native/32.1.1-r0/recipe-sysroot-native/usr/bin/env python3

which &quot;looks&quot; correct as the path exists, but too long. (The recipe needs to be fixed, but that is a different issue). This did generate permission errors due to bad interpreter. (That was a bit confusing, as the error did not say anything about bad interpreter) . 
So if sanity caught this, it would have saved me a lot of head scratching.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73276</commentid>
    <comment_count>4</comment_count>
    <who name="Markus Lehtonen">markus.lehtonen</who>
    <bug_when>2017-05-16 08:53:10 +0000</bug_when>
    <thetext>Moving this now to 2.4.

I think we should add a new test scanning all files found in the recipe recipe-sysroot-native.

In contrast to my previous comment, it should not be necessary to scan the files being installed into the target. There, the paths should always be reasonably short.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88473</commentid>
    <comment_count>5</comment_count>
    <who name="Dorinda">dorindabassey</who>
    <bug_when>2020-10-22 10:09:34 +0000</bug_when>
    <thetext>hi,
would it be wise to add a task function in the insane.bbclass that would perform the sanity check for long shebang lines like this below:

addtask do_shebangline_check before do_fetch
python do_shebangline_check(){
   #am still trying to figure this part out
   #determine if it is a shebang line
   if IFS= LC_ALL=C read -rN2 -d &apos;&apos; shebang &lt; file &amp;&amp; [ &quot;$shebang&quot; = &apos;#!&apos; ];
   then
      str = $0
      #limit the shebang line length to 80 chars
      if ${#str} &gt; 80
         echo &quot;shebang length is too long install into a directory with shorter path&quot;
      fi
   fi
}
#and export the function 
EXPORT_FUNCTIONS do_shebangline_check


some guide will be much appreciated

thanks,
Dorinda</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93406</commentid>
    <comment_count>6</comment_count>
    <who name="Paulo Neves">ptsneves</who>
    <bug_when>2022-06-06 16:09:09 +0000</bug_when>
    <thetext>@Dorinda, sorry for the late answer. Your proposal was in the end not required due to the check already existing for packages, needing only adaptations to make it also run on the staging task to fix this bug report. It can be found here [1]. It is a bit more optimized than your proposal, and does not require an extra task.

@Markus the files for the target are already scanned by [1] when packaging.

@all I submitted the following attempt at fixing it, including test:
https://lists.openembedded.org/g/openembedded-core/message/166651
https://lists.openembedded.org/g/openembedded-core/message/166652

[1] https://git.yoctoproject.org/poky/tree/meta/classes/insane.bbclass#n78</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93608</commentid>
    <comment_count>7</comment_count>
    <who name="Paulo Neves">ptsneves</who>
    <bug_when>2022-06-29 11:00:18 +0000</bug_when>
    <thetext>in master next</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93631</commentid>
    <comment_count>8</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2022-07-04 16:17:22 +0000</bug_when>
    <thetext>Master commit: https://git.openembedded.org/openembedded-core/commit/?id=280f68528c93b5ffab888c99190accf59e807a3f

Thanks Paulo!</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>