Ignore:
Timestamp:
Nov 12, 2012, 4:35:55 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server 3.5: update branche to 3.5.12

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.5.x/source3/libsmb/clifile.c

    r454 r732  
    21502150
    21512151struct cli_open_state {
     2152        struct tevent_context *ev;
     2153        struct cli_state *cli;
     2154        const char *fname;
    21522155        uint16_t vwv[15];
    21532156        uint16_t fnum;
     2157        unsigned openfn;
     2158        unsigned dos_deny;
     2159        uint8_t additional_flags;
    21542160        struct iovec bytes;
    21552161};
    21562162
    21572163static void cli_open_done(struct tevent_req *subreq);
     2164static void cli_open_ntcreate_done(struct tevent_req *subreq);
    21582165
    21592166struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
     
    21652172        struct tevent_req *req, *subreq;
    21662173        struct cli_open_state *state;
    2167         unsigned openfn;
    2168         unsigned accessmode;
    2169         uint8_t additional_flags;
    21702174        uint8_t *bytes;
    21712175
     
    21742178                return NULL;
    21752179        }
    2176 
    2177         openfn = 0;
     2180        state->ev = ev;
     2181        state->cli = cli;
     2182        state->fname = fname;
     2183
    21782184        if (flags & O_CREAT) {
    2179                 openfn |= (1<<4);
     2185                state->openfn |= (1<<4);
    21802186        }
    21812187        if (!(flags & O_EXCL)) {
    21822188                if (flags & O_TRUNC)
    2183                         openfn |= (1<<1);
     2189                        state->openfn |= (1<<1);
    21842190                else
    2185                         openfn |= (1<<0);
    2186         }
    2187 
    2188         accessmode = (share_mode<<4);
     2191                        state->openfn |= (1<<0);
     2192        }
     2193
     2194        state->dos_deny = (share_mode<<4);
    21892195
    21902196        if ((flags & O_ACCMODE) == O_RDWR) {
    2191                 accessmode |= 2;
     2197                state->dos_deny |= 2;
    21922198        } else if ((flags & O_ACCMODE) == O_WRONLY) {
    2193                 accessmode |= 1;
     2199                state->dos_deny |= 1;
    21942200        }
    21952201
    21962202#if defined(O_SYNC)
    21972203        if ((flags & O_SYNC) == O_SYNC) {
    2198                 accessmode |= (1<<14);
     2204                state->dos_deny |= (1<<14);
    21992205        }
    22002206#endif /* O_SYNC */
    22012207
    22022208        if (share_mode == DENY_FCB) {
    2203                 accessmode = 0xFF;
     2209                state->dos_deny = 0xFF;
    22042210        }
    22052211
     
    22082214        SSVAL(state->vwv + 1, 0, 0);
    22092215        SSVAL(state->vwv + 2, 0, 0);  /* no additional info */
    2210         SSVAL(state->vwv + 3, 0, accessmode);
     2216        SSVAL(state->vwv + 3, 0, state->dos_deny);
    22112217        SSVAL(state->vwv + 4, 0, aSYSTEM | aHIDDEN);
    22122218        SSVAL(state->vwv + 5, 0, 0);
    22132219        SIVAL(state->vwv + 6, 0, 0);
    2214         SSVAL(state->vwv + 8, 0, openfn);
     2220        SSVAL(state->vwv + 8, 0, state->openfn);
    22152221        SIVAL(state->vwv + 9, 0, 0);
    22162222        SIVAL(state->vwv + 11, 0, 0);
    22172223        SIVAL(state->vwv + 13, 0, 0);
    22182224
    2219         additional_flags = 0;
    2220 
    22212225        if (cli->use_oplocks) {
    22222226                /* if using oplocks then ask for a batch oplock via
    22232227                   core and extended methods */
    2224                 additional_flags =
     2228                state->additional_flags =
    22252229                        FLAG_REQUEST_OPLOCK|FLAG_REQUEST_BATCH_OPLOCK;
    22262230                SSVAL(state->vwv+2, 0, SVAL(state->vwv+2, 0) | 6);
     
    22382242        state->bytes.iov_len = talloc_get_size(bytes);
    22392243
    2240         subreq = cli_smb_req_create(state, ev, cli, SMBopenX, additional_flags,
     2244        subreq = cli_smb_req_create(state, ev, cli, SMBopenX,
     2245                                    state->additional_flags,
    22412246                                    15, state->vwv, 1, &state->bytes);
    22422247        if (subreq == NULL) {
     
    22792284        uint16_t *vwv;
    22802285        NTSTATUS status;
     2286        uint32_t access_mask, share_mode, create_disposition, create_options;
    22812287
    22822288        status = cli_smb_recv(subreq, 3, &wct, &vwv, NULL, NULL);
    2283         if (!NT_STATUS_IS_OK(status)) {
    2284                 TALLOC_FREE(subreq);
     2289        TALLOC_FREE(subreq);
     2290
     2291        if (NT_STATUS_IS_OK(status)) {
     2292                state->fnum = SVAL(vwv+2, 0);
     2293                tevent_req_done(req);
     2294                return;
     2295        }
     2296
     2297        if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
    22852298                tevent_req_nterror(req, status);
    22862299                return;
    22872300        }
    2288         state->fnum = SVAL(vwv+2, 0);
     2301
     2302        /*
     2303         * For the new shiny OS/X Lion SMB server, try a ntcreate
     2304         * fallback.
     2305         */
     2306
     2307        if (!map_open_params_to_ntcreate(state->fname, state->dos_deny,
     2308                                        state->openfn, &access_mask,
     2309                                        &share_mode, &create_disposition,
     2310                                        &create_options)) {
     2311                tevent_req_nterror(req, NT_STATUS_NOT_SUPPORTED);
     2312                return;
     2313        }
     2314
     2315        subreq = cli_ntcreate_send(state, state->ev, state->cli,
     2316                                state->fname, 0, access_mask,
     2317                                0, share_mode, create_disposition,
     2318                                create_options, 0);
     2319        if (tevent_req_nomem(subreq, req)) {
     2320                return;
     2321        }
     2322        tevent_req_set_callback(subreq, cli_open_ntcreate_done, req);
     2323}
     2324
     2325static void cli_open_ntcreate_done(struct tevent_req *subreq)
     2326{
     2327        struct tevent_req *req = tevent_req_callback_data(
     2328                subreq, struct tevent_req);
     2329        struct cli_open_state *state = tevent_req_data(
     2330                req, struct cli_open_state);
     2331        NTSTATUS status;
     2332
     2333        status = cli_ntcreate_recv(subreq, &state->fnum);
     2334        TALLOC_FREE(subreq);
     2335
     2336        if (!NT_STATUS_IS_OK(status)) {
     2337                tevent_req_nterror(req, status);
     2338                return;
     2339        }
    22892340        tevent_req_done(req);
    22902341}
Note: See TracChangeset for help on using the changeset viewer.