From 0e8fd3398771da2f016d72830179507f3edda51b Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Sat, 4 May 1996 07:50:46 +0000 Subject: Initial version imported to CVS (This used to be commit 291551d80711daab7b7581720bcd9a08d6096517) --- source3/lib/fault.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 source3/lib/fault.c (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c new file mode 100644 index 0000000000..20c75f7876 --- /dev/null +++ b/source3/lib/fault.c @@ -0,0 +1,86 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + Critical Fault handling + Copyright (C) Andrew Tridgell 1992-1995 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef LINUX +#define __KERNEL__ +#endif + +#include "includes.h" +extern int DEBUGLEVEL; + + +static void (*cont_fn)(); + + +/******************************************************************* +report a fault +********************************************************************/ +static void fault_report(int sig) +{ + DEBUG(0,("===============================================================\n")); + DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)getpid(),VERSION)); + DEBUG(0,("\nPlease read the file BUGS.txt in the distribution\n")); + DEBUG(0,("===============================================================\n")); + +#if AJT + ajt_panic(); +#endif + + if (cont_fn) + { + fault_setup(cont_fn); + cont_fn(NULL); +#ifdef SIGSEGV + signal(SIGSEGV,SIGNAL_CAST SIG_DFL); +#endif +#ifdef SIGBUS + signal(SIGBUS,SIGNAL_CAST SIG_DFL); +#endif + return; /* this should cause a core dump */ + } + exit(1); +} + +/**************************************************************************** +catch serious errors +****************************************************************************/ +static void sig_fault(int sig) +{ + fault_report(sig); +} + +/******************************************************************* +setup our fault handlers +********************************************************************/ +void fault_setup(void (*fn)()) +{ + cont_fn = fn; + +#ifdef SIGSEGV + signal(SIGSEGV,SIGNAL_CAST sig_fault); +#endif +#ifdef SIGBUS + signal(SIGBUS,SIGNAL_CAST sig_fault); +#endif +} + + + -- cgit From 08d00eb68ee93eaead0f3bbaabc3d89540e0818e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 24 Oct 1996 00:09:08 +0000 Subject: - added support for TMPDIR env variable - fixed fault.c for linux 2.1 - put back in the FIND_SELF failing code - cleaned up casts in encryption (This used to be commit 3af04f1580b2569c0a4f2549bf6352c7a25afa0d) --- source3/lib/fault.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index 20c75f7876..9bc2eca7e0 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -19,10 +19,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifdef LINUX -#define __KERNEL__ -#endif - #include "includes.h" extern int DEBUGLEVEL; -- cgit From 0f1f0ceb9519368188f695e18e2341ccfd1b2d15 Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Thu, 8 May 1997 01:14:17 +0000 Subject: 'The mother of all checkins' :-). Jeremy Allison (jallison@whistle.com) Wed May 7 1997: Update for 1.9.17alpha1 release - 'browsefix release' designed to make browsing across subnets work. byteorder.h: Updated copyright to 1997. charcnv.c: Updated copyright to 1997. charset.c Updated copyright to 1997. charset.h Updated copyright to 1997. client.c Updated copyright to 1997. clientutil.c Updated copyright to 1997. dir.c Updated copyright to 1997. fault.c Updated copyright to 1997. includes.h Updated copyright to 1997. interface.c Updated copyright to 1997. ipc.c Updated copyright to 1997. kanji.c Updated copyright to 1997. kanji.h Updated copyright to 1997. loadparm.c Updated copyright to 1997. locking.c Updated copyright to 1997. mangle.c Updated copyright to 1997. message.c Updated copyright to 1997. nameannounce.c Made use of WINS subnet explicit. Added reset_announce_timer() so announcement can be made immediately when we become a master. Expanded code to do sync with dmb. namebrowse.c Removed redundent checks for AM_MASTER in sync code. Made use of WINS subnet explicit. namedbname.c Made use of WINS subnet explicit. namedbresp.c Made use of WINS subnet explicit. namedbserver.c Made use of WINS subnet explicit. namedbsubnet.c Explicitly add workgroup to WINS subnet when we become a dmb. Made use of WINS subnet explicit. namedbwork.c Made use of WINS subnet explicit. Removed redundent check_work_servertype() function. nameelect.c Explicitly add workgroup to WINS subnet when we become a master browser. Made use of WINS subnet explicit. namelogon.c Updated copyright to 1997. namepacket.c Updated copyright to 1997. namequery.c Updated copyright to 1997. nameresp.c Made use of WINS subnet explicit. Made nmbd fail if configured as master browser and one exists already. nameserv.c Made use of WINS subnet explicit. Remove redundent logon server and domain master code. nameserv.h Add emumerate subnet macros. nameservreply.c Made use of WINS subnet explicit. nameservresp.c Updated copyright to 1997. namework.c Made use of WINS subnet explicit. Updated code to add sync browser entries to add subnet parameter. nmbd.c Added sanity check for misconfigured nmbd. nmblib.c Updated copyright to 1997. nmblookup.c Updated copyright to 1997. nmbsync.c Removed redundent AM_ANY_MASTER check. params.c Updated copyright to 1997. password.c Updated copyright to 1997. pipes.c Updated copyright to 1997. predict.c Updated copyright to 1997. printing.c Updated copyright to 1997. proto.h Changed protos for new nmbd code. quotas.c Updated copyright to 1997. replace.c Updated copyright to 1997. reply.c Updated copyright to 1997. server.c Updated copyright to 1997. shmem.c Updated copyright to 1997. smb.h Updated copyright to 1997. smbencrypt.c Updated copyright to 1997. smbpasswd.c Updated copyright to 1997. smbrun.c Updated copyright to 1997. status.c Updated copyright to 1997. system.c Updated copyright to 1997. testparm.c Updated copyright to 1997. testprns.c Updated copyright to 1997. time.c Updated copyright to 1997. trans2.c Updated copyright to 1997. trans2.h Updated copyright to 1997. uid.c Updated copyright to 1997. username.c Updated copyright to 1997. util.c Updated copyright to 1997. version.h Changed to 1.9.17alpha1. (This used to be commit cf23a155a1315f50d488794a2caf88402bf3e3e6) --- source3/lib/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index 9bc2eca7e0..61715a4f22 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -2,7 +2,7 @@ Unix SMB/Netbios implementation. Version 1.9. Critical Fault handling - Copyright (C) Andrew Tridgell 1992-1995 + Copyright (C) Andrew Tridgell 1992-1997 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -- cgit From 55f400bd84f26027f5ec9b7fa06b22895de7557c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 22 Jan 1998 13:27:43 +0000 Subject: This is *not* a big change (although it looks like one). This is merely updating the Copyright statements from 1997 to 1998. It's a once a year thing :-). NO OTHER CHANGES WERE MADE. Jeremy. (This used to be commit b9c16977231efb274e08856f7f3f4408dad6d96c) --- source3/lib/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index 61715a4f22..e3299c50db 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -2,7 +2,7 @@ Unix SMB/Netbios implementation. Version 1.9. Critical Fault handling - Copyright (C) Andrew Tridgell 1992-1997 + Copyright (C) Andrew Tridgell 1992-1998 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -- cgit From cac6a060af598bf94e6414b06e7365ec51ca360e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 13 Apr 1998 19:24:06 +0000 Subject: Changes to allow Samba to be compiled with -Wstrict-prototypes with gcc. (Not a big change although it looks like it :-). Jeremy. (This used to be commit cd2613c57261456485fe4eeecfda209ada70de8e) --- source3/lib/fault.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index e3299c50db..f46ccbb185 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -23,7 +23,7 @@ extern int DEBUGLEVEL; -static void (*cont_fn)(); +static void (*cont_fn)(void *); /******************************************************************* @@ -66,7 +66,7 @@ static void sig_fault(int sig) /******************************************************************* setup our fault handlers ********************************************************************/ -void fault_setup(void (*fn)()) +void fault_setup(void (*fn)(void *)) { cont_fn = fn; -- cgit From 64578c0589a3a741f81fb55c16eeb882128da00b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 29 Jul 1998 03:08:05 +0000 Subject: merge from the autoconf2 branch to the main branch (This used to be commit 3bda7ac417107a7b01d91805ca71c4330657ed21) --- source3/lib/fault.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index f46ccbb185..e1b3c6cd9f 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -45,10 +45,10 @@ static void fault_report(int sig) fault_setup(cont_fn); cont_fn(NULL); #ifdef SIGSEGV - signal(SIGSEGV,SIGNAL_CAST SIG_DFL); + CatchSignal(SIGSEGV,SIGNAL_CAST SIG_DFL); #endif #ifdef SIGBUS - signal(SIGBUS,SIGNAL_CAST SIG_DFL); + CatchSignal(SIGBUS,SIGNAL_CAST SIG_DFL); #endif return; /* this should cause a core dump */ } @@ -71,10 +71,10 @@ void fault_setup(void (*fn)(void *)) cont_fn = fn; #ifdef SIGSEGV - signal(SIGSEGV,SIGNAL_CAST sig_fault); + CatchSignal(SIGSEGV,SIGNAL_CAST sig_fault); #endif #ifdef SIGBUS - signal(SIGBUS,SIGNAL_CAST sig_fault); + CatchSignal(SIGBUS,SIGNAL_CAST sig_fault); #endif } -- cgit From e107f730824ce9ab9915dab4745e5eba1845bbe4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 11 Aug 1998 13:55:16 +0000 Subject: make sure that a fault cannot occur twice. The new Debug1() code is causing seg faults on my machine and because the fault code calls DEBUG() it is looping! now to find the bug in the Debug1() code ... (This used to be commit 83122bae2253221f085118c6e7e914982656bd64) --- source3/lib/fault.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index e1b3c6cd9f..9b665f65c7 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -31,28 +31,32 @@ report a fault ********************************************************************/ static void fault_report(int sig) { - DEBUG(0,("===============================================================\n")); - DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)getpid(),VERSION)); - DEBUG(0,("\nPlease read the file BUGS.txt in the distribution\n")); - DEBUG(0,("===============================================================\n")); + static int counter; + + if (counter) _exit(1); + + counter++; + + DEBUG(0,("===============================================================\n")); + DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)getpid(),VERSION)); + DEBUG(0,("\nPlease read the file BUGS.txt in the distribution\n")); + DEBUG(0,("===============================================================\n")); #if AJT - ajt_panic(); + ajt_panic(); #endif - if (cont_fn) - { - fault_setup(cont_fn); - cont_fn(NULL); + if (cont_fn) { + cont_fn(NULL); #ifdef SIGSEGV - CatchSignal(SIGSEGV,SIGNAL_CAST SIG_DFL); + CatchSignal(SIGSEGV,SIGNAL_CAST SIG_DFL); #endif #ifdef SIGBUS - CatchSignal(SIGBUS,SIGNAL_CAST SIG_DFL); + CatchSignal(SIGBUS,SIGNAL_CAST SIG_DFL); #endif - return; /* this should cause a core dump */ - } - exit(1); + return; /* this should cause a core dump */ + } + exit(1); } /**************************************************************************** @@ -60,7 +64,7 @@ catch serious errors ****************************************************************************/ static void sig_fault(int sig) { - fault_report(sig); + fault_report(sig); } /******************************************************************* @@ -68,13 +72,13 @@ setup our fault handlers ********************************************************************/ void fault_setup(void (*fn)(void *)) { - cont_fn = fn; + cont_fn = fn; #ifdef SIGSEGV - CatchSignal(SIGSEGV,SIGNAL_CAST sig_fault); + CatchSignal(SIGSEGV,SIGNAL_CAST sig_fault); #endif #ifdef SIGBUS - CatchSignal(SIGBUS,SIGNAL_CAST sig_fault); + CatchSignal(SIGBUS,SIGNAL_CAST sig_fault); #endif } -- cgit From 038e3433d39337f736b7b69ac1e6212e9f8e5406 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 21 Aug 1998 11:37:40 +0000 Subject: added new smb.conf option "panic action". see my samba-technical explanation. (This used to be commit c6899df44c34088a4d2bf1edc840320b0ba7e32e) --- source3/lib/fault.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index 9b665f65c7..6effaf7d7c 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -42,9 +42,7 @@ static void fault_report(int sig) DEBUG(0,("\nPlease read the file BUGS.txt in the distribution\n")); DEBUG(0,("===============================================================\n")); -#if AJT - ajt_panic(); -#endif + smb_panic("internal error"); if (cont_fn) { cont_fn(NULL); -- cgit From 693ffb8466ada58ecc59fde754ba79fc6f51528d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 2 May 2000 02:23:41 +0000 Subject: Added sys_fork() and sys_getpid() functions to stop the overhead of doing a system call every time we want to just get our pid. Jeremy. (This used to be commit 148628b616b5c29ba6340d65fc3ddbcabba6e67a) --- source3/lib/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index 6effaf7d7c..29272f1928 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -38,7 +38,7 @@ static void fault_report(int sig) counter++; DEBUG(0,("===============================================================\n")); - DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)getpid(),VERSION)); + DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)sys_getpid(),VERSION)); DEBUG(0,("\nPlease read the file BUGS.txt in the distribution\n")); DEBUG(0,("===============================================================\n")); -- cgit From dc1fc3ee8ec2199bc73bb5d7ec711c6800f61d65 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 2 Oct 2001 04:29:50 +0000 Subject: Removed 'extern int DEBUGLEVEL' as it is now in the smb.h header. (This used to be commit 2d0922b0eabfdc0aaf1d0797482fef47ed7fde8e) --- source3/lib/fault.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index 29272f1928..885e35e023 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -20,12 +20,9 @@ */ #include "includes.h" -extern int DEBUGLEVEL; - static void (*cont_fn)(void *); - /******************************************************************* report a fault ********************************************************************/ -- cgit From cd68afe31256ad60748b34f7318a180cfc2127cc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 30 Jan 2002 06:08:46 +0000 Subject: Removed version number from file header. Changed "SMB/Netbios" to "SMB/CIFS" in file header. (This used to be commit 6a58c9bd06d0d7502a24bf5ce5a2faf0a146edfa) --- source3/lib/fault.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index 885e35e023..e132ed8f67 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -1,6 +1,5 @@ /* - Unix SMB/Netbios implementation. - Version 1.9. + Unix SMB/CIFS implementation. Critical Fault handling Copyright (C) Andrew Tridgell 1992-1998 -- cgit From b390459450cbabc68f620c1a06bcee6c7a152edb Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 7 Apr 2003 18:27:32 +0000 Subject: BUGS.txt -> Bugs appendix in HOWTO Collection (This used to be commit f95741ae882ad1d1e7f709e30ea3bae02a4aff2d) --- source3/lib/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index e132ed8f67..a9e1b7bbb9 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -35,7 +35,7 @@ static void fault_report(int sig) DEBUG(0,("===============================================================\n")); DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)sys_getpid(),VERSION)); - DEBUG(0,("\nPlease read the file BUGS.txt in the distribution\n")); + DEBUG(0,("\nPlease read the appendix Bugs of the Samba HOWTO collection\n")); DEBUG(0,("===============================================================\n")); smb_panic("internal error"); -- cgit From 8bfe26b62db2e671b143d93a5428f8fb64a9df05 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 20 Aug 2003 17:13:38 +0000 Subject: metze's autogenerate patch for version.h (This used to be commit ae452e51b02672a56adf18aa7a7e365eeaba9272) --- source3/lib/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index a9e1b7bbb9..df7830ef83 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -34,7 +34,7 @@ static void fault_report(int sig) counter++; DEBUG(0,("===============================================================\n")); - DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)sys_getpid(),VERSION)); + DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)sys_getpid(),SAMBA_VERSION_STRING)); DEBUG(0,("\nPlease read the appendix Bugs of the Samba HOWTO collection\n")); DEBUG(0,("===============================================================\n")); -- cgit From fc33274a27b98d67a3f1172aebc9e70073b6dcab Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 22 Jan 2004 01:50:58 +0000 Subject: * Add SIGABRT to fault handling so we now got a backtrace, if we crash in libldap with SIGABRT metze (This used to be commit b5e814294eb3ce44131084d89014cb8a8840fe74) --- source3/lib/fault.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index df7830ef83..d8364ff225 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -47,6 +47,9 @@ static void fault_report(int sig) #endif #ifdef SIGBUS CatchSignal(SIGBUS,SIGNAL_CAST SIG_DFL); +#endif +#ifdef SIGABRT + CatchSignal(SIGABRT,SIGNAL_CAST SIG_DFL); #endif return; /* this should cause a core dump */ } @@ -74,7 +77,7 @@ void fault_setup(void (*fn)(void *)) #ifdef SIGBUS CatchSignal(SIGBUS,SIGNAL_CAST sig_fault); #endif +#ifdef SIGABRT + CatchSignal(SIGABRT,SIGNAL_CAST sig_fault); +#endif } - - - -- cgit From e906c370e5b0037cd1379f72c20e400ac1630db2 Mon Sep 17 00:00:00 2001 From: John Terpstra Date: Wed, 17 Aug 2005 06:01:38 +0000 Subject: r9353: Updating troublshooting error message. (This used to be commit 7744de8ead6aef67278368e407dd1db8b9437348) --- source3/lib/fault.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index d8364ff225..3cb6684639 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -35,7 +35,8 @@ static void fault_report(int sig) DEBUG(0,("===============================================================\n")); DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)sys_getpid(),SAMBA_VERSION_STRING)); - DEBUG(0,("\nPlease read the appendix Bugs of the Samba HOWTO collection\n")); + DEBUG(0,("\nPlease read the Trouble-Shooting section of the Samba3-HOWTO\n")); + DEBUG(0,("\nFrom: http://www.samba.org/samba/docs/Samba3-HOWTO.pdf\n")); DEBUG(0,("===============================================================\n")); smb_panic("internal error"); -- cgit From 4fa555980070d78b39711ef21d77628d26055bc2 Mon Sep 17 00:00:00 2001 From: James Peach Date: Tue, 4 Apr 2006 00:27:50 +0000 Subject: r14898: This change is an attempt to improve the quality of the information that is produced when a process exits abnormally. First, we coalesce the core dumping code so that we greatly improve our odds of being able to produce a core file, even in the case of a memory fault. I've removed duplicates of dump_core() and split it in two to reduce the amount of work needed to actually do the dump. Second, we refactor the exit_server code path to always log an explanation and a stack trace. My goal is to always produce enough log information for us to be able to explain any server exit, though there is a risk that this could produce too much log information on a flaky network. Finally, smbcontrol has gained a smbd fault injection operation to test the changes above. This is only enabled for developer builds. (This used to be commit 56bc02d64498eb3faf89f0c5452b9299daea8e95) --- source3/lib/fault.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 95 insertions(+), 2 deletions(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index 3cb6684639..8ae45f2435 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -20,7 +20,12 @@ #include "includes.h" +#ifdef HAVE_SYS_PRCTL_H +#include +#endif + static void (*cont_fn)(void *); +static pstring corepath; /******************************************************************* report a fault @@ -33,11 +38,11 @@ static void fault_report(int sig) counter++; - DEBUG(0,("===============================================================\n")); + DEBUGSEP(0); DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)sys_getpid(),SAMBA_VERSION_STRING)); DEBUG(0,("\nPlease read the Trouble-Shooting section of the Samba3-HOWTO\n")); DEBUG(0,("\nFrom: http://www.samba.org/samba/docs/Samba3-HOWTO.pdf\n")); - DEBUG(0,("===============================================================\n")); + DEBUGSEP(0); smb_panic("internal error"); @@ -82,3 +87,91 @@ void fault_setup(void (*fn)(void *)) CatchSignal(SIGABRT,SIGNAL_CAST sig_fault); #endif } + +/******************************************************************* +make all the preparations to safely dump a core file +********************************************************************/ + +void dump_core_setup(const char *progname) +{ + pstring logbase; + char * end; + + if (lp_logfile() && *lp_logfile()) { + snprintf(logbase, sizeof(logbase), "%s", lp_logfile()); + if ((end = strrchr_m(logbase, '/'))) { + *end = '\0'; + } + } else { + /* We will end up here is the log file is given on the command + * line by the -l option but the "log file" option is not set + * in smb.conf. + */ + snprintf(logbase, sizeof(logbase), "%s", dyn_LOGFILEBASE); + } + + SMB_ASSERT(progname != NULL); + + snprintf(corepath, sizeof(corepath), "%s/cores", logbase); + mkdir(corepath,0700); + + snprintf(corepath, sizeof(corepath), "%s/cores/%s", + logbase, progname); + mkdir(corepath,0700); + + sys_chown(corepath,getuid(),getgid()); + chmod(corepath,0700); + +#ifdef HAVE_GETRLIMIT +#ifdef RLIMIT_CORE + { + struct rlimit rlp; + getrlimit(RLIMIT_CORE, &rlp); + rlp.rlim_cur = MAX(16*1024*1024,rlp.rlim_cur); + setrlimit(RLIMIT_CORE, &rlp); + getrlimit(RLIMIT_CORE, &rlp); + DEBUG(3,("Maximum core file size limits now %d(soft) %d(hard)\n", + (int)rlp.rlim_cur,(int)rlp.rlim_max)); + } +#endif +#endif + +#if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE) + /* On Linux we lose the ability to dump core when we change our user + * ID. We know how to dump core safely, so let's make sure we have our + * dumpable flag set. + */ + prctl(PR_SET_DUMPABLE, 1); +#endif + + /* FIXME: if we have a core-plus-pid facility, configurably set + * this up here. + */ +} + + void dump_core(void) +{ + if (*corepath != '\0') { + /* The chdir might fail if we dump core before we finish + * processing the config file. + */ + if (chdir(corepath) != 0) { + DEBUG(0, ("unable to change to %s", corepath)); + DEBUGADD(0, ("refusing to dump core\n")); + exit(1); + } + + DEBUG(0,("dumping core in %s\n", corepath)); + } + + umask(~(0700)); + dbgflush(); + + /* Ensure we don't have a signal handler for abort. */ +#ifdef SIGABRT + CatchSignal(SIGABRT,SIGNAL_CAST SIG_DFL); +#endif + + abort(); +} + -- cgit From 0ed76af63d25fe98fc0366708675a514a3c5bddb Mon Sep 17 00:00:00 2001 From: James Peach Date: Tue, 16 May 2006 02:50:49 +0000 Subject: r15631: Add a new option "enable core files". Administrators can use this to disable automatic core file dumping. Core files are enabled by default. (This used to be commit b59189280057849b67ac65f31cec23b859e21c91) --- source3/lib/fault.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index 8ae45f2435..dc8c276d02 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -151,6 +151,15 @@ void dump_core_setup(const char *progname) void dump_core(void) { + /* Note that even if core dumping has been disabled, we still set up + * the core path. This is to handle the case where core dumping is + * turned on in smb.conf and the relevant daemon is not restarted. + */ + if (!lp_enable_core_files()) { + DEBUG(0, ("Exiting on internal error (core file administratively disabled\n")); + exit(1); + } + if (*corepath != '\0') { /* The chdir might fail if we dump core before we finish * processing the config file. -- cgit From 9a0273634860386ecdd6b4c606f30f2620ae3dc0 Mon Sep 17 00:00:00 2001 From: James Peach Date: Tue, 7 Nov 2006 17:18:00 +0000 Subject: r19626: Coalesce usage of DUMP_CORE. Fix formatting on chdir error message in core dump path. (This used to be commit 9a51fba71c5fa7082c331e1a78a98638d9aa06cf) --- source3/lib/fault.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index dc8c276d02..b632a5c82f 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -160,12 +160,13 @@ void dump_core_setup(const char *progname) exit(1); } +#if DUMP_CORE if (*corepath != '\0') { /* The chdir might fail if we dump core before we finish * processing the config file. */ if (chdir(corepath) != 0) { - DEBUG(0, ("unable to change to %s", corepath)); + DEBUG(0, ("unable to change to %s\n", corepath)); DEBUGADD(0, ("refusing to dump core\n")); exit(1); } @@ -182,5 +183,9 @@ void dump_core_setup(const char *progname) #endif abort(); + +#else /* DUMP_CORE */ + exit(1); +#endif /* DUMP_CORE */ } -- cgit From fc9f6d6087f591a0c48840a5686557ba5a13cb0d Mon Sep 17 00:00:00 2001 From: James Peach Date: Fri, 6 Apr 2007 19:17:15 +0000 Subject: r22107: Fix typo. (This used to be commit fd056b2426dea059fec50fe1c90e4fdd48f916d7) --- source3/lib/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index b632a5c82f..b214d9027e 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -156,7 +156,7 @@ void dump_core_setup(const char *progname) * turned on in smb.conf and the relevant daemon is not restarted. */ if (!lp_enable_core_files()) { - DEBUG(0, ("Exiting on internal error (core file administratively disabled\n")); + DEBUG(0, ("Exiting on internal error (core file administratively disabled)\n")); exit(1); } -- cgit From ffc03ada718225e93a6ec85f25838ac35598c0b0 Mon Sep 17 00:00:00 2001 From: Lars Müller Date: Tue, 17 Apr 2007 17:17:19 +0000 Subject: r22318: If we're running as non root we might not be able to dump the core file to the corepath. Even the chdir() will fail if the LOGFILEBASE path is set 0700. If the currrent user doesn't have the permission to create the core file we end with: unable to change to refusing to dump core The alternative would be to change the permissions of the directory. But taht would not ensure core dumps are working out of the box. (This used to be commit 0814a3acbe0fe40badf88690ab61d8ad106419d6) --- source3/lib/fault.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index b214d9027e..26b48a80cd 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -161,6 +161,13 @@ void dump_core_setup(const char *progname) } #if DUMP_CORE + /* If we're running as non root we might not be able to dump the core + * file to the corepath. There must not be an unbecome_root() before + * we call abort(). */ + if (getuid() != 0) { + become_root(); + } + if (*corepath != '\0') { /* The chdir might fail if we dump core before we finish * processing the config file. -- cgit From fdfe5301fa8293b21a1bc3e73863ce99ac42d5f8 Mon Sep 17 00:00:00 2001 From: Lars Müller Date: Tue, 17 Apr 2007 18:35:10 +0000 Subject: r22320: Be more careful and check for the euid instead of the uid. Thx for the hint James! (This used to be commit 72be9766a9b3a860717222a86d636c1dbbf61b12) --- source3/lib/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index 26b48a80cd..d429c19748 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -164,7 +164,7 @@ void dump_core_setup(const char *progname) /* If we're running as non root we might not be able to dump the core * file to the corepath. There must not be an unbecome_root() before * we call abort(). */ - if (getuid() != 0) { + if (geteuid() != 0) { become_root(); } -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/lib/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index d429c19748..9de0bfe9ae 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/lib/fault.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index 9de0bfe9ae..3ddb88edc7 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From b6514d02ecbeaff68b8f625e07e9c16dda8fddcf Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 14 Sep 2007 11:07:02 +0000 Subject: r25150: don't recursivly call call dump_core() as currently seen in 'make test' localy and in the farm metze (This used to be commit f41efe01b5a22889f5b18916df9a2f924263e7f9) --- source3/lib/fault.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index 3ddb88edc7..6ab1a07900 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -150,6 +150,14 @@ void dump_core_setup(const char *progname) void dump_core(void) { + static bool called; + + if (called) { + DEBUG(0, ("dump_core() called recursive\n")); + exit(1); + } + called = true; + /* Note that even if core dumping has been disabled, we still set up * the core path. This is to handle the case where core dumping is * turned on in smb.conf and the relevant daemon is not restarted. -- cgit From 68be9a820059ee96dd26c527efd7c14e679d3f2c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 15 Nov 2007 14:19:52 -0800 Subject: More pstring removal. This one was tricky. I had to add one horror (pstring_clean_name()) which will have to remain until I've removed all pstrings from the client code. Jeremy. (This used to be commit 1ea3ac80146b83c2522b69e7747c823366a2b47d) --- source3/lib/fault.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index 6ab1a07900..52c4ae63e5 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -24,7 +24,7 @@ #endif static void (*cont_fn)(void *); -static pstring corepath; +static char *corepath; /******************************************************************* report a fault @@ -93,11 +93,13 @@ make all the preparations to safely dump a core file void dump_core_setup(const char *progname) { - pstring logbase; - char * end; + char *logbase = NULL; + char *end = NULL; if (lp_logfile() && *lp_logfile()) { - snprintf(logbase, sizeof(logbase), "%s", lp_logfile()); + if (asprintf(&logbase, "%s", lp_logfile()) < 0) { + return; + } if ((end = strrchr_m(logbase, '/'))) { *end = '\0'; } @@ -106,21 +108,32 @@ void dump_core_setup(const char *progname) * line by the -l option but the "log file" option is not set * in smb.conf. */ - snprintf(logbase, sizeof(logbase), "%s", dyn_LOGFILEBASE); + if (asprintf(&logbase, "%s", dyn_LOGFILEBASE) < 0) { + return; + } } SMB_ASSERT(progname != NULL); - snprintf(corepath, sizeof(corepath), "%s/cores", logbase); + if (asprintf(&corepath, "%s/cores", logbase) < 0) { + SAFE_FREE(logbase); + return; + } mkdir(corepath,0700); - snprintf(corepath, sizeof(corepath), "%s/cores/%s", - logbase, progname); + SAFE_FREE(corepath); + if (asprintf(&corepath, "%s/cores/%s", + logbase, progname) < 0) { + SAFE_FREE(logbase); + return; + } mkdir(corepath,0700); sys_chown(corepath,getuid(),getgid()); chmod(corepath,0700); + SAFE_FREE(corepath); + #ifdef HAVE_GETRLIMIT #ifdef RLIMIT_CORE { -- cgit From b7db7c8352c4cab8bfd39c9767536fb9ecb93939 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 29 Nov 2007 16:30:18 -0800 Subject: Fix memleak. Jeremy. (This used to be commit ccacd170472869391bd1e5bc850b1467492b8fa3) --- source3/lib/fault.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index 52c4ae63e5..b5d290a2c8 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -133,6 +133,7 @@ void dump_core_setup(const char *progname) chmod(corepath,0700); SAFE_FREE(corepath); + SAFE_FREE(logbase); #ifdef HAVE_GETRLIMIT #ifdef RLIMIT_CORE -- cgit From 7faee02d0d351c5c039e8f1be7e82ce3a93cbe96 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 10 Dec 2007 11:30:37 -0800 Subject: Remove the char[1024] strings from dynconfig. Replace them with malloc'ing accessor functions. Should save a lot of static space :-). Jeremy. (This used to be commit 52dc5eaef2106015b3a8b659e818bdb15ad94b05) --- source3/lib/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index b5d290a2c8..33e1401d7a 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -108,7 +108,7 @@ void dump_core_setup(const char *progname) * line by the -l option but the "log file" option is not set * in smb.conf. */ - if (asprintf(&logbase, "%s", dyn_LOGFILEBASE) < 0) { + if (asprintf(&logbase, "%s", get_dyn_LOGFILEBASE()) < 0) { return; } } -- cgit From fe478af26aacd1b3ae7e24c4c82e03f576d71691 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 27 Jan 2008 10:22:42 +0100 Subject: We need to leave the corepath around In case we need to dump core, in line 191 we dereference corepath to be able to chdir there. Jeremy, please check! Volker (This used to be commit 3959b1954b02405ec174497fa17e345ca6d5ee94) --- source3/lib/fault.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index 33e1401d7a..1964955f1b 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -132,7 +132,6 @@ void dump_core_setup(const char *progname) sys_chown(corepath,getuid(),getgid()); chmod(corepath,0700); - SAFE_FREE(corepath); SAFE_FREE(logbase); #ifdef HAVE_GETRLIMIT -- cgit From 15ac8b6bc1abd754940b7f6fe3a5ae7e77fceb4f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 13 Jun 2008 11:56:40 +0200 Subject: Do not segfault if corepath is not set up properly (This used to be commit 41d1b9541ccb802f01f12038b3b81853b3b7c32d) --- source3/lib/fault.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index 1964955f1b..d4c1142937 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -188,6 +188,11 @@ void dump_core_setup(const char *progname) become_root(); } + if (corepath == NULL) { + DEBUG(0, ("Can not dump core: corepath not set up\n")); + exit(1); + } + if (*corepath != '\0') { /* The chdir might fail if we dump core before we finish * processing the config file. -- cgit