- 
      
- 
        Save devynspencer/ee8ea7163a1871b8264d to your computer and use it in GitHub Desktop. 
    Chef recipe to set noexec option for /dev/shm
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # 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