<?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>9262</bug_id>
          
          <creation_ts>2016-03-15 13:43:36 +0000</creation_ts>
          <short_desc>useradd class doesn&apos;t clean properly</short_desc>
          <delta_ts>2016-05-04 11:50:56 +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>unspecified</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></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>2.1 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Gary Thomas">gary</reporter>
          <assigned_to name="Maxin B. John">maxin.john</assigned_to>
          <cc>jku</cc>
    
    <cc>maxin.baby.john</cc>
    
    <cc>maxin.john</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>valentinx.hangan</cc>
          
          <qa_contact name="Valentin Hangan">valentinx.hangan</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>59972</commentid>
    <comment_count>0</comment_count>
    <who name="Gary Thomas">gary</who>
    <bug_when>2016-03-15 13:43:36 +0000</bug_when>
    <thetext>If a recipe is built that creates user(s) via useradd.bbclass, those users are not removed (at least from sysroot) when the recipe/package is cleaned, even using cleanall.

This can lead to confusion, in particular if the recipe is changed in a way that affects how the user(s) are created because they won&apos;t be recreated when the recipe is rebuilt.  For example if the recipe creates a user with no explicit --uid/--gid parameters, those parameters will be ignored if they are later added to the recipe and rebuilt.

Note: this may also be related to bug #7724</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>59999</commentid>
    <comment_count>1</comment_count>
    <who name="Jussi Kukkonen">jku</who>
    <bug_when>2016-03-16 08:19:30 +0000</bug_when>
    <thetext>Maxin was just looking at this or something very much like it -- CCing just in case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60003</commentid>
    <comment_count>2</comment_count>
    <who name="Maxin B. John">maxin.john</who>
    <bug_when>2016-03-16 11:12:40 +0000</bug_when>
    <thetext>Fedora User account handling policy says:
