[Bug 269213] /etc/rc.d/cleanvar interaction with samba fdescfs mount causes file deletions outside of /var/run

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 29 Jan 2023 02:35:13 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269213

            Bug ID: 269213
           Summary: /etc/rc.d/cleanvar interaction with samba fdescfs
                    mount causes file deletions outside of /var/run
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: misc
          Assignee: bugs@FreeBSD.org
          Reporter: julian@precisium.com.au

With newer samba versions there is apparently a requirement of the new VFS to
mount fdescfs with the nodup option.
Samba mounts fdescfs under /var/run   e.g /var/run/samba4/fd

This interacts badly with /etc/rc.d/cleanvar which uses 'find /var/run ...'  
to delete files under /var/run.

During startup - there appear to be various parts of the filesystem referenced
under /var/run/samba4/fd  so that the result is deletion of all files under
paths such as /bin /sbin /etc /root 

Rather than pushing to try to stop samba mounting this where it wants - I'm
filing this bug to see if it makes sense instead to make cleanvar safer, as
potentially other packages may do this sort of thing in future anyway.

I tried various -name & -path flags to exclude *samba4/fd/* etc -but 'find'
doesn't seem to recognise these as normal names & paths.
adding "-mount" to restrict find to the same device number as /var/run seems to
work.

e.g the relevant line in /etc/rc.d/cleanvar becomes:
find /var/run -mount \( -type f -or -type s | -name log -and ! -name logpriv \)
-delete

see also discussion at
https://forums.freebsd.org/threads/iocage-removes-files-at-startup.87733/

-- 
You are receiving this mail because:
You are the assignee for the bug.