From fa7bf2975e3423c4b47ec74708274cf4bee2a730 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 7 Nov 2024 11:55:41 +0100 Subject: [PATCH 1/2] Regex update Signed-off-by: Martin Zeithaml --- lib/initUtils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/initUtils.js b/lib/initUtils.js index b8afc34..3e36e56 100644 --- a/lib/initUtils.js +++ b/lib/initUtils.js @@ -322,7 +322,7 @@ module.exports.registerBundledPlugin = registerBundledPlugin; function readPortFromUnixConfig(configFile, regex) { let result = 0; - if (fs.fileExists(configFile)) { + if (fileExists(configFile)) { const configContent = fs.readFileSync(configFile, 'utf8'); if (configContent) { const configLines = configContent.split('\n'); @@ -343,7 +343,7 @@ function readPortFromUnixConfig(configFile, regex) { module.exports.setTerminalDefaults = function(configDestination, instanceItems) { if (instanceItems.indexOf('org.zowe.terminal.vt.json') != -1) { if (!process.env['ZWED_SSH_PORT']) { - const sshPort = readPortFromUnixConfig('/etc/ssh/sshd_config', /port[\s]+[0-9]{1,5}/i); + const sshPort = readPortFromUnixConfig('/etc/ssh/sshd_config', /^port[\s]+[0-9]{1,5}/i); if (sshPort) { process.env['ZWED_SSH_PORT'] = sshPort; } @@ -361,7 +361,7 @@ module.exports.setTerminalDefaults = function(configDestination, instanceItems) } if (instanceItems.indexOf('org.zowe.terminal.tn3270.json') != -1) { if (!process.env['ZWED_TN3270_PORT']) { - const telnetPort = readPortFromUnixConfig('/etc/services', /telnet[\s]+[0-9]{1,5}/i); + const telnetPort = readPortFromUnixConfig('/etc/services', /^telnet[\s]+[0-9]{1,5}/i); if (telnetPort) { process.env['ZWED_TN3270_PORT'] = telnetPort; } From db2adbaa885b9acd69e1eb1c145b90b4acc57b35 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 7 Nov 2024 12:12:48 +0100 Subject: [PATCH 2/2] Debug message Signed-off-by: Martin Zeithaml --- lib/initUtils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/initUtils.js b/lib/initUtils.js index 3e36e56..c9ccd7b 100644 --- a/lib/initUtils.js +++ b/lib/initUtils.js @@ -331,7 +331,8 @@ function readPortFromUnixConfig(configFile, regex) { if (matchLine) { const portNumber = parseInt(matchLine[0].replace(/\s+/g, " ").split(' ')[1]); if (portNumber > 0 && portNumber < 65536) { - result = portNumber; + printFormattedDebug(`readPortFromUnixConfig: ${configFile} -> "${matchLine[0]}" -> ${portNumber}`); + result = portNumber; } } }