mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
migrate limits and login defs
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
parent
8004d6f129
commit
2103a4485b
3 changed files with 14 additions and 32 deletions
|
@ -4,10 +4,10 @@
|
|||
|
||||
require 'utils/simpleconfig'
|
||||
|
||||
class LimitsConf < Vulcano::Resource
|
||||
class LimitsConf < Vulcano.resource(1)
|
||||
name 'limits_conf'
|
||||
|
||||
def initialize(path)
|
||||
@runner = Specinfra::Runner
|
||||
@conf_path = path
|
||||
@files_contents = {}
|
||||
@content = nil
|
||||
|
@ -26,11 +26,12 @@ class LimitsConf < Vulcano::Resource
|
|||
|
||||
def read_content
|
||||
# read the file
|
||||
if !@runner.check_file_is_file(@conf_path)
|
||||
file = @vulcano.file(@conf_path)
|
||||
if !file.is_file?
|
||||
return skip_resource "Can't find file \"#{@conf_path}\""
|
||||
end
|
||||
@content = read_file(@conf_path)
|
||||
if @content.empty? && @runner.get_file_size(@conf_path).stdout.strip.to_i > 0
|
||||
@content = file.contents
|
||||
if @content.empty? && file.size > 0
|
||||
return skip_resource "Can't read file \"#{@conf_path}\""
|
||||
end
|
||||
# parse the file
|
||||
|
@ -42,15 +43,4 @@ class LimitsConf < Vulcano::Resource
|
|||
@content
|
||||
end
|
||||
|
||||
def read_file(path)
|
||||
@files_contents[path] ||= @runner.get_file_content(path).stdout
|
||||
end
|
||||
end
|
||||
|
||||
module Serverspec::Type
|
||||
def limits_conf(path = nil)
|
||||
@limits_conf ||= {}
|
||||
dpath = path || '/etc/security/limits.conf'
|
||||
@limits_conf[dpath] ||= LimitsConf.new(dpath)
|
||||
end
|
||||
end
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
require 'utils/simpleconfig'
|
||||
|
||||
class LoginDef < Vulcano::Resource
|
||||
class LoginDef < Vulcano.resource(1)
|
||||
name 'login_defs'
|
||||
|
||||
def initialize(path = nil)
|
||||
@runner = Specinfra::Runner
|
||||
@conf_path = path || '/etc/login.defs'
|
||||
@files_contents = {}
|
||||
@content = nil
|
||||
|
@ -26,11 +26,12 @@ class LoginDef < Vulcano::Resource
|
|||
|
||||
def read_content
|
||||
# read the file
|
||||
if !@runner.check_file_is_file(@conf_path)
|
||||
file = @vulcano.file(@conf_path)
|
||||
if !file.is_file?
|
||||
return skip_resource "Can't find file \"#{@conf_path}\""
|
||||
end
|
||||
@content = read_file(@conf_path)
|
||||
if @content.empty? && @runner.get_file_size(@conf_path).stdout.strip.to_i > 0
|
||||
@content = file.contents
|
||||
if @content.empty? && file.size > 0
|
||||
return skip_resource "Can't read file \"#{@conf_path}\""
|
||||
end
|
||||
# parse the file
|
||||
|
@ -41,13 +42,4 @@ class LoginDef < Vulcano::Resource
|
|||
@content
|
||||
end
|
||||
|
||||
def read_file(path)
|
||||
@files_contents[path] ||= @runner.get_file_content(path).stdout
|
||||
end
|
||||
end
|
||||
|
||||
module Serverspec::Type
|
||||
def login_def(path = nil)
|
||||
LoginDef.new(path)
|
||||
end
|
||||
end
|
|
@ -11,8 +11,8 @@ require 'vulcano/resource'
|
|||
# require 'resources/file'
|
||||
# require 'resources/group_policy'
|
||||
# require 'resources/inetd_conf'
|
||||
# require 'resources/limits_conf'
|
||||
# require 'resources/login_def'
|
||||
require 'resources/limits_conf'
|
||||
require 'resources/login_def'
|
||||
require 'resources/mysql'
|
||||
require 'resources/mysql_conf'
|
||||
require 'resources/mysql_session'
|
||||
|
|
Loading…
Reference in a new issue