I'm working on a little side project on linux(Ubuntu) where I require one to be authenticated to access a service. My idea is that this authentication should be stored with the process and it's children, and not with the linux user itself.
This authentication should be done by calling for example "myapplogin" with a username, password and a script/application(Any application) to run with these credentials. I want it to be possible to retain these credentials in any children made by this process, and any grandchildren and so on.
I have looked at a few options for this capability.
Store a login id or something in the environment variables. This is, as far as I know, passed on to any children. However, environment variables can be written to by the process, thus allowing it to possibly gain access it should not have.
When logging in, store the process id of the process who logged in, and then on every operation to this service, check if it has the stored pid, or if anywhere in it's ancestry the stored pid exists. This will possibly become too slow if this ancestry grows large, and if the service is accessed often. An option then is to cache any pid who is in the ancestry, but that can have security implications with pid reuse in the OS.
Using process groups and link that with a login, but that can also be changed by the process itself, allowing it to possibly join an existing group without actually logging in.
Is there any way to do this? Preferably it should be something stored with the process, that any new children inherits, not possible for the process to overwrite, and readable externally from a kernel module.
Maybe I'm just overlooking something obvious? I would be grateful for any input on this =)