Basically I cant use os.Mkdir
or os.MkdirAll
because it will create the directories as root. I know I can go the exec.Cmd
route and set the syscall.Credential{}
. But thats a bit cumbersome and I have to remove and replace a lot of code.
I was wondering if there was anything global I can set so calls to the os package will be ran as a specified user.
Thanks in advance.
In general, a process will make system calls as the user that ran the process. Maybe seteuid
is what you're looking for?