Avoid accidental core dumps?

A 19.07 router is running an ash script which got stuck running a simple command (no idea why and I will never likely find out). Interestingly it has created a core file in /tmp

-rw------- 1 root root 253952 May 30 11:01 /tmp/sh.1685444492.18074.11.core

I have not done anything to enable creating this file. I have not seen it before on other routers.

What I have read is that I have to go to some work to enable core files on OpenWRT, which I have not enabled.

Is there a way to ensure that core files are NEVER created?

p.s. For the curious, the command that got stuck was "wg show wg0 dump"

Try this:

cat << "EOF" > /etc/sysctl.d/20-core-dump-disable.conf
fs.suid_dumpable=0
kernel.core_pattern = /bin/false
EOF
sysctl -p /etc/sysctl.d/20-core-dump-disable.conf
3 Likes