Ignore:
Timestamp:
May 27, 2009, 9:09:42 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.2 branch to 3.2.8

Location:
branches/samba-3.2.x/source/libsmb
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.2.x/source/libsmb/async_smb.c

    r204 r232  
    319319{
    320320        struct cli_state *cli = (struct cli_state *)p;
    321         struct cli_request *req;
     321        struct cli_request *req, *next;
    322322        NTSTATUS status;
    323323
     
    422422
    423423 sock_error:
    424         for (req = cli->outstanding_requests; req; req = req->next) {
     424        for (req = cli->outstanding_requests; req; req = next) {
     425                next = req;
    425426                async_req_error(req->async, status);
    426427        }
  • branches/samba-3.2.x/source/libsmb/cliconnect.c

    r228 r232  
    537537#define BASE_SESSSETUP_BLOB_PACKET_SIZE (35 + 24 + 22)
    538538
    539 static bool cli_session_setup_blob(struct cli_state *cli, DATA_BLOB blob, DATA_BLOB session_key_krb5)
     539static bool cli_session_setup_blob(struct cli_state *cli, DATA_BLOB blob)
    540540{
    541541        int32 remaining = blob.length;
     
    561561                        remaining -= max_blob_size;
    562562                } else {
    563                         DATA_BLOB null_blob = data_blob_null;
    564 
    565563                        send_blob.length = remaining;
    566564                        remaining = 0;
    567 
    568                         /* This is the last packet in the sequence - turn signing on. */
    569                         cli_simple_set_signing(cli, session_key_krb5, null_blob);
    570565                }
    571566
     
    615610        DATA_BLOB negTokenTarg;
    616611        DATA_BLOB session_key_krb5;
     612        NTSTATUS nt_status;
    617613        int rc;
     614
     615        cli_temp_set_signing(cli);
    618616
    619617        DEBUG(2,("Doing kerberos session setup\n"));
     
    632630#endif
    633631
    634         if (!cli_session_setup_blob(cli, negTokenTarg, session_key_krb5)) {
    635                 data_blob_free(&negTokenTarg);
    636                 data_blob_free(&session_key_krb5);
    637                 return ADS_ERROR_NT(cli_nt_error(cli));
     632        if (!cli_session_setup_blob(cli, negTokenTarg)) {
     633                nt_status = cli_nt_error(cli);
     634                goto nt_error;
     635        }
     636
     637        if (cli_is_error(cli)) {
     638                nt_status = cli_nt_error(cli);
     639                if (NT_STATUS_IS_OK(nt_status)) {
     640                        nt_status = NT_STATUS_UNSUCCESSFUL;
     641                }
     642                goto nt_error;
    638643        }
    639644
    640645        cli_set_session_key(cli, session_key_krb5);
     646
     647        if (cli_simple_set_signing(
     648                    cli, session_key_krb5, data_blob_null)) {
     649
     650                /* 'resign' the last message, so we get the right sequence numbers
     651                   for checking the first reply from the server */
     652                cli_calculate_sign_mac(cli, cli->outbuf);
     653
     654                if (!cli_check_sign_mac(cli, cli->inbuf)) {
     655                        nt_status = NT_STATUS_ACCESS_DENIED;
     656                        goto nt_error;
     657                }
     658        }
    641659
    642660        data_blob_free(&negTokenTarg);
    643661        data_blob_free(&session_key_krb5);
    644662
    645         if (cli_is_error(cli)) {
    646                 if (NT_STATUS_IS_OK(cli_nt_error(cli))) {
    647                         return ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL);
    648                 }
    649         }
    650         return ADS_ERROR_NT(cli_nt_error(cli));
     663        return ADS_ERROR_NT(NT_STATUS_OK);
     664
     665nt_error:
     666        data_blob_free(&negTokenTarg);
     667        data_blob_free(&session_key_krb5);
     668        cli->vuid = 0;
     669        return ADS_ERROR_NT(nt_status);
    651670}
    652671#endif  /* HAVE_KRB5 */
  • branches/samba-3.2.x/source/libsmb/clidfs.c

    r228 r232  
    307307
    308308        if (p) {
    309                 char *name = clean_name(NULL, p->mount);
     309                char *name = clean_name(NULL, mnt);
    310310                if (!name) {
    311311                        return;
    312312                }
     313                TALLOC_FREE(p->mount);
    313314                p->mount = talloc_strdup(p, name);
    314315                TALLOC_FREE(name);
  • branches/samba-3.2.x/source/libsmb/clientgen.c

    r141 r232  
    316316        size_t len = SVAL(cli->outbuf,smb_vwv11) + 4;
    317317        size_t nwritten=0;
    318         ssize_t ret;
     318        struct iovec iov[2];
    319319
    320320        /* fd == -1 causes segfaults -- Tom (tom@ninja.nl) */
     
    328328        }
    329329
    330         while (nwritten < len) {
    331                 ret = write_socket(cli->fd,cli->outbuf+nwritten,len - nwritten);
    332                 if (ret <= 0) {
    333                         close(cli->fd);
    334                         cli->fd = -1;
    335                         cli->smb_rw_error = SMB_WRITE_ERROR;
    336                         DEBUG(0,("Error writing %d bytes to client. %d (%s)\n",
    337                                 (int)len,(int)ret, strerror(errno) ));
    338                         return false;
    339                 }
    340                 nwritten += ret;
    341         }
    342 
    343         /* Now write the extra data. */
    344         nwritten=0;
    345         while (nwritten < extradata) {
    346                 ret = write_socket(cli->fd,p+nwritten,extradata - nwritten);
    347                 if (ret <= 0) {
    348                         close(cli->fd);
    349                         cli->fd = -1;
    350                         cli->smb_rw_error = SMB_WRITE_ERROR;
    351                         DEBUG(0,("Error writing %d extradata "
    352                                 "bytes to client. %d (%s)\n",
    353                                 (int)extradata,(int)ret, strerror(errno) ));
    354                         return false;
    355                 }
    356                 nwritten += ret;
     330        iov[0].iov_base = cli->outbuf;
     331        iov[0].iov_len = len;
     332        iov[1].iov_base = CONST_DISCARD(char *, p);
     333        iov[1].iov_len = extradata;
     334
     335        nwritten = write_data_iov(cli->fd, iov, 2);
     336        if (nwritten < (len + extradata)) {
     337                close(cli->fd);
     338                cli->fd = -1;
     339                cli->smb_rw_error = SMB_WRITE_ERROR;
     340                DEBUG(0,("Error writing %d bytes to client. (%s)\n",
     341                         (int)(len+extradata), strerror(errno)));
     342                return false;
    357343        }
    358344
  • branches/samba-3.2.x/source/libsmb/clilist.c

    r228 r232  
    8080                        p += clistr_align_in(cli, p, 0);
    8181
    82                         /* We can safely use +1 here (which is required by OS/2)
    83                          * instead of +2 as the STR_TERMINATE flag below is
     82                        /* We can safely use len here (which is required by OS/2)
     83                         * and the NAS-BASIC server instead of +2 or +1 as the
     84                         * STR_TERMINATE flag below is
    8485                         * actually used as the length calculation.
    85                          * The len+2 is merely an upper bound.
     86                         * The len is merely an upper bound.
    8687                         * Due to the explicit 2 byte null termination
    8788                         * in cli_receive_trans/cli_receive_nt_trans
     
    8990                         */
    9091
    91                         if (p + len + 1 > pdata_end) {
     92                        if (p + len > pdata_end) {
    9293                                return pdata_end - base;
    9394                        }
  • branches/samba-3.2.x/source/libsmb/dsgetdcname.c

    r228 r232  
    13841384}
    13851385
     1386static bool is_closest_site(struct netr_DsRGetDCNameInfo *info)
     1387{
     1388        if (info->dc_flags & DS_SERVER_CLOSEST) {
     1389                return true;
     1390        }
     1391
     1392        if (!info->client_site_name) {
     1393                return true;
     1394        }
     1395
     1396        if (!info->dc_site_name) {
     1397                return false;
     1398        }
     1399
     1400        if (strcmp(info->client_site_name, info->dc_site_name) == 0) {
     1401                return true;
     1402        }
     1403
     1404        return false;
     1405}
     1406
    13861407/********************************************************************
    13871408 dsgetdcname.
     
    14011422        struct netr_DsRGetDCNameInfo *myinfo = NULL;
    14021423        char *query_site = NULL;
     1424        bool first = true;
     1425        struct netr_DsRGetDCNameInfo *first_info = NULL;
    14031426
    14041427        DEBUG(10,("dsgetdcname: domain_name: %s, "
     
    14281451                                    flags, query_site, &myinfo);
    14291452        if (NT_STATUS_IS_OK(status)) {
    1430                 *info = myinfo;
    14311453                goto done;
    14321454        }
     
    14411463                                        &myinfo);
    14421464
    1443         if (NT_STATUS_IS_OK(status)) {
    1444                 *info = myinfo;
    1445         }
    1446 
    14471465 done:
    14481466        SAFE_FREE(query_site);
    14491467
    1450         return status;
    1451 }
     1468        if (!NT_STATUS_IS_OK(status)) {
     1469                if (!first) {
     1470                        *info = first_info;
     1471                        return NT_STATUS_OK;
     1472                }
     1473                return status;
     1474        }
     1475
     1476        if (!first) {
     1477                TALLOC_FREE(first_info);
     1478        } else if (!is_closest_site(myinfo)) {
     1479                first = false;
     1480                first_info = myinfo;
     1481                /* TODO: may use the next_closest_site here */
     1482                query_site = SMB_STRDUP(myinfo->client_site_name);
     1483                goto rediscover;
     1484        }
     1485
     1486        *info = myinfo;
     1487        return NT_STATUS_OK;
     1488}
  • branches/samba-3.2.x/source/libsmb/libsmb_context.c

    r149 r232  
    7070        smbc_setOptionOpenShareMode(context, SMBC_SHAREMODE_DENY_NONE);
    7171        smbc_setOptionSmbEncryptionLevel(context, SMBC_ENCRYPTLEVEL_NONE);
     72        smbc_setOptionCaseSensitive(context, False);
    7273        smbc_setOptionBrowseMaxLmbCount(context, 3);    /* # LMBs to query */
    7374        smbc_setOptionUrlEncodeReaddirEntries(context, False);
  • branches/samba-3.2.x/source/libsmb/libsmb_dir.c

    r149 r232  
    896896                /* url-encode the name.  get back remaining buffer space */
    897897                max_namebuf_len =
    898                         SMBC_urlencode(dest->name, src->name, max_namebuf_len);
     898                        smbc_urlencode(dest->name, src->name, max_namebuf_len);
    899899
    900900                /* We now know the name length */
     
    978978        }
    979979
    980         dirp = (struct smbc_dirent *)context->internal->dirent;
    981         maxlen = (sizeof(context->internal->dirent) -
    982                   sizeof(struct smbc_dirent));
     980        dirp = &context->internal->dirent;
     981        maxlen = sizeof(context->internal->_dirent_name);
    983982
    984983        smbc_readdir_internal(context, dirp, dirent, maxlen);
     
    10521051
    10531052                /* Do urlencoding of next entry, if so selected */
    1054                 dirent = (struct smbc_dirent *)context->internal->dirent;
    1055                 maxlen = (sizeof(context->internal->dirent) -
    1056                           sizeof(struct smbc_dirent));
     1053                dirent = &context->internal->dirent;
     1054                maxlen = sizeof(context->internal->_dirent_name);
    10571055                smbc_readdir_internal(context, dirent,
    10581056                                      dirlist->dirent, maxlen);
  • branches/samba-3.2.x/source/libsmb/libsmb_path.c

    r133 r232  
    4242
    4343/*
    44  * SMBC_urldecode()
     44 * smbc_urldecode()
    4545 * and urldecode_talloc() (internal fn.)
    4646 *
     
    123123
    124124int
    125 SMBC_urldecode(char *dest,
     125smbc_urldecode(char *dest,
    126126               char *src,
    127127               size_t max_dest_len)
     
    139139
    140140/*
    141  * SMBC_urlencode()
     141 * smbc_urlencode()
    142142 *
    143143 * Convert any characters not specifically allowed in a URL into their %xx
     
    147147 */
    148148int
    149 SMBC_urlencode(char *dest,
     149smbc_urlencode(char *dest,
    150150               char *src,
    151151               int max_dest_len)
     
    287287               
    288288                /* Copy the options */
    289                 if (*pp_options != NULL) {
     289                if (pp_options && *pp_options != NULL) {
    290290                        TALLOC_FREE(*pp_options);
    291291                        *pp_options = talloc_strdup(ctx, q);
  • branches/samba-3.2.x/source/libsmb/libsmb_server.c

    r228 r232  
    246246        int port_try_first;
    247247        int port_try_next;
     248        int is_ipc = (share != NULL && strcmp(share, "IPC$") == 0);
     249        uint32 fs_attrs = 0;
    248250        const char *username_used;
    249251        NTSTATUS status;
     
    311313                        }
    312314                       
     315                        /* Determine if this share supports case sensitivity */
     316                        if (is_ipc) {
     317                                DEBUG(4,
     318                                      ("IPC$ so ignore case sensitivity\n"));
     319                        } else if (!cli_get_fs_attr_info(c, &fs_attrs)) {
     320                                DEBUG(4, ("Could not retrieve "
     321                                          "case sensitivity flag: %s.\n",
     322                                          cli_errstr(c)));
     323
     324                                /*
     325                                 * We can't determine the case sensitivity of
     326                                 * the share. We have no choice but to use the
     327                                 * user-specified case sensitivity setting.
     328                                 */
     329                                if (smbc_getOptionCaseSensitive(context)) {
     330                                        cli_set_case_sensitive(c, True);
     331                                } else {
     332                                        cli_set_case_sensitive(c, False);
     333                                }
     334                        } else {
     335                                DEBUG(4,
     336                                      ("Case sensitive: %s\n",
     337                                       (fs_attrs & FILE_CASE_SENSITIVE_SEARCH
     338                                        ? "True"
     339                                        : "False")));
     340                                cli_set_case_sensitive(
     341                                        c,
     342                                        (fs_attrs & FILE_CASE_SENSITIVE_SEARCH
     343                                         ? True
     344                                         : False));
     345                        }
     346
    313347                        /*
    314348                         * Regenerate the dev value since it's based on both
     
    356390                return NULL;
    357391        }
    358        
     392
    359393        if (smbc_getOptionUseKerberos(context)) {
    360394                c->use_kerberos = True;
     
    371405         * null, so browse lists can work
    372406         */
    373         if (share == NULL || *share == '\0' || strcmp(share, "IPC$") == 0) {
     407        if (share == NULL || *share == '\0' || is_ipc) {
    374408                port_try_first = 139;
    375409                port_try_next = 445;
     
    475509        DEBUG(4,(" tconx ok\n"));
    476510       
     511        /* Determine if this share supports case sensitivity */
     512        if (is_ipc) {
     513                DEBUG(4, ("IPC$ so ignore case sensitivity\n"));
     514        } else if (!cli_get_fs_attr_info(c, &fs_attrs)) {
     515                DEBUG(4, ("Could not retrieve case sensitivity flag: %s.\n",
     516                          cli_errstr(c)));
     517
     518                /*
     519                 * We can't determine the case sensitivity of the share. We
     520                 * have no choice but to use the user-specified case
     521                 * sensitivity setting.
     522                 */
     523                if (smbc_getOptionCaseSensitive(context)) {
     524                        cli_set_case_sensitive(c, True);
     525                } else {
     526                        cli_set_case_sensitive(c, False);
     527                }
     528        } else {
     529                DEBUG(4, ("Case sensitive: %s\n",
     530                          (fs_attrs & FILE_CASE_SENSITIVE_SEARCH
     531                           ? "True"
     532                           : "False")));
     533                cli_set_case_sensitive(c,
     534                                       (fs_attrs & FILE_CASE_SENSITIVE_SEARCH
     535                                        ? True
     536                                        : False));
     537        }
     538
    477539        if (context->internal->smb_encryption_level) {
    478540                /* Attempt UNIX smb encryption. */
  • branches/samba-3.2.x/source/libsmb/libsmb_setget.c

    r133 r232  
    195195
    196196/**
     197 * Get whether to treat file names as case-sensitive if we can't determine
     198 * when connecting to the remote share whether the file system is case
     199 * sensitive. This defaults to FALSE since it's most likely that if we can't
     200 * retrieve the file system attributes, it's a very old file system that does
     201 * not support case sensitivity.
     202 */
     203smbc_bool
     204smbc_getOptionCaseSensitive(SMBCCTX *c)
     205{
     206        return c->internal->case_sensitive;
     207}
     208
     209/**
     210 * Set whether to treat file names as case-sensitive if we can't determine
     211 * when connecting to the remote share whether the file system is case
     212 * sensitive. This defaults to FALSE since it's most likely that if we can't
     213 * retrieve the file system attributes, it's a very old file system that does
     214 * not support case sensitivity.
     215 */
     216void
     217smbc_setOptionCaseSensitive(SMBCCTX *c, smbc_bool b)
     218{
     219        c->internal->case_sensitive = b;
     220}
     221
     222/**
    197223 * Get from how many local master browsers should the list of workgroups be
    198224 * retrieved.  It can take up to 12 minutes or longer after a server becomes a
  • branches/samba-3.2.x/source/libsmb/libsmb_xattr.c

    r204 r232  
    199199        }
    200200       
    201         TALLOC_FREE(ctx);
    202201        /* Converted OK */
    203202       
     
    205204                 domains[0], lp_winbind_separator(),
    206205                 names[0]);
     206
     207        TALLOC_FREE(ctx);
    207208}
    208209
  • branches/samba-3.2.x/source/libsmb/namequery.c

    r228 r232  
    3535#define SAFKEY_FMT      "SAF/DOMAIN/%s"
    3636#define SAF_TTL         900
     37#define SAFJOINKEY_FMT  "SAFJOIN/DOMAIN/%s"
     38#define SAFJOIN_TTL     3600
    3739
    3840static char *saf_key(const char *domain)
     
    4143
    4244        asprintf_strupper_m(&keystr, SAFKEY_FMT, domain);
     45
     46        return keystr;
     47}
     48
     49static char *saf_join_key(const char *domain)
     50{
     51        char *keystr;
     52
     53        asprintf_strupper_m(&keystr, SAFJOINKEY_FMT, domain);
    4354
    4455        return keystr;
     
    7081
    7182        key = saf_key( domain );
    72         expire = time( NULL ) + SAF_TTL;
     83        expire = time( NULL ) + lp_parm_int(-1, "saf","ttl", SAF_TTL);
    7384
    7485        DEBUG(10,("saf_store: domain = [%s], server = [%s], expire = [%u]\n",
     86                domain, servername, (unsigned int)expire ));
     87
     88        ret = gencache_set( key, servername, expire );
     89
     90        SAFE_FREE( key );
     91
     92        return ret;
     93}
     94
     95bool saf_join_store( const char *domain, const char *servername )
     96{
     97        char *key;
     98        time_t expire;
     99        bool ret = False;
     100
     101        if ( !domain || !servername ) {
     102                DEBUG(2,("saf_join_store: Refusing to store empty domain or servername!\n"));
     103                return False;
     104        }
     105
     106        if ( (strlen(domain) == 0) || (strlen(servername) == 0) ) {
     107                DEBUG(0,("saf_join_store: refusing to store 0 length domain or servername!\n"));
     108                return False;
     109        }
     110
     111        if ( !gencache_init() )
     112                return False;
     113
     114        key = saf_join_key( domain );
     115        expire = time( NULL ) + lp_parm_int(-1, "saf","join ttl", SAFJOIN_TTL);
     116
     117        DEBUG(10,("saf_join_store: domain = [%s], server = [%s], expire = [%u]\n",
    75118                domain, servername, (unsigned int)expire ));
    76119
     
    95138                return False;
    96139
     140        key = saf_join_key(domain);
     141        ret = gencache_del(key);
     142        SAFE_FREE(key);
     143
     144        if (ret) {
     145                DEBUG(10,("saf_delete[join]: domain = [%s]\n", domain ));
     146        }
     147
    97148        key = saf_key(domain);
    98149        ret = gencache_del(key);
     150        SAFE_FREE(key);
    99151
    100152        if (ret) {
    101153                DEBUG(10,("saf_delete: domain = [%s]\n", domain ));
    102154        }
    103 
    104         SAFE_FREE( key );
    105155
    106156        return ret;
     
    124174        if ( !gencache_init() )
    125175                return False;
     176
     177        key = saf_join_key( domain );
     178
     179        ret = gencache_get( key, &server, &timeout );
     180
     181        SAFE_FREE( key );
     182
     183        if ( ret ) {
     184                DEBUG(5,("saf_fetch[join]: Returning \"%s\" for \"%s\" domain\n",
     185                        server, domain ));
     186                return server;
     187        }
    126188
    127189        key = saf_key( domain );
     
    20992161        status = get_dc_list(domain, sitename, ip_list,
    21002162                        count, lookup_type, &ordered);
     2163        if (NT_STATUS_EQUAL(status, NT_STATUS_NO_LOGON_SERVERS)
     2164            && sitename) {
     2165                DEBUG(3,("get_sorted_dc_list: no server for name %s available"
     2166                         " in site %s, fallback to all servers\n",
     2167                         domain, sitename));
     2168                status = get_dc_list(domain, NULL, ip_list,
     2169                                     count, lookup_type, &ordered);
     2170        }
     2171
    21012172        if (!NT_STATUS_IS_OK(status)) {
    21022173                SAFE_FREE(*ip_list);
Note: See TracChangeset for help on using the changeset viewer.