summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2012-07-02 18:05:04 +0200
committerintrigeri <intrigeri@boum.org>2012-07-02 18:13:24 +0200
commit78ce35ce97ffc887f0786289789bec8f9880ca9c (patch)
tree7c6527b1b31a4506dd303810567aec80f8b6b8ec
parent02208c77ac7ebc7062d239f9c4873dcf96c906a6 (diff)
Use a temporary file + atomic move when exporting the repository public key.
-rw-r--r--templates/reprepro-export-key.sh.erb4
1 files changed, 3 insertions, 1 deletions
diff --git a/templates/reprepro-export-key.sh.erb b/templates/reprepro-export-key.sh.erb
index c99f06b..1afcef8 100644
--- a/templates/reprepro-export-key.sh.erb
+++ b/templates/reprepro-export-key.sh.erb
@@ -3,5 +3,7 @@
KEY="`gpg --homedir <%= basedir %>/.gnupg --with-colon --list-secret-keys | cut -d : -f 5 | head -n 1`"
if [ ! -z "$KEY" ]; then
- gpg --homedir <%= basedir %>/.gnupg --export --armor $KEY > <%= basedir %>/key.asc
+ tempfile=$(mktemp)
+ gpg --homedir <%= basedir %>/.gnupg --export --armor $KEY > "$tempfile"
+ mv "$tempfile" <%= basedir %>/key.asc
fi