Build ACL from source#197
Conversation
|
The created documentation from the pull request is available at: docu-html |
77b186d to
351ef77
Compare
The PR provides patch for building ACL from release.
The acl_to_text() wrapper previously forwarded nullptr ACL handles
directly into libacl. Under ASan/UBSan builds this triggered
undefined behavior inside libacl internals before the library
returned an error condition.
Add explicit parameter validation in the wrapper and return EINVAL
for invalid ACL inputs before invoking libacl.
The related test was updated to validate the wrapper contract
directly by passing nullptr instead of relying on acl_get_file("")
to indirectly produce an invalid ACL handle.
This change improves defensive behavior for invalid input handling
and avoids sanitizer failures caused by passing invalid pointers
into third-party C library internals.
|
@4og Here is the temp solution until we do not get dedicated modules for ACL and ATTR. As you can see I had to change ACL wrapper where I pass now nullptr (not waiting acl_get_file("") to produce an invalid ACL handle). If the solution is not good, feel free to provide better one. |
There was a problem hiding this comment.
Pull request overview
This PR switches the Linux ACL dependency from prebuilt Debian packages to building from upstream release source tarballs via http_archive, adding a companion attr build since ACL depends on it. It also tightens the OS wrapper behavior around acl_to_text() invalid inputs and adjusts the corresponding unit test.
Changes:
- Replace Debian-based ACL fetching with
http_archivebuilds foraclandattr, including Bazel BUILD files and patching needed headers/config. - Update the
//third_party/acland//third_party/attraliases to point at the new@bazel_acl/@bazel_attrrepos. - Add explicit invalid-parameter handling in
AclInstance::acl_to_text()and update the unit test accordingly.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| third_party/attr/BUILD | Adds a repo-local alias target for the external attr archive. |
| third_party/attr/attr.BUILD | Defines how to build the attr library from source under Bazel. |
| third_party/attr/attr.patch | Adds a Bazel-provided Linux config.h for attr. |
| third_party/acl/BUILD | Switches the ACL alias to the new external @bazel_acl build. |
| third_party/acl/acl.BUILD | Defines how to build the acl library from source and link against attr. |
| third_party/acl/acl.patch | Adds Linux config.h and small include fixes needed for building from source. |
| MODULE.bazel | Removes Debian ACL downloads and adds http_archive definitions for attr + acl. |
| score/os/acl_impl.cpp | Adds null-argument validation to the acl_to_text() wrapper. |
| score/os/test/acl_test.cpp | Updates a unit test to use a deterministic invalid-input case for acl_to_text(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if ((acl == nullptr) || (len_p == nullptr)) | ||
| { | ||
| errno = EINVAL; | ||
| return score::cpp::make_unexpected(score::os::Error::createFromErrno()); | ||
| } |
| ssize_t len{0}; | ||
| auto res = unit_.acl_to_text(result, &len); | ||
| ASSERT_FALSE(res.has_value()); | ||
|
|
||
| ::acl_free(result); | ||
| auto res = unit_.acl_to_text(nullptr, &len); | ||
|
|
||
| ASSERT_FALSE(res.has_value()); | ||
| } |
| cc_library( | ||
| name = "acl_h", | ||
| hdrs = ["include/acl.h"], | ||
| copts = [ | ||
| '-DEXPORT=__attribute__((visibility("default"))) extern', | ||
| ], | ||
| include_prefix = "sys", | ||
| includes = ["include"], | ||
| strip_include_prefix = "include", | ||
| ) |
| http_archive( | ||
| name = "bazel_attr", | ||
| build_file = "//third_party/attr:attr.BUILD", | ||
| patch_args = ["-p1"], | ||
| patches = ["//third_party/attr:attr.patch"], | ||
| strip_prefix = "attr-2.5.2", | ||
| urls = ["https://download.savannah.gnu.org/releases/attr/attr-2.5.2.tar.gz"], | ||
| ) | ||
|
|
||
| http_archive( | ||
| name = "bazel_acl", | ||
| build_file = "//third_party/acl:acl.BUILD", | ||
| patch_args = ["-p1"], | ||
| patches = ["//third_party/acl:acl.patch"], | ||
| strip_prefix = "acl-2.3.2", | ||
| urls = ["https://download.savannah.gnu.org/releases/acl/acl-2.3.2.tar.gz"], | ||
| ) |
| +/* Linux behavior */ | ||
| +#define HAVE_VISIBILITY_ATTRIBUTE 1 | ||
| +#define EXPORT __attribute__ ((visibility ("default"))) extern | ||
| + | ||
| +#endif /* ATTR_CONFIG_H */ | ||
| \ No newline at end of file |
The PR provides patch for building ACL from release.