Class: Ardecy::Harden::Mountpoint::ProcHidepid

Inherits:
MountInc
  • Object
show all
Defined in:
lib/ardecy/harden/mountpoint.rb

Instance Method Summary collapse

Methods inherited from MountInc

#add_group, #build_args, #edit_fstab, #fix, #group_search, #mount_match, #scan, #x

Methods included from NiTo

#mv, #sed

Methods included from Display

#display_fix_list, #kernel_show, #perm_show, #result, #show_bad_mod, #title

Constructor Details

#initialize(args) ⇒ ProcHidepid

Returns a new instance of ProcHidepid.



117
118
119
120
121
122
# File 'lib/ardecy/harden/mountpoint.rb', line 117

def initialize(args)
  super
  @name = 'proc'
  @ensure = [ 'hidepid=2', 'gid=proc' ]
  @group = 'proc'
end

Instance Method Details

#create_content(in_dir) ⇒ Object



136
137
138
139
140
141
142
143
144
145
# File 'lib/ardecy/harden/mountpoint.rb', line 136

def create_content(in_dir)
  content = [
    '[Service]',
    'SupplementaryGroups=proc',
    ''
  ]
  Dir.mkdir in_dir, 0700 unless Dir.exists? in_dir
  File.write("#{in_dir}/hidepid.conf", content.join("\n"), mode: 'w')
  puts " > Creating file #{in_dir}/hidepid.conf"
end

#systemd_caseObject

man logind.conf check under: > /etc/systemd/logind.conf.d/*.conf > /run/systemd/logind.conf.d/*.conf > /usr/lib/systemd/logind.conf.d/*.conf



128
129
130
131
132
133
134
# File 'lib/ardecy/harden/mountpoint.rb', line 128

def systemd_case
  return unless @args[:fix]

  if File.exist? '/etc/systemd/logind.conf'
    create_content '/etc/systemd/logind.conf.d'
  end
end