tests/sys/audit/file-attribute-modify.c creates multiple files and directories, adds chflags SF_IMMUTABLE and UF_OFFLINE to the files, and relies on kyua to clean up the files/directories. kyua does the best it can to clean up the directory, but it can't remove files with SF_IMMUTABLE on them. The cleanup routine needs to un-SF_IMMUTABLE the file so kyua can clean up the file/directory. Excerpt from [1]: Hi, I recently stumbled across undeletable files that are generated by kyua test runs, for example -rwxr-xr-x 1 root wheel 0 May 9 13:10 /tmp/kyua.aB4q62/8676/work/fileforaudit I haven't yet identified the test that generate those files, but it is impossible to delete them. I have clear_tmp_enable="YES" set in the /etc/rc.conf, but on every boot the system argues that these file aren't deletable. I tried to 'rm -rf' them by hand but, even this wasn't possible. I have looked for any extend attributes, but I didn't find any. Has anyone an idea how this is possible and may how these files can be deleted? --Gordon Excerpt from [2]: The issue is tests/sys/audit/file-attribute-modify.c , based on the file present that can’t be deleted. Can you please provide more information about the test run in a PR (I see how it can leave files behind, but I want to make sure it is what I think it is, first)? Cheers, -Enji 1. https://lists.freebsd.org/pipermail/freebsd-current/2020-June/076436.html 2. https://lists.freebsd.org/pipermail/freebsd-current/2020-July/076449.html
Related upstream issue: https://github.com/jmmv/kyua/issues/142 .
Confirmed that `:chflagsat_success` is the cause.
A commit references this bug: Author: ngie Date: Sun Jul 12 17:16:57 UTC 2020 New revision: 363132 URL: https://svnweb.freebsd.org/changeset/base/363132 Log: Don't leave `path` behind when executing `:chflags_success` Prior to this change a `SF_IMMUTABLE` chflagsat(2)'ed file (`path`) was left behind, which sabotaged kyua(1) from being able to clean up the work directory, This resulted in unnecessary work for folks having to clean up the work directory on non-disposable systems, which defaults to `/tmp`. Use `UF_OFFLINE` instead of `SF_IMMUTABLE`, in part because setting `SF_IMMUTABLE` isn't relevant to the test and `SF_IMMUTABLE` cannot be cleared at all securelevels, as pointed out by @asomers. Additional work is required to catch cases like this upfront in the future to avoid tester headache. See PR # 247765 for more details/followup. Suggested by: asomers Reviewed By: asomers, #tests MFC after: 1 week PR: 247761 Sponsored by: DellEMC Differential Revision: https://reviews.freebsd.org/D25561 Changes: head/tests/sys/audit/file-attribute-modify.c
A commit in branch stable/12 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=36855239502112971385bae3147ffb4f0a06ae93 commit 36855239502112971385bae3147ffb4f0a06ae93 Author: Enji Cooper <ngie@FreeBSD.org> AuthorDate: 2020-07-12 17:16:57 +0000 Commit: Enji Cooper <ngie@FreeBSD.org> CommitDate: 2022-04-11 01:26:49 +0000 Don't leave `path` behind when executing `:chflags_success` Prior to this change a `SF_IMMUTABLE` chflagsat(2)'ed file (`path`) was left behind, which sabotaged kyua(1) from being able to clean up the work directory, This resulted in unnecessary work for folks having to clean up the work directory on non-disposable systems, which defaults to `/tmp`. Use `UF_OFFLINE` instead of `SF_IMMUTABLE`, in part because setting `SF_IMMUTABLE` isn't relevant to the test and `SF_IMMUTABLE` cannot be cleared at all securelevels, as pointed out by @asomers. Additional work is required to catch cases like this upfront in the future to avoid tester headache. See PR # 247765 for more details/followup. Suggested by: asomers Reviewed By: asomers, #tests MFC after: 1 week PR: 247761 Sponsored by: DellEMC Differential Revision: https://reviews.freebsd.org/D25561 (cherry picked from commit cdb9318eed3852fbedc75e1cfba969ec161e2daa) tests/sys/audit/file-attribute-modify.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)