You are not logged in.

#1 2021-12-10 22:28:58

Fixxer
Member
From: Poland
Registered: 2011-08-29
Posts: 210

[EXPLAINED] As a warning - userdel from shadow 4.8.1-4

It would be nice if someone coud test / confirm only **on virtual environment**, do not try it on main system.

Command has caused strange things:

# userdel -rf tox-bootstrapd

I didn't save terminal output, but every binary has ended with error "no such file or directory" and reboot has ended "root fs not syncing" big_smile

Maybe "-" hyphen is the bloodthirsty silent killer...

Last edited by Fixxer (2021-12-11 10:31:48)

Offline

#2 2021-12-10 23:16:34

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: [EXPLAINED] As a warning - userdel from shadow 4.8.1-4

What was that users home directory set to?

Offline

#3 2021-12-11 04:22:40

Fixxer
Member
From: Poland
Registered: 2011-08-29
Posts: 210

Re: [EXPLAINED] As a warning - userdel from shadow 4.8.1-4

It's one user system, permissions are:

/root 750
/home/USER 700

In system there are no "against rules" and good practices modifications, umask is standard 0022.

Package toxcore isn't installed at the moment, it provides this settings in /usr/lib/sysusers.d/toxcore.conf.

There are also no symptoms filesystem nor hardware (ssd sata disk) failure, no significant kernel / system errors / warnings, etc. All is up to date, fully upgraded with stock kernel and linux-lts kernel (no custom kernel). There are also no foreign repositories instead of few local packages maintained on my own (unrelated).

EDITED:
The only visible deletion after command from first post there was lack of /etc directory. After restoring it with rsync from backup booting errors was the same (rootfs not syncing, /sbin/init not found, etc.) Probably /etc/passwd /etc/shadow was mismatched, but it's hard to say anything else.

Last edited by Fixxer (2021-12-11 05:42:37)

Offline

#4 2021-12-11 08:11:08

seth
Member
Registered: 2012-09-03
Posts: 49,967

Re: [EXPLAINED] As a warning - userdel from shadow 4.8.1-4

That doesn't aswer fukawi2's question at all.

The bloodthirsty killer is "-f" and while there might still be /bin, /sbin, /usr/bin directories, I guess they're now empty?
Chances are that the users $HOME was set to "/" and you went on to delete the user, his $HOME … and because of "-f" all files, even if they didn't belong to that user.

If you have a backup of the system that had the user included, check the /etc/passwd of that backup and where the users $HOME resided.

Offline

#5 2021-12-11 10:30:55

Fixxer
Member
From: Poland
Registered: 2011-08-29
Posts: 210

Re: [EXPLAINED] As a warning - userdel from shadow 4.8.1-4

Ok. It's not a bug - it's a feature big_smile Canonical examaple of "stupid commands which lead to fuckup". So be careful and do not use /-f/ force flag with userdel.

> The bloodthirsty killer is "-f" and while there might still be /bin, /sbin, /usr/bin directories, I guess they're now empty?

Safeguard / protection against rm -rf / works. There was deleted /etc directory and some other files (?), but not content of /bin/ /sbin /usr/bin.

By the way, it's rather not the best idea to set some system users home directory to "/", look at /usr/ilb/sysusers.d/*.conf. When system user home directory is set, eg. lxdm -> /var/lib/lxdm, then it's all OK. The tragedy is when home directory is set to "/" and flag / -f / is used.

Last edited by Fixxer (2021-12-11 10:34:19)

Offline

#6 2021-12-11 12:36:20

seth
Member
Registered: 2012-09-03
Posts: 49,967

Re: [EXPLAINED] As a warning - userdel from shadow 4.8.1-4

The tragedy is when … flag / -f / is used.

ftfy.

Offline

#7 2021-12-13 00:16:29

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: [EXPLAINED] As a warning - userdel from shadow 4.8.1-4

Fixxer wrote:

So be careful and do not use /-f/ force flag with userdel.

No. Be careful and understand what commands do before blindly running them on your own systems.

Fixxer wrote:

By the way, it's rather not the best idea to set some system users home directory to "/"

I can't think of any reasonable use case for this. If this came as part of a package, you should file a bug. If you did it yourself, well, caveat emptor.

Offline

Board footer

Powered by FluxBB