|
|
bc94d5 |
From 81be3c529ec1165f3135b4f14fbec2a19403cfbe Mon Sep 17 00:00:00 2001
|
|
|
bc94d5 |
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
|
|
|
bc94d5 |
Date: Fri, 27 Aug 2021 08:53:36 +0200
|
|
|
bc94d5 |
Subject: [PATCH 1/2] fence_zvmip: add ssl/tls support
|
|
|
bc94d5 |
|
|
|
bc94d5 |
---
|
|
|
bc94d5 |
agents/zvm/fence_zvmip.py | 20 ++++++++++++++++----
|
|
|
bc94d5 |
tests/data/metadata/fence_zvmip.xml | 19 +++++++++++++++++++
|
|
|
bc94d5 |
2 files changed, 35 insertions(+), 4 deletions(-)
|
|
|
bc94d5 |
|
|
|
bc94d5 |
diff --git a/agents/zvm/fence_zvmip.py b/agents/zvm/fence_zvmip.py
|
|
|
bc94d5 |
index 001106a44..874eb699f 100644
|
|
|
bc94d5 |
--- a/agents/zvm/fence_zvmip.py
|
|
|
bc94d5 |
+++ b/agents/zvm/fence_zvmip.py
|
|
|
bc94d5 |
@@ -26,12 +26,22 @@ def open_socket(options):
|
|
|
bc94d5 |
except socket.gaierror:
|
|
|
bc94d5 |
fail(EC_LOGIN_DENIED)
|
|
|
bc94d5 |
|
|
|
bc94d5 |
- conn = socket.socket()
|
|
|
bc94d5 |
+ if "--ssl" in options:
|
|
|
bc94d5 |
+ import ssl
|
|
|
bc94d5 |
+ sock = socket.socket()
|
|
|
bc94d5 |
+ sslcx = ssl.create_default_context()
|
|
|
bc94d5 |
+ if "--ssl-insecure" in options:
|
|
|
bc94d5 |
+ sslcx.check_hostname = False
|
|
|
bc94d5 |
+ sslcx.verify_mode = ssl.CERT_NONE
|
|
|
bc94d5 |
+ conn = sslcx.wrap_socket(sock, server_hostname=options["--ip"])
|
|
|
bc94d5 |
+ else:
|
|
|
bc94d5 |
+ conn = socket.socket()
|
|
|
bc94d5 |
conn.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
|
|
bc94d5 |
conn.settimeout(float(options["--shell-timeout"]) or None)
|
|
|
bc94d5 |
try:
|
|
|
bc94d5 |
conn.connect(addr)
|
|
|
bc94d5 |
- except socket.error:
|
|
|
bc94d5 |
+ except socket.error as e:
|
|
|
bc94d5 |
+ logging.debug(e)
|
|
|
bc94d5 |
fail(EC_LOGIN_DENIED)
|
|
|
bc94d5 |
|
|
|
bc94d5 |
return conn
|
|
|
bc94d5 |
@@ -122,11 +132,12 @@ def get_list_of_images(options, command, data_as_plug):
|
|
|
bc94d5 |
images = set()
|
|
|
bc94d5 |
|
|
|
bc94d5 |
if output_len > 3*INT4:
|
|
|
bc94d5 |
+ recvflag = socket.MSG_WAITALL if "--ssl" not in options else 0
|
|
|
bc94d5 |
array_len = struct.unpack("!i", conn.recv(INT4))[0]
|
|
|
bc94d5 |
data = ""
|
|
|
bc94d5 |
|
|
|
bc94d5 |
while True:
|
|
|
bc94d5 |
- read_data = conn.recv(1024, socket.MSG_WAITALL).decode("UTF-8")
|
|
|
bc94d5 |
+ read_data = conn.recv(1024, recvflag).decode("UTF-8")
|
|
|
bc94d5 |
data += read_data
|
|
|
bc94d5 |
if array_len == len(data):
|
|
|
bc94d5 |
break
|
|
|
bc94d5 |
@@ -146,7 +157,8 @@ def get_list_of_images(options, command, data_as_plug):
|
|
|
bc94d5 |
return (return_code, reason_code, images)
|
|
|
bc94d5 |
|
|
|
bc94d5 |
def main():
|
|
|
bc94d5 |
- device_opt = ["ipaddr", "login", "passwd", "port", "method", "missing_as_off", "inet4_only", "inet6_only"]
|
|
|
bc94d5 |
+ device_opt = ["ipaddr", "login", "passwd", "port", "method", "missing_as_off",
|
|
|
bc94d5 |
+ "inet4_only", "inet6_only", "ssl"]
|
|
|
bc94d5 |
|
|
|
bc94d5 |
atexit.register(atexit_handler)
|
|
|
bc94d5 |
|
|
|
bc94d5 |
diff --git a/tests/data/metadata/fence_zvmip.xml b/tests/data/metadata/fence_zvmip.xml
|
|
|
bc94d5 |
index f84115c08..d91192946 100644
|
|
|
bc94d5 |
--- a/tests/data/metadata/fence_zvmip.xml
|
|
|
bc94d5 |
+++ b/tests/data/metadata/fence_zvmip.xml
|
|
|
bc94d5 |
@@ -91,6 +91,21 @@ to access the system's directory manager.
|
|
|
bc94d5 |
<content type="string" />
|
|
|
bc94d5 |
<shortdesc lang="en">Physical plug number on device, UUID or identification of machine</shortdesc>
|
|
|
bc94d5 |
</parameter>
|
|
|
bc94d5 |
+ <parameter name="ssl" unique="0" required="0">
|
|
|
bc94d5 |
+ <getopt mixed="-z, --ssl" />
|
|
|
bc94d5 |
+ <content type="boolean" />
|
|
|
bc94d5 |
+ <shortdesc lang="en">Use SSL connection with verifying certificate</shortdesc>
|
|
|
bc94d5 |
+ </parameter>
|
|
|
bc94d5 |
+ <parameter name="ssl_insecure" unique="0" required="0">
|
|
|
bc94d5 |
+ <getopt mixed="--ssl-insecure" />
|
|
|
bc94d5 |
+ <content type="boolean" />
|
|
|
bc94d5 |
+ <shortdesc lang="en">Use SSL connection without verifying certificate</shortdesc>
|
|
|
bc94d5 |
+ </parameter>
|
|
|
bc94d5 |
+ <parameter name="ssl_secure" unique="0" required="0">
|
|
|
bc94d5 |
+ <getopt mixed="--ssl-secure" />
|
|
|
bc94d5 |
+ <content type="boolean" />
|
|
|
bc94d5 |
+ <shortdesc lang="en">Use SSL connection with verifying certificate</shortdesc>
|
|
|
bc94d5 |
+ </parameter>
|
|
|
bc94d5 |
<parameter name="username" unique="0" required="1" obsoletes="login">
|
|
|
bc94d5 |
<getopt mixed="-l, --username=[name]" />
|
|
|
bc94d5 |
<content type="string" />
|
|
|
bc94d5 |
@@ -181,6 +196,10 @@ to access the system's directory manager.
|
|
|
bc94d5 |
<content type="integer" default="1" />
|
|
|
bc94d5 |
<shortdesc lang="en">Count of attempts to retry power on</shortdesc>
|
|
|
bc94d5 |
</parameter>
|
|
|
bc94d5 |
+ <parameter name="gnutlscli_path" unique="0" required="0">
|
|
|
bc94d5 |
+ <getopt mixed="--gnutlscli-path=[path]" />
|
|
|
bc94d5 |
+ <shortdesc lang="en">Path to gnutls-cli binary</shortdesc>
|
|
|
bc94d5 |
+ </parameter>
|
|
|
bc94d5 |
</parameters>
|
|
|
bc94d5 |
<actions>
|
|
|
bc94d5 |
<action name="on" automatic="0"/>
|
|
|
bc94d5 |
|
|
|
bc94d5 |
From 8021e698095c5bd0ef33ee5f56fc448e946cb92c Mon Sep 17 00:00:00 2001
|
|
|
bc94d5 |
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
|
|
|
bc94d5 |
Date: Wed, 10 Nov 2021 16:31:24 +0100
|
|
|
bc94d5 |
Subject: [PATCH 2/2] fence_zvmip: use ssl by default
|
|
|
bc94d5 |
|
|
|
bc94d5 |
---
|
|
|
bc94d5 |
agents/zvm/fence_zvmip.py | 1 +
|
|
|
bc94d5 |
tests/data/metadata/fence_zvmip.xml | 2 +-
|
|
|
bc94d5 |
2 files changed, 2 insertions(+), 1 deletion(-)
|
|
|
bc94d5 |
|
|
|
bc94d5 |
diff --git a/agents/zvm/fence_zvmip.py b/agents/zvm/fence_zvmip.py
|
|
|
bc94d5 |
index 874eb699f..96021b13e 100644
|
|
|
bc94d5 |
--- a/agents/zvm/fence_zvmip.py
|
|
|
bc94d5 |
+++ b/agents/zvm/fence_zvmip.py
|
|
|
bc94d5 |
@@ -165,6 +165,7 @@ def main():
|
|
|
bc94d5 |
all_opt["ipport"]["default"] = "44444"
|
|
|
bc94d5 |
all_opt["shell_timeout"]["default"] = "5"
|
|
|
bc94d5 |
all_opt["missing_as_off"]["default"] = "1"
|
|
|
bc94d5 |
+ all_opt["ssl"]["default"] = "1"
|
|
|
bc94d5 |
options = check_input(device_opt, process_input(device_opt), other_conditions=True)
|
|
|
bc94d5 |
|
|
|
bc94d5 |
if len(options.get("--plug", "")) > 8:
|
|
|
bc94d5 |
diff --git a/tests/data/metadata/fence_zvmip.xml b/tests/data/metadata/fence_zvmip.xml
|
|
|
bc94d5 |
index d91192946..f32fc159d 100644
|
|
|
bc94d5 |
--- a/tests/data/metadata/fence_zvmip.xml
|
|
|
bc94d5 |
+++ b/tests/data/metadata/fence_zvmip.xml
|
|
|
bc94d5 |
@@ -93,7 +93,7 @@ to access the system's directory manager.
|
|
|
bc94d5 |
</parameter>
|
|
|
bc94d5 |
<parameter name="ssl" unique="0" required="0">
|
|
|
bc94d5 |
<getopt mixed="-z, --ssl" />
|
|
|
bc94d5 |
- <content type="boolean" />
|
|
|
bc94d5 |
+ <content type="boolean" default="1" />
|
|
|
bc94d5 |
<shortdesc lang="en">Use SSL connection with verifying certificate</shortdesc>
|
|
|
bc94d5 |
</parameter>
|
|
|
bc94d5 |
<parameter name="ssl_insecure" unique="0" required="0">
|