Bug 2313559

Summary: useradd returns an error message when creating system users
Product: [Fedora] Fedora Reporter: Vladislav Grigoryev <vg.aetera>
Component: shadow-utilsAssignee: Iker Pedrosa <ipedrosa>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 40CC: ipedrosa, tm, vg.aetera
Target Milestone: ---Keywords: Reopened, Triaged
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: shadow-utils-4.15.1-11.fc41 shadow-utils-4.15.1-12.fc41 shadow-utils-4.15.1-4.fc40 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-10-12 00:19:40 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Vladislav Grigoryev 2024-09-19 14:36:05 UTC
useradd returns an error message when creating system users.

Reproducible: Always

Steps to Reproduce:
```
sudo useradd -r test
```
Actual Results:  
```
> sudo useradd -r test
useradd: failed to reset the lastlog entry of UID 983: No such file or directory
```

Expected Results:  
useradd should not return errors when creating system users.

This problem also happens when installing packages with DNF.

Comment 1 Iker Pedrosa 2024-09-19 14:46:20 UTC
I think you catched https://github.com/shadow-maint/shadow/issues/1072. I'll start backporting it.

Just a heads-up but the fix will take some time to land in fedora 40.

Comment 2 Fedora Update System 2024-09-30 10:43:17 UTC
FEDORA-2024-60ccc2b07a (shadow-utils-4.15.1-11.fc41) has been submitted as an update to Fedora 41.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-60ccc2b07a

Comment 3 Fedora Update System 2024-10-01 01:45:59 UTC
FEDORA-2024-60ccc2b07a has been pushed to the Fedora 41 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-60ccc2b07a`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-60ccc2b07a

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 4 Fedora Update System 2024-10-03 00:15:59 UTC
FEDORA-2024-60ccc2b07a (shadow-utils-4.15.1-11.fc41) has been pushed to the Fedora 41 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 5 Vladislav Grigoryev 2024-10-03 05:21:13 UTC
I tested Fedora 41 and the problem persists:
```
> rpm -q shadow-utils 
shadow-utils-4.15.1-11.fc41.x86_64

> sudo useradd -r test
useradd: failed to reset the lastlog entry of UID 982: No such file or directory
```

Comment 6 Iker Pedrosa 2024-10-03 07:47:12 UTC
I'm unable to reproduce it after the patch. 

One thing I can think of is that you are reusing the UID of an already deleted user. Is that possible?

Comment 7 Vladislav Grigoryev 2024-10-03 09:06:01 UTC
Creating 100 users for testing:
```
> for I in $(seq 100); do sudo useradd -r test${RANDOM}; done
useradd: failed to reset the lastlog entry of UID 958: No such file or directory
useradd: failed to reset the lastlog entry of UID 957: No such file or directory
useradd: failed to reset the lastlog entry of UID 956: No such file or directory
[...]
useradd: failed to reset the lastlog entry of UID 861: No such file or directory
useradd: failed to reset the lastlog entry of UID 860: No such file or directory
useradd: failed to reset the lastlog entry of UID 859: No such file or directory
```

Comment 8 Iker Pedrosa 2024-10-03 14:54:00 UTC
Ok, now I've been able to reproduce it. I'll take a closer look and how to fix it in the following days.

Comment 9 Fedora Update System 2024-10-10 07:43:33 UTC
FEDORA-2024-7cf039d7dd (shadow-utils-4.15.1-12.fc41) has been submitted as an update to Fedora 41.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-7cf039d7dd

Comment 10 Fedora Update System 2024-10-11 01:35:27 UTC
FEDORA-2024-7cf039d7dd has been pushed to the Fedora 41 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-7cf039d7dd`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-7cf039d7dd

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 11 Fedora Update System 2024-10-12 00:19:40 UTC
FEDORA-2024-7cf039d7dd (shadow-utils-4.15.1-12.fc41) has been pushed to the Fedora 41 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 12 Fedora Update System 2024-10-15 08:09:22 UTC
FEDORA-2024-8bc9e9b4d9 (shadow-utils-4.15.1-4.fc40) has been submitted as an update to Fedora 40.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-8bc9e9b4d9

Comment 13 Fedora Update System 2024-10-16 01:54:22 UTC
FEDORA-2024-8bc9e9b4d9 has been pushed to the Fedora 40 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-8bc9e9b4d9`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-8bc9e9b4d9

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 14 Fedora Update System 2024-10-19 01:53:11 UTC
FEDORA-2024-8bc9e9b4d9 (shadow-utils-4.15.1-4.fc40) has been pushed to the Fedora 40 stable repository.
If problem still persists, please make note of it in this bug report.