]> ruderich.org/simon Gitweb - tlsproxy/tlsproxy.git/commitdiff
tlsproxy-setup: Prevent accidental overwrites.
authorSimon Ruderich <simon@ruderich.org>
Tue, 10 Dec 2013 13:16:13 +0000 (14:16 +0100)
committerSimon Ruderich <simon@ruderich.org>
Fri, 27 Dec 2013 15:56:43 +0000 (16:56 +0100)
man/tlsproxy-setup.txt
src/tlsproxy-setup

index 9e482f3f7e7626f3079593851e406bd34c0a262b..f5cf5110df203c027296438f8bc4ef83f8ad9f59 100644 (file)
@@ -10,7 +10,7 @@ tlsproxy-setup - create necessary files for tlsproxy
 SYNOPSIS
 --------
 
 SYNOPSIS
 --------
 
-*tlsproxy-setup*
+*tlsproxy-setup* ['--force']
 
 
 DESCRIPTION
 
 
 DESCRIPTION
@@ -21,11 +21,13 @@ empty directory.
 
 It creates the following files in the current directory:
 
 
 It creates the following files in the current directory:
 
-- proxy-ca.pem
-- proxy-ca-key.pem
-- proxy-dh.pem
-- proxy-key.pem
-- proxy-invalid.pem
+- `proxy-ca.pem`
+- `proxy-ca-key.pem`
+- `proxy-dh.pem`
+- `proxy-key.pem`
+- `proxy-invalid.pem`
+
+If any of these files exist, the program is aborted.
 
 Requires GnuTLS' *certtool*.
 
 
 Requires GnuTLS' *certtool*.
 
index d76c998689454c38d004a93d304f00aa932302ee..155b8c90786c9aff26a520b0d9caad45dfbec69d 100755 (executable)
 set -e
 
 
 set -e
 
 
-if test "$#" -ne 0; then
-    echo "Usage: $0"
+if test "$#" -ge 1 && test x"$*" != 'x--force'; then
+    echo "Usage: $0 [--force]" >&2
     exit 1
 fi
 
     exit 1
 fi
 
+# Prevent accidental overwrites.
+if test x"$1" != 'x--force'; then
+    for x in proxy-ca-key.pem proxy-ca.pem \
+             proxy-key.pem proxy-invalid.pem proxy-dh.pem; do
+        if test -f "$x"; then
+            echo "File '$x' already exists. Use --force to overwrite." >&2
+            exit 2
+        fi
+    done
+fi
+
+
 tempfile=`mktemp`
 trap 'rm -f "$tempfile"' EXIT
 
 tempfile=`mktemp`
 trap 'rm -f "$tempfile"' EXIT