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

Location:
branches/samba-3.5.x/source3/libsmb
Files:
2 edited

Legend:

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

    r599 r732  
    10751075                        if (dest_realm) {
    10761076                                realm = SMB_STRDUP(dest_realm);
     1077                                if (!realm) {
     1078                                        return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
     1079                                }
    10771080                                strupper_m(realm);
    10781081                        } else {
     
    10861089                        }
    10871090
    1088                         if (realm && *realm) {
    1089                                 principal = talloc_asprintf(talloc_tos(),
    1090                                                             "cifs/%s@%s",
    1091                                                             cli->desthost,
    1092                                                             realm);
    1093                                 if (!principal) {
    1094                                         SAFE_FREE(realm);
     1091                        if (realm == NULL || *realm == '\0') {
     1092                                realm = SMB_STRDUP(lp_realm());
     1093                                if (!realm) {
    10951094                                        return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
    10961095                                }
    1097                                 DEBUG(3,("cli_session_setup_spnego: guessed "
    1098                                         "server principal=%s\n",
    1099                                         principal ? principal : "<null>"));
     1096                                strupper_m(realm);
     1097                                DEBUG(3,("cli_session_setup_spnego: cannot "
     1098                                        "get realm from dest_realm %s, "
     1099                                        "desthost %s. Using default "
     1100                                        "smb.conf realm %s\n",
     1101                                        dest_realm ? dest_realm : "<null>",
     1102                                        cli->desthost,
     1103                                        realm));
    11001104                        }
     1105
     1106                        principal = talloc_asprintf(talloc_tos(),
     1107                                                    "cifs/%s@%s",
     1108                                                    cli->desthost,
     1109                                                    realm);
     1110                        if (!principal) {
     1111                                SAFE_FREE(realm);
     1112                                return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
     1113                        }
     1114                        DEBUG(3,("cli_session_setup_spnego: guessed "
     1115                                "server principal=%s\n",
     1116                                principal ? principal : "<null>"));
     1117
    11011118                        SAFE_FREE(realm);
    11021119                }
     
    17001717                struct timespec ts;
    17011718                bool negotiated_smb_signing = false;
     1719
     1720                if (wct != 0x11) {
     1721                        tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
     1722                        return;
     1723                }
    17021724
    17031725                /* NT protocol */
     
    17661788
    17671789        } else if (cli->protocol >= PROTOCOL_LANMAN1) {
     1790                if (wct != 0x0D) {
     1791                        tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
     1792                        return;
     1793                }
     1794
    17681795                cli->use_spnego = False;
    17691796                cli->sec_mode = SVAL(vwv + 1, 0);
  • 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.