mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
7d986c2d17
Signed-off-by: Patrick Münch <patrick.muench1111@gmail.com>
46 lines
1.4 KiB
Ruby
46 lines
1.4 KiB
Ruby
# encoding: utf-8
|
|
# copyright: 2015, Vulcano Security GmbH
|
|
# author: Dominik Richter
|
|
# author: Christoph Hartmann
|
|
# license: All rights reserved
|
|
|
|
module Inspec::Resources
|
|
class Postgres < Inspec.resource(1)
|
|
name 'postgres'
|
|
|
|
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"
|
|
@conf_path = File.join @conf_dir, 'postgresql.conf'
|
|
|
|
when 'arch'
|
|
@service = 'postgresql'
|
|
@data_dir = '/var/lib/postgres/data'
|
|
@conf_dir = '/var/lib/postgres/data'
|
|
@conf_path = File.join @conf_dir, 'postgresql.conf'
|
|
|
|
when 'centos', 'redhat'
|
|
@service = 'postgresql'
|
|
@version = inspec.command('ls /var/lib/pgsql/').stdout.chomp
|
|
@data_dir = "/var/lib/pgsql/#{@version}/data"
|
|
@conf_dir = "/var/lib/pgsql/#{@version}/data"
|
|
@conf_path = File.join @conf_dir, 'postgresql.conf'
|
|
|
|
else
|
|
@service = 'postgresql'
|
|
@data_dir = '/var/lib/postgresql'
|
|
@conf_dir = '/var/lib/pgsql/data'
|
|
@conf_path = File.join @conf_dir, 'postgresql.conf'
|
|
end
|
|
end
|
|
|
|
def to_s
|
|
'PostgreSQL'
|
|
end
|
|
end
|
|
end
|