Jira (PUP-10237) User resource with allowdupe executes usermod -o without -u {uid} argument

24 views
Skip to first unread message

Theo van Oostrum (JIRA)

unread,
Jan 17, 2020, 7:12:04 AM1/17/20
to puppe...@googlegroups.com
Theo van Oostrum created an issue
 
Puppet / Bug PUP-10237
User resource with allowdupe executes usermod -o without -u {uid} argument
Issue Type: Bug Bug
Affects Versions: PUP 6.3.0
Assignee: Unassigned
Components: Types and Providers
Created: 2020/01/17 4:11 AM
Priority: Normal Normal
Reporter: Theo van Oostrum

Puppet Version: 5.4.0
Puppet Server Version: 6.3.0
OS Name/Version: Ubuntu 18.04

I need to ensure a user with the same uid as another existing user but a different name. Creating the second user is done correctly, but when the second user's password is changed, puppet says it has changed the user's password successfully while in fact it has not changed the password. Any subsequent runs will also result in puppet reporting a change while actual password is never changed.

Desired Behavior:

When the user already exists the password is changed successfully with the option allowdupe.

Actual Behavior:

puppet code:

 

# ensure first user
user { 'user1name': 
  ensure => present,
  uid => $uid, 
  gid => $uid,
  home => $homedir, 
  shell => $user1[shell], 
  password => $user1[password] 
}
 
# ensure second user with allowdupe and same uid
user { 'user2name':
  ensure    => present,
  uid       => $uid,
  gid       => $uid,
  allowdupe => true,
  home      => $homedir,
  shell     => $user2[shell],
  password  => $user2[password],
  require   => [File[$homedir], Group[$user2[group]]]
}

 

 

Puppet output with --debug flag:

Debug: Executing: '/usr/sbin/usermod -p $6$rounds=5000$viVABC4ghFf32fu7$WynOf/iDV93iipWfANkKAomDTCqBk9IZK/NihhJaeuMuSDrzUVfFqg91/V9lWr2GK1D/E2.bqNJzUpMK2Xest1 -o user2name'
Notice: /Stage[pre]/Xroles::Users::Pre/User[user2name]/password: changed password
Debug: /User[user2name]: The container Class[Xroles::Users::Pre] will propagate my refresh event

Manually executing the usermod command as logged by puppet results in the error: 

usermod: -o flag is only allowed with the -u flag

It seems that the -u flag is missing from the command that is being executed to edit the user password.

Or is it possible that I am declaring my resource(s) in the wrong way?

If there is an issue in the code it will most likely be in:

/lib/puppet/provider/user/useradd.rb

 

 

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Theo van Oostrum (JIRA)

unread,
Jan 17, 2020, 7:13:03 AM1/17/20
to puppe...@googlegroups.com
Theo van Oostrum updated an issue
Change By: Theo van Oostrum
*Puppet Version: 5.4.0*
*Puppet Server Version: 6.3.0*
*OS Name/Version: Ubuntu 18.04*


I need to ensure a user with the same uid as another existing user but a different name.
Creating the second user is done correctly, but when the second user's password is changed, puppet says it has changed the user's password successfully while in fact it has not changed the password.
Any subsequent runs will also result in puppet reporting a change while actual password is never changed.

*Desired Behavior:*


When the user already exists the password is changed successfully with the option allowdupe.

*Actual Behavior:*

*puppet code:*

 
{code:java}

# ensure first user
user { 'user1name':
  ensure => present,
  uid => $uid,
  gid => $uid,
  home => $homedir,
  shell => $user1[shell],
  password => $user1[password]
}

# ensure second user with allowdupe and same uid
user { 'user2name':
  ensure    => present,
  uid       => $uid,
  gid       => $uid,
  allowdupe => true,
  home      => $homedir,
  shell     => $user2[shell],
  password  => $user2[password],
  require   => [File[$homedir], Group[$user2[group]]]
}{code}
 

 

*Puppet output with --debug flag:*


Debug: Executing: '/usr/sbin/usermod -p $6$rounds=5000$viVABC4ghFf32fu7$WynOf/iDV93iipWfANkKAomDTCqBk9IZK/NihhJaeuMuSDrzUVfFqg91/V9lWr2GK1D/E2.bqNJzUpMK2Xest1 -o user2name'
Notice: /Stage[pre]/Xroles::Users::Pre/User[user2name]/password: changed password
Debug: /User[user2name]: The container Class[Xroles::Users::Pre] will propagate my refresh event

Manually executing the usermod command as logged by puppet results in the error: 
{code:java}
usermod: -o flag is only allowed with the -u flag{code}

It seems that the -u flag is missing from the command that is being executed to edit the user password.

Or is it possible that I am declaring my resource(s) in the wrong way?

If there is an issue in the code it will most likely be in:
{code:java}
/lib/puppet/provider/user/useradd.rb
{code}
 

 

Theo van Oostrum (JIRA)

unread,
Jan 17, 2020, 7:13:04 AM1/17/20
to puppe...@googlegroups.com

Theo van Oostrum (JIRA)

unread,
Jan 17, 2020, 7:14:03 AM1/17/20
to puppe...@googlegroups.com

Theo van Oostrum (JIRA)

unread,
Jan 17, 2020, 7:14:04 AM1/17/20
to puppe...@googlegroups.com

Theo van Oostrum (JIRA)

unread,
Jan 17, 2020, 7:14:04 AM1/17/20
to puppe...@googlegroups.com

Theo van Oostrum (JIRA)

unread,
Jan 17, 2020, 7:14:04 AM1/17/20
to puppe...@googlegroups.com

Theo van Oostrum (JIRA)

unread,
Jan 17, 2020, 7:15:04 AM1/17/20
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
Jan 17, 2020, 6:04:03 PM1/17/20
to puppe...@googlegroups.com

Mihai Buzgau (JIRA)

unread,
Jan 21, 2020, 10:44:03 AM1/21/20
to puppe...@googlegroups.com

Mihai Buzgau (JIRA)

unread,
Jan 21, 2020, 10:45:04 AM1/21/20
to puppe...@googlegroups.com

Mihai Buzgau (JIRA)

unread,
Jan 22, 2020, 4:38:04 AM1/22/20
to puppe...@googlegroups.com

Luchian Nemes (JIRA)

unread,
Jan 27, 2020, 7:50:04 AM1/27/20
to puppe...@googlegroups.com

Luchian Nemes (JIRA)

unread,
Jan 27, 2020, 9:48:04 AM1/27/20
to puppe...@googlegroups.com
Luchian Nemes commented on Bug PUP-10237
 
Re: User resource with allowdupe executes usermod -o without -u {uid} argument

Hello Theo van Oostrum,

While trying to reproduce the issue on latest Puppet version and the provided version (5.4.0), I found out that the problem has already been solved in /lib/puppet/provider/user/useradd.rb (through ticket PUP-8470) by limiting the '-o' parameter usage (identifying just by username for 'usermod' is enough in this scenario). Please retry using 5.5.0 or higher.

Best regards,
Luchi

Reply all
Reply to author
Forward
0 new messages