@@ -150,7 +150,12 @@ private static PolicyManager createPolicyManager() {
150150 "org.elasticsearch.base" ,
151151 List .of (
152152 new CreateClassLoaderEntitlement (),
153- new FilesEntitlement (List .of (FileData .ofRelativePath (Path .of ("" ), FilesEntitlement .BaseDir .DATA , READ_WRITE )))
153+ new FilesEntitlement (
154+ List .of (
155+ FileData .ofPath (bootstrapArgs .repoDirResolver ().apply ("" ), READ_WRITE ),
156+ FileData .ofRelativePath (Path .of ("" ), FilesEntitlement .BaseDir .DATA , READ_WRITE )
157+ )
158+ )
154159 )
155160 ),
156161 new Scope ("org.elasticsearch.xcontent" , List .of (new CreateClassLoaderEntitlement ())),
@@ -165,34 +170,32 @@ private static PolicyManager createPolicyManager() {
165170 new LoadNativeLibrariesEntitlement (),
166171 new ManageThreadsEntitlement (),
167172 new FilesEntitlement (
168- Stream .concat (
169- Stream .of (
170- // Base ES directories
171- FileData .ofPath (bootstrapArgs .tempDir (), READ_WRITE ),
172- FileData .ofPath (bootstrapArgs .configDir (), READ ),
173- FileData .ofPath (bootstrapArgs .logsDir (), READ_WRITE ),
174- FileData .ofRelativePath (Path .of ("" ), FilesEntitlement .BaseDir .DATA , READ_WRITE ),
175-
176- // OS release on Linux
177- FileData .ofPath (Path .of ("/etc/os-release" ), READ ),
178- FileData .ofPath (Path .of ("/etc/system-release" ), READ ),
179- FileData .ofPath (Path .of ("/usr/lib/os-release" ), READ ),
180- // read max virtual memory areas
181- FileData .ofPath (Path .of ("/proc/sys/vm/max_map_count" ), READ ),
182- FileData .ofPath (Path .of ("/proc/meminfo" ), READ ),
183- // load averages on Linux
184- FileData .ofPath (Path .of ("/proc/loadavg" ), READ ),
185- // control group stats on Linux. cgroup v2 stats are in an unpredicable
186- // location under `/sys/fs/cgroup`, so unfortunately we have to allow
187- // read access to the entire directory hierarchy.
188- FileData .ofPath (Path .of ("/proc/self/cgroup" ), READ ),
189- FileData .ofPath (Path .of ("/sys/fs/cgroup/" ), READ ),
190- // // io stats on Linux
191- FileData .ofPath (Path .of ("/proc/self/mountinfo" ), READ ),
192- FileData .ofPath (Path .of ("/proc/diskstats" ), READ )
193- ),
194- getRepositoryFileData (bootstrapArgs )
195- ).toList ()
173+ List .of (
174+ // Base ES directories
175+ FileData .ofPath (bootstrapArgs .tempDir (), READ_WRITE ),
176+ FileData .ofPath (bootstrapArgs .configDir (), READ ),
177+ FileData .ofPath (bootstrapArgs .logsDir (), READ_WRITE ),
178+ FileData .ofRelativePath (Path .of ("" ), FilesEntitlement .BaseDir .DATA , READ_WRITE ),
179+ FileData .ofPath (bootstrapArgs .repoDirResolver ().apply ("" ), READ_WRITE ),
180+
181+ // OS release on Linux
182+ FileData .ofPath (Path .of ("/etc/os-release" ), READ ),
183+ FileData .ofPath (Path .of ("/etc/system-release" ), READ ),
184+ FileData .ofPath (Path .of ("/usr/lib/os-release" ), READ ),
185+ // read max virtual memory areas
186+ FileData .ofPath (Path .of ("/proc/sys/vm/max_map_count" ), READ ),
187+ FileData .ofPath (Path .of ("/proc/meminfo" ), READ ),
188+ // load averages on Linux
189+ FileData .ofPath (Path .of ("/proc/loadavg" ), READ ),
190+ // control group stats on Linux. cgroup v2 stats are in an unpredicable
191+ // location under `/sys/fs/cgroup`, so unfortunately we have to allow
192+ // read access to the entire directory hierarchy.
193+ FileData .ofPath (Path .of ("/proc/self/cgroup" ), READ ),
194+ FileData .ofPath (Path .of ("/sys/fs/cgroup/" ), READ ),
195+ // // io stats on Linux
196+ FileData .ofPath (Path .of ("/proc/self/mountinfo" ), READ ),
197+ FileData .ofPath (Path .of ("/proc/diskstats" ), READ )
198+ )
196199 )
197200 )
198201 ),
@@ -250,10 +253,6 @@ private static PolicyManager createPolicyManager() {
250253 );
251254 }
252255
253- private static Stream <FileData > getRepositoryFileData (EntitlementBootstrap .BootstrapArgs bootstrapArgs ) {
254- return Stream .of (FileData .ofPath (bootstrapArgs .repoDirResolver ().apply ("" ), READ_WRITE ));
255- }
256-
257256 private static Path getUserHome () {
258257 String userHome = System .getProperty ("user.home" );
259258 if (userHome == null ) {
0 commit comments