hroot
hroot copied to clipboard
When exporting to graph, chown files to user
If the environment variable SUDO_USER is set to a valid user, and the running user's uid is zero, set the ownership of all graph files to the uid of SUDO_USER while exporting.
This avoids the common problem of running docket as root (to get access to docket.sock) then being unable to mess with your graph repository, because root :(
The 'do nothing if current_uid != 0' logic is in case you're running as some other not-root user, in which case you're probably doing advanced wizardry and would be confused by files getting chowned around.
Also add --no-chown flag to unconditionally disable behavior.
As noted in #39, we should consider executing git as the SUDO_USER as well, unless git is smart enough to adjust for this on its own. Basically, research into which .gitconfig files git will use in what circumstances.