<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>33440</bug_id>
          
          <creation_ts>2017-05-01 12:48:36 +0300</creation_ts>
          <short_desc>passwd without username changes password for another user under su -</short_desc>
          <delta_ts>2018-07-02 02:05:01 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>passwd</component>
          <version>unstable</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>33439</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Ivan Zakharyaschev">imz</reporter>
          <assigned_to name="Dmitry V. Levin">ldv</assigned_to>
          <cc>ldv</cc>
    
    <cc>placeholder</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>163508</commentid>
    <comment_count>0</comment_count>
    <who name="Ivan Zakharyaschev">imz</who>
    <bug_when>2017-05-01 12:48:36 +0300</bug_when>
    <thetext>The same happens on Sisyphus:


[root@dd2 ~]# rpm -qf &quot;$(which passwd)&quot; &quot;$(which su)&quot;
passwd-1.0.13-alt1.x86_64
su-0.60-alt35.x86_64
[root@dd2 ~]# apt-cache depends passwd | sed -nre &apos;s:^    ::p&apos; | sort -u
control-0.7.6-alt1
glibc-core-6:2.25-alt2
libpam0-1.3.0-alt1
pam-config-1.7.0-alt1
pam0-config-1.7.0-alt1
sh-3.2.57-alt1
tcb-utils-1.1-alt1
[root@dd2 ~]# 

+++ This bug was initially created as a clone of Bug #33439 +++

$ rpm -qf &quot;$(which passwd)&quot; &quot;$(which su)&quot;
passwd-1.0.13-alt1
su-0.60-alt34
$ apt-cache depends passwd | sed -nre &apos;s:^    ::p&apos; | sort -u
control-0.7.6-alt1
glibc-core-6:2.23-alt3
libpam0-1.3.0-alt1
pam0-config-1.7.0-alt1
pam-config-1.7.0-alt1
sh-3.2.57-alt1
tcb-utils-1.1-alt1
$ 

I expect to change the password for root, but passwd without username changes password for another user under &quot;su -&quot;:

imz@rollerderby ~ $ su -
Password: 
rollerderby ~ # passwd
passwd: updating all authentication tokens for user imz.

...

(First, I didn&apos;t notice that the username is written in the message and couldn&apos;t understand what was happening!)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>163509</commentid>
    <comment_count>1</comment_count>
    <who name="Ivan Zakharyaschev">imz</who>
    <bug_when>2017-05-01 12:55:13 +0300</bug_when>
    <thetext>I&apos;ve checked this on old systems. The behavior is the same. Perhaps, this is not a bug, but an old feature...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>163510</commentid>
    <comment_count>2</comment_count>
    <who name="Ivan Zakharyaschev">imz</who>
    <bug_when>2017-05-01 13:00:15 +0300</bug_when>
    <thetext>But the behavior is like I expected (i.e., different from ALT) on a RHEL7.2-clone:

{box} [user@dd1 ~]$ su -
Password: 
Last login: Thu Apr 27 18:08:58 MSK 2017 from gateway on pts/1
{box} [root@dd1 ~]# passwd
Changing password for user root.
New password: 
{box} [root@dd1 ~]# cat /etc/os-release 
NAME=&quot;Scientific Linux&quot;
VERSION=&quot;7.2 (Nitrogen)&quot;
ID=&quot;rhel&quot;
ID_LIKE=&quot;fedora&quot;
VERSION_ID=&quot;7.2&quot;
PRETTY_NAME=&quot;Scientific Linux 7.2 (Nitrogen)&quot;
ANSI_COLOR=&quot;0;31&quot;
CPE_NAME=&quot;cpe:/o:scientificlinux:scientificlinux:7.2:GA&quot;
HOME_URL=&quot;http://www.scientificlinux.org//&quot;
BUG_REPORT_URL=&quot;mailto:scientific-linux-devel@listserv.fnal.gov&quot;

REDHAT_BUGZILLA_PRODUCT=&quot;Scientific Linux 7&quot;
REDHAT_BUGZILLA_PRODUCT_VERSION=7.2
REDHAT_SUPPORT_PRODUCT=&quot;Scientific Linux&quot;
REDHAT_SUPPORT_PRODUCT_VERSION=&quot;7.2&quot;
{box} [root@dd1 ~]# rpm -qf &quot;$(which passwd)&quot; &quot;$(which su)&quot;
passwd-0.79-4.el7.x86_64
util-linux-2.23.2-26.el7.x86_64
{box} [root@dd1 ~]#</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>163511</commentid>
    <comment_count>3</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2017-05-01 13:04:09 +0300</bug_when>
    <thetext>(In reply to comment #1)
&gt; I&apos;ve checked this on old systems. The behavior is the same. Perhaps, this is
&gt; not a bug, but an old feature...

Yes, quite old. It&apos;s the name returned by getlogin(3) and printed by logname(1).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>163512</commentid>
    <comment_count>4</comment_count>
    <who name="Ivan Zakharyaschev">imz</who>
    <bug_when>2017-05-01 13:14:21 +0300</bug_when>
    <thetext>From http://openbsd-archive.7691.n7.nabble.com/passwd-without-argument-in-sudo-td274304.html :

&gt; when I &apos;sudo su - &apos; into a root shell and issue a &apos;passwd&apos; without a 
&gt; username 
&gt; argument, then it does not try to change the passwd for the current user (in 
&gt; this case root) but for the user from which I issued the &apos;sudo&apos;. 

This is because passwd changes the password for the logged in user 
by default, as returned by the logname system call.  You can run 
the logname command to see that this is not changed when you run 
su. 

It&apos;s probably worth mentioning this in the passwd manual as it does 
seem to cause some confusion. 

--------

But on the RHEL7.2-clone the user reported by logname and the user the password is changed for (root, as expected) are different: 

{box} [root@dd1 ~]# logname
user
{box} [root@dd1 ~]# passwd
Changing password for user root.
New password: 
{box} [root@dd1 ~]# 

Such a difference in the behavior between different distributions is confusing, isn&apos;t it? But I don&apos;t know what a good solution could be... Like here http://lists.suckless.org/hackers/1407/5172.html : &quot;allow passwd without argument, prompt which user password is changed&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>163515</commentid>
    <comment_count>5</comment_count>
    <who name="Ivan Zakharyaschev">imz</who>
    <bug_when>2017-05-01 15:53:54 +0300</bug_when>
    <thetext>This was discussed already in the beginning of 2003 -- https://lists.altlinux.org/pipermail/sisyphus/2003-February/238619.html .

Perhaps, to avoid confusion, the invocation without an argument should be simply disallowed (for /usr/sbin/passwd, i.e., for root, who can easily change the password for another user by mistake).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>172358</commentid>
    <comment_count>6</comment_count>
    <who name="Repository Robot">repository-robot</who>
    <bug_when>2018-07-02 02:05:01 +0300</bug_when>
    <thetext>passwd-1.0.14-alt1 -&gt; sisyphus:

Sun Jul 01 2018 Dmitry V. Levin &lt;ldv@altlinux&gt; 1.0.14-alt1
- Refuse to change password for different logged in user by default
  (closes: #33440).
- passwd -d: clarify the meaning of delete option (closes: #34906).
- passwd -S: support detection of modern encryption modes (by vt@).</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>