Unable to delete currently logged in user

Bug #1342875 reported by Robert C Jennings
36
This bug affects 5 people
Affects Status Importance Assigned to Milestone
shadow (Ubuntu)
Fix Released
Medium
Unassigned
Trusty
Fix Released
Medium
Unassigned
Utopic
Won't Fix
Medium
Unassigned

Bug Description

[SRU justification]
Regression from previous releases, this prevents cloud instance setup processes from removing the default admin account that's exists solely for the purpose of the setup itself.

[Test case]
1. Create a trusty schroot environment
2. Log into the trusty schroot environment as a non-root admin user: schroot -c trusty
3. Attempt to remove the admin account: sudo userdel -f vorlon (warning! do not use -r if your host system's home directory is mounted!)
4. Observe the following error:
userdel: user vorlon is currently used by process 5253
userdel: cannot open /etc/subuid
5. Upgrade to the passwd package from trusty-proposed
6. Attempt to remove the admin account again
7. Verify that the command has succeeded.

[Regression potential]
Minimal, as this is a targeted bugfix to the error handling for subuids.

A user can not delete themselves using the command 'sudo userdel -rf <username>', this is common in cloud tools that clean up running images prior to capture. A quick test shows that this worked from Precise (didn't look back further) to Raring and stopped working with Saucy.

Here's a quick example of the failure (from trusty):
# sudo adduser test
# sudo usermod -aG sudo test
## As the 'test' user
# sudo userdel -rf test
userdel: user test is currently used by process 9600
userdel: cannot open /etc/subuid
## User is not removed

Previously (output from precise)
# sudo userdel -rf test
userdel: user test is currently logged in
userdel: warning: can't remove /var/mail/test: No such file or directory
## User is removed

This is being run as the last command by tools that remove the 'ubuntu' user to clean the image prior to capture. This had previously worked and it is preferable that this could be made to work again. The alternative is removal by root, but the root user on cloud images is locked down and we would not want the user to enable root to run userdel on the risk of it not getting disabled properly prior to image capture.

John Agosta (jagosta)
Changed in shadow (Ubuntu):
status: New → Fix Committed
status: Fix Committed → New
Changed in shadow (Ubuntu Utopic):
importance: Undecided → Medium
Changed in shadow (Ubuntu Trusty):
importance: Undecided → Medium
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in shadow (Ubuntu Trusty):
status: New → Confirmed
Changed in shadow (Ubuntu):
status: New → Confirmed
Revision history for this message
Konstantin Pavlov (thresh) wrote :

As a temporary workaround for tools like waagent -deprovision+user, I can suggest rm -f /etc/sub{g,u}id{-} before running the waagent.

Hope it'll get fixed sooner than later because this really is a huge problem.

tags: added: trusty utopic
tags: added: vivid
Revision history for this message
Brian Murray (brian-murray) wrote :

This was a deliberate change by upstream as a part of adding support for subordinate ids. You can find the full list of patches in shadow devel mailing list:

https://lists.alioth.debian.org/pipermail/pkg-shadow-devel/2013-January/thread.html#9561

The specific patch affecting userdel can be found here:

https://lists.alioth.debian.org/pipermail/pkg-shadow-devel/2013-January/009561.html

Changed in shadow (Ubuntu):
status: Confirmed → Invalid
Changed in shadow (Ubuntu Trusty):
status: Confirmed → Won't Fix
Changed in shadow (Ubuntu Utopic):
status: Confirmed → Won't Fix
Revision history for this message
Brian Murray (brian-murray) wrote :

Actually, it seems to me that the following fix resolves the issue.

shadow (1:4.1.5.1-1.1ubuntu4) vivid; urgency=medium

  * debian/patches/1020_fix_user_busy_errors:
    - libmisc/user_busy.c: Call sub_uid_close in all error cases, otherwise
      code that later opens it as RW fails obscurely. (LP: #1436937)
 -- William Grant <email address hidden> Mon, 20 Apr 2015 18:41:47 +0100

(vivid-amd64)root@impulse:/home/bdmurray# apt-get install passwd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
  passwd
1 upgraded, 0 newly installed, 0 to remove and 60 not upgraded.
Need to get 760 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ vivid-proposed/main passwd amd64 1:4.1.5.1-1.1ubuntu4 [760 kB]
Fetched 760 kB in 6s (117 kB/s)
(Reading database ... 14236 files and directories currently installed.)
Preparing to unpack .../passwd_1%3a4.1.5.1-1.1ubuntu4_amd64.deb ...
Unpacking passwd (1:4.1.5.1-1.1ubuntu4) over (1:4.1.5.1-1.1ubuntu3) ...
(vivid-amd64)root@impulse:/home/bdmurray# su test
(vivid-amd64)test@impulse:/home/bdmurray$ sudo userdel -rf test
sudo: unable to resolve host impulse
userdel: user test is currently used by process 32256
userdel: test mail spool (/var/mail/test) not found
(vivid-amd64)test@impulse:/home/bdmurray$ exit
su: User not known to the underlying authentication module
(vivid-amd64)root@impulse:/home/bdmurray# su test
No passwd entry for user 'test'

Changed in shadow (Ubuntu):
status: Invalid → Triaged
Revision history for this message
Robert C Jennings (rcj) wrote :

I tested the vivid package. 1:4.1.5.1-1.1ubuntu3 recreated the issue but in 1:4.1.5.1-1.1ubuntu4 --force works.

Requesting SRU of fixes from bug #1436937 back to Trusty/Utopic.

Changed in shadow (Ubuntu Trusty):
status: Won't Fix → Triaged
Changed in shadow (Ubuntu Utopic):
status: Won't Fix → Triaged
Changed in shadow (Ubuntu):
status: Triaged → Fix Released
Revision history for this message
lic_interop (lic-interop) wrote :

This issue still exists in the latest 12.04, 14.04, and 14.10 images in Azure

On 12.04:
# userdel -f -r azureuser
userdel: user azureuser is currently logged in
userdel: warning: can't remove /var/mail/azureuser: No such file or directory
sent invalidate(passwd) request, exiting
sent invalidate(group) request, exiting
sent invalidate(passwd) request, exiting
sent invalidate(group) request, exiting

On 14.04 and 14.10:
# userdel -f -r azureuser
userdel: user azureuser is currently used by process 1783
userdel: cannot open /etc/subuid

Steve Langasek (vorlon)
description: updated
Revision history for this message
Chris J Arges (arges) wrote : Please test proposed package

Hello Robert, or anyone else affected,

Accepted shadow into trusty-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/shadow/1:4.1.5.1-1ubuntu9.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in shadow (Ubuntu Trusty):
status: Triaged → Fix Committed
tags: added: verification-needed
Changed in shadow (Ubuntu Utopic):
status: Triaged → Fix Committed
Revision history for this message
Chris J Arges (arges) wrote :

Hello Robert, or anyone else affected,

Accepted shadow into utopic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/shadow/1:4.1.5.1-1.1ubuntu2.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Revision history for this message
Simon Déziel (sdeziel) wrote :

I successfully tested the fix on Trusty and since Utopic reached EOL on July 23rd I ignored it thus marking the verification as done. The Vivid verification was reported successfully in comment # 6

tags: added: verification-done
removed: verification-needed
Changed in shadow (Ubuntu Utopic):
status: Fix Committed → Won't Fix
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package shadow - 1:4.1.5.1-1ubuntu9.1

---------------
shadow (1:4.1.5.1-1ubuntu9.1) trusty; urgency=medium

  [ William Grant ]
  * debian/patches/1020_fix_user_busy_errors:
    - libmisc/user_busy.c: Call sub_uid_close in all error cases, otherwise
      code that later opens it as RW fails obscurely. (LP: #1342875)

 -- Steve Langasek <email address hidden> Fri, 10 Jul 2015 13:06:20 -0700

Changed in shadow (Ubuntu Trusty):
status: Fix Committed → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote : Update Released

The verification of the Stable Release Update for shadow has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Ubuntu QA Website (ubuntuqa) wrote :

This bug has been reported on the Ubuntu ISO testing tracker.

A list of all reports related to this bug can be found here:
http://iso.qa.ubuntu.com/qatracker/reports/bugs/1342875

tags: added: iso-testing
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.