LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   A few questions about passwd (https://www.linuxquestions.org/questions/linux-newbie-8/a-few-questions-about-passwd-650928/)

Neavirc 06-22-2008 03:34 PM

A few questions about passwd
 
I was reading the man page for passwd utility and there were some not clear points for me.

Firstly, how can I see the result of the following option?

Quote:

-k, --keep-tokens
Indicate password change should be performed only for expired authentication tokens (passwords). The user wishes to keep their non-expired tokens as before.
I thought that the command "passwd -k" won't have effect if my password isn't expired, but this is wrong! I can change any password with "passwd -k"!

Let's create a test user (I will type the following commands as root):

> useradd -m foo

then let's set a password for it:

> passwd foo
Enter new UNIX password: bar
Retype new UNIX password: bar
passwd: password updated successfully

To make sure that the password isn't outdated type this:

> passwd -S foo
foo P 06/23/2008 0 99999 7 -1

99999 is enough large number of days.

But the password will be changed anyway if I'll run "passwd -k" under foo (or "passwd -k foo" under root). Why? What does actually mean the -k option? How can I use it?

Secondly, there is an option to limit the period between password changes - "--mindays":

Quote:

-m, --mindays MIN_DAYS
Set the minimum number of days between password changes to MIN_DAYS. A value of zero for this field indicates that the user may change his/her password at any time.
But this doesn't work!

Let's create a test user:

> useradd -m bar

with some password:

> passwd bar
Enter new UNIX password: 123
Retype new UNIX password: 123
passwd: password updated successfully

Default value of MIN_DAYS is 0, which means that user can change his/her password at any time:

> passwd -S bar
bar P 06/23/2008 0 99999 7 -1

Set the MIN_DAYS to 3 days by the following commands:

> passwd --mindays 3 bar
Password changed.
> passwd -S bar
bar P 06/23/2008 3 99999 7 -1

That is the user bar can change his password only once every three days. But this isn't true! Under bar I can change the password indefinite number of times as before!

Thanks!

amani 06-22-2008 04:34 PM

Did you login as the particular user before attempting the changes?

root can override anything.


Best

A. Mani

Neavirc 06-22-2008 04:51 PM

Quote:

Originally Posted by amani (Post 3192062)
Did you login as the particular user before attempting the changes?

Yes, I did. I tried that out as both foo/bar and root.

For example here is three passwd calls related to the second question (--mindays):

Code:

Quote:

[bar@aldan-3 sergey]$ passwd -S bar
bar P 06/23/2008 3 99999 7 -1
[bar@aldan-3 sergey]$ passwd
Changing password for bar.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
[bar@aldan-3 sergey]$ passwd
Changing password for bar.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
[bar@aldan-3 sergey]$ passwd
Changing password for bar.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

amani 06-23-2008 09:47 AM

All these are distro-specific and there are many possibilities. For example, If you enable NIS, then users will not be able to change passwords at all.

Neavirc 06-23-2008 11:09 AM

Quote:

Originally Posted by amani (Post 3192655)
All these are distro-specific and there are many possibilities. For example, If you enable NIS, then users will not be able to change passwords at all.

Thanks for your answer.

So it isn't a bug? I was going to post a bug report at bugtracker of my distro this evening =)


All times are GMT -5. The time now is 03:30 PM.