-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write SSH keys in default encoding #146
base: master
Are you sure you want to change the base?
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.