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

Tim Prouty tprouty at samba.org
Wed Feb 25 15:16:00 MST 2009


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
>>
>> Still, source/lib/fault.c:dump_core_setup routine doesn't detect  
>> such thing.
>> source/lib/fault.c:dump_core will write the message "dumping core  
>> in <regular_corepath>"
>> and do 'chdir' there, but with configured 'kernel.core_pattern' it  
>> doesn't make any effect.
>> After abort() a core will be dumped to the path specified by  
>> kernel.core_pattern instead of current dir.
>>
>> To avoid false message with corepath I propose to patch source/lib/ 
>> fault.c:dump_core_setup
>> to acquire kernel.core_pattern by sysctl
>> with __sysctl_args.name = {CTL_KERN, KERN_CORE_PATTERN} and skip  
>> corepath generation from logbase
>> if this parameter has basename (i.e. we have '/' as the 1st  
>> character).
>>
>> Alternatively we can read kernel.core_pattern from /proc/sys/kernel/ 
>> core_pattern as from regular text file
>> (if /proc/sys is available).
>>
>> The thing I don't know is how to make autoconf detect the presence  
>> of corresponding sysctl or /proc/sys.
>>
>> What do you think?
>
> 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.
>
> You'll probably want to add a check in source3/configure.in for the  
> existence of _sysctl, and maybe even have the configure check call  
> _sysctl with kernel.core_pattern to make sure that the sysctl will  
> work.  There are many examples of different types of checks already  
> in configure.in, so I would recommend modeling your check after one  
> of the existing ones.

Hi Volodymyr,

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

-Tim


More information about the samba-technical mailing list