diff options
author | root <root@localhost> | 2013-02-14 00:00:00 +0000 |
---|---|---|
committer | root <root@localhost> | 2013-02-14 00:00:00 +0000 |
commit | 4fe095e1c7ce9f75e215772cc5c1b553c4613891 (patch) | |
tree | a4932c95ba842071b1dd64664d07f478bc0e0813 | |
parent | 3f3c9f05fc7265b8bcee3fa6742839de821a7784 (diff) | |
download | git-remote-gcrypt-4fe095e1c7ce9f75e215772cc5c1b553c4613891.zip git-remote-gcrypt-4fe095e1c7ce9f75e215772cc5c1b553c4613891.tar.gz git-remote-gcrypt-4fe095e1c7ce9f75e215772cc5c1b553c4613891.tar.bz2 |
Use a shorter repository id in the URL, to simplify a tiny bit
-rw-r--r-- | README.rst | 4 | ||||
-rwxr-xr-x | git-remote-gcrypt | 11 |
2 files changed, 8 insertions, 7 deletions
@@ -23,8 +23,8 @@ Example use:: git remote add cryptremote gcrypt::ssh://example.com:repo git push cryptremote master > gcrypt: Setting up new repository at ssh://example.com:repo - > gcrypt: Repository ID is 99b45a84a13168fc5efe - > gcrypt: Repository URL is gcrypt::ssh://example.com:repo/G/99b45a84a13168fc5efe + > gcrypt: Repository ID is KNBr0wKzct52 + > gcrypt: Repository URL is gcrypt::ssh://example.com:repo/G/KNBr0wKzct52 > gcrypt: (configuration for cryptremote updated) > [ more lines .. ] > To gcrypt::[...] diff --git a/git-remote-gcrypt b/git-remote-gcrypt index e758173..b0a4fdf 100755 --- a/git-remote-gcrypt +++ b/git-remote-gcrypt @@ -217,9 +217,10 @@ PRIVDECRYPT() }) } +# Generate $1 random bytes genkey() { - gpg --armor --gen-rand 1 128 | tr -d \\n + gpg --armor --gen-rand 1 "$1" } pack_hash() @@ -260,15 +261,15 @@ make_new_repo() local urlid_= fix_config= echo_info "Setting up new repository at $URL" PUTREPO "$URL" - Masterkey="$(genkey)" + Masterkey="$(genkey 128)" # We need a relatively short ID for URL+REPO # The manifest will be stored at SHA224(urlid_) # Needed assumption: the same user should have no duplicate urlid_ - # For now, we use 20 random hex digits (80 bits), can be increased - urlid_=$(genkey | pack_hash | cut -c 1-20) + # For now, we arbitrarily use 9 random bytes (72 bits) + urlid_=$(genkey 9 | tr '/+' 'Zz') Repoid=$(xecho_n "$urlid_" | pack_hash) - echo_info "Repository ID is" "$urlid_" + echo_info "Repository ID is" "$urlid_" isnoteq "${NAME#gcrypt::}" "$URL" && { git config "remote.$NAME.url" "gcrypt::$URL/G/$urlid_" fix_config=1 |