1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

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 <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2021-01-11 13:55:38 +01:00 committed by Jeremy Allison
parent 3d0e55b6d9
commit 49ab5431c5

View File

@ -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);