Package: etckeeper
Version: 0.48

If etckeeper is using git as its VCS, setting the GIT_DIR or GIT_WORK_TREE
environment variables can lead to etckeeper using a repository other than
/etc/.git or a working directory other than /etc. This should be easily
fixed by sanitizing those variables before calling git.

Here's an example where I set GIT_DIR to point to the nagios-plugins git
repository:

root@host:~/git# git clone git://
github.com/nagios-plugins/nagios-plugins.git
Cloning into nagios-plugins...
[...clone completes...]
Resolving deltas: 100% (10894/10894), done.
root@host:~/git# etckeeper vcs log | head -5    # correct result
commit d2aed14f26b083aa9a29b741365776e16eabdb6f
Author: root <root@host.(none)>
Date:   Fri Sep 28 22:40:27 2012 -0700

    Initial commit
root@host:~/git# export GIT_DIR=/root/git/nagios-plugins/.git
root@host:~/git# etckeeper vcs log | head -5     # wrong
commit 05c4c9bfc649ba8f66e470667824200c2cda5314
Merge: c5583ab 2672e95
Author: Sven Nierlein <s...@nierlein.org>
Date:   Tue Sep 25 07:48:14 2012 -0700

This can really create a mess if, say, I've set GIT_DIR during some
development work unrelated to /etc and happen to use apt-get to install a
package:

root@host:~/git# apt-get install linuxlogo
[linuxlogo installs, then etckeeper makes commits to
/root/git/nagios-plugins/.git which replace the nagios-plugins files with
the contents of /etc]
root@host:~/git# git log | head -20
commit 493cf79c6e7726d974e468a9fcada45755de6b3e
Author: root <root@host.(none)>
Date:   Fri Sep 28 23:10:15 2012 -0700

    committing changes in /etc after apt run

    Package changes:

commit 0fd04d9aec990189180ed421344a551238bc49ba
Author: root <root@host>
Date:   Fri Sep 28 23:10:13 2012 -0700

    saving uncommitted changes in /etc prior to apt run

commit 05c4c9bfc649ba8f66e470667824200c2cda5314
Merge: c5583ab 2672e95
Author: Sven Nierlein <s...@nierlein.org>
Date:   Tue Sep 25 07:48:14 2012 -0700

    Merge pull request #19 from gvarisco/patch-1

Here's a less dramatic example with GIT_WORK_TREE set:

root@host:~/git# unset GIT_DIR
root@host:~/git# etckeeper vcs log | head -5  # back to normal
commit d2aed14f26b083aa9a29b741365776e16eabdb6f
Author: root <root@host.(none)>
Date:   Fri Sep 28 22:40:27 2012 -0700

    Initial commit
root@host:~/git# export GIT_WORK_TREE=/root/git/nagios-plugins
root@host:~/git# etckeeper commit
fatal: pathspec '.etckeeper' did not match any files
root@host:~/git# unset GIT_WORK_TREE
root@host:~/git# etckeeper commit
[master acd2dca] [... commit succeeds]

(The hostname has been anonymized in the above examples.)

Regards,
Alex Bradley

Reply via email to