aws / ec2-macos-init

EC2 macOS Init is the launch daemon used to initialize Mac instances within EC2.
https://aws.amazon.com/ec2/instance-types/mac/
Apache License 2.0
148 stars 19 forks source link

Userdata file created by module may not be fully written before executed #29

Closed jahkeup closed 1 year ago

jahkeup commented 1 year ago

It seems that the code writing the userdata script to disk isn't ensuring the file is fully written when the module goes to execute the script.

https://github.com/aws/ec2-macos-init/blob/856afa4039a4acc4b4b87ef1c4595c59965f699a/lib/ec2macosinit/userdata.go#L45-L62

The defer file.Close() is the most suspicious here.