Ignore:
Timestamp:
Oct 30, 2009, 9:39:05 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.3 to 3.3.9

Location:
branches/samba-3.3.x/source/libsmb
Files:
7 edited

Legend:

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

    r221 r342  
    239239        }
    240240
     241        if ((raw_pdu_len == 4) && (CVAL(pdu, 0) == SMBkeepalive)) {
     242                DEBUG(10, ("Got keepalive\n"));
     243                TALLOC_FREE(pdu);
     244                return;
     245        }
     246
    241247        /*
    242248         * TODO: Handle oplock break requests
  • branches/samba-3.3.x/source/libsmb/clireadwrite.c

    r206 r342  
    155155}
    156156
     157struct cli_readall_state {
     158        struct cli_state *cli;
     159        uint16_t fnum;
     160        off_t start_offset;
     161        size_t size;
     162        size_t received;
     163        uint8_t *buf;
     164};
     165
     166static void cli_readall_done(struct async_req *subreq);
     167
     168static struct async_req *cli_readall_send(TALLOC_CTX *mem_ctx,
     169                                          struct cli_state *cli,
     170                                          uint16_t fnum,
     171                                          off_t offset, size_t size)
     172{
     173        struct async_req *req, *subreq;
     174        struct cli_readall_state *state;
     175
     176        req = async_req_new(mem_ctx, cli->event_ctx);
     177        if (req == NULL) {
     178                return NULL;
     179        }
     180        state = talloc(req, struct cli_readall_state);
     181        if (state == NULL) {
     182                TALLOC_FREE(req);
     183                return NULL;
     184        }
     185        req->private_data = state;
     186
     187        state->cli = cli;
     188        state->fnum = fnum;
     189        state->start_offset = offset;
     190        state->size = size;
     191        state->received = 0;
     192        state->buf = NULL;
     193
     194        subreq = cli_read_andx_send(state, cli, fnum, offset, size);
     195        if (subreq == NULL) {
     196                TALLOC_FREE(req);
     197                return NULL;
     198        }
     199        subreq->async.fn = cli_readall_done;
     200        subreq->async.priv = req;
     201        return req;
     202}
     203
     204static void cli_readall_done(struct async_req *subreq)
     205{
     206        struct async_req *req = talloc_get_type_abort(
     207                subreq->async.priv, struct async_req);
     208        struct cli_readall_state *state = talloc_get_type_abort(
     209                req->private_data, struct cli_readall_state);
     210        ssize_t received;
     211        uint8_t *buf;
     212        NTSTATUS status;
     213
     214        status = cli_read_andx_recv(subreq, &received, &buf);
     215        if (!NT_STATUS_IS_OK(status)) {
     216                async_req_error(req, status);
     217                return;
     218        }
     219
     220        if (received == 0) {
     221                /* EOF */
     222                async_req_done(req);
     223                return;
     224        }
     225
     226        if ((state->received == 0) && (received == state->size)) {
     227                /* Ideal case: Got it all in one run */
     228                state->buf = buf;
     229                state->received += received;
     230                async_req_done(req);
     231                return;
     232        }
     233
     234        /*
     235         * We got a short read, issue a read for the
     236         * rest. Unfortunately we have to allocate the buffer
     237         * ourselves now, as our caller expects to receive a single
     238         * buffer. cli_read_andx does it from the buffer received from
     239         * the net, but with a short read we have to put it together
     240         * from several reads.
     241         */
     242
     243        if (state->buf == NULL) {
     244                state->buf = talloc_array(state, uint8_t, state->size);
     245                if (async_req_nomem(state->buf, req)) {
     246                        return;
     247                }
     248        }
     249        memcpy(state->buf + state->received, buf, received);
     250        state->received += received;
     251
     252        TALLOC_FREE(subreq);
     253
     254        if (state->received >= state->size) {
     255                async_req_done(req);
     256                return;
     257        }
     258
     259        subreq = cli_read_andx_send(state, state->cli, state->fnum,
     260                                    state->start_offset + state->received,
     261                                    state->size - state->received);
     262        if (async_req_nomem(subreq, req)) {
     263                return;
     264        }
     265        subreq->async.fn = cli_readall_done;
     266        subreq->async.priv = req;
     267}
     268
     269static NTSTATUS cli_readall_recv(struct async_req *req, ssize_t *received,
     270                                 uint8_t **rcvbuf)
     271{
     272        struct cli_readall_state *state = talloc_get_type_abort(
     273                req->private_data, struct cli_readall_state);
     274
     275        SMB_ASSERT(req->state >= ASYNC_REQ_DONE);
     276        if (req->state == ASYNC_REQ_ERROR) {
     277                return req->status;
     278        }
     279        *received = state->received;
     280        *rcvbuf = state->buf;
     281        return NT_STATUS_OK;
     282}
     283
    157284/*
    158285 * Parallel read support.
     
    163290 */
    164291
     292struct cli_pull_subreq {
     293        struct async_req *req;
     294        size_t received;
     295        uint8_t *buf;
     296};
     297
    165298struct cli_pull_state {
    166299        struct async_req *req;
     
    180313         */
    181314        int num_reqs;
    182         struct async_req **reqs;
     315        struct cli_pull_subreq *reqs;
    183316
    184317        /*
     
    269402        state->num_reqs = MIN(state->num_reqs, cli->max_mux);
    270403
    271         state->reqs = TALLOC_ZERO_ARRAY(state, struct async_req *,
     404        state->reqs = TALLOC_ZERO_ARRAY(state, struct cli_pull_subreq,
    272405                                        state->num_reqs);
    273406        if (state->reqs == NULL) {
     
    289422                request_thistime = MIN(size_left, state->chunk_size);
    290423
    291                 state->reqs[i] = cli_read_andx_send(
     424                state->reqs[i].req = cli_readall_send(
    292425                        state->reqs, cli, fnum,
    293426                        state->start_offset + state->requested,
    294427                        request_thistime);
    295428
    296                 if (state->reqs[i] == NULL) {
     429                if (state->reqs[i].req == NULL) {
    297430                        goto failed;
    298431                }
    299432
    300                 state->reqs[i]->async.fn = cli_pull_read_done;
    301                 state->reqs[i]->async.priv = result;
     433                state->reqs[i].req->async.fn = cli_pull_read_done;
     434                state->reqs[i].req->async.priv = result;
    302435
    303436                state->requested += request_thistime;
     
    321454        struct cli_pull_state *state = talloc_get_type_abort(
    322455                pull_req->private_data, struct cli_pull_state);
    323         struct cli_request *read_state = cli_request_get(read_req);
     456        ssize_t received;
     457        uint8_t *buf;
    324458        NTSTATUS status;
    325 
    326         status = cli_read_andx_recv(read_req, &read_state->data.read.received,
    327                                     &read_state->data.read.rcvbuf);
     459        int i;
     460
     461        status = cli_readall_recv(read_req, &received, &buf);
    328462        if (!NT_STATUS_IS_OK(status)) {
    329463                async_req_error(state->req, status);
    330464                return;
    331465        }
     466
     467        for (i=0; i<state->num_reqs; i++) {
     468                if (state->reqs[i].req == read_req) {
     469                        break;
     470                }
     471        }
     472
     473        if (i == state->num_reqs) {
     474                /* Got something we did not send. Just drop it. */
     475                TALLOC_FREE(read_req);
     476                return;
     477        }
     478
     479        state->reqs[i].received = received;
     480        state->reqs[i].buf = buf;
    332481
    333482        /*
     
    340489         */
    341490
    342         while (state->reqs[state->top_req] != NULL) {
    343                 struct cli_request *top_read;
     491        while (state->reqs[state->top_req].req != NULL) {
     492                struct cli_pull_subreq *top_read;
    344493
    345494                DEBUG(11, ("cli_pull_read_done: top_req = %d\n",
    346495                           state->top_req));
    347496
    348                 if (state->reqs[state->top_req]->state < ASYNC_REQ_DONE) {
     497                if (state->reqs[state->top_req].req->state < ASYNC_REQ_DONE) {
    349498                        DEBUG(11, ("cli_pull_read_done: top request not yet "
    350499                                   "done\n"));
     
    352501                }
    353502
    354                 top_read = cli_request_get(state->reqs[state->top_req]);
     503                top_read = &state->reqs[state->top_req];
    355504
    356505                DEBUG(10, ("cli_pull_read_done: Pushing %d bytes, %d already "
    357                            "pushed\n", (int)top_read->data.read.received,
     506                           "pushed\n", (int)top_read->received,
    358507                           (int)state->pushed));
    359508
    360                 status = state->sink((char *)top_read->data.read.rcvbuf,
    361                                      top_read->data.read.received,
     509                status = state->sink((char *)top_read->buf, top_read->received,
    362510                                     state->priv);
    363511                if (!NT_STATUS_IS_OK(status)) {
     
    365513                        return;
    366514                }
    367                 state->pushed += top_read->data.read.received;
    368 
    369                 TALLOC_FREE(state->reqs[state->top_req]);
     515                state->pushed += top_read->received;
     516
     517                TALLOC_FREE(state->reqs[state->top_req].req);
    370518
    371519                if (state->requested < state->size) {
     
    384532                                   state->top_req));
    385533
    386                         new_req = cli_read_andx_send(
     534                        new_req = cli_readall_send(
    387535                                state->reqs, state->cli, state->fnum,
    388536                                state->start_offset + state->requested,
     
    396544                        new_req->async.priv = pull_req;
    397545
    398                         state->reqs[state->top_req] = new_req;
     546                        state->reqs[state->top_req].req = new_req;
    399547                        state->requested += request_thistime;
    400548                }
  • branches/samba-3.3.x/source/libsmb/dsgetdcname.c

    r223 r342  
    627627                struct ip_service_name *r = &dclist[count];
    628628
    629                 r->port = dcs[count].port;
    630                 r->hostname = dcs[count].hostname;
     629                r->port = dcs[i].port;
     630                r->hostname = dcs[i].hostname;
    631631
    632632                /* If we don't have an IP list for a name, lookup it up */
  • branches/samba-3.3.x/source/libsmb/libsmb_context.c

    r222 r342  
    656656        const char *signing_state = "off";
    657657       
    658         if (!context ||
    659             ! workgroup || ! *workgroup ||
    660             ! user || ! *user ||
    661             ! password || ! *password) {
     658        if (! context) {
    662659           
    663660                return;
    664661        }
    665662
     663        if (! workgroup || ! *workgroup) {
     664                workgroup = smbc_getWorkgroup(context);
     665        }
     666
     667        if (! user) {
     668                user = smbc_getUser(context);
     669        }
     670
     671        if (! password) {
     672                password = "";
     673        }
     674
    666675        if (smbc_getOptionUseKerberos(context)) {
    667676                use_kerberos = True;
  • branches/samba-3.3.x/source/libsmb/libsmb_dir.c

    r223 r342  
    626626                                 * Get the backup list ...
    627627                                 */
    628                                 if (!name_status_find(server, 0, 0,
     628                                if (!name_status_find(server, 0x20, 0x20,
    629629                                                      &rem_ss, buserver)) {
    630630
  • branches/samba-3.3.x/source/libsmb/namequery.c

    r221 r342  
    409409
    410410        for (i=0;i<count;i++) {
    411                 if (status[i].type == type)
     411                /* Find first one of the requested type that's not a GROUP. */
     412                if (status[i].type == type && ! (status[i].flags & 0x80))
    412413                        break;
    413414        }
  • branches/samba-3.3.x/source/libsmb/passchange.c

    r309 r342  
    153153                result = cli_rpc_pipe_open_ntlmssp(cli,
    154154                                                   &ndr_table_samr.syntax_id,
     155                                                   NCACN_NP,
    155156                                                   PIPE_AUTH_LEVEL_PRIVACY,
    156157                                                   "", /* what domain... ? */
Note: See TracChangeset for help on using the changeset viewer.