]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: Avoid all_string_sub() in smb_panic()
authorVolker Lendecke <vl@samba.org>
Mon, 11 Jan 2021 12:55:38 +0000 (13:55 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 12 Jan 2021 00:10:30 +0000 (00:10 +0000)
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>
lib/util/fault.c

index b1da1bb4121263a0829710609ba7971f1a7c1ce3..90552a391b63194d304a2d49b20461f740a502e6 100644 (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);