@@ -147,6 +147,37 @@ private static PolicyManager createPolicyManager() {
147147 );
148148
149149 List <Scope > serverScopes = new ArrayList <>();
150+ List <FileData > serverModuleFileDatas = new ArrayList <>();
151+ Collections .addAll (
152+ serverModuleFileDatas ,
153+ // Base ES directories
154+ FileData .ofPath (bootstrapArgs .tempDir (), READ_WRITE ),
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 ),
162+ FileData .ofPath (Path .of ("/etc/system-release" ), READ ),
163+ FileData .ofPath (Path .of ("/usr/lib/os-release" ), READ ),
164+ // read max virtual memory areas
165+ FileData .ofPath (Path .of ("/proc/sys/vm/max_map_count" ), READ ),
166+ FileData .ofPath (Path .of ("/proc/meminfo" ), READ ),
167+ // load averages on Linux
168+ FileData .ofPath (Path .of ("/proc/loadavg" ), READ ),
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 ),
173+ FileData .ofPath (Path .of ("/sys/fs/cgroup/" ), READ ),
174+ // // io stats on Linux
175+ FileData .ofPath (Path .of ("/proc/self/mountinfo" ), READ ),
176+ FileData .ofPath (Path .of ("/proc/diskstats" ), READ )
177+ );
178+ if (bootstrapArgs .pidFile () != null ) {
179+ serverModuleFileDatas .add (FileData .ofPath (bootstrapArgs .pidFile (), READ_WRITE ));
180+ }
150181 Collections .addAll (
151182 serverScopes ,
152183 new Scope (
@@ -172,34 +203,7 @@ private static PolicyManager createPolicyManager() {
172203 new OutboundNetworkEntitlement (),
173204 new LoadNativeLibrariesEntitlement (),
174205 new ManageThreadsEntitlement (),
175- new FilesEntitlement (
176- List .of (
177- // Base ES directories
178- FileData .ofPath (bootstrapArgs .tempDir (), READ_WRITE ),
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 ),
186- FileData .ofPath (Path .of ("/etc/system-release" ), READ ),
187- FileData .ofPath (Path .of ("/usr/lib/os-release" ), READ ),
188- // read max virtual memory areas
189- FileData .ofPath (Path .of ("/proc/sys/vm/max_map_count" ), READ ),
190- FileData .ofPath (Path .of ("/proc/meminfo" ), READ ),
191- // load averages on Linux
192- FileData .ofPath (Path .of ("/proc/loadavg" ), READ ),
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 ),
197- FileData .ofPath (Path .of ("/sys/fs/cgroup/" ), READ ),
198- // // io stats on Linux
199- FileData .ofPath (Path .of ("/proc/self/mountinfo" ), READ ),
200- FileData .ofPath (Path .of ("/proc/diskstats" ), READ )
201- )
202- )
206+ new FilesEntitlement (serverModuleFileDatas )
203207 )
204208 ),
205209 new Scope ("org.apache.httpcomponents.httpclient" , List .of (new OutboundNetworkEntitlement ())),
0 commit comments