61 lines
2.1 KiB
Diff
61 lines
2.1 KiB
Diff
From 2837b835f101d81704f018a4f872b1d660eb6f3e Mon Sep 17 00:00:00 2001
|
|
From: Brett Holman <bholman.devel@gmail.com>
|
|
Date: Wed, 23 Feb 2022 11:57:59 -0700
|
|
Subject: [PATCH] Do not silently ignore integer uid (#1280)
|
|
|
|
Reference:https://github.com/canonical/cloud-init/commit/2837b835f101d81704f018a4f872b1d660eb6f3e
|
|
Conflict:NA
|
|
|
|
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
|
|
---
|
|
cloudinit/distros/__init__.py | 2 ++
|
|
tests/integration_tests/modules/test_users_groups.py | 8 ++++++++
|
|
2 files changed, 10 insertions(+)
|
|
|
|
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
|
|
index 9a695be..2ee8c9e 100755
|
|
--- a/cloudinit/distros/__init__.py
|
|
+++ b/cloudinit/distros/__init__.py
|
|
@@ -495,6 +495,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 bcb17b7..326df67 100644
|
|
--- a/tests/integration_tests/modules/test_users_groups.py
|
|
+++ b/tests/integration_tests/modules/test_users_groups.py
|
|
@@ -39,6 +39,10 @@ AHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/
|
|
gecos: Magic Cloud App Daemon User
|
|
inactive: true
|
|
system: true
|
|
+ - name: eric
|
|
+ uid: 1742
|
|
+ - name: archivist
|
|
+ uid: '1743'
|
|
"""
|
|
|
|
|
|
@@ -76,6 +80,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):
|
|
--
|
|
2.33.0
|
|
|
|
|