Skip to content

Cloud-config user 'inactive' option can't be set due to 'no_create_home' bug #76

@nullptr0000

Description

@nullptr0000

If cloud-config userdata tries to configure a user with the 'inactive' option set to True, the creation of that user fails with the exception "The user is required to be enabled if public_keys or create_home are set".

This is due to the undocumented option 'no_create_home' also having to be set to True for the 'inactive' option to work.

Unfortunately this isn't possible as an error in cloudbaseinit/plugins/common/userdataplugins/cloudconfigplugins/users.py (line 118) means that the code checks the value of 'no_create_home ' (with an extra space added to the end) not the proper option 'no_create_home'. This means the option cannot be set by the userdata and always remains at the default value of False, which in turn makes it impossible to use the 'inactive' option.

Replacing the incorrect item.get('no_create_home ', False)) with item.get('no_create_home', False)) makes the code function as expected.

Extra comments:

  • The exception message refers to the internal variable names from the local code, not to the actual configuration item names that need to be set. This is confusing for the end user / wrong!
  • The 'no_create_home' option is completely undocumented, including the dependency with 'inactive'.
  • The test for this function only checks the failure case of the values being misaligned so doesn't detect this bug as the code always fails. There are no proper validation tests for the 'inactive' or 'no_create_home' settings working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions