From 4bc49bdcd634c51e24b33b138d89750d39e240e5 Mon Sep 17 00:00:00 2001 From: MerlinDMC Date: Wed, 22 Aug 2012 13:15:28 +0200 Subject: [PATCH 1/3] mdata-get does not continue if the socket/serial device is not accessible --- src/linux/lib/smartdc/mdata-get | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/linux/lib/smartdc/mdata-get b/src/linux/lib/smartdc/mdata-get index 9b0a3ed..e1f8fa9 100755 --- a/src/linux/lib/smartdc/mdata-get +++ b/src/linux/lib/smartdc/mdata-get @@ -43,9 +43,19 @@ case $(uname -s) in esac if [[ -n ${NC_SOCK} ]]; then + if [[ ! -e ${NC_SOCK} ]]; then + echo "mdata-get: socket not accessible" >&2 + exit 2 + fi + coproc nc -U ${NC_SOCK} exec <&${COPROC[0]} 3>&${COPROC[1]} else + if [[ ! -e ${SERIAL_DEV} ]]; then + echo "mdata-get: socket not accessible" >&2 + exit 2 + fi + exec <${SERIAL_DEV} 3>>${SERIAL_DEV} fi From 2fb501b567b5a774e14396c5b30b5252fe859d24 Mon Sep 17 00:00:00 2001 From: MerlinDMC Date: Sat, 25 Aug 2012 20:01:27 +0200 Subject: [PATCH 2/3] if root_authorized_keys is not in customer_metadata the return value of "No metadata for root_authorized_keys" should not be used as a key --- src/linux/lib/smartdc/set-root-authorized-keys | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/linux/lib/smartdc/set-root-authorized-keys b/src/linux/lib/smartdc/set-root-authorized-keys index 2f5e469..a27a3e5 100755 --- a/src/linux/lib/smartdc/set-root-authorized-keys +++ b/src/linux/lib/smartdc/set-root-authorized-keys @@ -5,7 +5,7 @@ if [[ ! -f /root/.ssh/authorized_keys ]]; then authorized_keys=$(/lib/smartdc/mdata-get root_authorized_keys 2>>/dev/console) - if [[ -n ${authorized_keys} ]]; then + if [[ $? -eq 0 && -n ${authorized_keys} ]]; then mkdir -p /root/.ssh echo "${authorized_keys}" > /root/.ssh/authorized_keys chmod 700 /root/.ssh From c356301728c34eb730131239a3d14767b1192829 Mon Sep 17 00:00:00 2001 From: MerlinDMC Date: Sat, 25 Aug 2012 20:03:38 +0200 Subject: [PATCH 3/3] trash the user-script if no script was set in customer_metadata --- src/linux/lib/smartdc/run-user-script | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/linux/lib/smartdc/run-user-script b/src/linux/lib/smartdc/run-user-script index d02704d..1c849b5 100755 --- a/src/linux/lib/smartdc/run-user-script +++ b/src/linux/lib/smartdc/run-user-script @@ -10,4 +10,6 @@ if [[ $? -eq 0 ]] ; then chmod +x /root/user-script exec /root/user-script fi +else + rm -f /root/user-script fi