New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Permission issues using file_puts_contents on /etc/hosts #5
Comments
I had to play around with permissions a bit as well so I'm not too sure of a perfect solution. I'll keep this open for now though in case anyone else has any good ideas since I'd also like to get some good documentation in place for any prep needed to the hosts file. |
+1 |
sudo chmod 664 /etc/hosts works for me on Mac. |
@TTiger better solution than mine, I was just |
Thanks all, I think it's pretty safe to close this for now since it's more of a platform / permissions related issue. I made a small note in the Troubleshooting section of the ReadMe with the chmod settings from @TTiger |
Please note that adding more permissions to /etc/hosts may make your system vulnerable to DNS hijacking attack since /etc/hosts is preferred over any DNS server Better solution would be to trigger sudo prompt, maybe something bit like this <?php
namespace App\FileManagers;
class HostsFileManager extends BaseFileManager {
public function appendLine($line)
{
// Do we need to sanitize these variables? Probably yes
return exec('echo "' . $line . PHP_EOL . '" | sudo tee -a ' . $this->filePath);
}
} (Only works for Linux and OSX) |
Thanks Kehet, I'll keep this open for now and see if we can get an update in place for Linux/OSX |
and I'm back using |
Because I use sudo to access my /etc/hosts file, writing to it from line 133 is returning permission denied. Is there a way around this without 'chmod-ing' my hosts file?
The text was updated successfully, but these errors were encountered: