How to Fix dnsmasq Permissions Issue with SELinux?

0
4
Asked By CuriousCoder92 On

I'm trying to use dnsmasq with the --addn-hosts option to add additional hosts from a file. It works fine when I run it directly from the command line, but it fails when I try to run it from rc.local due to SELinux restrictions. I keep getting a "Permission denied" error in the syslog. I know I need to use the chcon command to set the correct SELinux type on the file, but I'm unsure which type it should be. I've tried copying the context from rc.local, but that didn't work, and searching online hasn't been very helpful. Do any of you know what SELinux context I need for the addn-hosts files? **EDIT:** I figured it out! It's chcon -t dnsmasq_etc_t ...

3 Answers

Answered By ScriptingSage On

It's worth asking why you're using rc.local instead of setting up a proper service for dnsmasq. Also, check if the path you're using for the addn-hosts file is out of the ordinary for typical service access, like directories under your home folder. SELinux is strict about services accessing unusual paths.

Answered By CuriousCoder92 On

Yeah, I confirmed it was a SELinux issue, but I didn't want to disable it entirely. I was actually using a custom path that's not in my home directory, just somewhere under / where I keep my scripts and custom setups. **EDIT:** I eventually solved it—check my update above!

Answered By TechGuruX On

First, you should confirm if SELinux is actually causing the issue. Run `getenforce` in your terminal. If it returns 1, then SELinux is enabled. If that's the case, try running `setenforce 0` to put SELinux into permissive mode. This way, you'll log the potential issues without blocking them. After that, check if your setup works from rc.local. If it does, then you know SELinux is indeed the problem.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.