From: Volker Lendecke Date: Mon, 11 Jan 2021 12:55:38 +0000 (+0100) Subject: lib: Avoid all_string_sub() in smb_panic() X-Git-Tag: samba-4.14.0rc1~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49ab5431c5b10ead543bf8bf2c0455dcfb262d59;p=thirdparty%2Fsamba.git lib: Avoid all_string_sub() in smb_panic() smb_panic() should be available everywhere. Avoid a dependency on all_string_sub(), this pulls in a lot of other dependencies. The only change is that this uses "strstr" instead of "strstr_m", but having non-ascii panic actions strings can be called rare. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/lib/util/fault.c b/lib/util/fault.c index b1da1bb4121..90552a391b6 100644 --- a/lib/util/fault.c +++ b/lib/util/fault.c @@ -35,7 +35,6 @@ #include "debug.h" #include "lib/util/signal.h" /* Avoid /usr/include/signal.h */ -#include "substitute.h" #include "fault.h" static struct { @@ -134,8 +133,22 @@ static void smb_panic_default(const char *why) if (strlcpy(cmdstring, panic_action, sizeof(cmdstring)) < sizeof(cmdstring)) { int result; char pidstr[20]; + char subst[200]; + char *p = NULL; snprintf(pidstr, sizeof(pidstr), "%d", (int) getpid()); - all_string_sub(cmdstring, "%d", pidstr, sizeof(cmdstring)); + + p = strstr(cmdstring, "%d"); + if (p != NULL) { + snprintf(subst, + sizeof(subst), + "%.*s%s%s", + (int)(p-cmdstring), + cmdstring, + pidstr, + p+2); + strlcpy(cmdstring, subst, sizeof(cmdstring)); + } + DEBUG(0, ("smb_panic(): calling panic action [%s]\n", cmdstring)); result = system(cmdstring);