Skip to content

Commit ab7bd9b

Browse files
authored
Fix file entitlements for shared data dir (#131748)
This fixes incomplete entitlements added in #131680 and is necessary due to the lack of entitlement delegation.
1 parent edc3a64 commit ab7bd9b

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

libs/entitlement/src/main/java/org/elasticsearch/entitlement/bootstrap/HardcodedEntitlements.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ private static List<Scope> createServerEntitlements(Path pidFile) {
9292
new CreateClassLoaderEntitlement(),
9393
new FilesEntitlement(
9494
List.of(
95-
// TODO: what in es.base is accessing shared repo?
95+
// necessary due to lack of delegation ES-12382
9696
FilesEntitlement.FileData.ofBaseDirPath(SHARED_REPO, READ_WRITE),
97+
FilesEntitlement.FileData.ofBaseDirPath(SHARED_DATA, READ_WRITE),
9798
FilesEntitlement.FileData.ofBaseDirPath(DATA, READ_WRITE)
9899
)
99100
)
@@ -122,6 +123,7 @@ private static List<Scope> createServerEntitlements(Path pidFile) {
122123
new FilesEntitlement(
123124
List.of(
124125
FilesEntitlement.FileData.ofBaseDirPath(CONFIG, READ),
126+
FilesEntitlement.FileData.ofBaseDirPath(SHARED_DATA, READ_WRITE),
125127
FilesEntitlement.FileData.ofBaseDirPath(DATA, READ_WRITE)
126128
)
127129
)
@@ -130,7 +132,12 @@ private static List<Scope> createServerEntitlements(Path pidFile) {
130132
new Scope(
131133
"org.apache.lucene.misc",
132134
List.of(
133-
new FilesEntitlement(List.of(FilesEntitlement.FileData.ofBaseDirPath(DATA, READ_WRITE))),
135+
new FilesEntitlement(
136+
List.of(
137+
FilesEntitlement.FileData.ofBaseDirPath(SHARED_DATA, READ_WRITE),
138+
FilesEntitlement.FileData.ofBaseDirPath(DATA, READ_WRITE)
139+
)
140+
),
134141
new ReadStoreAttributesEntitlement()
135142
)
136143
),
@@ -145,7 +152,12 @@ private static List<Scope> createServerEntitlements(Path pidFile) {
145152
"org.elasticsearch.nativeaccess",
146153
List.of(
147154
new LoadNativeLibrariesEntitlement(),
148-
new FilesEntitlement(List.of(FilesEntitlement.FileData.ofBaseDirPath(DATA, READ_WRITE)))
155+
new FilesEntitlement(
156+
List.of(
157+
FilesEntitlement.FileData.ofBaseDirPath(SHARED_DATA, READ_WRITE),
158+
FilesEntitlement.FileData.ofBaseDirPath(DATA, READ_WRITE)
159+
)
160+
)
149161
)
150162
)
151163
);

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/entitlements/FilesEntitlement.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,9 @@ private static BaseDir parseBaseDir(String baseDir) {
182182
case "config" -> BaseDir.CONFIG;
183183
case "data" -> BaseDir.DATA;
184184
case "home" -> BaseDir.USER_HOME;
185+
case "shared_data" -> BaseDir.SHARED_DATA;
185186
// it would be nice to limit this to just ES modules, but we don't have a way to plumb that through to here
186-
// however, we still don't document in the error case below that shared_repo is valid
187+
// however, we still don't document in the error case below that shared_repo and shared_data is valid
187188
case "shared_repo" -> BaseDir.SHARED_REPO;
188189
default -> throw new PolicyValidationException(
189190
"invalid relative directory: " + baseDir + ", valid values: [config, data, home]"

plugins/store-smb/src/main/plugin-metadata/entitlement-policy.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ ALL-UNNAMED:
33
- relative_path: "indices/"
44
relative_to: data
55
mode: read_write
6+
- relative_path: ""
7+
relative_to: shared_data
8+
mode: read_write

x-pack/plugin/searchable-snapshots/src/main/plugin-metadata/entitlement-policy.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ org.elasticsearch.searchablesnapshots:
66
- relative_path: indices
77
relative_to: data
88
mode: read_write
9+
- relative_path: ""
10+
relative_to: shared_data
11+
mode: read_write

0 commit comments

Comments
 (0)