Prevent remote folder to be erased during user deletion

A 5 star hangout for overworked and underpaid system admins.
Post Reply
abraun
Posts: 2
Joined: 2020/08/13 12:31:03

Prevent remote folder to be erased during user deletion

Post by abraun » 2020/08/13 12:40:29

I have this issue that's giving me some headaches. I have a user, let's say "pepito" with its user folder as /home/pepito and inside of it a folder that is /home/pepito/share which actually points to a remote storage defined in /etc/fstab.
The problem is that when I delete the user "pepito" (with userdel) not only the reference to remote folder is deleted but the folder itself! This is non-sense. I don't want the folder in the storage to be deleted. Why is this happening? How can i prevent this?

User avatar
KernelOops
Posts: 390
Joined: 2013/12/18 15:04:03
Location: xfs file system

Re: Prevent remote folder to be erased during user deletion

Post by KernelOops » 2020/08/13 19:38:04

You can't. "userdel" is a rather stupid tool with no real checks on what its doing...

for example, if you try to remove a user with "/" as home dir, userdel will go ahead and delete your entire system... give it a go, try to delete the user "systemd-resolve" ;)

fun stuff!
--
I love my computer - all my friends live there.
--

abraun
Posts: 2
Joined: 2020/08/13 12:31:03

Re: Prevent remote folder to be erased during user deletion

Post by abraun » 2020/08/14 01:49:56

Oh well, in that case, any suggestion of which other command could i use to delete a user?

Thanks!

roudaki
Posts: 2
Joined: 2020/08/26 09:16:20

Re: Prevent remote folder to be erased during user deletion

Post by roudaki » 2020/08/26 12:23:11

I would cheat and just remove them from all groups and changed the password first. In case I made the mistake or something changes.
There is usermod but gpasswd can do the trick

gpasswd [option] group
Options: Here only -A and -M options can be combined.

-a, –add : This option is used to add a user to the named group.
-d, –delete : It is used to remove a user from the named group.
-r, –remove-password : It is used to remove the password from the named group.
-R, –restrict : This option will restrict the access to the named group.
-A, –administrators : Set the list of administrative users.
-M, –members : It set the list of group members.
-h, –help : It displays the help message and exit

from: https://linux.die.net/man/1/gpasswd

I hope it helps

Post Reply

Return to “CentOS Social”