I have a Python script that access the network, and I want to deny it network access sometimes. How can I achieve this with SELinux or AppArmor? I want to be able to launch this specific script with restricted access.
If you have SELinux enabled, I was under the impression that the default action was to deny access so what you want to do is to allow network access at times, right?
I suspect that you going to have to do something like this answer on serverfault, which contains SE Linux configuration for a single process
AppArmor has already been well-answered :)
AppArmor has the ability to block network connections from applications. I've never done it myself, but you should look at the AppArmor community page and the network rules page for details on how to do it.
From the looks of it, the