@@ -143,10 +143,6 @@ private static PolicyManager createPolicyManager() {
143143 bootstrapArgs .settingGlobResolver ()
144144 );
145145
146- // TODO: we have this logic repeated all over. we should move it to elasticsearch.base
147- String os = System .getProperty ("os.name" );
148- boolean isLinux = os .startsWith ("Linux" );
149-
150146 List <Scope > serverScopes = new ArrayList <>();
151147 List <FileData > serverModuleFileDatas = new ArrayList <>();
152148 Collections .addAll (
@@ -155,30 +151,26 @@ private static PolicyManager createPolicyManager() {
155151 FileData .ofPath (bootstrapArgs .configDir (), READ ),
156152 FileData .ofPath (bootstrapArgs .logsDir (), READ_WRITE ),
157153 FileData .ofRelativePath (Path .of ("" ), FilesEntitlement .BaseDir .DATA , READ_WRITE ),
158- FileData .ofPath (bootstrapArgs .repoDirResolver ().apply ("" ), READ_WRITE )
154+ FileData .ofPath (bootstrapArgs .repoDirResolver ().apply ("" ), READ_WRITE ),
155+
156+ // OS release on Linux
157+ FileData .ofPath (Path .of ("/etc/os-release" ), READ ),
158+ FileData .ofPath (Path .of ("/etc/system-release" ), READ ),
159+ FileData .ofPath (Path .of ("/usr/lib/os-release" ), READ ),
160+ // read max virtual memory areas
161+ FileData .ofPath (Path .of ("/proc/sys/vm/max_map_count" ), READ ),
162+ FileData .ofPath (Path .of ("/proc/meminfo" ), READ ),
163+ // load averages on Linux
164+ FileData .ofPath (Path .of ("/proc/loadavg" ), READ ),
165+ // control group stats on Linux. cgroup v2 stats are in an unpredicable
166+ // location under `/sys/fs/cgroup`, so unfortunately we have to allow
167+ // read access to the entire directory hierarchy.
168+ FileData .ofPath (Path .of ("/proc/self/cgroup" ), READ ),
169+ FileData .ofPath (Path .of ("/sys/fs/cgroup/" ), READ ),
170+ // // io stats on Linux
171+ FileData .ofPath (Path .of ("/proc/self/mountinfo" ), READ ),
172+ FileData .ofPath (Path .of ("/proc/diskstats" ), READ )
159173 );
160- if (isLinux ) {
161- Collections .addAll (
162- serverModuleFileDatas ,
163- // OS release on Linux
164- FileData .ofPath (Path .of ("/etc/os-release" ), READ ),
165- FileData .ofPath (Path .of ("/etc/system-release" ), READ ),
166- FileData .ofPath (Path .of ("/usr/lib/os-release" ), READ ),
167- // read max virtual memory areas
168- FileData .ofPath (Path .of ("/proc/sys/vm/max_map_count" ), READ ),
169- FileData .ofPath (Path .of ("/proc/meminfo" ), READ ),
170- // load averages on Linux
171- FileData .ofPath (Path .of ("/proc/loadavg" ), READ ),
172- // control group stats on Linux. cgroup v2 stats are in an unpredicable
173- // location under `/sys/fs/cgroup`, so unfortunately we have to allow
174- // read access to the entire directory hierarchy.
175- FileData .ofPath (Path .of ("/proc/self/cgroup" ), READ ),
176- FileData .ofPath (Path .of ("/sys/fs/cgroup/" ), READ ),
177- // // io stats on Linux
178- FileData .ofPath (Path .of ("/proc/self/mountinfo" ), READ ),
179- FileData .ofPath (Path .of ("/proc/diskstats" ), READ )
180- );
181- }
182174 if (bootstrapArgs .pidFile () != null ) {
183175 serverModuleFileDatas .add (FileData .ofPath (bootstrapArgs .pidFile (), READ_WRITE ));
184176 }
0 commit comments