<?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>7724</bug_id>
          
          <creation_ts>2015-05-06 18:38:24 +0000</creation_ts>
          <short_desc>useradd.bbclass users cannot be safely referred to by dependent recipes due to sstate-induced race with base-passwd</short_desc>
          <delta_ts>2017-04-13 17:52:37 +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>1.7</version>
          <rep_platform>All</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>TC needed</status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>2.4 M1</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Richard Tollerton">rich.tollerton</reporter>
          <assigned_to name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</assigned_to>
          <cc>alexandru.c.georgescu</cc>
    
    <cc>ben.shelton</cc>
    
    <cc>bluelightning</cc>
    
    <cc>haris.okanovic</cc>
    
    <cc>jose.a.lamego</cc>
    
    <cc>juan.m.cruz.alcaraz</cc>
    
    <cc>leonardo.sandoval.gonzalez</cc>
    
    <cc>maxin.john</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>rich.tollerton</cc>
    
    <cc>richard.purdie</cc>
          
          <qa_contact name="Costin">costin.c.constantin</qa_contact>
          <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>50831</commentid>
    <comment_count>0</comment_count>
    <who name="Richard Tollerton">rich.tollerton</who>
    <bug_when>2015-05-06 18:38:24 +0000</bug_when>
    <thetext>I have observed an organic situation today (not doing anything wrong AFAIK) where
- base-passwd gets rebuilt due to a nominally unrelated change (specifically adding a couple of CVS patches to the glibc build)
- a useradd.bbclass-inheriting package does *not* get rebuilt, and its setscene runs before base-passwd gets rebuilt
- a dependent package fails because the new user is missing from /etc/passwd

This build failure is persistent; it will continue until the useradd-inheriting recipe gets force-rebuilt. (Also note that this recipe will not appear in the build failure logs.)

AFAIK, the root problem seems to be that if base-passwd repopulates sysroot and a useradd package is cached, there isn&apos;t anything that forces useradd_preint() to be run again.


To reproduce:

1) Build a clean openembedded-core (I built core-image-minimal from master)
2) Create meta/recipes-core/useraddtest-a.bb:

SUMMARY = &quot;useradd test A&quot;
LICENSE = &quot;MIT&quot;
LIC_FILES_CHKSUM = &quot;file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \
                    file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420&quot;

ALLOW_EMPTY_${PN} = &quot;1&quot;
inherit allarch useradd
USERADD_PACKAGES = &quot;${PN}&quot;

GROUPADD_PARAM_${PN} = &quot; --system foo&quot;
USERADD_PARAM_${PN} = &quot;-N -g foo foo&quot;



3) Create meta/recipes-core/useraddtest-b_1.0.bb:

DEPENDS += &quot;useraddtest-a&quot;
LICENSE = &quot;MIT&quot;
LIC_FILES_CHKSUM = &quot;file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \
                    file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420&quot;

FILES_${PN} = &quot;${datadir}/foo&quot;

do_install () {
	   mkdir -p ${D}${datadir}
	   echo foo &gt; ${D}${datadir}/foo
	   chown foo:foo ${D}${datadir}/foo
}


4) Set CORE_IMAGE_EXTRA_INSTALL=&quot;useraddtest-b&quot; in local.conf.
5) Rebuild core-image-minimal.
6) Make trivial changes to *both* meta/recipes-core/base-passwd/base-passwd_3.5.29.bb and meta/recipes-core/useraddtest/useraddtest-b_1.0.bb to invalidate their sstate caches and trigger a rebuild. For base-passwd_3.5.29.bb, I added a space between URIs in SRC_URI. For useraddtest-b_1.0.bb, I changed &quot;echo foo&quot; to &quot;echo foo2&quot;.
7) Rebuild core-image-minimal. This will fail with the following error:

