2015-08-01 07:21:32 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
# copyright: 2015, Vulcano Security GmbH
|
2015-10-06 16:55:44 +00:00
|
|
|
# author: Dominik Richter
|
|
|
|
# author: Christoph Hartmann
|
2015-08-01 07:21:32 +00:00
|
|
|
# license: All rights reserved
|
|
|
|
|
2016-03-08 18:06:55 +00:00
|
|
|
module Inspec::Resources
|
|
|
|
class Postgres < Inspec.resource(1)
|
|
|
|
name 'postgres'
|
2015-08-28 19:37:03 +00:00
|
|
|
|
2016-03-08 18:06:55 +00:00
|
|
|
attr_reader :service, :data_dir, :conf_dir, :conf_path
|
|
|
|
def initialize
|
|
|
|
case inspec.os[:family]
|
|
|
|
when 'ubuntu', 'debian'
|
|
|
|
@service = 'postgresql'
|
|
|
|
@data_dir = '/var/lib/postgresql'
|
|
|
|
@version = inspec.command('ls /etc/postgresql/').stdout.chomp
|
|
|
|
@conf_dir = "/etc/postgresql/#{@version}/main"
|
2016-03-09 09:39:07 +00:00
|
|
|
@conf_path = File.join @conf_dir, 'postgresql.conf'
|
2015-08-01 07:21:32 +00:00
|
|
|
|
2016-03-08 18:06:55 +00:00
|
|
|
when 'arch'
|
|
|
|
@service = 'postgresql'
|
|
|
|
@data_dir = '/var/lib/postgres/data'
|
|
|
|
@conf_dir = '/var/lib/postgres/data'
|
2016-03-09 09:39:07 +00:00
|
|
|
@conf_path = File.join @conf_dir, 'postgresql.conf'
|
2015-08-01 07:21:32 +00:00
|
|
|
|
2016-03-08 18:06:55 +00:00
|
|
|
else
|
|
|
|
@service = 'postgresql'
|
|
|
|
@data_dir = '/var/lib/postgresql'
|
|
|
|
@conf_dir = '/var/lib/pgsql/data'
|
2016-03-09 09:39:07 +00:00
|
|
|
@conf_path = File.join @conf_dir, 'postgresql.conf'
|
2016-03-08 18:06:55 +00:00
|
|
|
end
|
2015-08-01 07:21:32 +00:00
|
|
|
end
|
2015-10-12 11:01:58 +00:00
|
|
|
|
2016-03-08 18:06:55 +00:00
|
|
|
def to_s
|
|
|
|
'PostgreSQL'
|
|
|
|
end
|
2015-10-12 11:01:58 +00:00
|
|
|
end
|
2015-08-01 07:21:32 +00:00
|
|
|
end
|