Yedidyah Bar David has uploaded a new change for review.

Change subject: bin: safer console password input
......................................................................

bin: safer console password input

Allow reading the console password from a variable or interactively.

Change-Id: I9b672e30d5cd834778e228794e13c7aa0dd1c6ab
Bug-Url: https://bugzilla.redhat.com/1021902
Signed-off-by: Yedidyah Bar David <d...@redhat.com>
---
M src/bin/hosted-engine.in
1 file changed, 36 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup 
refs/changes/98/21498/1

diff --git a/src/bin/hosted-engine.in b/src/bin/hosted-engine.in
index 2d9241f..6fb3774 100644
--- a/src/bin/hosted-engine.in
+++ b/src/bin/hosted-engine.in
@@ -28,6 +28,11 @@
         VM status according to the HA agent
     --add-console-password=<password>
         Create a temporary password for vnc/spice connection
+    --add-console-password
+        Create a temporary password for vnc/spice connection - password
+        will be taken from the environment variable
+        OVIRT_HOSTED_ENGINE_CONSOLE_PASSWORD if it's set, otherwise
+        will be read interactively
     --check-liveliness
         Checks liveliness page of engine
     --connect-storage
@@ -41,6 +46,26 @@
 
 __EOF__
     exit $rc
+}
+
+readpassword() {
+        (
+                cleanup() {
+                        [ -n "${STTY_ORIG}" ] && stty "${STTY_ORIG}"
+                }
+
+                STTY_ORIG=
+                trap cleanup 0
+                [ -t 0 ] || die "Standard input is not a terminal"
+                STTY_ORIG="$(stty -g)"
+                stty -echo || die "Failed to disable terminal input echo"
+                echo -n "Enter password: " >&2
+                read pass
+                echo >&2
+                cat << __EOF__
+${pass}
+__EOF__
+        )
 }
 
 if [ -z "$1" ] ; then
@@ -102,6 +127,17 @@
                 echo "You must run --deploy first"
             fi
         ;;
+        --add-console-password)
+            if [ -n "${vmid}" ] ; then
+                pass="${OVIRT_HOSTED_ENGINE_CONSOLE_PASSWORD}"
+                if [ -z "${pass}" ]; then
+                    pass="$(readpassword)" || exit 1
+                fi
+                ${VDSCOMMAND} setVmTicket "${vmid}" "${pass}" 120
+            else
+                echo "You must run --deploy first"
+            fi
+        ;;
         --add-console-password=*)
             if [ -n "${vmid}" ] ; then
                 ${VDSCOMMAND} setVmTicket "${vmid}" "${v}" 120


-- 
To view, visit http://gerrit.ovirt.org/21498
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9b672e30d5cd834778e228794e13c7aa0dd1c6ab
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-setup
Gerrit-Branch: ovirt-hosted-engine-setup-1.0
Gerrit-Owner: Yedidyah Bar David <d...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to