From d6b7033f2bb79e6243eb866f83cce43add1fba56 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 22 Feb 2014 10:13:51 +0100 Subject: [PATCH 1/3] ++changes Signed-off-by: Nico Schottelius --- docs/changelog | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 1dbc0787..66a83b31 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,8 +5,10 @@ Changelog * Exception: No braces means author == Nico Schottelius -3.0.10: +next: * Type __git: Pass onwer/group/mode values to __directory + * Type __ssh_authorized_keys: Allow managing existing keys (Steven Armstrong) + 3.0.9: 2014-02-14 * Core: Ignore order dependencies if override is set (Daniel Heule) From ce0f779664e5808382134f12904553b30db65c22 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 24 Feb 2014 16:00:12 +0100 Subject: [PATCH 2/3] include the owner into the object_id for line Signed-off-by: Nico Schottelius --- cdist/conf/type/__ssh_authorized_keys/manifest | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__ssh_authorized_keys/manifest b/cdist/conf/type/__ssh_authorized_keys/manifest index 01a29c37..313e3b23 100755 --- a/cdist/conf/type/__ssh_authorized_keys/manifest +++ b/cdist/conf/type/__ssh_authorized_keys/manifest @@ -1,6 +1,7 @@ #!/bin/sh # # 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc) +# 2014 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -75,7 +76,11 @@ IFS=$'\n' for key in $(cat "$__object/parameter/key"); do unset IFS raw_key="$(echo "$key" | tr ' ' '\n' | awk '/^ssh-(rsa|dsa)/ {printf $1" ";getline;printf $1}')" - set -- "$(_cksum "$raw_key")" + + cksum_key="$(_cksum "$raw_key")" + line_id="${owner}-${cksum_key}" + + set -- "$line_id" set -- "$@" --file "$file" set -- "$@" --regex ".*$raw_key.*" if [ "$state" = 'present' ]; then From a126bd955ff2aafc2e715a9fb9b7a5c515bcc0d2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 24 Feb 2014 18:06:15 +0100 Subject: [PATCH 3/3] use while read -> avoids ifs problem Signed-off-by: Nico Schottelius --- cdist/conf/type/__ssh_authorized_keys/manifest | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/cdist/conf/type/__ssh_authorized_keys/manifest b/cdist/conf/type/__ssh_authorized_keys/manifest index 313e3b23..efcd2d7a 100755 --- a/cdist/conf/type/__ssh_authorized_keys/manifest +++ b/cdist/conf/type/__ssh_authorized_keys/manifest @@ -71,21 +71,17 @@ _cksum() { echo "$1" | cksum | cut -d' ' -f 1 } -# Add each key -IFS=$'\n' -for key in $(cat "$__object/parameter/key"); do - unset IFS - raw_key="$(echo "$key" | tr ' ' '\n' | awk '/^ssh-(rsa|dsa)/ {printf $1" ";getline;printf $1}')" - - cksum_key="$(_cksum "$raw_key")" +while read key; do + cksum_key="$(_cksum "$key")" line_id="${owner}-${cksum_key}" set -- "$line_id" set -- "$@" --file "$file" - set -- "$@" --regex ".*$raw_key.*" + set -- "$@" --regex ".*$key.*" if [ "$state" = 'present' ]; then set -- "$@" --line "$key" fi set -- "$@" --state "$state" - require="__block/$__object_name" __line "$@" -done + # Ensure __line does not read stdin + require="__block/$__object_name" __line "$@" < /dev/null +done < "$__object/parameter/key"