From 0ad96dd0c4403e53aca56f5fadd9d2e31ae06db2 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Wed, 6 Nov 2024 09:30:17 +0100 Subject: [PATCH 1/5] Use xplatform for logging Signed-off-by: Martin Zeithaml --- CHANGELOG.md | 3 ++- bin/libs/common.ts | 33 +++++++++------------------------ 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47b1fe90de..4d0ce09f1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ All notable changes to the Zowe Installer will be documented in this file. ## `3.0.1` -- Bugfix: When `--log-dir` parameter for `zwe` command is a file, there might be an error "InternalError: stack overflow". [#40nn](https://github.com/zowe/zowe-install-packaging/pull/40nn) +- Bugfix: When logging `zwe` command, sometimes the log has wrong file tag and the log is unreadable. [#40nn](https://github.com/zowe/zowe-install-packaging/pull/40nn) +- Bugfix: When `--log-dir` parameter for `zwe` command is a file, there might be an error "InternalError: stack overflow". [#4064](https://github.com/zowe/zowe-install-packaging/pull/4064) - Enhancement: new javascript funtion `getStatvfs()` to obtain information about the file sysytem [#3994](https://github.com/zowe/zowe-install-packaging/pull/3994) - Enhancement: schema validation update for `zowe.job.name` and `zowe.job.prefix` [#4060](https://github.com/zowe/zowe-install-packaging/pull/4060) diff --git a/bin/libs/common.ts b/bin/libs/common.ts index ad3457926c..47bdd94dcc 100644 --- a/bin/libs/common.ts +++ b/bin/libs/common.ts @@ -128,36 +128,21 @@ export function date(...args: string[]): string|undefined { let logExists = false; -let logFile:std.File|null = null; function writeLog(message: string): boolean { + const filename = std.getenv('ZWE_PRIVATE_LOG_FILE'); + if (!filename) { + return false; + } + logExists = fs.fileExists(filename); if (!logExists) { - const filename = std.getenv('ZWE_PRIVATE_LOG_FILE'); - if (filename) { + fs.createFile(filename, 0o640, message); logExists = fs.fileExists(filename); - if (!logExists) { - fs.createFile(filename, 0o640, message); - logExists = fs.fileExists(filename); - } - if (logExists) { - let errObj = {errno:undefined}; - logFile = std.open(filename, 'w', errObj); - if (errObj.errno) { - printError(`Error opening file ${filename}, errno=${errObj.errno}`); - logFile=null; - logExists=false; - return false; - } - } - } - } - if (logFile===undefined || logFile===null) { - return false; } else { - //TODO this does utf8. should we flip it to 1047 on zos? - logFile.puts(message); - return true; + xplatform.appendFileUTF8(filename, xplatform.AUTO_DETECT, message); + return true; } + return logExists; } From d8f566b05c7c8fd4552a117c560d85c5362d240a Mon Sep 17 00:00:00 2001 From: Martin Zeithaml <66114686+Martin-Zeithaml@users.noreply.github.com> Date: Wed, 6 Nov 2024 09:31:50 +0100 Subject: [PATCH 2/5] Update CHANGELOG.md Signed-off-by: Martin Zeithaml <66114686+Martin-Zeithaml@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d0ce09f1e..a1867a095a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to the Zowe Installer will be documented in this file. ## `3.0.1` -- Bugfix: When logging `zwe` command, sometimes the log has wrong file tag and the log is unreadable. [#40nn](https://github.com/zowe/zowe-install-packaging/pull/40nn) +- Bugfix: When logging `zwe` command, sometimes the log has wrong file tag and the log is unreadable. [#4071](https://github.com/zowe/zowe-install-packaging/pull/4071) - Bugfix: When `--log-dir` parameter for `zwe` command is a file, there might be an error "InternalError: stack overflow". [#4064](https://github.com/zowe/zowe-install-packaging/pull/4064) - Enhancement: new javascript funtion `getStatvfs()` to obtain information about the file sysytem [#3994](https://github.com/zowe/zowe-install-packaging/pull/3994) - Enhancement: schema validation update for `zowe.job.name` and `zowe.job.prefix` [#4060](https://github.com/zowe/zowe-install-packaging/pull/4060) From 6e55faf74436c9b45db95c9cf512e54c2e459b2e Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Wed, 20 Nov 2024 17:45:27 +0100 Subject: [PATCH 3/5] d.ts update Signed-off-by: Martin Zeithaml --- build/zwe/types/@qjstypes/xplatform.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/build/zwe/types/@qjstypes/xplatform.d.ts b/build/zwe/types/@qjstypes/xplatform.d.ts index f139e1ac00..6d4572936e 100644 --- a/build/zwe/types/@qjstypes/xplatform.d.ts +++ b/build/zwe/types/@qjstypes/xplatform.d.ts @@ -27,6 +27,7 @@ export function stringFromBytes(data:ArrayBuffer, offset:number, length:number, */ export function loadFileUTF8(path:string, sourceCCSID:number):string; export function storeFileUTF8(path:string, targetCCSID:number, content:string):number; +export function appendFileUTF8(path: string, targetCCSID:number, content:string):number; export var AUTO_DETECT:number; export var NO_CONVERT:number; From e8e790fc03c97025ff4e2adfb93df44af5417b93 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 21 Nov 2024 11:09:56 +0100 Subject: [PATCH 4/5] Read arrays by internal config get Signed-off-by: Martin Zeithaml --- bin/commands/init/certificate/index.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/commands/init/certificate/index.sh b/bin/commands/init/certificate/index.sh index f226009c5b..df10620ad0 100644 --- a/bin/commands/init/certificate/index.sh +++ b/bin/commands/init/certificate/index.sh @@ -95,13 +95,17 @@ elif [[ "${cert_type}" == JCE*KS ]]; then keyring_option=2 fi fi +# Trace or debug information will be part of the output, let's turn it off for the inline zwe commands +save_trace=$ZWE_PRIVATE_LOG_LEVEL_ZWELS +ZWE_PRIVATE_LOG_LEVEL_ZWELS= # read keystore domains -cert_import_CAs=$(read_yaml_configmgr "${ZWE_CLI_PARAMETER_CONFIG}" ".zowe.setup.certificate.importCertificateAuthorities" | tr '\n' ',') +cert_import_CAs=$(zwecli_inline_execute_command internal config get --config "${ZWE_CLI_PARAMETER_CONFIG}" --path ".zowe.setup.certificate.importCertificateAuthorities" | tr '\n' ',') # read keystore domains -cert_domains=$(read_yaml_configmgr "${ZWE_CLI_PARAMETER_CONFIG}" ".zowe.setup.certificate.san" | tr '\n' ',') +cert_domains=$(zwecli_inline_execute_command internal config get --config "${ZWE_CLI_PARAMETER_CONFIG}" --path ".zowe.setup.certificate.san" | tr '\n' ',') if [ -z "${cert_domains}" ]; then - cert_domains=$(read_yaml_configmgr "${ZWE_CLI_PARAMETER_CONFIG}" ".zowe.externalDomains" | tr '\n' ',') + cert_domains=$(zwecli_inline_execute_command internal config get --config "${ZWE_CLI_PARAMETER_CONFIG}" --path ".zowe.externalDomains" | tr '\n' ',') fi +ZWE_PRIVATE_LOG_LEVEL_ZWELS=$save_trace # read z/OSMF info for item in user ca; do From 40e625432698d55e4ca229c0f6546710d8253a4d Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 28 Nov 2024 11:08:05 +0100 Subject: [PATCH 5/5] Delete last char Signed-off-by: Martin Zeithaml --- bin/commands/init/certificate/index.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/commands/init/certificate/index.sh b/bin/commands/init/certificate/index.sh index df10620ad0..90106839fb 100644 --- a/bin/commands/init/certificate/index.sh +++ b/bin/commands/init/certificate/index.sh @@ -99,11 +99,11 @@ fi save_trace=$ZWE_PRIVATE_LOG_LEVEL_ZWELS ZWE_PRIVATE_LOG_LEVEL_ZWELS= # read keystore domains -cert_import_CAs=$(zwecli_inline_execute_command internal config get --config "${ZWE_CLI_PARAMETER_CONFIG}" --path ".zowe.setup.certificate.importCertificateAuthorities" | tr '\n' ',') +cert_import_CAs=$(zwecli_inline_execute_command internal config get --config "${ZWE_CLI_PARAMETER_CONFIG}" --path ".zowe.setup.certificate.importCertificateAuthorities" | tr '\n' ',' | awk '{ print substr( $0, 1, length($0)-1 ) }') # read keystore domains -cert_domains=$(zwecli_inline_execute_command internal config get --config "${ZWE_CLI_PARAMETER_CONFIG}" --path ".zowe.setup.certificate.san" | tr '\n' ',') +cert_domains=$(zwecli_inline_execute_command internal config get --config "${ZWE_CLI_PARAMETER_CONFIG}" --path ".zowe.setup.certificate.san" | tr '\n' ',' | awk '{ print substr( $0, 1, length($0)-1 ) }') if [ -z "${cert_domains}" ]; then - cert_domains=$(zwecli_inline_execute_command internal config get --config "${ZWE_CLI_PARAMETER_CONFIG}" --path ".zowe.externalDomains" | tr '\n' ',') + cert_domains=$(zwecli_inline_execute_command internal config get --config "${ZWE_CLI_PARAMETER_CONFIG}" --path ".zowe.externalDomains" | tr '\n' ',' | awk '{ print substr( $0, 1, length($0)-1 ) }') fi ZWE_PRIVATE_LOG_LEVEL_ZWELS=$save_trace