diff options
| author | Jesse Wolfe <jes5199@gmail.com> | 2010-12-20 12:17:52 -0800 |
|---|---|---|
| committer | Jesse Wolfe <jes5199@gmail.com> | 2010-12-20 16:43:36 -0800 |
| commit | 76fe2b3b24f6c04cd1cff7c8492d479d15258566 (patch) | |
| tree | 2c30345fd6d82b446eb863eab2d3e40c52056978 /lib | |
| parent | a17f2616b4cb0a9231745090ace5bb25e7bc77c9 (diff) | |
| download | puppet-76fe2b3b24f6c04cd1cff7c8492d479d15258566.tar.gz puppet-76fe2b3b24f6c04cd1cff7c8492d479d15258566.tar.xz puppet-76fe2b3b24f6c04cd1cff7c8492d479d15258566.zip | |
Implement #5168 and #5169 ctime and mtime are properties
File ctime and mtime are now implemented as read-only properties, so
they can be examined with audit.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/type/file.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/type/file/ctime.rb | 18 | ||||
| -rw-r--r-- | lib/puppet/type/file/mtime.rb | 17 | ||||
| -rwxr-xr-x | lib/puppet/type/file/type.rb | 17 |
4 files changed, 42 insertions, 12 deletions
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index 6523c99a0..eee948cd5 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -797,3 +797,5 @@ require 'puppet/type/file/group' require 'puppet/type/file/mode' require 'puppet/type/file/type' require 'puppet/type/file/selcontext' # SELinux file context +require 'puppet/type/file/ctime' +require 'puppet/type/file/mtime' diff --git a/lib/puppet/type/file/ctime.rb b/lib/puppet/type/file/ctime.rb new file mode 100644 index 000000000..24b098703 --- /dev/null +++ b/lib/puppet/type/file/ctime.rb @@ -0,0 +1,18 @@ +module Puppet + Puppet::Type.type(:file).newproperty(:ctime) do + desc "A read-only state to check the file ctime." + + def retrieve + current_value = :absent + if stat = @resource.stat(false) + current_value = stat.ctime + end + current_value + end + + validate do + fail "ctime is read-only" + end + end +end + diff --git a/lib/puppet/type/file/mtime.rb b/lib/puppet/type/file/mtime.rb new file mode 100644 index 000000000..8ca7ed0d6 --- /dev/null +++ b/lib/puppet/type/file/mtime.rb @@ -0,0 +1,17 @@ +module Puppet + Puppet::Type.type(:file).newproperty(:mtime) do + desc "A read-only state to check the file mtime." + + def retrieve + current_value = :absent + if stat = @resource.stat(false) + current_value = stat.mtime + end + current_value + end + + validate do + fail "mtime is read-only" + end + end +end diff --git a/lib/puppet/type/file/type.rb b/lib/puppet/type/file/type.rb index eb50b81f9..4da54e2cb 100755 --- a/lib/puppet/type/file/type.rb +++ b/lib/puppet/type/file/type.rb @@ -3,23 +3,16 @@ module Puppet require 'etc' desc "A read-only state to check the file type." - #munge do |value| - # raise Puppet::Error, ":type is read-only" - #end - def retrieve - currentvalue = :absent + current_value = :absent if stat = @resource.stat(false) - currentvalue = stat.ftype + current_value = stat.ftype end - # so this state is never marked out of sync - @should = [currentvalue] - currentvalue + current_value end - - def sync - raise Puppet::Error, ":type is read-only" + validate do + fail "type is read-only" end end end |
