Skip to content
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

server: fix when cloud-config has no default user #1687

Merged
merged 1 commit into from Jun 29, 2023

Conversation

dbungert
Copy link
Collaborator

@dbungert dbungert commented Jun 6, 2023

If a cloud-config is sent that adjusts the users but creates no default user, Subiquity crashes with a exception while mishandling the None.

cloudinit.distros.ug_util.extract_default is documented as returning None in the event that the default user cannot be found.

Example bad from the Subiquity point of view but otherwise valid cloud-config:

users:
- name: ubuntu-server

subiquity/server/tests/test_server.py Outdated Show resolved Hide resolved
If a cloud-config is sent that adjusts the users but creates no default
user, Subiquity crashes with a exception while mishandling the None.

cloudinit.distros.ug_util.extract_default is documented as returning
None in the event that the default user cannot be found.

Example bad cloud-config:
```yaml
users:
- name: ubuntu-server
```
if username is None:
# extract_default can return None, if there is no default user
self.installer_user_passwd_kind = PasswordKind.NONE
elif self._user_has_password(username):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, so the error we are avoiding here is _user_has_password fails with something like:

TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's exactly what happens

@dbungert dbungert merged commit 446f377 into canonical:main Jun 29, 2023
9 checks passed
@dbungert dbungert deleted the default-user-none branch June 29, 2023 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants