I would like to be able to spawn a linux process that would only have access to stdin, stdout, and stderr (nothing more and nothing less). Can I do this at the process level itself? I am also implicitly stating (oxymoron) that I don't want the spawned process to be able to change the "thing" that the other end of the stream points to.
Metaphorically:
I am also currently looking at SElinux. Would this allow me to create a process that only had access to these three streams? Thank you.
As stated in another answer SELinux does have various permissions that help lock down any process.
The kernel manages access to certain objects (with associated set of permissions) for example a file is an object, a directory is an object, a unix datagram socket is an object and many more.
probably the easiest thing to do is write a little policy. Luckily SELinux is deny by default so run your program and look at the logs for SELinux denials and only allow your program to do what you want. In other words you would avoid adding permission that involve object classes like msg (messages in a systemV message queue), msgq (SystemV message queue itself), sem (semaphores), shm (shared memory) and probably others depending on what it does.
I suggest the first time you do it have SELinux on but in permissive (see setenforce 0)
I would also suggest tools to help you build some policy, it can be a bit overwhelming to write basically raw M4
This sounds very much like what is described this LWN article which basically blocks all syscalls except read, write and exit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With