If someone has hacked my machine with my user account, it seems like they are in a very good position of changing my /etc/hosts file without my script to help them. Right?
No. This is why we have different user accounts. Your user does not have write access to /etc/hosts and therefore anyone who compromises your account also lack the write access to that file. If you bypass that by some means in your script (sudo, setuid, whatever) then the attacker suddenly does have access to write to the previously protected file via your script.
So don't do that.
In reply to Re^8: Best way to write to a file owned by root?
by hippo
in thread Best way to write to a file owned by root?
by nysus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |