git: 368552395021 - stable/12 - Don't leave `path` behind when executing `:chflags_success`

From: Enji Cooper <ngie_at_FreeBSD.org>
Date: Mon, 11 Apr 2022 02:07:46 UTC
The branch stable/12 has been updated by ngie:

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

diff --git a/tests/sys/audit/file-attribute-modify.c b/tests/sys/audit/file-attribute-modify.c
index 1701b6add7eb..8df1d6d2d95f 100644
--- a/tests/sys/audit/file-attribute-modify.c
+++ b/tests/sys/audit/file-attribute-modify.c
@@ -704,7 +704,7 @@ ATF_TC_BODY(chflagsat_success, tc)
 	/* File needs to exist to call chflagsat(2) */
 	ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
 	FILE *pipefd = setup(fds, auclass);
-	ATF_REQUIRE_EQ(0, chflagsat(AT_FDCWD, path, SF_IMMUTABLE, 0));
+	ATF_REQUIRE_EQ(0, chflagsat(AT_FDCWD, path, UF_OFFLINE, 0));
 	check_audit(fds, successreg, pipefd);
 	close(filedesc);
 }
@@ -726,7 +726,7 @@ ATF_TC_BODY(chflagsat_failure, tc)
 {
 	FILE *pipefd = setup(fds, auclass);
 	/* Failure reason: file does not exist */
-	ATF_REQUIRE_EQ(-1, chflagsat(AT_FDCWD, errpath, SF_IMMUTABLE, 0));
+	ATF_REQUIRE_EQ(-1, chflagsat(AT_FDCWD, errpath, UF_OFFLINE, 0));
 	check_audit(fds, failurereg, pipefd);
 }