Skip to content

Instantly share code, notes, and snippets.

@devynspencer
Forked from geewiz/fs.rb
Created December 4, 2015 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devynspencer/ee8ea7163a1871b8264d to your computer and use it in GitHub Desktop.
Save devynspencer/ee8ea7163a1871b8264d to your computer and use it in GitHub Desktop.
Chef recipe to set noexec option for /dev/shm
# remount /dev/shm
execute "remount_shm" do
action :nothing
command "mount -o remount /dev/shm"
end
# set noexec for /dev/shm
bash "shm_noexec" do
user "root"
cwd "/etc"
code <<-EOH
sed -i.bak -e '/\/dev\/shm/d' /etc/fstab
echo "none /dev/shm tmpfs nodev,nosuid,noexec 0 0" >>/etc/fstab
EOH
not_if 'grep -q -e "/dev/shm.*noexec" /etc/fstab'
notifies :run, "execute[remount_shm]"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment