Removing jailkit user does not clear jailkit files from web directory
Summary
See $Subject
Steps to reproduce
- Setup basic ISPconfig 3.2.9 on Ubunto 22.04 using ispc-autoinstaller
- Create shell user with jailkit
- Remove this shell user again, wait for ISPconfig cronjob
Correct behaviour
The web directory should not have any jailkit specific files (hardlinks to /usr, /etc/, etc files) any more.
Environment
Server OS + version: Ubuntu 22.04 server ISPConfig version: 3.2.9
Proposed fix
If jailkit does not provide this functionality (remove jailkit specific hardlinks), we can recreate this by finding all files owned by root with link_count > 1 and removing them, and then removing all non-default empty folders (i.e. exclude everything with +i attribute). Something like this:
find $WEBDIR -type f -links +1 | xargs rm
find $WEBDIR -type d | tac | xargs rmdir # rmdir fails on non-empty folders, and tac reverses order