Skip to content

Commit

Permalink
Cherry-pick: Ensure edited scripts provided from the client with newl…
Browse files Browse the repository at this point in the history
…ine switches and no other changes get converted to "\n" (#22196) (#22202)

Merged to `main` in #22199.

```
git checkout minor-fleet-v4.57.0
git checkout -b 22196-cherry-pick
git cherry-pick ea2a978
git push -u origin 22196-cherry-pick
```
  • Loading branch information
iansltx committed Sep 18, 2024
1 parent 0b5b129 commit 7d36b1b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ee/server/service/software_installers.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,16 @@ func (svc *Service) UpdateSoftwareInstaller(ctx context.Context, payload *fleet.

if installScript != existingInstaller.InstallScript {
dirty["InstallScript"] = true
payload.InstallScript = &installScript
}
payload.InstallScript = &installScript
}

if payload.PostInstallScript != nil {
postInstallScript := file.Dos2UnixNewlines(*payload.PostInstallScript)
if postInstallScript != existingInstaller.PostInstallScript {
dirty["PostInstallScript"] = true
payload.PostInstallScript = &postInstallScript
}
payload.PostInstallScript = &postInstallScript
}

if payload.UninstallScript != nil {
Expand All @@ -270,10 +270,10 @@ func (svc *Service) UpdateSoftwareInstaller(ctx context.Context, payload *fleet.

preProcessUninstallScript(payloadForUninstallScript)
if payloadForUninstallScript.UninstallScript != existingInstaller.UninstallScript {
uninstallScript = payloadForUninstallScript.UninstallScript
dirty["UninstallScript"] = true
payload.UninstallScript = &uninstallScript
}
uninstallScript = payloadForUninstallScript.UninstallScript
payload.UninstallScript = &uninstallScript
}

// persist changes starting here, now that we've done all the validation/diffing we can
Expand Down

0 comments on commit 7d36b1b

Please sign in to comment.