Repository navigation
Add apparmor change hat functionality to fpm - #373
Conversation
|
You may be better to ask internals@php.net so that someone who know fpm to commit this. I would like to help you, but I don't use apparmor. |
|
@yohgaki this was already diskussen on internals and there is an rfc for it; but there were only three votes. So it was suggested to contact the maintainers of fpm - but they haven't answered so far :( |
|
I know the discussion and I know there are many cases that good patches are forgotten. Since this is new feature that only applied to master, I may merge the patch if there is good test scripts for this change. I cannot help making test script as I don't use apparmor, though. Could you provide test script? |
|
I'd be happy to write a test script. But at the moment I'm not really sure how:
So right now it is a bit hard to create a test.
Maybe I can detect from the log file, that the profile change went wrong and can test the error cases. But at the moment two things can happen:
Because of all of this I wouldn't recommend putting that into the php sources. I could try to provide virtual machine image which has everything set up for testing. On a completely unrelated note: I could rewrite the whole thing to not require libapparmor and talk directly to the kernel. Would be one less dependency and IMHO shouldn't have any disadvantages. |
|
It is possible to get a partial test, to where you can make a change_hat/profile call and get an error code returned by apparmor without having to load policy. change_profile will return ENOENT when it can't find the specified profile Upstream apparmor would also be willing to carry a regression test, which could do the policy loads etc, for this if that would help. |
|
Sry for taking so long; I had some other stuff going on and I didn't want to just write some small test script, but create phpt tests for fpm and some helpful scripts for adding more tests in the future. Sadly I had to write a new command line option for fpm (--force-stderr) so I can catch the error log in the tests. Without this php-fpm detects that stderr is not a TTY and just rejects to write to it. I hope this small change is not a big problem for this patch. I wanted to test more, but since root privileges are needed for detecting anything apparmor related (existing profiles, if it is running, ...) I just added a test that tries to switch to a non existent hat if apparmor is compiled in. |
|
Hello! |
|
As far as I can see, it is still part of php (checked the current master). Usage: |
|
Thanks! My understanding is that there's usually a parent policy in place Appreciate you taking the time!
|
|
On 09/14/2016 04:03 AM, Chris Fidao wrote:
|
With this patch the pool config gets the additional parameter apparmor_hat.
Workers of this pool change their app armor hat to the configured one during spawn.
Original Pull Request: #343
Changed aa_change_hat to aa_change_profile. Thx to @jjohansen for spotting the error.
RFC: https://wiki.php.net/rfc/fpm_change_hat