# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../libdomainkeys/libdomainkeys-dknewkey.patch
# Copyright (C) 2009 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This patch file is dual-licensed. It is available under the license the
# patched project is licensed under, as long as it is an OpenSource license
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
# of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# --- SDE-COPYRIGHT-NOTE-END ---

--- ../libdomainkeys-0.66/dknewkey	2005-04-08 22:35:58.000000000 +0300
+++ ./dknewkey	2005-06-25 19:45:11.000000000 +0300
@@ -1,13 +1,18 @@
 #!/bin/sh
 
 BITS=384
+if [ -z "$1" ]; then
+	echo >&2 "Usage: dknewkey keyfile [bits]"
+	exit 1
+fi
+tmpfile=$(mktemp ${TMPDIR:-/tmp}/dknewkeyXXXXXX) || exit 1
 if test -n "$2"; then BITS=$2; fi
 
 openssl genrsa -out $1 $BITS 2>/dev/null
-openssl rsa -in $1 -out /tmp/dknewkey.$$ -pubout -outform PEM 2>/dev/null
-if test -f /usr/local/bin/tinydns-data; then
-  printf "'%s._domainkey.example.com:k=rsa; p=%s\n" `basename $1` `grep -v ^-- /tmp/dknewkey.$$ | tr -d '\n'`
+openssl rsa -in $1 -out $tmpfile -pubout -outform PEM 2>/dev/null
+if test -f /usr/bin/tinydns-data; then
+  printf "'%s._domainkey.example.com:k=rsa; p=%s\n" `basename -- $1` `grep -v ^-- $tmpfile | tr -d '\n'`
 else
-  printf "%s._domainkey\tIN\tTXT\t\"k=rsa; p=%s\"\n" `basename $1` `grep -v ^-- /tmp/dknewkey.$$ | tr -d '\n'`
+  printf "%s._domainkey\tIN\tTXT\t\"k=rsa; p=%s\"\n" `basename -- $1` `grep -v ^-- $tmpfile | tr -d '\n'`
 fi
-rm -f /tmp/dknewkey.$$
+rm -f $tmpfile