Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
hfm committed Jul 3, 2016
1 parent fc28379 commit 4f52f4b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
48 changes: 32 additions & 16 deletions manifests/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,39 @@
}

if $handle_sudo_config {
validate_string($sudoers_name)
if $sudoers_name {
validate_string($sudoers_name)

augeas {'sudo pam with stns':
context => '/files/etc/pam.d/sudo',
changes => [
'ins "01" after #comment',
'set 01/type auth',
'set 01/control sufficient',
'set 01/module libpam_stns.so',
'set 01/argument[1] sudo',
"set 01/argument[2] ${sudoers_name}",
],
onlyif => [
"values *[type = 'auth']/module not_include libpam_stns.so",
"match *[module = 'libpam_stns.so']/argument size < 2",
"match *[module = 'libpam_stns.so']/argument != ['sudo', ${sudoers_name}]",
],
augeas {'sudo pam with stns':
context => '/files/etc/pam.d/sudo',
changes => [
'ins "01" after #comment',
'set 01/type auth',
'set 01/control sufficient',
'set 01/module libpam_stns.so',
'set 01/argument[1] sudo',
"set 01/argument[2] ${sudoers_name}",
],
onlyif => [
"values *[type = 'auth']/module not_include libpam_stns.so",
"match *[module = 'libpam_stns.so']/argument size < 2",
"match *[module = 'libpam_stns.so']/argument != ['sudo', ${sudoers_name}]",
],
}
} else {
augeas {'sudo pam with stns':
context => '/files/etc/pam.d/sudo',
changes => [
'ins "01" after #comment',
'set 01/type auth',
'set 01/control sufficient',
'set 01/module libpam_stns.so',
],
onlyif => [
"values *[type = 'auth']/module not_include libpam_stns.so",
"match *[module = 'libpam_stns.so']/argument size == 0",
],
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions spec/acceptance/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class { '::stns::client':
handle_nsswitch => true,
handle_sshd_config => true,
handle_sudo_config => true,
sudoers_name => 'example_user',
}
EOS
end
Expand Down Expand Up @@ -80,6 +79,6 @@ class { '::stns::client':
end

describe file('/etc/pam.d/sudo') do
its(:content) { should match /^#%PAM-1.0\nauth\s+sufficient\s+libpam_stns.so\s+sudo\s+example_user$/ }
its(:content) { should match /^#%PAM-1.0\nauth\s+sufficient\s+libpam_stns.so$/ }
end
end

0 comments on commit 4f52f4b

Please sign in to comment.