Solved Can't delete jail directory.

rigoletto@

Developer
Hello,

I was trying Jails but I end up with a directory I can't delete: /usr/jail/www.

I did it using:

Code:
setenv D /usr/jail/www
mkdir -p $D
cd /usr/src
make installworld DESTDIR=$D
make distribution DESTDIR=$D

Any ideia?

Thanks!

EDIT:

Code:
rm: /usr/jail/www/bin/rcp: Operation not permitted
rm: /usr/jail/www/bin: Directory not empty
rm: /usr/jail/www/lib/libc.so.7: Operation not permitted
rm: /usr/jail/www/lib/libcrypt.so.5: Operation not permitted
rm: /usr/jail/www/lib/libthr.so.3: Operation not permitted
rm: /usr/jail/www/lib: Directory not empty
rm: /usr/jail/www/libexec/ld-elf.so.1: Operation not permitted
rm: /usr/jail/www/libexec: Directory not empty
rm: /usr/jail/www/sbin/init: Operation not permitted
rm: /usr/jail/www/sbin: Directory not empty
rm: /usr/jail/www/usr/bin/chpass: Operation not permitted
rm: /usr/jail/www/usr/bin/chfn: Operation not permitted
rm: /usr/jail/www/usr/bin/chsh: Operation not permitted
rm: /usr/jail/www/usr/bin/ypchpass: Operation not permitted
rm: /usr/jail/www/usr/bin/ypchfn: Operation not permitted
rm: /usr/jail/www/usr/bin/ypchsh: Operation not permitted
rm: /usr/jail/www/usr/bin/login: Operation not permitted
rm: /usr/jail/www/usr/bin/opieinfo: Operation not permitted
rm: /usr/jail/www/usr/bin/opiepasswd: Operation not permitted
rm: /usr/jail/www/usr/bin/passwd: Operation not permitted
rm: /usr/jail/www/usr/bin/yppasswd: Operation not permitted
rm: /usr/jail/www/usr/bin/rlogin: Operation not permitted
rm: /usr/jail/www/usr/bin/rsh: Operation not permitted
rm: /usr/jail/www/usr/bin/su: Operation not permitted
rm: /usr/jail/www/usr/bin/crontab: Operation not permitted
rm: /usr/jail/www/usr/bin: Directory not empty
rm: /usr/jail/www/usr/lib/librt.so.1: Operation not permitted
rm: /usr/jail/www/usr/lib: Directory not empty
rm: /usr/jail/www/usr: Directory not empty
rm: /usr/jail/www: Directory not empty
 
chflags -R noschg * did the job.
this solved the issue for me - but just trying to understand if * should be applied to the specific jail directory or just as it's mentioned.

Also trying to understand the noschg argument, couldn't understand/find it on the man page
 
this solved the issue for me - but just trying to understand if * should be applied to the specific jail directory or just as it's mentioned.
You certainly don't want to recursively change flags on your whole system, do you? 🤷‍♂️
Sure this assumes your current directory IS the jail you want to modify.

Also trying to understand the noschg argument, couldn't understand/find it on the man page
It's right here in chflags(1):
Code:
           schg, schange, simmutable
                       set the system immutable flag (super-user only)

[...]

     Putting the letters “no” before or removing the letters “no” from a
     keyword causes the flag to be cleared.  For example:

           nouchg  clear the user immutable flag (owner or super-user only)
           dump    clear the nodump flag (owner or super-user only)
 
If you're using ZFS, I'd highly recommend creating a dataset per jail. File flags will not stop you from running zfs destroy (it's a lot faster than rm anyway...).
 
Back
Top