<?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>9497</bug_id>
          
          <creation_ts>2016-04-21 09:02:38 +0000</creation_ts>
          <short_desc>systemd users</short_desc>
          <delta_ts>2016-06-16 15:45:52 +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.1</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></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>2.2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Patrick Ohly">patrick.ohly</reporter>
          <assigned_to name="Stephano Cetola">stephano</assigned_to>
          <cc>joshuagloe</cc>
    
    <cc>kergoth</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>philip</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>61475</commentid>
    <comment_count>0</comment_count>
    <who name="Patrick Ohly">patrick.ohly</who>
    <bug_when>2016-04-21 09:02:38 +0000</bug_when>
    <thetext>systemd_229.bb sets /bin/nologin as login command, but the actual file on disk is /sbin/nologin. The effect of course is the same, so this is merely an oddity.

meta/recipes-core/systemd/systemd_229.bb:USERADD_PARAM_${PN} += &quot;${@bb.utils.contains(&apos;PACKAGECONFIG&apos;, &apos;microhttpd&apos;, &apos;--system -d / -M --shell /bin/nologin systemd-journal-gateway;&apos;, &apos;&apos;, d)}&quot;
meta/recipes-core/systemd/systemd_229.bb:USERADD_PARAM_${PN} += &quot;${@bb.utils.contains(&apos;PACKAGECONFIG&apos;, &apos;timesyncd&apos;, &apos;--system -d / -M --shell /bin/nologin systemd-timesync;&apos;, &apos;&apos;, d)}&quot;

However, the recipe seems out of sync with the actual users potentially needed by systemd. For example, systemd may also need &quot;systemd-network&quot; (from /usr/lib/sysusers.d/systemd.conf when networkd is enabled).

Presumably the explicit useradd in the recipe was added to ensure that /etc/passwd already gets created during image building, to support a read-only rootfs.

I&apos;d like to propose a different solution that I added to Ostro OS: read and parse sysusers.d after installation and then do the necessary operations at image build time.

Code is currently here:
https://github.com/ostroproject/meta-ostro/commits/master/meta-ostro/classes/systemd-sysusers.bbclass

I still need to fix one issue in it, though (must set --shell /sbin/nologin).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61560</commentid>
    <comment_count>1</comment_count>
    <who name="Phlip Balister">philip</who>
    <bug_when>2016-04-22 13:53:17 +0000</bug_when>
    <thetext>I&apos;m having issues starting networkd that seem related. I see this in the log:

