The curious case of missing directories from Apache

While putting together a automated cod-coverage tool for our project (using Cobertura), I hit upon a very peculiar problem. The code-coverage reports were to be auto-triggered for every build of the IBM JDK and published for measuring our code coverage internally. It was observed that only certain directories were showing up on the web server while the others simply were not.

After several trial and errors (changing path where the reports were shown, running as a different user id, etc) we were still unable to crack the source of the issue. What added more intrigue to all of this was the fact that if I create a new file manually, it would show up but not the one's triggered from the coverage tool.

We ran through the httpd.conf to make sure that things were fine there and they were.

Post several google searches, I stumbled upon this not so often used extension to the "ls" command "-Z".

Documentation states
-Z --context - print any SELinux security context of each file
When I went about running this command on the directory that would be serving the code-coverage report, I saw this:
While most of the other folders were labeled with a httpd_sys_content_t security context, one of them oddly stood out as user_home_t. For more information on security contexts and what they mean, read this

I had no clue that my system was running with SELinux enabled and so before making any change, I ran "sestatus" which reported:
confirming that the system was indeed running with SELinux enabled.

Then, I went looking for a command to change the security context to reflect the right content of the file and "chcon" came in handy.
Now, after I generate the coverage reports, I simply set the security context of the files to httpd_sys_content_t and voila they appear automatically.

While there could be other ways of doing the same (by changing the global SELinux setting or a directory based change), my fix was quick and did not mess up with any other system config.

Comments

Popular posts from this blog

From API Keys to Local Power: Run Your CrewAI Agents Offline

The Talent Gap Myth: How Traditional Engineers Evolve in the GenAI Era

Traditional AI vs. Generative AI: Same Foundations, Different Language