How can I use etckeeper via sudo with different users and have the correct user in the commit message? [duplicate]

I’m working on a server with several admin users. Each of them can use sudo to make configuration changes. We’re keepeing our /etc directory version-controlled using etckeeper.

However, when I or another admin calls sudo etckeeper commit COMMITMESSAGE, git uses the root user’s name and e-mail for the commit message. Setting git config user.name on the etc repository doesn’t work in this case, because then each time etckeeper commit is called, the same data will be used.

What I want is the actual user’s name and email be present in the etckeeper git repository, so that from the commit log I can track down who did which change.

Any help is greatly appreciated!

Answer

I just tested this out and got this for my output on git log:

commit 1a8e8fb2952cd6e80f0a5211e8d4e8f698fbd02c
Author: ngrayson <ngrayson@<hostname>
Date:   Thu Jan 10 18:09:47 2013 +0000

    init

So it looks like it should grab the user and not run it as root.

Attribution
Source : Link , Question Author : andreas-h , Answer Author : nicgrayson

Leave a Comment