systemd-tmpfiles[123]: [[0;1;31m[/usr/lib/tmpfiles.d/sys
temd.conf:19] Unknown user &apos;systemd-network&apos;.[[0m


Looks like we need to fix this ASAP.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61572</commentid>
    <comment_count>2</comment_count>
    <who name="Phlip Balister">philip</who>
    <bug_when>2016-04-22 17:44:15 +0000</bug_when>
    <thetext>(In reply to comment #0)
&gt; systemd_229.bb sets /bin/nologin as login command, but the actual file on
&gt; disk is /sbin/nologin. The effect of course is the same, so this is merely
&gt; an oddity.
&gt; 
&gt; meta/recipes-core/systemd/systemd_229.bb:USERADD_PARAM_${PN} +=
&gt; &quot;${@bb.utils.contains(&apos;PACKAGECONFIG&apos;, &apos;microhttpd&apos;, &apos;--system -d / -M
&gt; --shell /bin/nologin systemd-journal-gateway;&apos;, &apos;&apos;, d)}&quot;
&gt; meta/recipes-core/systemd/systemd_229.bb:USERADD_PARAM_${PN} +=
&gt; &quot;${@bb.utils.contains(&apos;PACKAGECONFIG&apos;, &apos;timesyncd&apos;, &apos;--system -d / -M
&gt; --shell /bin/nologin systemd-timesync;&apos;, &apos;&apos;, d)}&quot;
&gt; 
&gt; However, the recipe seems out of sync with the actual users potentially
&gt; needed by systemd. For example, systemd may also need &quot;systemd-network&quot;
&gt; (from /usr/lib/sysusers.d/systemd.conf when networkd is enabled).
&gt; 
&gt; Presumably the explicit useradd in the recipe was added to ensure that
&gt; /etc/passwd already gets created during image building, to support a
&gt; read-only rootfs.
&gt; 
&gt; I&apos;d like to propose a different solution that I added to Ostro OS: read and
&gt; parse sysusers.d after installation and then do the necessary operations at
&gt; image build time.
&gt; 
&gt; Code is currently here:
&gt; https://github.com/ostroproject/meta-ostro/commits/master/meta-ostro/classes/
&gt; systemd-sysusers.bbclass
&gt; 
&gt; I still need to fix one issue in it, though (must set --shell /sbin/nologin).

From the looks of it, your class only works if the sysusers PACKAGECONFIG is set? I do not see the sysusers.d directory in my build, unless I enable that option.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61573</commentid>
    <comment_count>3</comment_count>
    <who name="Stephano Cetola">stephano</who>
    <bug_when>2016-04-22 17:47:18 +0000</bug_when>
    <thetext>This also conflicts with the useradd-staticids class. I&apos;m looking into a good fix for this now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61803</commentid>
    <comment_count>4</comment_count>
    <who name="Stephano Cetola">stephano</who>
    <bug_when>2016-04-28 15:37:42 +0000</bug_when>
    <thetext>Looks like the reach-only-rootfs systemd functionality is already included here:

http://git.openembedded.org/openembedded-core/tree/meta/classes/rootfs-postcommands.bbclass  

(ln 77)

Is there a reason this isn&apos;t being used in Ostro?

I agree with Philip that the sysusers PACKAGECONFIG is required for the sysusers.d directory (and conf files) to be created. So if you do not have sysusers as a config option then you probably will not have a networkd user created.

My guess is that sysusers should be a default config option, but I&apos;ll look into that. We could manually (conditionally) add all the required users for systemd in the recipe, but that feels like we are duplicating sysusers functionality.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61805</commentid>
    <comment_count>5</comment_count>
    <who name="Patrick Ohly">patrick.ohly</who>
    <bug_when>2016-04-28 16:13:18 +0000</bug_when>
    <thetext>(In reply to comment #4)
&gt; Looks like the reach-only-rootfs systemd functionality is already included
&gt; here:
&gt; 
&gt; http://git.openembedded.org/openembedded-core/tree/meta/classes/rootfs-
&gt; postcommands.bbclass  
&gt; 
&gt; (ln 77)
&gt; 
&gt; Is there a reason this isn&apos;t being used in Ostro?

I wasn&apos;t aware that it exists. It is not active in Ostro because we are not building with &quot;read-only-rootfs&quot; in IMAGE_FEATURES. Our goal is similar to read-only-rootfs, but not quite the same.

My comment about &quot;read-only rootfs&quot; was speculation from me about the reason why the systemd recipe adds some users explicitly; turns out that this isn&apos;t the reason (or the reason isn&apos;t valid anymore).

So given that the code exists, can we make it available also when not building with read-only-rootfs?

IMHO it can even be unconditional. Why do something only at runtime when it can already be done at image build time?

However, beware that the existing code has the same bug as my own initial version ;-) It misses a &quot;--shell /sbin/nologin&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61810</commentid>
    <comment_count>6</comment_count>
    <who name="Stephano Cetola">stephano</who>
    <bug_when>2016-04-28 17:02:34 +0000</bug_when>
    <thetext>Thanks, I&apos;ll fix that issue as well since I&apos;ll be reworking that function anyway.

I agree that having this option, regardless of read-only, would be a benefit. Many users will want to boot directly to a working systemd setup, without the need for user creation at runtime.

I&apos;ll run this by the team and then make the necessary changes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63054</commentid>
    <comment_count>7</comment_count>
    <who name="Stephano Cetola">stephano</who>
    <bug_when>2016-06-16 15:45:52 +0000</bug_when>
    <thetext>With commit 98a4c642444a524f547f5d978a28814d20c12354 I&apos;ve allowed users to add this functionality by simply adding: ROOTFS_POSTPROCESS_COMMAND += &quot;systemd_create_users&quot;.

I&apos;ve also added YOCTO #9788 to add &quot;-m&quot; flag processing to this function.

Finally, I&apos;ve added YOCTO #9789 to check the staticids data and apply appropriate ids if needed.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>