Sha256: 8aad5c76809bdc95a8a90209c7252ac9b123694a0b09f2ba41fb042e9680c180
Contents?: true
Size: 1.31 KB
Versions: 6
Compression:
Stored size: 1.31 KB
Contents
require 'wright/provider' require 'wright/provider/user' module Wright class Provider class User # GNU passwd user provider. Used as a provider for # {Resource::User} on GNU systems. class GnuPasswd < Wright::Provider::User private def create_user exec_or_fail('useradd', [*user_options, user_name], "cannot create user '#{user_name}'") end def update_user exec_or_fail('usermod', [*user_options, user_name], "cannot create user '#{user_name}'") end def remove_user exec_or_fail('userdel', [user_name], "cannot remove user '#{user_name}'") end def user_options options = { '-u' => uid, '-g' => primary_group, '-c' => comment, '-G' => group_list, '-s' => shell, '-d' => home }.reject { |_k, v| v.nil? }.flatten options << '-r' if system_user? options.map(&:to_s) end def comment full_name.nil? ? nil : "#{full_name},,," end def group_list groups.nil? ? nil : groups.join(',') end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems