|
32 | 32 | import org.elasticsearch.core.AbstractRefCounted; |
33 | 33 | import org.elasticsearch.core.CheckedConsumer; |
34 | 34 | import org.elasticsearch.core.IOUtils; |
35 | | -import org.elasticsearch.core.PathUtils; |
36 | 35 | import org.elasticsearch.core.SuppressForbidden; |
37 | 36 | import org.elasticsearch.entitlement.bootstrap.EntitlementBootstrap; |
38 | 37 | import org.elasticsearch.entitlement.runtime.api.NotEntitledException; |
@@ -483,16 +482,7 @@ static void initializeNatives(final Path tmpFile, final boolean mlockAll, final |
483 | 482 | } |
484 | 483 |
|
485 | 484 | if (IOUtils.LINUX) { |
486 | | - // The coredump filter determines which types of memory are added to core dumps. By default, Java |
487 | | - // includes memory mapped files, bits 2 and 3. Here we disable those bits. Note that the VM |
488 | | - // has special options to disable these, but the filter is then inherited from the parent process |
489 | | - // which is the server CLI, which is also a JVM so it has these bits set. Thus, we set it explicitly. |
490 | | - // See https://man7.org/linux/man-pages/man5/core.5.html for more info on the relevant bits of the filter |
491 | | - try { |
492 | | - Files.writeString(PathUtils.get("/proc/self/coredump_filter"), "0x23"); |
493 | | - } catch (IOException e) { |
494 | | - throw new RuntimeException("Could not set coredump filter", e); |
495 | | - } |
| 485 | + setCoredumpFilter(); |
496 | 486 | } |
497 | 487 |
|
498 | 488 | // init lucene random seed. it will use /dev/urandom where available: |
@@ -609,6 +599,20 @@ static Map<String, Set<String>> findPluginsWithNativeAccess(Map<String, Policy> |
609 | 599 | return pluginsWithNativeAccess; |
610 | 600 | } |
611 | 601 |
|
| 602 | + @SuppressForbidden(reason = "access proc filesystem") |
| 603 | + private static void setCoredumpFilter() { |
| 604 | + // The coredump filter determines which types of memory are added to core dumps. By default, Java |
| 605 | + // includes memory mapped files, bits 2 and 3. Here we disable those bits. Note that the VM |
| 606 | + // has special options to disable these, but the filter is then inherited from the parent process |
| 607 | + // which is the server CLI, which is also a JVM so it has these bits set. Thus, we set it explicitly. |
| 608 | + // See https://man7.org/linux/man-pages/man5/core.5.html for more info on the relevant bits of the filter |
| 609 | + try { |
| 610 | + Files.writeString(Path.of("/proc/self/coredump_filter"), "0x23"); |
| 611 | + } catch (IOException e) { |
| 612 | + throw new RuntimeException("Could not set coredump filter", e); |
| 613 | + } |
| 614 | + } |
| 615 | + |
612 | 616 | // -- instance |
613 | 617 |
|
614 | 618 | private static volatile Elasticsearch INSTANCE; |
|
0 commit comments