Skip to content

Commit

Permalink
Merge pull request #18 from jordiprats/master
Browse files Browse the repository at this point in the history
improved pam::ttyaudit class
  • Loading branch information
jordiprats authored Sep 20, 2017
2 parents 90a3e22 + 5cc0110 commit 1d04577
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
/spec/fixtures/manifests
/spec/fixtures/modules
/Gemfile.lock
/.yardwarns
/.yardoc
/doc
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 0.1.15

* added ensure to **pam::ttyaudit**

## 0.1.14

* improved CIS support by setting an arbitrary option order
Expand Down
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
$cracklib_package_name = 'libpwquality'
$pwqualityconf = '/etc/security/pwquality.conf'
$pamcracklib = false
$pam_lockout='faillock'
$pam_lockout = 'faillock'
#
$authconfig_systemauth_custom_file='/etc/pam.d/system-auth-local'
$authconfig_systemauth_template="${module_name}/lockout/faillock/systemauth.erb"
Expand Down
40 changes: 26 additions & 14 deletions manifests/ttyaudit.pp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#
# @param ensure enable/disable pam_tty_audit (default: present)
# @param enable array of userts to enable pam_tty_audit
# @param disable array of users without pam_tty_audit (default: empty array)
#
class pam::ttyaudit (
$disable=undef,
$enable=['*']
$ensure = 'present',
$enable = [ '*' ],
$disable = [],
) inherits pam::params {

if($disable!=undef)
{
validate_array($disable)
}

if($enable!=undef)
{
validate_array($enable)
Expand All @@ -18,12 +18,24 @@
path => '/sbin:/bin:/usr/sbin:/usr/bin',
}

# command => "sed '/pam_tty_audit.so/d' -i /etc/pam.d/sshd; echo 'session required pam_tty_audit.so enable=${enable}' >> /etc/pam.d/sshd",
# unless => "grep 'session required pam_tty_audit.so enable=${enable}' /etc/pam.d/sshd",
exec { 'afegint pam_tty_audit sshd':
command => inline_template('sed \'/pam_tty_audit.so/d\' -i /etc/pam.d/sshd; echo \'session required pam_tty_audit.so<% if defined?(@disable) %> disable=<%= @disable.join(\',\') %><% end %> enable=<%= @enable.join(\',\') %>\' >> /etc/pam.d/sshd'),
unless => inline_template('grep \'session required pam_tty_audit.so<% if defined?(@disable) %> disable=<%= @disable.join(\',\') %><% end %> enable=<%= @enable.join(\',\') %>\' /etc/pam.d/sshd'),
case $ensure
{
'present':
{
# command => "sed '/pam_tty_audit.so/d' -i /etc/pam.d/sshd; echo 'session required pam_tty_audit.so enable=${enable}' >> /etc/pam.d/sshd",
# unless => "grep 'session required pam_tty_audit.so enable=${enable}' /etc/pam.d/sshd",
exec { 'afegint pam_tty_audit sshd':
command => inline_template('sed \'/pam_tty_audit.so/d\' -i /etc/pam.d/sshd; echo \'session required pam_tty_audit.so<% if @disable.any? %> disable=<%= @disable.join(\',\') %><% end %> enable=<%= @enable.join(\',\') %>\' >> /etc/pam.d/sshd'),
unless => inline_template('grep \'session required pam_tty_audit.so<% if @disable.any? %> disable=<%= @disable.join(\',\') %><% end %> enable=<%= @enable.join(\',\') %>\' /etc/pam.d/sshd'),
}
}
'absent':
{
exec { 'eliminant pam_tty_audit sshd':
command => inline_template('sed \'/pam_tty_audit.so/d\' -i /etc/pam.d/sshd'),
onlyif => inline_template('grep \'session required pam_tty_audit.so\' /etc/pam.d/sshd'),
}
}
default: { fail('unsupported') }
}


}
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eyp-pam",
"version": "0.1.14",
"version": "0.1.15",
"author": "eyp",
"summary": "PAM modules, /etc/security/limits.conf and /etc/securetty management",
"license": "Apache-2.0",
Expand Down

0 comments on commit 1d04577

Please sign in to comment.