smbd: Enable "smbd:suicide mode" for smb2
authorVolker Lendecke <vl@samba.org>
Tue, 21 May 2019 12:52:22 +0000 (14:52 +0200)
committerRalph Boehme <slow@samba.org>
Wed, 22 May 2019 18:54:24 +0000 (18:54 +0000)
The next commit needs an smbd to just exit and leave data behind in the
locking.tdb file. Don't make it harder to eventually phase out SMB1: Do
the test in SMB2.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13957
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/smb2_server.c

index 5057cf68d7b276990a794eab8fc3ce0ddc077eb5..7b6e82ba2f01e38c94c3da7fa318999816f6ccdf 100644 (file)
@@ -30,6 +30,7 @@
 #include "../librpc/gen_ndr/krb5pac.h"
 #include "lib/util/iov_buf.h"
 #include "auth.h"
+#include "libcli/smb/smbXcli_base.h"
 
 #include <gnutls/gnutls.h>
 #include <gnutls/crypto.h>
@@ -447,6 +448,17 @@ static NTSTATUS smbd_smb2_inbuf_parse_compound(struct smbXsrv_connection *xconn,
                 */
 
                if (len < SMB2_HDR_BODY + 2) {
+
+                       if ((len == 5) &&
+                           (IVAL(hdr, 0) == SMB_SUICIDE_PACKET) &&
+                           lp_parm_bool(-1, "smbd", "suicide mode", false)) {
+                               uint8_t exitcode = CVAL(hdr, 4);
+                               DBG_WARNING("SUICIDE: Exiting immediately "
+                                           "with code %"PRIu8"\n",
+                                           exitcode);
+                               exit(exitcode);
+                       }
+
                        DEBUG(10, ("%d bytes left, expected at least %d\n",
                                   (int)len, SMB2_HDR_BODY));
                        goto inval;