Impossible to setup exec runner for none root user

According to the documentation you should be able to setup the exec runner for a non-root user by putting the config file inside ~/.drone-runner-exec/config however, when you need to setup the exec runner you need to run drone-runner-exec service install which needs to be run by using sudo or by the root user, in either case your current user for that process gets changed to root, which means you can only install the drone exec runner as root.

What I have found out is that drone-runner-exec uses os/user which in turn uses the syscall getUID to get the current user. getUID will return root when running it with sudo and that’s why this bug occurs.

My suggestion would be to use logname or who am i to get the current user and set the right configuration by that. logname and who am i both will return the current logged in user even when using sudo to call them. which would fix the problem

You can only install the service as root, but (as root) it can be configured to run with a given user. For me it’s working well (Ubuntu), all the files created by the exec runner are owned by my configured user. See my StackOverflow answer below: