-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(wsl-pro-service): Do not translate empty paths (#858)
I wanted this PR to be laser-focus, just a bugfix, thus I'm not refactoring the executable-mocking just yet. The issue is: when we invoke `wslpath -au ''` we get the absolute path of the current working directory. That's surely not what we expect of a Windows path. It could be problematic if the user passes a custom Landscape config file containing this line `ssl_public_key= `, as we'd modify the final client.conf into `ssl_public_key = /` (systemd makes it so our current working directory is `/`). Landscape client would tolerate the empty value in the INI sintax, but this would force it to try to read `/` as a certificate file. Clearly not what we want. A similar thing could happen in `system.UserProfileDir()`, but that's even funnier. Having %USERPROFILE% set to an empty string is indeed an odd edge case, so I'm not 100% sure the added code is worth it, as we're likely to err out attempting to open inexistant directories. I think it worths it because we are sure on how we err out. Leaving as it was could lead us into reading files we were not supposed to. They issues were: `echo %USERPROFILE%` would output `ECHO is on` if that environment variable is empty. We fix it by running `echo.%USERPROFILE%` instead. It outputs an empty line for that case. Finally, if the output is empty, we bail out. ![image](https://github.com/user-attachments/assets/1fceae7f-3985-4148-b6e5-60a014068621) I made some modifications in the wslpath and cmd.exe mocks to get closer to the surprising behavior, so I could add test cases demonstrating the surprising behavior. --- Closes UDENG-3788
- Loading branch information
Showing
6 changed files
with
50 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...TestEnsureValidLandscapeConfig/golden/do_not_transform_windows_ssl_certificate_empty_path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[client] | ||
hostagent_uid = landscapeUID1234 | ||
ssl_public_key = | ||
computer_title = TEST_DISTRO |
4 changes: 4 additions & 0 deletions
4
wsl-pro-service/internal/system/testdata/landscape.conf.d/windows_ssl_empty.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[client] | ||
hostagent_uid = landscapeUID1234 | ||
ssl_public_key = | ||
computer_title = TEST_DISTRO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters