Page MenuHomeFreeBSD

Add some more non-portable acl_* functions.
ClosedPublic

Authored by arrowd on Jan 20 2021, 3:55 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Mar 30, 1:30 PM
Unknown Object (File)
Fri, Mar 29, 3:19 PM
Unknown Object (File)
Thu, Mar 28, 12:43 PM
Unknown Object (File)
Jan 22 2024, 10:57 PM
Unknown Object (File)
Jan 13 2024, 12:38 AM
Unknown Object (File)
Jan 7 2024, 2:08 AM
Unknown Object (File)
Jan 7 2024, 2:08 AM
Unknown Object (File)
Jan 7 2024, 2:08 AM
Subscribers

Details

Summary

This review adds acl_from_mode_np, acl_cmp_np and acl_equiv_mode_np functions.
These functions without _np prefix are present in Linux libacl and some software
(KDE, specifically) uses them along with standard POSIX ACL functions.

It is impossible to implement some of them outside of libc, and since we already
have a bit of *_np functions, I decided to implement these.

Test Plan

I did no testing for these functions. I guess, getting this in requires adding
some regressions tests? If yes, I need a guide on how to write and execute tests,
and then I'm happy to do the work.

Special attention should be payed to man pages - I both non-native English
speaker and non-proficient with mandoc.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 36372
Build 33261: arc lint + arc unit

Event Timeline

Interacting with kyau, the test suite, is described here on the wiki.

lib/libc/posix1e/acl_cmp_np.3
54

Another instance of referring to spec making it seem to differ from implementation, as described below.

56

Same as above.

lib/libc/posix1e/acl_equiv_mode_np.3
27

I don't believe &FreeBSD& is needed or encouraged anymore, as it's not used by git - but someone else should probably confirm this.

45

You missed a word here.

47

A bit of wordsmithing to help ledgibility

54–55

Is it supposed to be 'mode values or 'a mode value'?

57

Missed a letter here.

68

Same as above.

lib/libc/posix1e/acl_from_mode_np.3
52

I think it's better to stick with terminology that relates to the VM subsystem here? The dash is optional, but I think it looks better with it.

58

'shall return' makes it sounds like a spec is being quoted, and that the implementation doesn't follow this - I assume that's not the intention?

63

Same as above.

65

Same as above.

69

Same as above.

arrowd marked 12 inline comments as done.
  • Address comments on man pages.

Interacting with kyau, the test suite, is described here on the wiki.

Thanks for the link, I'll look into that.

lib/libc/posix1e/acl_equiv_mode_np.3
54–55

The latter, thanks.

lib/libc/posix1e/acl_from_mode_np.3
58

That's right - there is no spec as these functions are non-standard.

From a manual page point of view, this looks good to me.

I can't speak to the actual code and whether it matches the documentation, though.

  • Add ATF C test for newly added acl_* functions.

I've added an ATF test for new functions. For now, the issues are

  • I had to remove assert(_acl_brand(a) != ACL_BRAND_UNKNOWN) from acl_support.c. I don't quite see why these asserts were there in first place, but I need them removed to make use of _acl_differs in acl_cmp_np.
  • The acl_equiv_mode is very similar to our acl_is_trivial_np. I wonder if something should be done about this.
  • I plan to run the same ATF test on Linux to ensure identical semantics Done, test passes.

Two small nits on the man pages, otherwise LGTM.

lib/libc/posix1e/acl_cmp_np.3
49

New sentence, new line.

lib/libc/posix1e/acl_equiv_mode_np.3
49

New sentence new line.

arrowd marked 3 inline comments as done.
  • Address comments.
  • tests/sys/acl: Add compatibility code for Linux.
  • libc/posix1e: Add acl_extended_file_np() function.
  • Fix for silly error in acl_extended_file_np().
kib added inline comments.
lib/libc/posix1e/Symbol.map
88

1.7

lib/libc/posix1e/acl_cmp_np.c
47

Opening brace should be on the previous line.

Why do you check for NULL? This is untypical for libc interfaces.

53

return (1); style requires () around return value

lib/libc/posix1e/acl_equiv_mode_np.c
105

if (mode_p != NULL)

lib/libc/posix1e/acl_cmp_np.c
47

No idea, to be honest. This is what Linux libacl does, so I just replicated its behavior. Should I remove it?

arrowd marked 3 inline comments as done.

Address comments.

lib/libc/posix1e/acl_cmp_np.c
47

If Linux does that ok. C code cannot validate a pointer, the check for NULL sometimes makes sense when API interprets it as absence of the value.

53

I did not marked all places with the style problems. Issues I pointed out are systematic. For instance the return on the next line needs (). And '{' the placement is not fixed, it is also everywhere.

tests/sys/acl/acl-api-test.c
28 ↗(On Diff #93947)

sys/param.h already includes sys/types.h

45 ↗(On Diff #93947)

static const?

78 ↗(On Diff #93947)

Blank line is needed after declaration block. Space is needed there: while (num_tests--)

arrowd marked 6 inline comments as done.
  • Thorough style(9) check.
  • Address comments.
lib/libc/posix1e/acl_cmp_np.c
53

Right. I feel so stupid about this, what I have been thinking? -_\
The style should be fine now.

lib/libc/posix1e/acl_equiv_mode_np.c
63

Why not write this as a for() loop, to keep all control in single place?
Remove initialization of cur_entry, then just write

   for (cur_entry = 0; cur_entry < acl->ats_acl.acl_cnt; cur_entry++) {
       entry = &acl->ats_acl.acl_entry[cur_entry];
...
70

Move '{' to the previous line

78

Note that 'continue' is correct but somewhat non-idiomatic there. Wouldn't 'break' do the same?

lib/libc/posix1e/acl_extended_file_np.c
80 ↗(On Diff #93965)

Why acl_free() cannot be done right after the call to acl_is_trivial_np? I.e.

retval = acl_is_trivial_np(acl, &istrivial);
acl_free(acl);
if (retval == -1)
     return (-1);
return (!istrivial);
lib/libc/posix1e/acl_from_mode_np.c
57

should this be acl == NULL?

arrowd marked 5 inline comments as done.

Address comments.

This revision is now accepted and ready to land.Aug 21 2021, 12:14 PM