@@ -148,6 +148,36 @@ private static PolicyManager createPolicyManager() {
148148 );
149149
150150 List <Scope > serverScopes = new ArrayList <>();
151+ List <FileData > serverModuleFileDatas = new ArrayList <>();
152+ Collections .addAll (
153+ serverModuleFileDatas ,
154+ // Base ES directories
155+ FileData .ofPath (bootstrapArgs .configDir (), READ ),
156+ FileData .ofPath (bootstrapArgs .logsDir (), READ_WRITE ),
157+ FileData .ofRelativePath (Path .of ("" ), DATA , READ_WRITE ),
158+ FileData .ofRelativePath (Path .of ("" ), SHARED_REPO , READ_WRITE ),
159+
160+ // OS release on Linux
161+ FileData .ofPath (Path .of ("/etc/os-release" ), READ ).withPlatform (LINUX ),
162+ FileData .ofPath (Path .of ("/etc/system-release" ), READ ).withPlatform (LINUX ),
163+ FileData .ofPath (Path .of ("/usr/lib/os-release" ), READ ).withPlatform (LINUX ),
164+ // read max virtual memory areas
165+ FileData .ofPath (Path .of ("/proc/sys/vm/max_map_count" ), READ ).withPlatform (LINUX ),
166+ FileData .ofPath (Path .of ("/proc/meminfo" ), READ ).withPlatform (LINUX ),
167+ // load averages on Linux
168+ FileData .ofPath (Path .of ("/proc/loadavg" ), READ ).withPlatform (LINUX ),
169+ // control group stats on Linux. cgroup v2 stats are in an unpredicable
170+ // location under `/sys/fs/cgroup`, so unfortunately we have to allow
171+ // read access to the entire directory hierarchy.
172+ FileData .ofPath (Path .of ("/proc/self/cgroup" ), READ ).withPlatform (LINUX ),
173+ FileData .ofPath (Path .of ("/sys/fs/cgroup/" ), READ ).withPlatform (LINUX ),
174+ // // io stats on Linux
175+ FileData .ofPath (Path .of ("/proc/self/mountinfo" ), READ ).withPlatform (LINUX ),
176+ FileData .ofPath (Path .of ("/proc/diskstats" ), READ ).withPlatform (LINUX )
177+ );
178+ if (bootstrapArgs .pidFile () != null ) {
179+ serverModuleFileDatas .add (FileData .ofPath (bootstrapArgs .pidFile (), READ_WRITE ));
180+ }
151181 Collections .addAll (
152182 serverScopes ,
153183 new Scope (
@@ -173,33 +203,7 @@ private static PolicyManager createPolicyManager() {
173203 new OutboundNetworkEntitlement (),
174204 new LoadNativeLibrariesEntitlement (),
175205 new ManageThreadsEntitlement (),
176- new FilesEntitlement (
177- List .of (
178- // Base ES directories
179- FileData .ofPath (bootstrapArgs .configDir (), READ ),
180- FileData .ofPath (bootstrapArgs .logsDir (), READ_WRITE ),
181- FileData .ofRelativePath (Path .of ("" ), DATA , READ_WRITE ),
182- FileData .ofRelativePath (Path .of ("" ), SHARED_REPO , READ_WRITE ),
183-
184- // OS release on Linux
185- FileData .ofPath (Path .of ("/etc/os-release" ), READ ).withPlatform (LINUX ),
186- FileData .ofPath (Path .of ("/etc/system-release" ), READ ).withPlatform (LINUX ),
187- FileData .ofPath (Path .of ("/usr/lib/os-release" ), READ ).withPlatform (LINUX ),
188- // read max virtual memory areas
189- FileData .ofPath (Path .of ("/proc/sys/vm/max_map_count" ), READ ).withPlatform (LINUX ),
190- FileData .ofPath (Path .of ("/proc/meminfo" ), READ ).withPlatform (LINUX ),
191- // load averages on Linux
192- FileData .ofPath (Path .of ("/proc/loadavg" ), READ ).withPlatform (LINUX ),
193- // control group stats on Linux. cgroup v2 stats are in an unpredicable
194- // location under `/sys/fs/cgroup`, so unfortunately we have to allow
195- // read access to the entire directory hierarchy.
196- FileData .ofPath (Path .of ("/proc/self/cgroup" ), READ ).withPlatform (LINUX ),
197- FileData .ofPath (Path .of ("/sys/fs/cgroup/" ), READ ).withPlatform (LINUX ),
198- // // io stats on Linux
199- FileData .ofPath (Path .of ("/proc/self/mountinfo" ), READ ).withPlatform (LINUX ),
200- FileData .ofPath (Path .of ("/proc/diskstats" ), READ ).withPlatform (LINUX )
201- )
202- )
206+ new FilesEntitlement (serverModuleFileDatas )
203207 )
204208 ),
205209 new Scope ("org.apache.httpcomponents.httpclient" , List .of (new OutboundNetworkEntitlement ())),
0 commit comments