Jira (PUP-11241) Not all user attributes honor forcelocal (e.g. home, shell)

33 views
Skip to first unread message

Nate McCurdy (Jira)

unread,
Sep 14, 2021, 9:04:02 PM9/14/21
to puppe...@googlegroups.com
Nate McCurdy created an issue
 
Puppet / Bug PUP-11241
Not all user attributes honor forcelocal (e.g. home, shell)
Issue Type: Bug Bug
Affects Versions: PUP 7.9.0, PUP 6.19.1
Assignee: Unassigned
Created: 2021/09/14 6:03 PM
Priority: Normal Normal
Reporter: Nate McCurdy

Puppet Version: 6.19.1, 7.9.0
Puppet Server Version: N/A
OS Name/Version: CentOS 7

When setting forcelocal => true on a user resource, I'd expect all user attributes available via /etc/passwd to be used as the "is" value for the insync? check.

This appears to not be the case for the home}] and {{shell attributes.

Those are always checked against their values from directory services rather than from /etc/passwd, which means those attributes appear to change on each puppet run and the user resource is no longer idempotent.

Desired Behavior:

When an OS has directory services enabled (e.g. LDAP via SSSD), and with an /etc/passwd file containing:

nate:x:1000:1001:hello world:/opt/hello:/bin/zsh

This code should read "shell", "home", and "comment" all from /etc/passwd when comparing the "is" state to the "should" state:

user { 'nate':
  ensure     => present,
  forcelocal => true,
  shell      => '/bin/zsh',
  home       => '/opt/hello',
  comment    => 'hello world',
}

Actual Behavior:

Only "uid", "gid", "comment", and "groups" are fetched from /etc/passwd when forcelocal => true:
https://github.com/puppetlabs/puppet/blob/7.11.0/lib/puppet/provider/user/useradd.rb#L60-L78

"home" and "shell" are fetched from directory services, not from /etc/passwd.

The user resource shows a change to "home" and "shell" on each Puppet run even though nothing is changing.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Nate McCurdy (Jira)

unread,
Sep 14, 2021, 9:05:03 PM9/14/21
to puppe...@googlegroups.com
Nate McCurdy updated an issue
Change By: Nate McCurdy
*Puppet Version:* 6.19.1, 7.9.0
*Puppet Server Version:* N/A
*OS Name/Version:* CentOS 7


When setting {{forcelocal => true}} on a {{user}} resource, I'd expect all user attributes available via {{/etc/passwd}} to be used as the "is" value for the insync? check.

This appears to not be the case for the {{home}] and {{shell}} attributes.

Those are always checked against their values from directory services rather than from {{/etc/passwd}}, which means those attributes appear to change on each puppet run and the {{user}} resource is no longer idempotent.

*Desired Behavior:*

When an OS has directory services enabled (e.g. LDAP via SSSD)
, and with a puppet-managed user exists in LDAP...

Given
an {{/etc/passwd}} file containing:
{noformat}

nate:x:1000:1001:hello world:/opt/hello:/bin/zsh
{noformat}


This code should read "shell", "home", and "comment" all from {{/etc/passwd}} when comparing the "is" state to the "should" state:
{code}

user { 'nate':
  ensure     => present,
  forcelocal => true,
  shell      => '/bin/zsh',
  home       => '/opt/hello',
  comment    => 'hello world',
}
{code}

*Actual Behavior:*


Only "uid", "gid", "comment", and "groups" are fetched from {{/etc/passwd}} when {{forcelocal => true}}:
https://github.com/puppetlabs/puppet/blob/7.11.0/lib/puppet/provider/user/useradd.rb#L60-L78

"home" and "shell" are fetched from directory services, not from {{/etc/passwd}}.


The user resource shows a change to "home" and "shell" on each Puppet run even though nothing is changing.

Nate McCurdy (Jira)

unread,
Sep 14, 2021, 9:10:03 PM9/14/21
to puppe...@googlegroups.com
Nate McCurdy updated an issue
*Puppet Version:* 6.19.1, 7.9.0
*Puppet Server Version:* N/A
*OS Name/Version:* CentOS 7

When setting {{forcelocal => true}} on a {{user}} resource, I'd expect all user attributes available via {{/etc/passwd}} to be used as the "is" value for the insync? check.

This appears to not be the case for the {{home}] and {{shell}} attributes.

Those are always checked against their values from directory services rather than from {{/etc/passwd}}, which means those attributes appear to change on each puppet run and the {{user}} resource is no longer idempotent.

*Desired Behavior:*

When an OS has directory services enabled (e.g. LDAP via SSSD) and a puppet-managed user exists in LDAP...


Given an {{/etc/passwd}} file containing:
{noformat}
nate:x:1000:1001:hello world:/opt/hello:/bin/zsh
{noformat}

This code should read "shell", "home", and "comment" all from {{/etc/passwd}} when comparing the "is" state to the "should" state:
{code}
user { 'nate':
  ensure     => present,
  forcelocal => true,
  shell      => '/bin/zsh',
  home       => '/opt/hello',
  comment    => 'hello world',
}
{code}

*Actual Behavior:*

Only "uid", "gid", "comment", and "groups" are fetched from {{/etc/passwd}} when {{forcelocal => true}}:
https://github.com/puppetlabs/puppet/blob/7.11.0/lib/puppet/provider/user/useradd.rb#L60-L78

"home" and "shell" are fetched from directory services, not from {{/etc/passwd}}.

The user resource shows a change to "home" and "shell" on each Puppet run even though nothing is changing.


*Related:*
Support for "comment" when forcelocal is true was added here: https://github.com/puppetlabs/puppet/pull/7768

Basically, I'm asking for that same support for all the other attributes pulled from {{/etc/passwd}} in [the finduser() method|https://github.com/puppetlabs/puppet/blob/7.11.0/lib/puppet/provider/user/useradd.rb#L80-L96]

Nate McCurdy (Jira)

unread,
Sep 14, 2021, 9:21:02 PM9/14/21
to puppe...@googlegroups.com
Nate McCurdy updated an issue
Change By: Nate McCurdy
Affects Version/s: PUP 7.10.0

Nate McCurdy (Jira)

unread,
Sep 15, 2021, 3:57:02 PM9/15/21
to puppe...@googlegroups.com

Nate McCurdy (Jira)

unread,
Sep 15, 2021, 4:42:03 PM9/15/21
to puppe...@googlegroups.com

Gabriel Nagy (Jira)

unread,
Sep 17, 2021, 7:40:01 AM9/17/21
to puppe...@googlegroups.com

Gabriel Nagy (Jira)

unread,
Sep 17, 2021, 7:40:02 AM9/17/21
to puppe...@googlegroups.com
Gabriel Nagy updated an issue
 
Change By: Gabriel Nagy
Fix Version/s: PUP 7.12.0
Fix Version/s: PUP 6.25.0

Gabriel Nagy (Jira)

unread,
Sep 17, 2021, 7:43:03 AM9/17/21
to puppe...@googlegroups.com
Gabriel Nagy updated an issue
Change By: Gabriel Nagy
Community Contributors: natemccurdy
Release Notes: Bug Fix
Release Notes Summary: Fix an issue where setting `forcelocal => true` on an user resource would still check the resource's `home` and `shell` attributes against their values from the directory service provider.

Ciprian Badescu (Jira)

unread,
Sep 20, 2021, 3:56:02 AM9/20/21
to puppe...@googlegroups.com

Ciprian Badescu (Jira)

unread,
Sep 20, 2021, 3:57:02 AM9/20/21
to puppe...@googlegroups.com

Ciprian Badescu (Jira)

unread,
Sep 22, 2021, 3:28:02 AM9/22/21
to puppe...@googlegroups.com

Claire Cadman (Jira)

unread,
Oct 5, 2021, 8:11:02 AM10/5/21
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages