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