components/ruby/puppet/patches/puppet-09-PUP-6796-role-shell.patch
changeset 7565 48aa82a0931f
equal deleted inserted replaced
7564:f958607559a6 7565:48aa82a0931f
       
     1 Merged with upstream PUP 4.9.0
       
     2 (PUP-6796) Support setting/checking shell in user_role_add
       
     3 https://tickets.puppetlabs.com/browse/PUP-6796
       
     4 
       
     5 diff --git a/lib/puppet/provider/user/user_role_add.rb b/lib/puppet/provider/user/user_role_add.rb
       
     6 --- a/lib/puppet/provider/user/user_role_add.rb
       
     7 +++ b/lib/puppet/provider/user/user_role_add.rb
       
     8 @@ -12,6 +12,7 @@ Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd, :source =>
       
     9    options :home, :flag => "-d", :method => :dir
       
    10    options :comment, :method => :gecos
       
    11    options :groups, :flag => "-G"
       
    12 +  options :shell, :flag => "-s"
       
    13    options :roles, :flag => "-R"
       
    14    options :auths, :flag => "-A"
       
    15    options :profiles, :flag => "-P"
       
    16 @@ -26,8 +27,23 @@ Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd, :source =>
       
    17      value !~ /\s/
       
    18    end
       
    19  
       
    20 +  def shell=(value)
       
    21 +    check_valid_shell
       
    22 +    set("shell", value)
       
    23 +  end
       
    24 +
       
    25    has_features :manages_homedir, :allows_duplicates, :manages_solaris_rbac, :manages_passwords, :manages_password_age, :manages_shell
       
    26  
       
    27 +
       
    28 +  def check_valid_shell
       
    29 +    unless File.exists?(@resource.should(:shell))
       
    30 +      raise(Puppet::Error, "Shell #{@resource.should(:shell)} must exist")
       
    31 +    end
       
    32 +    unless File.executable?(@resource.should(:shell).to_s)
       
    33 +      raise(Puppet::Error, "Shell #{@resource.should(:shell)} must be executable")
       
    34 +    end
       
    35 +  end
       
    36 +
       
    37    #must override this to hand the keyvalue pairs
       
    38    def add_properties
       
    39      cmd = []