Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,6 @@ register_toolchains(

deb = use_repo_rule("@download_utils//download/deb:defs.bzl", "download_deb")

deb(
name = "acl-deb",
build = "//third_party/acl:acl.BUILD",
urls = ["https://archive.ubuntu.com/ubuntu/pool/main/a/acl/libacl1-dev_2.2.52-3build1_amd64.deb"],
visibility = ["//visibility:public"],
)

deb(
name = "acl-deb-aarch64",
build = "//third_party/acl:acl.BUILD",
urls = ["https://ports.ubuntu.com/ubuntu-ports/pool/main/a/acl/libacl1-dev_2.2.52-3build1_arm64.deb"],
visibility = ["//visibility:public"],
)

deb(
name = "valgrind-deb",
build = "//third_party/valgrind:valgrind.BUILD",
Expand Down Expand Up @@ -183,6 +169,26 @@ deb(
visibility = ["//visibility:public"],
)

http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

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"],
)
Comment on lines +174 to +190

bazel_dep(name = "flatbuffers", version = "25.12.19")
bazel_dep(name = "nlohmann_json", version = "3.11.3")
bazel_dep(name = "bazel_skylib", version = "1.9.0")
Expand Down
7 changes: 7 additions & 0 deletions score/os/acl_impl.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/********************************************************************************

Check failure on line 1 in score/os/acl_impl.cpp

View workflow job for this annotation

GitHub Actions / Restricted file changes

score/os/acl_impl.cpp is in a restricted path
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
Expand Down Expand Up @@ -400,11 +400,18 @@
ssize_t* const len_p) const noexcept
/* KW_SUPPRESS_END:MISRA.VAR.HIDDEN:Wrapper function is identifiable through namespace usage */
{
if ((acl == nullptr) || (len_p == nullptr))
{
errno = EINVAL;
return score::cpp::make_unexpected(score::os::Error::createFromErrno());
}
Comment on lines +403 to +407

auto* const acl_text = ::acl_to_text(acl, len_p);
if (acl_text == nullptr)
{
return score::cpp::make_unexpected(score::os::Error::createFromErrno());
}

return acl_text;
}

Expand Down
11 changes: 5 additions & 6 deletions score/os/test/acl_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/********************************************************************************

Check failure on line 1 in score/os/test/acl_test.cpp

View workflow job for this annotation

GitHub Actions / Restricted file changes

score/os/test/acl_test.cpp is in a restricted path
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
Expand Down Expand Up @@ -242,15 +242,14 @@
RecordProperty("Verifies", "SCR-46010294");
RecordProperty("ASIL", "QM");
RecordProperty("Description", "ACL shall return error if pass invalid ACL");
RecordProperty("TestType", "requirements-based"); // requirements test
RecordProperty("DerivationTechnique", "requirements-analysis"); // requirements
RecordProperty("TestType", "requirements-based");
RecordProperty("DerivationTechnique", "requirements-analysis");

auto* result = ::acl_get_file("", ACL_TYPE_ACCESS);
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());
}
Comment on lines 248 to 253

// Test to set fd return error if invalid parameters are passed
Expand Down
5 changes: 1 addition & 4 deletions third_party/acl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@

alias(
name = "acl",
actual = select({
"@platforms//cpu:aarch64": "@acl-deb-aarch64//:acl",
"//conditions:default": "@acl-deb//:acl",
}),
actual = "@bazel_acl//:acl",
visibility = ["//:__subpackages__"],
)
76 changes: 68 additions & 8 deletions third_party/acl/acl.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
# Copyright (c) 2026 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
Expand All @@ -11,18 +11,78 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

""" Bazel BUILD file for the ACL library.
"""

load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
name = "acl",
srcs = select({
"@platforms//cpu:aarch64": ["usr/lib/libacl.a"],
"@platforms//cpu:x86_64": ["usr/lib/libacl.a"],
name = "config",
hdrs = select({
"@platforms//os:linux": ["bazel/configs/linux/config.h"],
}),
strip_include_prefix = select({
"@platforms//os:linux": "bazel/configs/linux",
}),
)

cc_library(
name = "acl_h",
hdrs = ["include/acl.h"],
copts = [
'-DEXPORT=__attribute__((visibility("default"))) extern',
],
include_prefix = "sys",
includes = ["include"],
strip_include_prefix = "include",
)
Comment on lines +29 to +38

cc_library(
name = "libacl_h",
hdrs = ["include/libacl.h"],
include_prefix = "acl",
includes = ["include"],
strip_include_prefix = "include",
)

cc_library(
name = "includes",
hdrs = [
"usr/include/acl/libacl.h",
"usr/include/sys/acl.h",
"include/acl_ea.h",
"include/misc.h",
"include/walk_tree.h",
],
includes = ["include"],
)

cc_library(
name = "acl",
srcs = glob(["libacl/*c"]) + [
"libmisc/high_water_alloc.c",
"libmisc/next_line.c",
"libmisc/quote.c",
"libmisc/uid_gid_lookup.c",
"libmisc/unquote.c",
"libmisc/walk_tree.c",
],
includes = ["usr/include/"],
hdrs = glob(["libacl/*h"]),
copts = [
"-include libacl/perm_copy.h",
"-include",
"config.h",
"-Wno-error=missing-prototypes",
"-Wno-error=cast-qual",
"-Wno-error=int-conversion",
"-Wno-error=implicit-function-declaration",
],
includes = ["libacl"],
linkstatic = True,
visibility = ["//visibility:public"],
deps = [
":acl_h",
":config",
":includes",
":libacl_h",
"@bazel_attr//:attr",
],
)
83 changes: 83 additions & 0 deletions third_party/acl/acl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
diff --git a/bazel/configs/linux/config.h b/bazel/configs/linux/config.h
new file mode 100644
index 0000000..e7c5ff6
--- /dev/null
+++ b/bazel/configs/linux/config.h
@@ -0,0 +1,41 @@
+#ifndef ACL_CONFIG_H
+#define ACL_CONFIG_H
+
+#define HAVE_CONFIG_H 1
+
+#define PACKAGE "acl"
+#define PACKAGE_NAME "acl"
+#define PACKAGE_VERSION "2.3.2"
+#define VERSION "2.3.2"
+
+/* Headers */
+#define HAVE_ERRNO_H 1
+#define HAVE_FCNTL_H 1
+#define HAVE_LIMITS_H 1
+#define HAVE_STDARG_H 1
+#define HAVE_STDDEF_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRING_H 1
+#define HAVE_SYS_ACL_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_UNISTD_H 1
+
+/* Functions */
+#define HAVE_FCHMOD 1
+#define HAVE_FCHOWN 1
+#define HAVE_GETXATTR 1
+#define HAVE_FGETXATTR 1
+#define HAVE_SETXATTR 1
+#define HAVE_FSETXATTR 1
+#define HAVE_LISTXATTR 1
+#define HAVE_FLISTXATTR 1
+#define HAVE_REMOVEXATTR 1
+#define HAVE_FREMOVEXATTR 1
+
+/* Linux behavior */
+#define HAVE_VISIBILITY_ATTRIBUTE 1
+#define EXPORT __attribute__ ((visibility ("default"))) extern
+
+#endif /* ACL_CONFIG_H */
diff --git a/include/acl.h b/include/acl.h
index 710bf31..4edc471 100644
--- a/include/acl.h
+++ b/include/acl.h
@@ -21,6 +21,7 @@
#define __SYS_ACL_H

#include <sys/types.h>
+#include "config.h"

#ifdef __cplusplus
extern "C" {
diff --git a/libacl/acl_get_fd.c b/libacl/acl_get_fd.c
index 089ec79..ff930ca 100644
--- a/libacl/acl_get_fd.c
+++ b/libacl/acl_get_fd.c
@@ -24,6 +24,7 @@
#include <unistd.h>
#include <stdio.h>
#include <sys/xattr.h>
+#include <alloca.h>
#include "libacl.h"
#include "__acl_from_xattr.h"

diff --git a/libacl/acl_get_file.c b/libacl/acl_get_file.c
index 4a86d1a..f062bf2 100644
--- a/libacl/acl_get_file.c
+++ b/libacl/acl_get_file.c
@@ -19,6 +19,7 @@
*/

#include "config.h"
+#include <alloca.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
18 changes: 18 additions & 0 deletions third_party/attr/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

alias(
name = "attr",
actual = "@bazel_attr//:attr",
visibility = ["//:__subpackages__"],
)
77 changes: 77 additions & 0 deletions third_party/attr/attr.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# *******************************************************************************
# Copyright (c) 2026 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

""" The BUILD file for the bazel_attr module. This module provides a C library for
extended attributes (xattr) on Linux. It includes a configuration header and
the source files for the library. The library is built as a static library and
is visible to other modules. The configuration header is selected based on the
platform, and the library depends on the platforms and rules_cc modules.
"""

load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
name = "config",
hdrs = select({
"@platforms//os:linux": ["bazel/configs/linux/config.h"],
}),
strip_include_prefix = select({
"@platforms//os:linux": "bazel/configs/linux",
}),
)

cc_library(
name = "attr_h",
hdrs = [
"include/attributes.h",
"include/libattr.h",
],
include_prefix = "attr",
includes = ["include"],
strip_include_prefix = "include",
)

cc_library(
name = "includes",
hdrs = [
"include/error_context.h",
"include/misc.h",
"include/nls.h",
"include/walk_tree.h",
],
includes = ["include"],
)

cc_library(
name = "attr",
srcs = [
"libattr/libattr.c",
],
hdrs = [
"libattr/libattr.h",
],
copts = [
"-DSYSCONFDIR=\\\"$(location :xattr.conf)\\\"",
"-Wno-error=cast-qual",
"-Wno-error=missing-prototypes",
],
data = [":xattr.conf"],
includes = ["libattr"],
linkstatic = True,
visibility = ["//visibility:public"],
deps = [
":attr_h",
":config",
":includes",
],
)
Loading
Loading