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

Update source to 3.0.28a

File:
1 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                /*
Note: See TracChangeset for help on using the changeset viewer.