( https://fedoraproject.org/wiki/Packaging:UsersAndGroups )
&quot;
Do not remove users or groups

We never remove users or groups created by packages. There&apos;s no sane way to check if files owned by those users/groups are left behind (and even if there would, what would we do with them?) and leaving those behind with ownerships pointing to now nonexistent users/groups may result in security issues when a semantically unrelated user/group is created later and reuses the UID/GID. Also, in some setups deleting the user/group might not be possible or/nor desirable (eg. when using a shared, remote user/group database). Cleanup of unused users/groups is left to the system administrators to take care of if they so desire.
&quot;

Debian also has similar policy:
( https://wiki.debian.org/AccountHandlingInMaintainerScripts )

&quot;
Technical Issues of account removal 

Deleting an account is significantly harder than creating it because of the following reasons:

at package purge time, a package can no longer rely on its dependencies being installed
the local admin might have decided to chown unrelated files to the package account
if we remove the account on purge, it is possible that the UID will be re-used at some later time
&quot;

Also Yocto #8078 describes a use-case where &quot;Package A&quot; depends on user created by &quot;Package B&quot;. If we remove the user along with &quot;Package B&quot;, then, we might end up with a broken &quot;Package A&quot; in the device.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60004</commentid>
    <comment_count>3</comment_count>
    <who name="Gary Thomas">gary</who>
    <bug_when>2016-03-16 11:27:30 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; Fedora User account handling policy says:
&gt; ( https://fedoraproject.org/wiki/Packaging:UsersAndGroups )
&gt; &quot;
&gt; Do not remove users or groups
&gt; 
&gt; We never remove users or groups created by packages. There&apos;s no sane way to
&gt; check if files owned by those users/groups are left behind (and even if
&gt; there would, what would we do with them?) and leaving those behind with
&gt; ownerships pointing to now nonexistent users/groups may result in security
&gt; issues when a semantically unrelated user/group is created later and reuses
&gt; the UID/GID. Also, in some setups deleting the user/group might not be
&gt; possible or/nor desirable (eg. when using a shared, remote user/group
&gt; database). Cleanup of unused users/groups is left to the system
&gt; administrators to take care of if they so desire.
&gt; &quot;
&gt; 
&gt; Debian also has similar policy:
&gt; ( https://wiki.debian.org/AccountHandlingInMaintainerScripts )
&gt; 
&gt; &quot;
&gt; Technical Issues of account removal 
&gt; 
&gt; Deleting an account is significantly harder than creating it because of the
&gt; following reasons:
&gt; 
&gt; at package purge time, a package can no longer rely on its dependencies
&gt; being installed
&gt; the local admin might have decided to chown unrelated files to the package
&gt; account
&gt; if we remove the account on purge, it is possible that the UID will be
&gt; re-used at some later time
&gt; &quot;
&gt; 
&gt; Also Yocto #8078 describes a use-case where &quot;Package A&quot; depends on user
&gt; created by &quot;Package B&quot;. If we remove the user along with &quot;Package B&quot;, then,
&gt; we might end up with a broken &quot;Package A&quot; in the device.

So how does one handle the scenario as described?  It seems a bit harsh to have to wipe &quot;tmp&quot; and start over, if that even works...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60007</commentid>
    <comment_count>4</comment_count>
    <who name="Gary Thomas">gary</who>
    <bug_when>2016-03-16 12:20:14 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; (In reply to comment #2)
&gt; &gt; Fedora User account handling policy says:
&gt; &gt; ( https://fedoraproject.org/wiki/Packaging:UsersAndGroups )
&gt; &gt; &quot;
&gt; &gt; Do not remove users or groups
&gt; &gt; 
&gt; &gt; We never remove users or groups created by packages. There&apos;s no sane way to
&gt; &gt; check if files owned by those users/groups are left behind (and even if
&gt; &gt; there would, what would we do with them?) and leaving those behind with
&gt; &gt; ownerships pointing to now nonexistent users/groups may result in security
&gt; &gt; issues when a semantically unrelated user/group is created later and reuses
&gt; &gt; the UID/GID. Also, in some setups deleting the user/group might not be
&gt; &gt; possible or/nor desirable (eg. when using a shared, remote user/group
&gt; &gt; database). Cleanup of unused users/groups is left to the system
&gt; &gt; administrators to take care of if they so desire.
&gt; &gt; &quot;
&gt; &gt; 
&gt; &gt; Debian also has similar policy:
&gt; &gt; ( https://wiki.debian.org/AccountHandlingInMaintainerScripts )
&gt; &gt; 
&gt; &gt; &quot;
&gt; &gt; Technical Issues of account removal 
&gt; &gt; 
&gt; &gt; Deleting an account is significantly harder than creating it because of the
&gt; &gt; following reasons:
&gt; &gt; 
&gt; &gt; at package purge time, a package can no longer rely on its dependencies
&gt; &gt; being installed
&gt; &gt; the local admin might have decided to chown unrelated files to the package
&gt; &gt; account
&gt; &gt; if we remove the account on purge, it is possible that the UID will be
&gt; &gt; re-used at some later time
&gt; &gt; &quot;
&gt; &gt; 
&gt; &gt; Also Yocto #8078 describes a use-case where &quot;Package A&quot; depends on user
&gt; &gt; created by &quot;Package B&quot;. If we remove the user along with &quot;Package B&quot;, then,
&gt; &gt; we might end up with a broken &quot;Package A&quot; in the device.
&gt; 
&gt; So how does one handle the scenario as described?  It seems a bit harsh to
&gt; have to wipe &quot;tmp&quot; and start over, if that even works...

To follow up on this, OE is not Debian nor Fedora.  What I mean is that in those environments, single packages are built and the build system knows nothing of package interdependencies.  OE on the other hand knows all about such things and it should be no big problem that if a package causes the removal of a user/group ID then any dependent packages would be also marked appropriately so they will be rebuilt/reinstalled.  I don&apos;t know how &quot;hard&quot; this is to make happen, but the fact that it can be done and it makes the build system more &quot;correct&quot;, then that&apos;s how it should behave.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60075</commentid>
    <comment_count>5</comment_count>
    <who name="Maxin B. John">maxin.john</who>
    <bug_when>2016-03-17 12:29:22 +0000</bug_when>
    <thetext>(In reply to comment #3)

&gt; 
&gt; So how does one handle the scenario as described?  It seems a bit harsh to
&gt; have to wipe &quot;tmp&quot; and start over, if that even works...

We don&apos;t need to wipe &quot;tmp&quot; directory for that. 
# bitbake -c cleansstate base-passwd

should do it. However,that method also has some problems at the moment(Please see bug #8759)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60208</commentid>
    <comment_count>6</comment_count>
      <attachid>3049</attachid>
    <who name="Maxin B. John">maxin.john</who>
    <bug_when>2016-03-21 15:18:24 +0000</bug_when>
    <thetext>Created attachment 3049
userdel_sysroot_sstate patch

This patch provides a function which cleans-up users/groups during cleansstate/cleanall task.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60209</commentid>
    <comment_count>7</comment_count>
    <who name="Maxin B. John">maxin.john</who>
    <bug_when>2016-03-21 15:21:24 +0000</bug_when>
    <thetext>Please let me know if this is an acceptable fix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60268</commentid>
    <comment_count>8</comment_count>
    <who name="Gary Thomas">gary</who>
    <bug_when>2016-03-22 07:33:27 +0000</bug_when>
    <thetext>(In reply to comment #7)
&gt; Please let me know if this is an acceptable fix.

Yes, this does seem to solve the issue I was having.  I created my package then reran bitbake after altering the useradd settings in the recipe and the changes worked as desired unlike before where nothing happened the second time around.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60270</commentid>
    <comment_count>9</comment_count>
    <who name="Maxin B. John (inactive)">maxin.baby.john</who>
    <bug_when>2016-03-22 08:57:24 +0000</bug_when>
    <thetext>(In reply to comment #8)
&gt; (In reply to comment #7)
&gt; &gt; Please let me know if this is an acceptable fix.
&gt; 
&gt; Yes, this does seem to solve the issue I was having.  I created my package
&gt; then reran bitbake after altering the useradd settings in the recipe and the
&gt; changes worked as desired unlike before where nothing happened the second
&gt; time around.

Thanks a lot!

Fix sent to oe-core mailing list:
http://lists.openembedded.org/pipermail/openembedded-core/2016-March/119264.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60600</commentid>
    <comment_count>10</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2016-03-31 14:06:07 +0000</bug_when>
    <thetext>We really need to have this removal code run at any of the points sstate_clean() is called. This means the user would be removed for do_clean, when a version is upgraded and the sysroot is cleaned out during do_configure and so on. I talked with Maxin about this and have some pointers as to how we might be able to add some hooks to sstate_clean to make this work. If we don&apos;t do this, I worry we&apos;ll only fix the issue for some cases and not all.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60786</commentid>
    <comment_count>11</comment_count>
    <who name="Maxin B. John">maxin.john</who>
    <bug_when>2016-04-05 07:36:38 +0000</bug_when>
    <thetext>v2 sent to oe-core ML:
http://lists.openembedded.org/pipermail/openembedded-core/2016-April/119879.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60885</commentid>
    <comment_count>12</comment_count>
    <who name="Maxin B. John">maxin.john</who>
    <bug_when>2016-04-07 07:55:25 +0000</bug_when>
    <thetext>http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=cbe33ecb15f71737354184cd9f3b7507ab97b2e4</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>3049</attachid>
            <date>2016-03-21 15:18:24 +0000</date>
            <delta_ts>2016-03-21 15:18:24 +0000</delta_ts>
            <desc>userdel_sysroot_sstate patch</desc>
            <filename>0001-useradd.bbclass-remove-user-group-created-by-the-pac.patch</filename>
            <type>text/plain</type>
            <size>2168</size>
            <attacher name="Maxin B. John">maxin.john</attacher>
            
              <data encoding="base64">RnJvbSBiMWRiZjhjYzdjMTNjYTM1MWFmYzYxMTNhZGNhODJjODExOWEzMTdmIE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiAiTWF4aW4gQi4gSm9obiIgPG1heGluLmpvaG5AaW50ZWwuY29t
PgpEYXRlOiBNb24sIDIxIE1hciAyMDE2IDE3OjAyO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