@@ -165,33 +165,34 @@ private static PolicyManager createPolicyManager() {
165165 new LoadNativeLibrariesEntitlement (),
166166 new ManageThreadsEntitlement (),
167167 new FilesEntitlement (
168- List .of (
169- // Base ES directories
170- FileData .ofPath (bootstrapArgs .tempDir (), READ_WRITE ),
171- FileData .ofPath (bootstrapArgs .configDir (), READ ),
172- FileData .ofPath (bootstrapArgs .logsDir (), READ_WRITE ),
173- FileData .ofRelativePath (Path .of ("" ), FilesEntitlement .BaseDir .DATA , READ_WRITE ),
174-
175- // OS release on Linux
176- FileData .ofPath (Path .of ("/etc/os-release" ), READ ),
177- FileData .ofPath (Path .of ("/etc/system-release" ), READ ),
178- FileData .ofPath (Path .of ("/usr/lib/os-release" ), READ ),
179- // read max virtual memory areas
180- FileData .ofPath (Path .of ("/proc/sys/vm/max_map_count" ), READ ),
181- FileData .ofPath (Path .of ("/proc/meminfo" ), READ ),
182- // load averages on Linux
183- FileData .ofPath (Path .of ("/proc/loadavg" ), READ ),
184- // control group stats on Linux. cgroup v2 stats are in an unpredicable
185- // location under `/sys/fs/cgroup`, so unfortunately we have to allow
186- // read access to the entire directory hierarchy.
187- FileData .ofPath (Path .of ("/proc/self/cgroup" ), READ ),
188- FileData .ofPath (Path .of ("/sys/fs/cgroup/" ), READ ),
189- // // io stats on Linux
190- FileData .ofPath (Path .of ("/proc/self/mountinfo" ), READ ),
191- FileData .ofPath (Path .of ("/proc/diskstats" ), READ )
192-
193- // TODO: use FileData.ofPathSetting("repositories.fs.location", READ_WRITE)
194- )
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 ()
195196 )
196197 )
197198 ),
@@ -249,6 +250,10 @@ private static PolicyManager createPolicyManager() {
249250 );
250251 }
251252
253+ private static Stream <FileData > getRepositoryFileData (EntitlementBootstrap .BootstrapArgs bootstrapArgs ) {
254+ return Stream .of (FileData .ofPath (bootstrapArgs .repoDirResolver ().apply ("" ), READ_WRITE ));
255+ }
256+
252257 private static Path getUserHome () {
253258 String userHome = System .getProperty ("user.home" );
254259 if (userHome == null ) {
0 commit comments