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'
|
require 'utils/simpleconfig'
|
||||||
|
|
||||||
class LimitsConf < Vulcano::Resource
|
class LimitsConf < Vulcano.resource(1)
|
||||||
|
name 'limits_conf'
|
||||||
|
|
||||||
def initialize(path)
|
def initialize(path)
|
||||||
@runner = Specinfra::Runner
|
|
||||||
@conf_path = path
|
@conf_path = path
|
||||||
@files_contents = {}
|
@files_contents = {}
|
||||||
@content = nil
|
@content = nil
|
||||||
|
@ -26,11 +26,12 @@ class LimitsConf < Vulcano::Resource
|
||||||
|
|
||||||
def read_content
|
def read_content
|
||||||
# read the file
|
# 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}\""
|
return skip_resource "Can't find file \"#{@conf_path}\""
|
||||||
end
|
end
|
||||||
@content = read_file(@conf_path)
|
@content = file.contents
|
||||||
if @content.empty? && @runner.get_file_size(@conf_path).stdout.strip.to_i > 0
|
if @content.empty? && file.size > 0
|
||||||
return skip_resource "Can't read file \"#{@conf_path}\""
|
return skip_resource "Can't read file \"#{@conf_path}\""
|
||||||
end
|
end
|
||||||
# parse the file
|
# parse the file
|
||||||
|
@ -42,15 +43,4 @@ class LimitsConf < Vulcano::Resource
|
||||||
@content
|
@content
|
||||||
end
|
end
|
||||||
|
|
||||||
def read_file(path)
|
|
||||||
@files_contents[path] ||= @runner.get_file_content(path).stdout
|
|
||||||
end
|
|
||||||
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'
|
require 'utils/simpleconfig'
|
||||||
|
|
||||||
class LoginDef < Vulcano::Resource
|
class LoginDef < Vulcano.resource(1)
|
||||||
|
name 'login_defs'
|
||||||
|
|
||||||
def initialize(path = nil)
|
def initialize(path = nil)
|
||||||
@runner = Specinfra::Runner
|
|
||||||
@conf_path = path || '/etc/login.defs'
|
@conf_path = path || '/etc/login.defs'
|
||||||
@files_contents = {}
|
@files_contents = {}
|
||||||
@content = nil
|
@content = nil
|
||||||
|
@ -26,11 +26,12 @@ class LoginDef < Vulcano::Resource
|
||||||
|
|
||||||
def read_content
|
def read_content
|
||||||
# read the file
|
# 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}\""
|
return skip_resource "Can't find file \"#{@conf_path}\""
|
||||||
end
|
end
|
||||||
@content = read_file(@conf_path)
|
@content = file.contents
|
||||||
if @content.empty? && @runner.get_file_size(@conf_path).stdout.strip.to_i > 0
|
if @content.empty? && file.size > 0
|
||||||
return skip_resource "Can't read file \"#{@conf_path}\""
|
return skip_resource "Can't read file \"#{@conf_path}\""
|
||||||
end
|
end
|
||||||
# parse the file
|
# parse the file
|
||||||
|
@ -41,13 +42,4 @@ class LoginDef < Vulcano::Resource
|
||||||
@content
|
@content
|
||||||
end
|
end
|
||||||
|
|
||||||
def read_file(path)
|
|
||||||
@files_contents[path] ||= @runner.get_file_content(path).stdout
|
|
||||||
end
|
|
||||||
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/file'
|
||||||
# require 'resources/group_policy'
|
# require 'resources/group_policy'
|
||||||
# require 'resources/inetd_conf'
|
# require 'resources/inetd_conf'
|
||||||
# require 'resources/limits_conf'
|
require 'resources/limits_conf'
|
||||||
# require 'resources/login_def'
|
require 'resources/login_def'
|
||||||
require 'resources/mysql'
|
require 'resources/mysql'
|
||||||
require 'resources/mysql_conf'
|
require 'resources/mysql_conf'
|
||||||
require 'resources/mysql_session'
|
require 'resources/mysql_session'
|
||||||
|
|
Loading…
Reference in a new issue