diff options
author | Brett Holman <bholman.devel@gmail.com> | 2022-02-23 11:57:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-23 12:57:59 -0600 |
commit | 2837b835f101d81704f018a4f872b1d660eb6f3e (patch) | |
tree | 7277c751a513509d402f553ea158c8dbd201355f | |
parent | 3053adb7aa62743059a6ba3dadbc5f74feb9a251 (diff) | |
download | cloud-init-git-2837b835f101d81704f018a4f872b1d660eb6f3e.tar.gz |
Do not silently ignore integer uid (#1280)
The docs do not make it obvious that uid is supposed to be of type string.
Current behavior is to silently ignore integer uid.
LP: #1875772
-rwxr-xr-x | cloudinit/distros/__init__.py | 2 | ||||
-rw-r--r-- | tests/integration_tests/modules/test_users_groups.py | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 76acd6a3..f2d9de10 100755 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -529,6 +529,8 @@ class Distro(persistence.CloudInitPickleMixin, metaclass=abc.ABCMeta): if not util.is_group(group): self.create_group(group) LOG.debug("created group '%s' for user '%s'", group, name) + if "uid" in kwargs.keys(): + kwargs["uid"] = str(kwargs["uid"]) # Check the values and create the command for key, val in sorted(kwargs.items()): diff --git a/tests/integration_tests/modules/test_users_groups.py b/tests/integration_tests/modules/test_users_groups.py index fddff681..8fa37bb4 100644 --- a/tests/integration_tests/modules/test_users_groups.py +++ b/tests/integration_tests/modules/test_users_groups.py @@ -38,6 +38,10 @@ AHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/ gecos: Magic Cloud App Daemon User inactive: true system: true + - name: eric + uid: 1742 + - name: archivist + uid: '1743' """ @@ -75,6 +79,10 @@ class TestUsersGroups: ), # Test the cloudy user (["passwd", "cloudy"], r"cloudy:x:[0-9]{3,4}:"), + # Test str uid + (["passwd", "eric"], r"eric:x:1742:"), + # Test int uid + (["passwd", "archivist"], r"archivist:x:1743:"), ], ) def test_users_groups(self, regex, getent_args, class_client): |