Log data follows:
| DEBUG: Executing shell function do_install
| chown: invalid user: &apos;foo:foo&apos;
| WARNING: /ssd/rtollert/oe-core-build/tmp-glibc/work/i586-oe-linux/useraddtest-b/1.0-r0/temp/run.do_install.15042:1 exit 1 from
|   chown foo:foo /ssd/rtollert/oe-core-build/tmp-glibc/work/i586-oe-linux/useraddtest-b/1.0-r0/image/usr/share/foo
| ERROR: Function failed: do_install (log file is located at /ssd/rtollert/oe-core-build/tmp-glibc/work/i586-oe-linux/useraddtest-b/1.0-r0/temp/log.do_install.15042)
ERROR: Task 261 (/mnt/rtollert/src/openembedded-core/meta/recipes-core/useraddtest/useraddtest-b_1.0.bb, do_install) failed with exit code &apos;1&apos;


Workarounds:

- Invalidate sstate cache of useradd-inheriting package
- Delete sstate cache
- Avoid referring to users/groups created by useradd-inheriting packages in other packages. (This may not be possible depending on the situation.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50854</commentid>
    <comment_count>1</comment_count>
    <who name="Saul Wold">sgw</who>
    <bug_when>2015-05-07 15:07:16 +0000</bug_when>
    <thetext>Please assign to someone in GDC to become new owner for useradd issues, this also needs unit tests.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51806</commentid>
    <comment_count>2</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2015-06-18 19:04:05 +0000</bug_when>
    <thetext>Patch is now on master: 5d426794f9a9d3ca4ffd21b0c5a300e3daeef4b9</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55744</commentid>
    <comment_count>3</comment_count>
    <who name="Costin">costin.c.constantin</who>
    <bug_when>2015-10-26 14:31:04 +0000</bug_when>
    <thetext>Hello,

Just tested this on latest master:

on an Ubuntu machine: 505a82673ac2487df5ea343a6422c2fc47018831

I followed comment#1 directions and i get the same error message as described:

~/costin-poky/build$ bitbake core-image-minimal
...
NOTE: Executing RunQueue Tasks
ERROR: Function failed: do_install (log file is located at /home/autobuilder/costin-poky/build/tmp/work/i586-poky-linux/useraddtestb/1.0-r0/temp/log.do_install.22591)
ERROR: Logfile of failure stored in: /home/autobuilder/costin-poky/build/tmp/work/i586-poky-linux/useraddtestb/1.0-r0/temp/log.do_install.22591
Log data follows:
| DEBUG: Executing shell function do_install
| chown: invalid user: &apos;foo:foo&apos;
| WARNING: exit code 1 from a shell command.
| ERROR: Function failed: do_install (log file is located at /home/autobuilder/costin-poky/build/tmp/work/i586-poky-linux/useraddtestb/1.0-r0/temp/log.do_install.22591)
ERROR: Task 256 (/home/autobuilder/costin-poky/meta/recipes-core/useradd_tests/useraddtestb.bb, do_install) failed with exit code &apos;1&apos;
NOTE: Tasks Summary: Attempted 2023 tasks of which 2017 didn&apos;t need to be rerun and 1 failed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55768</commentid>
    <comment_count>4</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2015-10-26 16:20:25 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; Hello,
&gt; 
&gt; Just tested this on latest master:
&gt; 
&gt; on an Ubuntu machine: 505a82673ac2487df5ea343a6422c2fc47018831
&gt; 
&gt; I followed comment#1 directions and i get the same error message as
&gt; described:
&gt; 

there must be something on a configuration file that do not match between mine and yours. I just created a core image with those two recipes included, started from a clean tmp folder, and did not notice anything bad after baking. I have pushed my dev branch on 

http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=lsandov1/useradd

can you give it a try on a clean tmp folder? You can either use my branch or use yours, it should not matter. In the other hand, this is how my local.conf looks like

MACHINE ??= &quot;qemux86-64&quot;
DISTRO ?= &quot;poky&quot;
PACKAGE_CLASSES ?= &quot;package_rpm package_ipk package_deb&quot;
EXTRA_IMAGE_FEATURES = &quot;debug-tweaks&quot;
USER_CLASSES ?= &quot;buildstats image-mklibs image-prelink&quot;
BB_DISKMON_DIRS = &quot;\
    STOPTASKS,${TMPDIR},1G,100K \
    STOPTASKS,${DL_DIR},1G,100K \
    STOPTASKS,${SSTATE_DIR},1G,100K \
    ABORT,${TMPDIR},100M,1K \
    ABORT,${DL_DIR},100M,1K \
    ABORT,${SSTATE_DIR},100M,1K&quot; 
PACKAGECONFIG_append_pn-qemu-native = &quot; sdl&quot;
PACKAGECONFIG_append_pn-nativesdk-qemu = &quot; sdl&quot;
ASSUME_PROVIDED += &quot;libsdl-native&quot;
CONF_VERSION = &quot;1&quot;
INHERIT += &quot;own-mirrors&quot;
SSTATE_MIRRORS ?= &quot;file://.* http://yocto-ab-master.jf.intel.com/sstate/PATH&quot;
SOURCE_MIRROR_URL ?= &quot;file:///srv/current_sources&quot;

CORE_IMAGE_EXTRA_INSTALL = &quot;useraddtest-b&quot;



&gt; ~/costin-poky/build$ bitbake core-image-minimal
&gt; ...
&gt; NOTE: Executing RunQueue Tasks
&gt; ERROR: Function failed: do_install (log file is located at
&gt; /home/autobuilder/costin-poky/build/tmp/work/i586-poky-linux/useraddtestb/1.
&gt; 0-r0/temp/log.do_install.22591)
&gt; ERROR: Logfile of failure stored in:
&gt; /home/autobuilder/costin-poky/build/tmp/work/i586-poky-linux/useraddtestb/1.
&gt; 0-r0/temp/log.do_install.22591
&gt; Log data follows:
&gt; | DEBUG: Executing shell function do_install
&gt; | chown: invalid user: &apos;foo:foo&apos;
&gt; | WARNING: exit code 1 from a shell command.
&gt; | ERROR: Function failed: do_install (log file is located at
&gt; /home/autobuilder/costin-poky/build/tmp/work/i586-poky-linux/useraddtestb/1.
&gt; 0-r0/temp/log.do_install.22591)
&gt; ERROR: Task 256
&gt; (/home/autobuilder/costin-poky/meta/recipes-core/useradd_tests/useraddtestb.
&gt; bb, do_install) failed with exit code &apos;1&apos;
&gt; NOTE: Tasks Summary: Attempted 2023 tasks of which 2017 didn&apos;t need to be
&gt; rerun and 1 failed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56441</commentid>
    <comment_count>5</comment_count>
    <who name="Saul Wold">sgw</who>
    <bug_when>2015-11-12 16:31:30 +0000</bug_when>
    <thetext>It appears that Leo assigned this to Constin to check an updated version in a private branch, please take a look.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56448</commentid>
    <comment_count>6</comment_count>
    <who name="Stephen K Jolley">sjolley.yp.pm</who>
    <bug_when>2015-11-12 18:33:49 +0000</bug_when>
    <thetext>Question asked.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57139</commentid>
    <comment_count>7</comment_count>
    <who name="Haris Okanovic">haris.okanovic</who>
    <bug_when>2015-12-08 23:35:02 +0000</bug_when>
    <thetext>*** Bug 8759 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57743</commentid>
    <comment_count>8</comment_count>
    <who name="Costin">costin.c.constantin</who>
    <bug_when>2016-01-12 13:51:49 +0000</bug_when>
    <thetext>Hi Leo,

Sorry for the late reply.

I just re-tested this and still get the same output as on comment #3.

This time i did everything on a clean env. by freshly cloning poky. The only things that may relate to something already existing are these two lines i use to speed up build in local.conf:
...
DL_DIR ?= &quot;/media/sstate/downloads&quot;
SSTATE_DIR ?= &quot;/media/sstate&quot;
...

The rest stays the same as when clone done.
My build screen looks like this:

BB_VERSION        = &quot;1.28.0&quot;
BUILD_SYS         = &quot;x86_64-linux&quot;
NATIVELSBSTRING   = &quot;Ubuntu-15.04&quot;
TARGET_SYS        = &quot;i686-poky-linux&quot;
MACHINE           = &quot;genericx86&quot;
DISTRO            = &quot;poky&quot;
...     
meta-yocto-bsp    = &quot;master:1724ffd32d1c169a2de66f2cb88ba18c56da6146&quot;


I will give it a shot without sstate and downloads remote dirs. Will post the result of that shortly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57747</commentid>
    <comment_count>9</comment_count>
    <who name="Costin">costin.c.constantin</who>
    <bug_when>2016-01-12 14:53:59 +0000</bug_when>
    <thetext>Hi,

Did the same as per last comment without external DL_DIR and SSTATE_DIR and got the same issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58686</commentid>
    <comment_count>10</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2016-02-05 22:00:59 +0000</bug_when>
    <thetext>Missed 2.0.1. Moved to 2.0.2</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60806</commentid>
    <comment_count>11</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2016-04-05 15:20:53 +0000</bug_when>
    <thetext>Problem is indeed present on current master [1], although problem is reported for 2.0.2. Working on it.

[1]
commit 1ca71e5178ed8514655524f714877e02f6db90af
Refs: {origin/HEAD}, {origin/master}, 2.1_M1-2261-g1ca71e5
Author:     Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;
AuthorDate: Tue Mar 29 16:09:52 2016 +0100</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60823</commentid>
    <comment_count>12</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2016-04-05 21:34:05 +0000</bug_when>
    <thetext>The error show is actually expected: the reason is that the useraddtest-b change does not trigger the prefunc do_install function which actually add the groups and users needed. 

Under this scenario, the task useraddtest-a&apos;s do_install must be tainted, so when building core-image-minimal again (including useraddtest-b), useraddtest-a&apos;s do_install (and its prefunc) is executed, then useraddtest-b is built again and properly added into the final image.

These are the commands to be used for this scenario once [1] is done:

bitbake -f -c install useraddtest-a
bitbake core-image-minimal


[1] https://bugzilla.yoctoproject.org/show_bug.cgi?id=7724#c0</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60825</commentid>
    <comment_count>13</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2016-04-05 21:52:24 +0000</bug_when>
    <thetext>Reopening to review the current status and the proposed workaround.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60963</commentid>
    <comment_count>14</comment_count>
    <who name="Maxin B. John">maxin.john</who>
    <bug_when>2016-04-08 07:58:52 +0000</bug_when>
    <thetext>(In reply to comment #12)
&gt; The error show is actually expected: the reason is that the useraddtest-b
&gt; change does not trigger the prefunc do_install function which actually add
&gt; the groups and users needed. 
&gt; 
&gt; Under this scenario, the task useraddtest-a&apos;s do_install must be tainted, so
&gt; when building core-image-minimal again (including useraddtest-b),
&gt; useraddtest-a&apos;s do_install (and its prefunc) is executed, then useraddtest-b
&gt; is built again and properly added into the final image.
&gt; 
&gt; These are the commands to be used for this scenario once [1] is done:
&gt; 
&gt; bitbake -f -c install useraddtest-a
&gt; bitbake core-image-minimal
&gt; 
&gt; 
&gt; [1] https://bugzilla.yoctoproject.org/show_bug.cgi?id=7724#c0


Almost the same observation for similar scenario in Bug #8078. 
It can be achieved by adding the below line in useradd.bbclass.

do_install[nostamp] = &quot;1&quot;

However, this causes longer rebuild time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60981</commentid>
    <comment_count>15</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2016-04-08 17:16:07 +0000</bug_when>
    <thetext>
&gt; Almost the same observation for similar scenario in Bug #8078. 
&gt; It can be achieved by adding the below line in useradd.bbclass.
&gt; 
&gt; do_install[nostamp] = &quot;1&quot;

Right, that is another option.

&gt; 
&gt; However, this causes longer rebuild time.


The reason of this behavior was introduced by this commit:

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=0aed04a49ec13c3331169ca4fd2c820b03faf19c</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60982</commentid>
    <comment_count>16</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2016-04-08 17:24:39 +0000</bug_when>
    <thetext>To give some better information about what is going on here, the issue is that base-passwd is listed in layer.conf in SIGGEN_EXCLUDERECIPES_ABISAFE. This was done since base-passwd is not allarch and without this, you couldn&apos;t have an allarch recipe which added users.

If we agree that allarch recipes shouldn&apos;t be able to add users, you could revert that however I suspect people would have some issues with that.

The next solution could be to save copies of the original master/group entries, then upon sstate uninstall, remove these, upon addition, add in the new entries and never overwrite the files completely.

Another option would be to find some cleverer way of handling  SIGGEN_EXCLUDERECIPES_ABISAFE such that some types of changes are reflected in the sstate hash but I can&apos;t see a way to make this work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61527</commentid>
    <comment_count>17</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2016-04-21 19:00:34 +0000</bug_when>
    <thetext>This problem could not be resolved on time, so moving it to 2.2 M1. Also, it is present on jethro AND master (krogoth).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>70022</commentid>
    <comment_count>18</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2017-01-23 15:56:48 +0000</bug_when>
    <thetext>I&apos;d suggest this is retested now recipe specific sysroots has merged as I&apos;m hoping this solves the problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71832</commentid>
    <comment_count>19</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2017-03-28 21:10:17 +0000</bug_when>
    <thetext>Following the steps on current HEAD, now the error is produced on step 4 with the following log:

| NOTE: gettext-minimal-native exists in sysroot, skipping
| DEBUG: Python function extend_recipe_sysroot finished
| DEBUG: Executing shell function do_install
| chown: invalid user: ‘foo:foo’
| WARNING: /home/lsandov1/poky/build/tmp/work/i586-poky-linux/useraddtest-b/1.0-r0/temp/run.do_install.48180:1 exit 1 from &apos;chown foo:foo /home/lsandov1/poky/build/tmp/work/i586-poky-linux/useraddtest-b/1.0-r0/image/usr/share/foo&apos;
| ERROR: Function failed: do_install (log file is located at /home/lsandov1/poky/build/tmp/work/i586-poky-linux/useraddtest-b/1.0-r0/temp/log.do_install.48180)
ERROR: Task (/home/lsandov1/poky/meta-useradd/recipes-core/useradd/useraddtest-b_1.0.bb:do_install) failed with exit code &apos;1&apos;
NOTE: Tasks Summary: Attempted 2404 tasks of which 2396 didn&apos;t need to be rerun and 1 failed.

Summary: 1 task failed:
  /home/lsandov1/poky/meta-useradd/recipes-core/useradd/useraddtest-b_1.0.bb:do_install
Summary: There was 1 ERROR message shown, returning a non-zero exit code.

next step is to check if this is expected base on comment 18</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71911</commentid>
    <comment_count>20</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2017-03-30 15:11:14 +0000</bug_when>
    <thetext>useradd related issues will be targeted at 2.4, so moving it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>72485</commentid>
    <comment_count>21</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2017-04-13 17:52:37 +0000</bug_when>
    <thetext>Fixed by [1]. For further reference [2], the useradd test recipes were created as provided in the comment 0 but 1) including a base folder (useradd) and including DEPENDS += &quot;shadow-native&quot; on the b recipe.

[1] http://lists.openembedded.org/pipermail/openembedded-core/2017-April/135611.html

[2] http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=lsandov1/useradd-bug7724-scenario</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>