s4:smb_server/smb2: add the same SMB_SIGNING_AUTO logic as for smb1
authorStefan Metzmacher <metze@samba.org>
Wed, 2 Nov 2011 16:50:23 +0000 (17:50 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 3 Nov 2011 15:55:11 +0000 (16:55 +0100)
metze

source4/smb_server/smb2/negprot.c

index dd69c9fc7ece4f5b71a7de31b9592bef05fb462d..892953635caf421965d399034d53e65c719140d0 100644 (file)
@@ -97,6 +97,8 @@ static NTSTATUS smb2srv_negprot_backend(struct smb2srv_request *req, struct smb2
        struct timeval boot_time;
        uint16_t i;
        uint16_t dialect = 0;
+       enum smb_signing_setting signing_setting;
+       struct loadparm_context *lp_ctx = req->smb_conn->lp_ctx;
 
        /* we only do one dialect for now */
        if (io->in.dialect_count < 1) {
@@ -119,12 +121,33 @@ static NTSTATUS smb2srv_negprot_backend(struct smb2srv_request *req, struct smb2
        boot_time = timeval_current(); /* TODO: fix me */
 
        ZERO_STRUCT(io->out);
-       switch (lpcfg_server_signing(req->smb_conn->lp_ctx)) {
+
+       signing_setting = lpcfg_server_signing(lp_ctx);
+       if (signing_setting == SMB_SIGNING_AUTO) {
+               /*
+                * If we are a domain controller, SMB signing is
+                * really important, as it can prevent a number of
+                * attacks on communications between us and the
+                * clients
+                *
+                * However, it really sucks (no sendfile, CPU
+                * overhead) performance-wise when used on a
+                * file server, so disable it by default
+                * on non-DCs
+                */
+
+               if (lpcfg_server_role(lp_ctx) >= ROLE_DOMAIN_CONTROLLER) {
+                       signing_setting = SMB_SIGNING_REQUIRED;
+               } else {
+                       signing_setting = SMB_SIGNING_OFF;
+               }
+       }
+
+       switch (signing_setting) {
        case SMB_SIGNING_OFF:
                io->out.security_mode = 0;
                break;
        case SMB_SIGNING_SUPPORTED:
-       case SMB_SIGNING_AUTO:
                io->out.security_mode = SMB2_NEGOTIATE_SIGNING_ENABLED;
                break;
        case SMB_SIGNING_REQUIRED: