summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2013-05-16 11:09:43 +1000
committerDamien Miller <djm@mindrot.org>2013-05-16 11:09:43 +1000
commitb6a63d7239cca644e5a8e2512a18768266887286 (patch)
treef5a5ccca5c0461185af1b73df30dae925c0e2c08
parent0bb4a4d24a23df1a754111aa45e2d34b98378e24 (diff)
- (djm) [contrib/ssh-copy-id] Fix bug that could cause "rm *" to be
executed if mktemp failed; bz#2105 ok dtucker@
-rw-r--r--ChangeLog4
-rw-r--r--contrib/ssh-copy-id9
2 files changed, 12 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 69221ad9..2bd3e335 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+20130516
+ - (djm) [contrib/ssh-copy-id] Fix bug that could cause "rm *" to be
+ executed if mktemp failed; bz#2105 ok dtucker@
+
20130510
- (djm) OpenBSD CVS Cherrypick
- djm@cvs.openbsd.org 2013/04/11 02:27:50
diff --git a/contrib/ssh-copy-id b/contrib/ssh-copy-id
index af18a192..9f2817b6 100644
--- a/contrib/ssh-copy-id
+++ b/contrib/ssh-copy-id
@@ -165,6 +165,9 @@ done
eval set -- "$SAVEARGS"
+if [ $# == 0 ] ; then
+ usage
+fi
if [ $# != 1 ] ; then
printf '%s: ERROR: Too many arguments. Expecting a target hostname, got: %s\n\n' "$0" "$SAVEARGS" >&2
usage
@@ -196,7 +199,11 @@ populate_new_ids() {
umask 0177
local L_TMP_ID_FILE=$(mktemp ~/.ssh/ssh-copy-id_id.XXXXXXXXXX)
- trap "rm -f $L_TMP_ID_FILE*" EXIT TERM INT QUIT
+ if test $? -ne 0 || test "x$L_TMP_ID_FILE" = "x" ; then
+ echo "mktemp failed" 1>&2
+ exit 1
+ fi
+ trap "rm -f $L_TMP_ID_FILE ${L_TMP_ID_FILE}.pub" EXIT TERM INT QUIT
printf '%s: INFO: attempting to log in with the new key(s), to filter out any that are already installed\n' "$0" >&2
NEW_IDS=$(
eval $GET_ID | {