Azure / Azure/azure-linux-extensions
Check for user being a system user is incorrect
- Dominant language
- Python
- Stars
- 333
- Forks
- 278
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 4
Description
The code here checks /etc/login.defs to see if the user's UID is less than UID_MIN.
However, login.defs also has settings to defined min/max SYSTEM UID range:
```
# System accounts
SYS_UID_MIN 201
SYS_UID_MAX 999
```
In our use case, this causes problems because the admin ID is created very early in provisioning BEFORE we can set our standard values for UID_MIN / UID_MAX... and after we do, then the admin ID falls outside the range and is marked as a system user.
The check would be better to also validate against SYS_UID_MAX.
```
uid_min = None
try:
uid_min = int(ext_utils.get_line_starting_with("UID_MIN", "/etc/login.defs").split()[1])
except (ValueError, KeyError, AttributeError, EnvironmentError):
pass
if uid_min is None:
uid_min = 100
if user_entry is not None and user_entry[2] < uid_min:
logger.error(
"CreateAccount: " + user + " is a system user. Will not set password.")
return "Failed to set password for system user: " + user + " (0x06)."
```
https://github.com/Azure/azure-linux-extensions/blob/b4d783a87157675f81505aa94af5bb2935a1307d/Utils/distroutils.py#L175
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in Utils/distroutils.py around the user check linked in the issue, and read how /etc/login.defs values are parsed. Verify the system-user decision against the documented UID ranges, including SYS_UID_MAX, and confirm that an early-provisioned admin is no longer misclassified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100