Ignore:
Timestamp:
Mar 12, 2008, 9:08:18 AM (17 years ago)
Author:
Paul Smedley
Message:

Update source to 3.0.28a

Location:
branches/samba-3.0/source/libsmb
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.0/source/libsmb/cliconnect.c

    r62 r124  
    4141};
    4242
     43static const char *star_smbserver_name = "*SMBSERVER";
     44
    4345/**
    4446 * Set the user session key for a connection
     
    629631                data_blob_free(&negTokenTarg);
    630632                data_blob_free(&session_key_krb5);
    631                 ADS_ERROR_NT(cli_nt_error(cli));
     633                return ADS_ERROR_NT(cli_nt_error(cli));
    632634        }
    633635
     
    862864                }
    863865               
    864                 rc = cli_session_setup_kerberos(cli, principal, domain);
    865                 if (ADS_ERR_OK(rc) || !cli->fallback_after_kerberos) {
     866                /* If we get a bad principal, try to guess it if
     867                   we have a valid host NetBIOS name.
     868                 */
     869                if (strequal(principal, ADS_IGNORE_PRINCIPAL)) {
    866870                        SAFE_FREE(principal);
    867                         return rc;
     871                }
     872                if (principal == NULL &&
     873                        !is_ipaddress(cli->desthost) &&
     874                        !strequal(star_smbserver_name,
     875                                cli->desthost)) {
     876                        char *realm = NULL;
     877                        char *machine = NULL;
     878                        char *host = NULL;
     879                        DEBUG(3,("cli_session_setup_spnego: got a "
     880                                "bad server principal, trying to guess ...\n"));
     881
     882                        host = strchr_m(cli->desthost, '.');
     883                        if (host) {
     884                                machine = SMB_STRNDUP(cli->desthost,
     885                                        host - cli->desthost);
     886                        } else {
     887                                machine = SMB_STRDUP(cli->desthost);
     888                        }
     889                        if (machine == NULL) {
     890                                return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
     891                        }
     892
     893                        realm = kerberos_get_default_realm_from_ccache();
     894                        if (realm && *realm) {
     895                                if (asprintf(&principal, "%s$@%s",
     896                                                machine, realm) < 0) {
     897                                        SAFE_FREE(machine);
     898                                        SAFE_FREE(realm);
     899                                        return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
     900                                }
     901                                DEBUG(3,("cli_session_setup_spnego: guessed "
     902                                        "server principal=%s\n",
     903                                        principal ? principal : "<null>"));
     904                        }
     905                        SAFE_FREE(machine);
     906                        SAFE_FREE(realm);
     907                }
     908
     909                if (principal) {
     910                        rc = cli_session_setup_kerberos(cli, principal, domain);
     911                        if (ADS_ERR_OK(rc) || !cli->fallback_after_kerberos) {
     912                                SAFE_FREE(principal);
     913                                return rc;
     914                        }
    868915                }
    869916        }
     
    14131460
    14141461        /* reasonable default hostname */
    1415         if (!host) host = "*SMBSERVER";
     1462        if (!host) host = star_smbserver_name;
    14161463
    14171464        fstrcpy(cli->desthost, host);
     
    15281575                        goto again;
    15291576                }
    1530                 if (strcmp(called.name, "*SMBSERVER")) {
    1531                         make_nmb_name(&called , "*SMBSERVER", 0x20);
     1577                if (strcmp(called.name, star_smbserver_name)) {
     1578                        make_nmb_name(&called , star_smbserver_name, 0x20);
    15321579                        goto again;
    15331580                }
     
    16531700
    16541701        if(is_ipaddress(desthost)) {
    1655                 make_nmb_name(&called, "*SMBSERVER", 0x20);
     1702                make_nmb_name(&called, star_smbserver_name, 0x20);
    16561703        } else {
    16571704                make_nmb_name(&called, desthost, 0x20);
     
    16621709                struct nmb_name smbservername;
    16631710
    1664                 make_nmb_name(&smbservername , "*SMBSERVER", 0x20);
     1711                make_nmb_name(&smbservername, star_smbserver_name, 0x20);
    16651712
    16661713                /*
  • branches/samba-3.0/source/libsmb/clierror.c

    r39 r124  
    470470        SIVAL(cli->inbuf, smb_rcls, NT_STATUS_V(status));
    471471}
     472
     473/* Reset an error. */
     474
     475void cli_reset_error(struct cli_state *cli)
     476{
     477        if (SVAL(cli->inbuf,smb_flg2) & FLAGS2_32_BIT_ERROR_CODES) {
     478                SIVAL(cli->inbuf, smb_rcls, NT_STATUS_V(NT_STATUS_OK));
     479        } else {
     480                SCVAL(cli->inbuf,smb_rcls,0);
     481                SSVAL(cli->inbuf,smb_err,0);
     482        }
     483}
  • branches/samba-3.0/source/libsmb/clikrb5.c

    r44 r124  
    337337                        data_blob_free(&auth_data_wrapped);
    338338                       
    339                         if (!got_auth_data_pac) {
    340                                 continue;
     339                        if (got_auth_data_pac) {
     340                                return true;
    341341                        }
    342342                }
     
    364364                        got_auth_data_pac = unwrap_pac(mem_ctx, &auth_data_wrapped, auth_data);
    365365                        data_blob_free(&auth_data_wrapped);
    366                        
    367                         if (!got_auth_data_pac) {
    368                                 continue;
     366
     367                        if (got_auth_data_pac) {
     368                                return true;
    369369                        }
    370370                }
  • branches/samba-3.0/source/libsmb/clilist.c

    r22 r124  
    248248                                       &rdata, &data_len) &&
    249249                    cli_is_dos_error(cli)) {
    250                         /* we need to work around a Win95 bug - sometimes
     250                        /* We need to work around a Win95 bug - sometimes
    251251                           it gives ERRSRV/ERRerror temprarily */
    252252                        uint8 eclass;
     
    257257
    258258                        cli_dos_error(cli, &eclass, &ecode);
     259
     260                        /*
     261                         * OS/2 might return "no more files",
     262                         * which just tells us, that searchcount is zero
     263                         * in this search.
     264                         * Guenter Kukkukk <linux@kukkukk.com>
     265                         */
     266
     267                        if (eclass == ERRDOS && ecode == ERRnofiles) {
     268                                ff_searchcount = 0;
     269                                cli_reset_error(cli);
     270                                break;
     271                        }
     272
    259273                        if (eclass != ERRSRV || ecode != ERRerror)
    260274                                break;
  • branches/samba-3.0/source/libsmb/clitrans.c

    r39 r124  
    9696        }
    9797
    98         /* Note we're in a trans state. Save the sequence
    99          * numbers for replies. */
    100         client_set_trans_sign_state_on(cli, mid);
    101 
    10298        if (this_ldata < ldata || this_lparam < lparam) {
    10399                /* receive interim response */
    104100                if (!cli_receive_smb(cli) || cli_is_error(cli)) {
    105                         client_set_trans_sign_state_off(cli, mid);
    106101                        return(False);
    107102                }
     
    145140                        show_msg(cli->outbuf);
    146141                        if (!cli_send_smb(cli)) {
    147                                 client_set_trans_sign_state_off(cli, mid);
    148142                                return False;
    149143                        }
     
    324318  out:
    325319
    326         client_set_trans_sign_state_off(cli, SVAL(cli->inbuf,smb_mid));
    327320        return ret;
    328321}
     
    392385        }       
    393386
    394         /* Note we're in a trans state. Save the sequence
    395          * numbers for replies. */
    396         client_set_trans_sign_state_on(cli, mid);
    397 
    398387        if (this_ldata < ldata || this_lparam < lparam) {
    399388                /* receive interim response */
    400389                if (!cli_receive_smb(cli) || cli_is_error(cli)) {
    401                         client_set_trans_sign_state_off(cli, mid);
    402390                        return(False);
    403391                }
     
    441429
    442430                        if (!cli_send_smb(cli)) {
    443                                 client_set_trans_sign_state_off(cli, mid);
    444431                                return False;
    445432                        }
     
    641628  out:
    642629
    643         client_set_trans_sign_state_off(cli, SVAL(cli->inbuf,smb_mid));
    644630        return ret;
    645631}
  • branches/samba-3.0/source/libsmb/nmblib.c

    r1 r124  
    703703                return(NULL);
    704704
     705        ZERO_STRUCTP(p);        /* initialize for possible padding */
     706
    705707        p->next = NULL;
    706708        p->prev = NULL;
  • branches/samba-3.0/source/libsmb/smb_signing.c

    r1 r124  
    2727        uint16 mid;
    2828        uint32 reply_seq_num;
    29         BOOL can_delete; /* Set to False in trans state. */
    3029};
    3130
     
    4443        for (t = *list; t; t = t->next) {
    4544                if (t->mid == mid) {
    46                         return False;
     45                        DLIST_REMOVE(*list, t);
     46                        SAFE_FREE(t);
     47                        break;
    4748                }
    4849        }
     
    5354        t->mid = mid;
    5455        t->reply_seq_num = reply_seq_num;
    55         t->can_delete = True;
    5656
    5757        /*
     
    8080                        DEBUG(10,("get_sequence_for_reply: found seq = %u mid = %u\n",
    8181                                (unsigned int)t->reply_seq_num, (unsigned int)t->mid ));
    82                         if (t->can_delete) {
    83                                 DLIST_REMOVE(*list, t);
    84                                 SAFE_FREE(t);
    85                         }
    86                         return True;
    87                 }
    88         }
    89         return False;
    90 }
    91 
    92 static BOOL set_sequence_can_delete_flag(struct outstanding_packet_lookup **list, uint16 mid, BOOL can_delete_entry)
    93 {
    94         struct outstanding_packet_lookup *t;
    95 
    96         for (t = *list; t; t = t->next) {
    97                 if (t->mid == mid) {
    98                         t->can_delete = can_delete_entry;
     82                        DLIST_REMOVE(*list, t);
     83                        SAFE_FREE(t);
    9984                        return True;
    10085                }
     
    605590
    606591/***********************************************************
    607  Enter trans/trans2/nttrans state.
    608 ************************************************************/
    609 
    610 BOOL client_set_trans_sign_state_on(struct cli_state *cli, uint16 mid)
    611 {
    612         struct smb_sign_info *si = &cli->sign_info;
    613         struct smb_basic_signing_context *data = (struct smb_basic_signing_context *)si->signing_context;
    614 
    615         if (!si->doing_signing) {
    616                 return True;
    617         }
    618 
    619         if (!data) {
    620                 return False;
    621         }
    622 
    623         if (!set_sequence_can_delete_flag(&data->outstanding_packet_list, mid, False)) {
    624                 return False;
    625         }
    626 
    627         return True;
    628 }
    629 
    630 /***********************************************************
    631  Leave trans/trans2/nttrans state.
    632 ************************************************************/
    633 
    634 BOOL client_set_trans_sign_state_off(struct cli_state *cli, uint16 mid)
    635 {
    636         uint32 reply_seq_num;
    637         struct smb_sign_info *si = &cli->sign_info;
    638         struct smb_basic_signing_context *data = (struct smb_basic_signing_context *)si->signing_context;
    639 
    640         if (!si->doing_signing) {
    641                 return True;
    642         }
    643 
    644         if (!data) {
    645                 return False;
    646         }
    647 
    648         if (!set_sequence_can_delete_flag(&data->outstanding_packet_list, mid, True)) {
    649                 return False;
    650         }
    651 
    652         /* Now delete the stored mid entry. */
    653         if (!get_sequence_for_reply(&data->outstanding_packet_list, mid, &reply_seq_num)) {
    654                 return False;
    655         }
    656 
    657         return True;
    658 }
    659 
    660 /***********************************************************
    661592 SMB signing - Server implementation - send the MAC.
    662593************************************************************/
  • branches/samba-3.0/source/libsmb/smbencrypt.c

    r1 r124  
    445445           This prevents username swapping during the auth exchange
    446446        */
    447         if (!ntv2_owf_gen(nt_hash, user, domain, True, ntlm_v2_hash)) {
     447        if (!ntv2_owf_gen(nt_hash, user, domain, False, ntlm_v2_hash)) {
    448448                return False;
    449449        }
  • branches/samba-3.0/source/libsmb/trusts_util.c

    r1 r124  
    4242
    4343        if (cli->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) {
    44                 uint32 neg_flags = NETLOGON_NEG_AUTH2_FLAGS;
     44                uint32 neg_flags = NETLOGON_NEG_SELECT_AUTH2_FLAGS;
    4545
    4646                result = rpccli_netlogon_setup_creds(cli,
  • branches/samba-3.0/source/libsmb/unexpected.c

    r1 r124  
    6060        len = build_packet(buf, p);
    6161
     62        ZERO_STRUCT(key);       /* needed for potential alignment */
     63
    6264        key.packet_type = p->packet_type;
    6365        key.timestamp = p->timestamp;
     
    8183{
    8284        struct unexpected_key key;
     85
     86        if (kbuf.dsize != sizeof(key)) {
     87                tdb_delete(ttdb, kbuf);
     88        }
    8389
    8490        memcpy(&key, kbuf.dptr, sizeof(key));
     
    120126        struct unexpected_key key;
    121127        struct packet_struct *p;
     128
     129        if (kbuf.dsize != sizeof(key)) {
     130                return 0;
     131        }
    122132
    123133        memcpy(&key, kbuf.dptr, sizeof(key));
Note: See TracChangeset for help on using the changeset viewer.