google-guest-agent fails to insert keys if the username includes a space
BlazingIntensity opened this issue · comments
In windows it is possible for the user name to include a space such that the metadata record can look something like this:
flast:ssh-rsa RSA-KEY-GOES-HERE FIRSTS-PC\FIRST LAST@FIRSTS-PC
Prior to commit fbdff753ac709e2dc00305eee0661ae7da6e4cf4
non_windows_accounts.go was simply taking everything before the colon as the username and everything after as the key. However that commit changed it so that a split on spaces is performed to handle optional expiry data. This results in an error that looks something like this:
ERROR non_windows_accounts.go:199 invalid character 'L' looking for beginning of value: flast:ssh-rsa
It looks like rather than parsing the above metadata as:
- Username: flast
- Key: RSA-KEY-GOES-HERE FIRSTS-PC\FIRST LAST@FIRSTS-PC
It's instead parsing it as:
- Username: flast
- Key: RSA-KEY-GOES-HERE FIRSTS-PC\FIRST
- Expiry: LAST@FIRSTS-PC
This is preventing windows users with spaces in their username from accessing any VM with the updated google-guest-agent package.
It looks like both before and after the commit you referenced, the key is being split on spaces for expiration data.
Did you mean to link a different commit id?
You're right, I'd missed that removeExpiredKeys
was doing that work before the commit. I'll look and see if I can't find where this went bad, but what I can add is that google-guest-agent=20201217.02-0ubuntu1~20.04.0
works for us and google-guest-agent=20220622.00-0ubuntu2~20.04.2
doesn't, and that the error message above definitely suggests that this is a split-on-space issue.
To confirm, the original error message happened when running the most recent version of guest agent, correct? And you were able to test to see that
google-guest-agent=20220622.00-0ubuntu2~20.04.2
was another version of guest agent which had this error.
To confirm the format of the key being used, the specific key had exactly three spaces in it, as opposed to having exactly two spaces in it, correct?
The format which was mentioned seemed to have three spaces.
flast:ssh-rsa RSA-KEY-GOES-HERE FIRSTS-PC\FIRST LAST@FIRSTS-PC
Correct; most of our usernames have two spaces and function fine. The negatively impacted users have 3 spaces in their metadata record.
We are working on a fix with the pull request #198.
This fix is already in Ubuntu Lunar:
https://launchpad.net/ubuntu/+source/google-guest-agent/20230330.00-0ubuntu1
I'm closing the issue.