From 4a863c38ced0e2581454888b15275aa1eb381e56 Mon Sep 17 00:00:00 2001 From: Andrew Shafer Date: Wed, 1 Oct 2008 17:23:14 -0600 Subject: Adding user_attr util to parse attributes on solaris read /etc/user_attr and makes a hash based on the file contents --- lib/puppet/util/user_attr.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/puppet/util/user_attr.rb (limited to 'lib') diff --git a/lib/puppet/util/user_attr.rb b/lib/puppet/util/user_attr.rb new file mode 100644 index 000000000..db8fb81b9 --- /dev/null +++ b/lib/puppet/util/user_attr.rb @@ -0,0 +1,21 @@ +class UserAttr + def self.get_attributes_by_name(name) + attributes = nil + + File.readlines('/etc/user_attr').each do |line| + next if line =~ /^#/ + + token = line.split(':') + + if token[0] == name + attributes = {:name => name} + token[4].split(';').each do |attr| + key_value = attr.split('=') + attributes[key_value[0].intern] = key_value[1].strip + end + break + end + end + return attributes + end +end -- cgit