Bug 230687

Summary: rmuser kill_procs kills processes in jails
Product: Base System Reporter: ikanobori <simon>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Only Me    
Priority: ---    
Version: 11.2-STABLE   
Hardware: Any   
OS: Any   

Description ikanobori 2018-08-17 08:24:25 UTC
The usr.sbin/adduser/rmuser.sh script which ends up in /usr/sbin/rmuser when ran from a host system such as `rmuser user` will kill all processes owned by `user` in its kill_procs routine by identifying processes with `ps -U $USER`.

This includes jailed processes which is not something to be expected (or is it?).

I could submit a patch which would remove processes which have a J flag hidden behind an argument such as --no-jail / -F but don't know if this is desirable.

It doesn't seem there are much better options here as we can't get the current JID as far as I'm aware. If that were possible we could add the -J $JID flag to ps.
Comment 1 ikanobori 2018-08-17 08:25:42 UTC
Reproduction:

- create user user1 on host system
- create jail1 with user1
- run process in jail1 as user1
- rmuser user1 on host system
- process running in jail1 gets killed

Expected:

- jailed processes are not the same user as the host system and should not be killed