-
Notifications
You must be signed in to change notification settings - Fork 697
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
[JENKINS-75230] Fixes the use of an init script with Windows AMI using a Linux launcher #1046
Conversation
scp.upload( | ||
initScript.getBytes(StandardCharsets.UTF_8), | ||
tmpDir + "/init.sh", | ||
List.of(PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.OWNER_READ), | ||
List.of( | ||
PosixFilePermission.OWNER_READ, |
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.
The changes look good to me. Just want to understand why all the permissions are enabled?
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.
At least, OWNER_WRITE
is needed, so that Windows doesn't set the read-only
flag. OWNER
should suffice, I'm also adding GROUP_XXX
and OTHERS_XXX
to make sure that the permissions will no longer be a problem.
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.
scp.put(initScript.getBytes(StandardCharsets.UTF_8), "init.sh", tmpDir, "0700")
Before the Mina changes, the script was uploaded with permissions set to 0700, ensuring that only the owner could read, write, and execute it. I guess maintaining the same level of restriction (0700: OWNER_READ, OWNER_WRITE, OWNER_EXECUTE) should be sufficient, as it prevents unintended access by other users.
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.
Agree with @Priya-CB , we should keep permissions as they were before this bug was introduced (https://github.com/jenkinsci/ec2-plugin/blob/1797.ve8a_edb_7e5f6a_/src/main/java/hudson/plugins/ec2/ssh/EC2MacLauncher.java#L216), I'd remove GROUP_*
and OTHER_*
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 we verify if group and others permissions are really needed?
scp.upload( | ||
initScript.getBytes(StandardCharsets.UTF_8), | ||
tmpDir + "/init.sh", | ||
List.of(PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.OWNER_READ), | ||
List.of( | ||
PosixFilePermission.OWNER_READ, |
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.
Agree with @Priya-CB , we should keep permissions as they were before this bug was introduced (https://github.com/jenkinsci/ec2-plugin/blob/1797.ve8a_edb_7e5f6a_/src/main/java/hudson/plugins/ec2/ssh/EC2MacLauncher.java#L216), I'd remove GROUP_*
and OTHER_*
PosixFilePermission.GROUP_READ, | ||
PosixFilePermission.GROUP_WRITE, | ||
PosixFilePermission.GROUP_EXECUTE, | ||
PosixFilePermission.OTHERS_READ, | ||
PosixFilePermission.OTHERS_WRITE, | ||
PosixFilePermission.OTHERS_EXECUTE), |
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.
ditto
Thanks for the feedback. |
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.
LGTM
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.
LGTM :)
Fix for https://issues.jenkins.io/browse/JENKINS-75230
Previously, the
init.sh
script was uploaded without thewrite
permission. On Windows, this creates aread-only
file. This read-only file is then impossible to replace when the end user wants to reuse the same node. This read-only file causesscp
to get stuck.All uploaded files (the init script ant the remoting jar) now have the
write
permissions set.🚨 Important notice 🚨
Users with version
1822.v87175d209b_b_5
or later using a Windows image and theunix
launcher who upgrade the plugin will have to disable manually the read-only flag on theinit.sh
andremoting.jar
located in the temporary folder of the Windows machine or, alternatively, delete the the files.Testing done
Windows AMI
A dedicated AMI was created, based on
ami-0abaed814109888a5
(Microsoft Windows Server 2025 Base). The created AMI contains:openssh
(configured to use the RSA key),GitBash
andjava
.The connection was successful:
The configured init script:
The init script was properly executed:
![image](https://private-user-images.githubusercontent.com/7381315/411585557-211c1677-b26c-476f-a1d9-b4c36e3e7fd3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1NTUwMDUsIm5iZiI6MTczOTU1NDcwNSwicGF0aCI6Ii83MzgxMzE1LzQxMTU4NTU1Ny0yMTFjMTY3Ny1iMjZjLTQ3NmYtYTFkOS1iNGMzNmUzZTdmZDMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTRUMTczODI1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NWI4ZDkxYThiYTU3MDhiYmZjZWE1ZmNlMTZiNTU3NzRmZmIzZTBmMjg5YWE5Mjk0OWUwY2RiMzJmYWYxNWY4MSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.Sh-DkAGPdCZlZbtykd2iHIQowS1rVWpyfdKiivsMsKk)
Linux AMI
AMI used:
ami-08b1d20c6a69a7100
(Amazon Linux 2023 AMI)The connection was successful:
The configured init script:
The init script was properly executed:
MacLauncher
Same configuration as the Linux AMI, but using the MacLauncher:
Submitter checklist