<?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>10062</bug_id>
          
          <creation_ts>2016-08-02 10:56:20 +0000</creation_ts>
          <short_desc>useradd dollar sign requires three prepending backslash characters to avoid unintended expansion</short_desc>
          <delta_ts>2016-08-26 08:09:47 +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>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.2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Niko Mauno">niko.mauno</reporter>
          <assigned_to name="Maxin B. John">maxin.john</assigned_to>
          <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>sgw</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>Regression (Used to work)</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>64779</commentid>
    <comment_count>0</comment_count>
    <who name="Niko Mauno">niko.mauno</who>
    <bug_when>2016-08-02 10:56:20 +0000</bug_when>
    <thetext>In Krogoth when calling &quot;useradd -p &apos;&lt;encrypted_password&gt;&apos; ...&quot; in EXTRA_USERS_PARAMS, it is now necessary to escape dollar signs in &lt;encrypted password&gt; with three prepending backslashes, whereas before Krogoth just one prepending backslash was sufficient to avoid unintended expansion.

I would suspect this change in behaviour was introduced in commit 57a525ca7271a8fe3913c61aa87cb0ba1674b4b2 - later commit 9fe3d01f27445652c3020413d66a5cdeb3c3259c apparently addresses the problem wrt. usermod call, but not useradd.

As a possible fix, I removed (locally) the &quot;apostrophe-to-double-quote-conversion&quot; operation from useradd (and groupadd also, for good measure) - which seemed like a safe thing to do after the change introduced in commit 9fe3d01f27445652c3020413d66a5cdeb3c3259c. The change is below:

--- a/meta/classes/useradd_base.bbclass
+++ b/meta/classes/useradd_base.bbclass
@@ -17,7 +17,6 @@ perform_groupadd () {
        local groupname=`echo &quot;$opts&quot; | awk &apos;{ print $NF }&apos;`
        local group_exists=&quot;`grep &quot;^$groupname:&quot; $rootdir/etc/group || true`&quot;
        if test &quot;x$group_exists&quot; = &quot;x&quot;; then
-               opts=`echo $opts | sed s/\&apos;/\&quot;/g`
                eval flock -x $rootdir${sysconfdir} -c \&quot;$PSEUDO groupadd \$opts\&quot; || true
                group_exists=&quot;`grep &quot;^$groupname:&quot; $rootdir/etc/group || true`&quot;
                if test &quot;x$group_exists&quot; = &quot;x&quot;; then
@@ -35,7 +34,6 @@ perform_useradd () {
        local username=`echo &quot;$opts&quot; | awk &apos;{ print $NF }&apos;`
        local user_exists=&quot;`grep &quot;^$username:&quot; $rootdir/etc/passwd || true`&quot;
        if test &quot;x$user_exists&quot; = &quot;x&quot;; then
-               opts=`echo $opts | sed s/\&apos;/\&quot;/g`
                eval flock -x $rootdir${sysconfdir} -c  \&quot;$PSEUDO useradd \$opts\&quot; || true
                user_exists=&quot;`grep &quot;^$username:&quot; $rootdir/etc/passwd || true`&quot;
                if test &quot;x$user_exists&quot; = &quot;x&quot;; then


As an example of this issue, the following entry in EXTRA_USERS_PARAMS:
&quot;groupadd voter; useradd -p &apos;\$6\$ASFORME\$IDONTTHINKTHAT.VOTING/IS/STUPID/&apos; -g voter -G users voter;&quot;
without the above change translates to following line in /etc/shadow:
&quot;voter:.VOTING/IS/STUPID/:17015:0:99999:7:::&quot;
Thus logging in as user &apos;voter&apos; will not work against the provided (encrypted) password on the target system.

With the above &quot;possible fix&quot; change included, the associated resulting line in /etc/shadow is now:
&quot;voter:$6$ASFORME$IDONTTHINKTHAT.VOTING/IS/STUPID/:17015:0:99999:7:::&quot;
which would seem to revert the adduser dollar sign escaping behaviour to pre-Krogoth -style.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65218</commentid>
    <comment_count>1</comment_count>
      <attachid>3359</attachid>
    <who name="Maxin B. John">maxin.john</who>
    <bug_when>2016-08-16 08:56:35 +0000</bug_when>
    <thetext>Created attachment 3359
useradd recipe for verification</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65381</commentid>
    <comment_count>2</comment_count>
    <who name="Maxin B. John">maxin.john</who>
    <bug_when>2016-08-22 05:37:26 +0000</bug_when>
    <thetext>patch sent to oe-core:
http://lists.openembedded.org/pipermail/openembedded-core/2016-August/125171.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65453</commentid>
    <comment_count>3</comment_count>
    <who name="Niko Mauno">niko.mauno</who>
    <bug_when>2016-08-23 15:26:06 +0000</bug_when>
    <thetext>I noticed the change in poky&apos;s master-next - will this fix also be backported to Krogoth?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65457</commentid>
    <comment_count>4</comment_count>
    <who name="Maxin B. John">maxin.john</who>
    <bug_when>2016-08-23 16:00:13 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; I noticed the change in poky&apos;s master-next - will this fix also be
&gt; backported to Krogoth?

Yes, this fix looks like a good candidate for backporting to Krogoth as well.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65476</commentid>
    <comment_count>5</comment_count>
    <who name="Maxin B. John">maxin.john</who>
    <bug_when>2016-08-24 08:46:19 +0000</bug_when>
    <thetext>Fix in master branch:
http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=e8168a55e7a1e1bd2081c4bbe25c1c852937b695</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65553</commentid>
    <comment_count>6</comment_count>
    <who name="Maxin B. John">maxin.john</who>
    <bug_when>2016-08-26 08:09:47 +0000</bug_when>
    <thetext>Fix available in master branch. Requested for cherry-pick to krogoth.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>3359</attachid>
            <date>2016-08-16 08:56:35 +0000</date>
            <delta_ts>2016-08-16 08:56:35 +0000</delta_ts>
            <desc>useradd recipe for verification</desc>
            <filename>useraddtest-a.bb</filename>
            <type>application/octet-stream</type>
            <size>434</size>
            <attacher name="Maxin B. John">maxin.john</attacher>
            
              <data encoding="base64">U1VNTUFSWSA9ICJ1c2VyYWRkIHRlc3QgQSIKTElDRU5TRSA9ICJNSVQiCkxJQ19GSUxFU19DSEtT
VU0gPSAiZmlsZTovLyR7Q09SRUJBU0V9L0xJQ0VOU0U7bWQ1PTRkOTJjZDM3M2FiZGEzOTM3YzJi
YzQ3ZmJjNDlkNjkwIFwKICAgICAgICAgICAgICAgICAgICBmaWxlOi8vJHtDT1JFQkFTRX0vbWV0
YS9DT1BZSU5HLk1JVDttZDU9M2RhOWNmYmNiNzg4YzgwYTAzODQzNjFiNGRlMjA0MjAiCgpBTExP
V19FTVBUWV8ke1BOfSA9ICIxIgppbmhlcml0IHVzZXJhZGQKVVNFUkFERF9QQUNLQUdFUyA9ICIk
e1BOfSIKCkdST1VQQUREX1BBUkFNXyR7UE59ID0gIiAtLXN5c3RlbSB2b3RlciIKVVNFUkFERF9Q
QVJBTV8ke1BOfSA9ICIgLXAgJ1wkNlwkQVNGT1JNRVwkSURPTlRUSElOS1RIQVQuVk9USU5HL0lT
L1NUVVBJRC8nIC1nIHZvdGVyIC1HIHVzZXJzIHZvdGVyIgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>