Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/smbd/signing.c

    r740 r988  
    2323#include "smbd/smbd.h"
    2424#include "smbd/globals.h"
    25 #include "smb_signing.h"
     25#include "../libcli/smb/smb_signing.h"
     26#include "lib/param/param.h"
    2627
    2728/***********************************************************
     
    2930************************************************************/
    3031
    31 bool srv_check_sign_mac(struct smbd_server_connection *conn,
     32bool srv_check_sign_mac(struct smbXsrv_connection *conn,
    3233                        const char *inbuf, uint32_t *seqnum,
    3334                        bool trusted_channel)
    3435{
     36        const uint8_t *inhdr;
     37        size_t len;
     38
    3539        /* Check if it's a non-session message. */
    3640        if(CVAL(inbuf,0)) {
     
    3842        }
    3943
     44        len = smb_len(inbuf);
     45        inhdr = (const uint8_t *)inbuf + NBT_HDR_SIZE;
     46
    4047        if (trusted_channel) {
    4148                NTSTATUS status;
    4249
    43                 if (smb_len(inbuf) < (smb_ss_field + 8 - 4)) {
     50                if (len < (HDR_SS_FIELD + 8)) {
    4451                        DEBUG(1,("smb_signing_check_pdu: Can't check signature "
    4552                                 "on short packet! smb_len = %u\n",
    46                                  smb_len(inbuf)));
    47                         return false;
    48                 }
    49 
    50                 status = NT_STATUS(IVAL(inbuf, smb_ss_field + 4));
     53                                 (unsigned)len));
     54                        return false;
     55                }
     56
     57                status = NT_STATUS(IVAL(inhdr, HDR_SS_FIELD + 4));
    5158                if (!NT_STATUS_IS_OK(status)) {
    5259                        DEBUG(1,("smb_signing_check_pdu: trusted channel passed %s\n",
     
    5562                }
    5663
    57                 *seqnum = IVAL(inbuf, smb_ss_field);
     64                *seqnum = IVAL(inhdr, HDR_SS_FIELD);
    5865                return true;
    5966        }
     
    6168        *seqnum = smb_signing_next_seqnum(conn->smb1.signing_state, false);
    6269        return smb_signing_check_pdu(conn->smb1.signing_state,
    63                                      (const uint8_t *)inbuf,
     70                                     inhdr, len,
    6471                                     *seqnum);
    6572}
     
    6976************************************************************/
    7077
    71 void srv_calculate_sign_mac(struct smbd_server_connection *conn,
     78void srv_calculate_sign_mac(struct smbXsrv_connection *conn,
    7279                            char *outbuf, uint32_t seqnum)
    7380{
     81        uint8_t *outhdr;
     82        size_t len;
     83
    7484        /* Check if it's a non-session message. */
    7585        if(CVAL(outbuf,0)) {
     
    7787        }
    7888
    79         smb_signing_sign_pdu(conn->smb1.signing_state, (uint8_t *)outbuf, seqnum);
     89        len = smb_len(outbuf);
     90        outhdr = (uint8_t *)outbuf + NBT_HDR_SIZE;
     91
     92        smb_signing_sign_pdu(conn->smb1.signing_state, outhdr, len, seqnum);
    8093}
    8194
     
    8497 Called to indicate a oneway request
    8598************************************************************/
    86 void srv_cancel_sign_response(struct smbd_server_connection *conn)
     99void srv_cancel_sign_response(struct smbXsrv_connection *conn)
    87100{
    88101        smb_signing_cancel_reply(conn->smb1.signing_state, true);
     
    155168************************************************************/
    156169
    157 bool srv_init_signing(struct smbd_server_connection *conn)
     170bool srv_init_signing(struct smbXsrv_connection *conn)
    158171{
    159172        bool allowed = true;
     173        bool desired;
    160174        bool mandatory = false;
    161175
    162         switch (lp_server_signing()) {
    163         case Required:
    164                 mandatory = true;
    165                 break;
    166         case Auto:
    167                 break;
    168         case True:
    169                 break;
    170         case False:
    171                 allowed = false;
    172                 break;
    173         }
     176        struct loadparm_context *lp_ctx = loadparm_init_s3(conn, loadparm_s3_helpers());
     177        if (lp_ctx == NULL) {
     178                DEBUG(10, ("loadparm_init_s3 failed\n"));
     179                return false;
     180        }
     181
     182        /*
     183         * if the client and server allow signing,
     184         * we desire to use it.
     185         *
     186         * This matches Windows behavior and is needed
     187         * because not every client that requires signing
     188         * sends FLAGS2_SMB_SECURITY_SIGNATURES_REQUIRED.
     189         *
     190         * Note that we'll always allow signing if the client
     191         * does send FLAGS2_SMB_SECURITY_SIGNATURES_REQUIRED.
     192         */
     193
     194        desired = lpcfg_server_signing_allowed(lp_ctx, &mandatory);
     195        talloc_unlink(conn, lp_ctx);
    174196
    175197        if (lp_async_smb_echo_handler()) {
     
    177199
    178200                /* setup the signing state in shared memory */
    179                 s = talloc_zero(smbd_event_context(), struct smbd_shm_signing);
     201                s = talloc_zero(conn, struct smbd_shm_signing);
    180202                if (s == NULL) {
    181203                        return false;
     
    190212                talloc_set_destructor(s, smbd_shm_signing_destructor);
    191213                conn->smb1.signing_state = smb_signing_init_ex(s,
    192                                                         allowed, mandatory,
     214                                                        allowed, desired, mandatory,
    193215                                                        smbd_shm_signing_alloc,
    194216                                                        smbd_shm_signing_free);
     
    199221        }
    200222
    201         conn->smb1.signing_state = smb_signing_init(smbd_event_context(),
    202                                                     allowed, mandatory);
     223        conn->smb1.signing_state = smb_signing_init(conn,
     224                                                    allowed, desired, mandatory);
    203225        if (!conn->smb1.signing_state) {
    204226                return false;
     
    208230}
    209231
    210 void srv_set_signing_negotiated(struct smbd_server_connection *conn)
    211 {
    212         smb_signing_set_negotiated(conn->smb1.signing_state);
     232void srv_set_signing_negotiated(struct smbXsrv_connection *conn,
     233                                bool allowed, bool mandatory)
     234{
     235        smb_signing_set_negotiated(conn->smb1.signing_state,
     236                                   allowed, mandatory);
    213237}
    214238
     
    218242************************************************************/
    219243
    220 bool srv_is_signing_active(struct smbd_server_connection *conn)
     244bool srv_is_signing_active(struct smbXsrv_connection *conn)
    221245{
    222246        return smb_signing_is_active(conn->smb1.signing_state);
     
    229253************************************************************/
    230254
    231 bool srv_is_signing_negotiated(struct smbd_server_connection *conn)
     255bool srv_is_signing_negotiated(struct smbXsrv_connection *conn)
    232256{
    233257        return smb_signing_is_negotiated(conn->smb1.signing_state);
     
    238262************************************************************/
    239263
    240 void srv_set_signing(struct smbd_server_connection *conn,
     264void srv_set_signing(struct smbXsrv_connection *conn,
    241265                     const DATA_BLOB user_session_key,
    242266                     const DATA_BLOB response)
Note: See TracChangeset for help on using the changeset viewer.