Bug 247761 - tests/sys/audit/file-attribute-modify:chflagsat_success leaves chflags files behind; kyua can't clean up directories
Summary: tests/sys/audit/file-attribute-modify:chflagsat_success leaves chflags files ...
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: tests (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: Enji Cooper
Depends on:
Reported: 2020-07-04 15:59 UTC by Enji Cooper
Modified: 2020-07-12 17:24 UTC (History)
2 users (show)

See Also:
ngie: mfc-stable12?
ngie: mfc-stable11?


Note You need to log in before you can comment on or make changes to this bug.
Description Enji Cooper freebsd_committer 2020-07-04 15:59:12 UTC
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]:


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?


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)?

1. https://lists.freebsd.org/pipermail/freebsd-current/2020-June/076436.html
2. https://lists.freebsd.org/pipermail/freebsd-current/2020-July/076449.html
Comment 1 Enji Cooper freebsd_committer 2020-07-04 16:09:00 UTC
Related upstream issue: https://github.com/jmmv/kyua/issues/142 .
Comment 2 Enji Cooper freebsd_committer 2020-07-04 16:12:23 UTC
Confirmed that `:chflagsat_success` is the cause.
Comment 3 commit-hook freebsd_committer 2020-07-12 17:17:48 UTC
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

  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