Page MenuHomeFreeBSD

Add basic ATF tests for Capability mode .. lookups
ClosedPublic

Authored by cem on Dec 11 2016, 4:07 AM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 8 2024, 1:36 PM
Unknown Object (File)
Jan 9 2024, 5:13 AM
Unknown Object (File)
Jan 9 2024, 5:13 AM
Unknown Object (File)
Jan 9 2024, 5:13 AM
Unknown Object (File)
Jan 9 2024, 5:13 AM
Unknown Object (File)
Jan 9 2024, 5:13 AM
Unknown Object (File)
Jan 9 2024, 5:13 AM
Unknown Object (File)
Jan 9 2024, 4:23 AM
Subscribers
None

Details

Summary
Test Plan

Could also use symlink tests. Anything else?

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

cem retitled this revision from to Add basic ATF tests for Capability mode .. lookups.
cem updated this object.
cem edited the test plan for this revision. (Show Details)
cem added reviewers: emaste, allanjude, oshogbo, kib, ngie.
tests/sys/vfs/lookup_cap_dotdot.c
41 ↗(On Diff #22808)

Why is this hardcoded to /tmp ? This violates the kyua test sandbox and makes this test impossible to cleanup after if it's interrupted or killed mid-test :(.

Honestly, it seems like you should be able to create a directory under the sandbox, 2 elements deep, which would fulfill your requirements.

56–60 ↗(On Diff #22808)
ATF_CHECK(mkdirat(testdir_fd, "b", 0700) == 0);

is simpler.

84–97 ↗(On Diff #22808)

This should be replaced with this simpler logic (which uses the feature_present(3) API):

#include "freebsd_test_suite/macros.h"

/* ... */

ATF_REQUIRE_FEATURE("security_capabilities");
ATF_REQUIRE_FEATURE("security_capability_mode");

Be sure to add:

CFLAGS+= ${SRCTOP}/tests

to the Makefile.

Could also use symlink tests. Anything else?

Tests that cross mount points, perhaps?

I think it would be useful to include all tests from the original ed program, including non-capsicum kinds.
https://github.com/emaste/snippets/blob/master/test_openat.c

In D8748#181282, @kib wrote:

I think it would be useful to include all tests from the original ed program, including non-capsicum kinds.
https://github.com/emaste/snippets/blob/master/test_openat.c

Will do, thanks.

tests/sys/vfs/lookup_cap_dotdot.c
41 ↗(On Diff #22808)

I'm unfamiliar with kyua sandboxing. How do I use it? Is it just the current directory during test body?

I'm not attached to /tmp, just not aware of anything better.

56–60 ↗(On Diff #22808)

Ok.

84–97 ↗(On Diff #22808)

Thanks. That's in HEAD or BODY?

cem marked 6 inline comments as done.
cem edited edge metadata.

Address ngie@ review feedback.

  • Use cwd (assuming that's the sandbox) instead of tmp, drop cleanup code
  • Use ATF_CHECK/ATF_REQUIRE for simplicity
  • Use ATF_REQUIRE_FEATURE macro instead of raw sysctls

Actually fix commit and push changes.

Bring in Ed's openat tests, adapted to ATF. Includes symlink tests.

We don't want to put it under tools/regression/capsicum ?

We don't want to put it under tools/regression/capsicum ?

As an ATF test the logical place is under tests/. I don't know any good reason to prefer tools/regression over tests or vice versa, so as this is already implemented, I'm inclined to keep it as-is (if it isn't broken, don't fix it).

kib edited edge metadata.
kib added inline comments.
tests/sys/vfs/lookup_cap_dotdot.c
193 ↗(On Diff #22818)

We use c89-style /* */ comments in FreeBSD source code.

This revision is now accepted and ready to land.Dec 12 2016, 10:47 AM
This revision was automatically updated to reflect the committed changes.