Skip to content
Snippets Groups Projects
Verified Commit c8994a2c authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

gitsig: Re-create the git-gpg instead of providing it

Recreate the gpg home directory instead of packing it in git. It seems
the format is not transferable.

Also, provide maintenance script to refresh the keys (import
revocations, etc).

And move the directory to .git-gpg, so it doesn't bother people.
parent f0dde7a6
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ Setup
-----
All these tools use separate gnupg home with the trusted keys. They expect the
directory to be $HOME/git-gpg. It may be possible (and better from security
directory to be $HOME/.git-gpg. It may be possible (and better from security
point of view) if some of the files weren't writable by the current user, to
ensure malicious attacker can't add another key into the keyring.
......@@ -17,7 +17,7 @@ questionable if this adds any level of security, or if the attacker could
disable the check completely when already in the position to tamper with local
files.
It is important to check the gpg -k *every time* the git-gpg directory is
It is important to check the gpg -k *every time* the .git-gpg directory is
updated (so an attacker couldn't sneak a key into the git repository and wait
for it to be installed by accident).
......@@ -35,3 +35,16 @@ Signed tip
This script simply terminates successfully if the tip of the current branch is
signed by a trusted key and fails if it is not. It is expected to be run before
any code from any repository is used.
gen-gpg
-------
This is a maintainance script. It imports the keys and trust settings from
files in this directory (trusted_keys.gpg and trust.txt) and creates the
$HOME/.git-gpg.
gpg-refresh
-----------
Refresh keys from a keyserver. This will import any revocations or possible new
signatures on the keys. It is recommended to put into a cron script.
#!/bin/bash
# Copyright (c) 2015, CZ.NIC, z.s.p.o. (http://www.nic.cz/)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the CZ.NIC nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL CZ.NIC BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
set -e
export GNUPGHOME=$HOME/.git-gpg
mkdir -p $GNUPGHOME
chmod 0700 $GNUPGHOME
gpg --batch --import trusted_keys.gpg
gpg --batch --import-ownertrust <trust.txt
./gpg-refresh
gpg --batch --check-trustdb
echo "****************************************"
echo "* Check the following output manually! *"
echo "****************************************"
gpg -k
879
ruth
v:1:
File deleted
File deleted
#!/bin/bash
# Copyright (c) 2015, CZ.NIC, z.s.p.o. (http://www.nic.cz/)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the CZ.NIC nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL CZ.NIC BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
set -e
export GNUPGHOME=$HOME/.git-gpg
gpg --keyserver hkp://pgp.mit.edu --refresh-keys
......@@ -25,5 +25,5 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
export GNUPGHOME=$HOME/git-gpg
export GNUPGHOME=$HOME/.git-gpg
git log -n1 --pretty="%G?" | grep -qF 'G'
# List of assigned trustvalues, created Tue 08 Dec 2015 01:10:13 PM CET
# (Use "gpg --import-ownertrust" to restore them)
EB7F8CD1A01B184215D86E0FEFFA16C329C1DDB2:2:
460B4CF5E995864B71D719B78CB80BB7F8233AEA:6:
This diff is collapsed.
......@@ -30,12 +30,12 @@ use Storable qw(store retrieve);
# Configure where the gpg directory with trusted keys to sign git commits lives.
# Then run the git-log command that reads and checks the signatures on commits.
$ENV{GNUPGHOME} = "$ENV{HOME}/git-gpg";
$ENV{GNUPGHOME} = "$ENV{HOME}/.git-gpg";
open my $cmd, '-|', 'git', 'log', '--pretty=%H %G? %ae %ce %s' or die "Couldn't run the git log command: $!\n";
# Read cache of known commits, but don't fail if the file is not there
my $known_commits = {};
my $cache_file = "$ENV{HOME}/git-gpg/known_commits";
my $cache_file = "$ENV{HOME}/.git-gpg/known_commits";
eval { $known_commits = retrieve $cache_file };
# Regular expression of addresses of people who must sign their commits.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment