Linux kernel: Samba doesn't detect coredump path override by sysctl kernel.core_pattern

Timur I. Bakeyev timur at FreeBSD.org
Thu Feb 26 07:37:39 MST 2009


Hi, Tim, all!

On Wed, Feb 25, 2009 at 11:16 PM, Tim Prouty <tprouty at samba.org> wrote:

> On Nov 3, 2008, at 4:08 PM, Tim Prouty wrote:
>
>> On Nov 3, 2008, at 3:46 AM, Volodymyr Khomenko wrote:
>>
>>  Hi all,
>>>
>>> I've encountered pity issue in samba binaries in Linux environment:
>>> here I can override the path for coredumps (globally for all processes)
>>> by "sysctl -w" command, so I will have such configuration for example:
>>>
>>> # sysctl kernel.core_pattern
>>> kernel.core_pattern = /var/coredumps/core-%h-%u-%e.%p
>>>
>>
>> FreeBSD uses similar global sysctls to control the core file location, so
>> making the core path in samba aware of these sysctls would be useful for
>> other OSs as well.  Your approach to make the corepath sysctl aware sounds
>> good.
>>
>
> There is now a codepath in origin/master that does this for FreeBSD.  It
> should now be fairly easy for you to add a new version for linux.
>
> See:
>
> http://git.samba.org/?p=samba.git;a=commit;h=95e428e2279b706ac590ffb964fda07fd1ee2200
>

I've looked into the patch and got few comments regarding it.

> + * On FreeBSD the current working directory is ignored when creating a
core file

That's not entirely correct statement, default value of kern.corefile is
"%N.core", which assumes dumping core in the CWD. So, I guess, at least
comment should be rephrased.

+               if (len > 1024)  {
+                       goto err_out;
+               }

I'd use MAXPATHLEN instead of hardcoded 1024 to be more portable.

In general, instead of doing loop to approximate necessary buffer size it
could be cheaper to call sysctl*() with the NULL buffer and receive exact
size of the MIB value.

Another thing that should be kept in mind is the usage of expandable
variables. For example, core(5) gives such an example:

kern.corefile="/var/coredumps/%U/%N.core"

Which means that all the core files will go into the /var/coredumps/${UID}/
directory. It could be any other combination of the flags, so if we want to
show exact path where the core file will be dumped we need to expand those
variables first.

Code example for such a routine can be found in
/usr/src/sys/kern/kern_sig.c:expand_name().

In general, I'm not sure does one string on a core dump worth all this
hassle :)

With best regards,
Timur.


More information about the samba-technical mailing list