Write SSH keys in default encoding#146
Conversation
This feature is needed for edge systems that don't use UTF-8
natively, like z/OS.
|
Can this not just be set to ASCII? |
|
Unfortunately, no. zOS natively uses IBM-1047 (EBCDIC) code pages. This seems to be the only way that this could be addressed for that operating system. |
|
So then the correct fix should be to use the agent JVM’s default encoding? Which would usually be UTF-8, occasionally some ASCII superset on Windows machines for example, and EBCDIC on z/OS? |
jglick
left a comment
There was a problem hiding this comment.
Can you verify that the default encoding approach indeed works on z/OS?
| keyFile.write(contents.toString(), computer.getDefaultCharset()); | ||
|
|
||
| keyFile.chmod(0400); |
There was a problem hiding this comment.
| keyFile.write(contents.toString(), computer.getDefaultCharset()); | |
| keyFile.chmod(0400); | |
| keyFile.write(contents.toString(), computer.getDefaultCharset()); | |
| keyFile.chmod(0400); |
(tabs → spaces for consistency)
| Computer computer = keyFile.toComputer(); | ||
| keyFile.write(contents.toString(), computer.getDefaultCharset()); |
There was a problem hiding this comment.
| Computer computer = keyFile.toComputer(); | |
| keyFile.write(contents.toString(), computer.getDefaultCharset()); | |
| keyFile.write(contents.toString(), null); |
as per https://javadoc.jenkins.io/hudson/FilePath.html#write-java.lang.String-java.lang.String-
|
BTW what will the impact be on z/OS of openjdk/jdk#4733 whenever that is ported? |
|
sorry, I am in the process of validating this now, and will clean up the pull request once everything is validated. |
The code change will take, if provided, the user property setting of an ssh key's file encoding,
and it will set it on the remote agent's computer. If left unset, it will use the default of UTF-8.
This feature is needed for edge systems that don't use UTF-8 natively, like zOS(the mainframe). So, to allow the
ssh keyfiles to be generated correctly, we can specify the encoding type.
This has been manually tested on a jenkins/zOS, and works as intended.