In my CMS (Rails 4), I need to let a user make CRUD processes on CIFS mount points. In order to have a permanent CIFS mount on a CentOS (6) system, I need to edit the /etc/fstab
file and update the mount list with the sudo mount -a
command. When I try to open /etc/fstab
file with File.open
:
File.open("/etc/fstab", "a") do |f|
f.puts "\n test"
end
I get this error:
Errno::EACCES: Permission denied - /etc/fstab
It's normal because /etc/fstab
file belongs to the root user. Is there a way to open a file as super user? At the other hand, I'm open to different ideas. My requirement is to edit the fstab file from inside of my application.