So revisiting this patch because it caused #4963 and #4975 I noticed the
change from the first version:
+ #Read in /etc/shadow, find the line for this user (skipping comments,
> because who knows) and return it
> #No abstraction, all esoteric knowledge of file formats, yay
> + def shadow_entry
> + return @shadow_entry if defined? @shadow_entry
> + @shadow_entry = File.readlines("/etc/shadow").reject { |r| r =~
> /^[^\w]/ }.collect { |l| l.chomp.split(':') }.find { |user, _| user ==
> @resource[:name] }
> + end
> +
> def password
> - #got perl?
> - if ary = File.readlines("/etc/shadow").reject { |r| r =~
> /^[^\w]/}.collect { |l| l.split(':')[0..1] }.find { |user, passwd| user ==
> @resource[:name] }
> - pass = ary[1]
> - end
> - pass
> + shadow_entry[1] if shadow_entry
> end
>
I have several objections to this code, such as the awful, laborious
"return ... if defined ..." recreation of "||=", but the most serious is the
change in behaviour: how does caching the shadow entry for the first user we
encounter in the provider play out when more than one user is being managed?
-- Markus
-----------------------------------------------------------
The power of accurate observation is
commonly called cynicism by those
who have not got it. ~George Bernard Shaw
------------------------------------------------------------
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.