I'm running GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu) on a Linux Mint 21.2 Victoria system.
I'll be grateful if anyone can explain this for me as I haven't been able to find any documentation which does. Everything is working as I would like it to but I don't know what mechanism allows 'user' to write to 'root' files without permission.
I'll be happy to provide further documentation if needed.
Synopsis:
anacron invokes 'foo' as 'root' and redirects 2>&1 to create/overwrite a debug file
'root' invocation of 'foo' calls 'runuser' to invoke 'foo' as 'user' redirecting 2>&1 to create/overwrite or append a debug file
it doesn't matter whether the 'runuser' redirection is to the same file or a different file
it doesn't matter whether the 'runuser' redirection creates/overwrites or appends to the file
the output file from the anacron/runuser redirection is owned by 'root' - permissions '0644')
'root' invocation of 'foo' exits, having written to the debug file which it owns
'user' invocation of 'foo' runs, appends/overwrites the debug file which 'root' owns
'user' invocation of 'foo' exits, having written to the debug file which 'root' owns
Invoking 'foo' as 'user' and redirecting to the 'root' owned debug file in a Terminal session gets "Permission denied"