Public bug reported:

Given content of 'user-data' such as
```
users:
  - default
  - name: eric
    uid: 1742
  - name: archivist
    uid: '1724'
```
the created account as listed in '/etc/passwd' are
```
eric:x:1000:1000::/home/eric:/bin/bash
archivist:x:1724:1724::/home/archivist:/bin/bash
ubuntu:x:1725:1725:Ubuntu:/home/ubuntu:/bin/bash
```

Notice that account 'eric' has `uid=1000` even though the 'user-data'
config specifies `uid: 1742`. No error, warning or other obvious message
appears in 'cloud-init.log'.

The relevant source code appears to begin around [line 458 of
cloudinit/distros/__init__.py](https://github.com/canonical/cloud-
init/blob/7276aa5240b8cb84671a56d795d811f15dfba8e2/cloudinit/distros/__init__.py#L458):
`if key in useradd_opts and val and isinstance(val, str)`.

The ubuntu image where this occurs is `ubuntu-20.04-preinstalled-server-
arm64+raspi.img.xz`; although I expect it exists everywhere cloud-init
version 20.1 is used.

A moderately helpful fix is to add error reporting to the conditional
when `isinstance(val, str)` fails. A more user-friendly fix is to simply
convert `val` to a string.

** Affects: cloud-init (Ubuntu)
     Importance: Undecided
         Status: New

** Attachment added: "apport.cloud-init.vtu1o72j.apport"
   
https://bugs.launchpad.net/bugs/1875772/+attachment/5363035/+files/apport.cloud-init.vtu1o72j.apport

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1875772

Title:
  user_add silently ignores numeric uid

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1875772/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to