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
Files:
52 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.3.x/source/Makefile.in

    r260 r342  
    13791379                $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS)
    13801380
    1381 bin/mount.cifs@EXEEXT@: $(BINARY_PREREQS) $(CIFS_MOUNT_OBJ) @BUILD_POPT@
    1382         @echo Linking $@
    1383         @$(CC) $(FLAGS) -o $@ $(CIFS_MOUNT_OBJ) $(DYNEXP) $(LDFLAGS) $(POPT_LIBS)
    1384 
    1385 bin/umount.cifs@EXEEXT@: $(BINARY_PREREQS) $(CIFS_UMOUNT_OBJ) @BUILD_POPT@
    1386         @echo Linking $@
    1387         @$(CC) $(FLAGS) -o $@ $(CIFS_UMOUNT_OBJ) $(DYNEXP) $(LDFLAGS) $(POPT_LIBS)
     1381bin/mount.cifs@EXEEXT@: $(BINARY_PREREQS) $(CIFS_MOUNT_OBJ)
     1382        @echo Linking $@
     1383        @$(CC) $(FLAGS) -o $@ $(CIFS_MOUNT_OBJ) $(DYNEXP) $(LDFLAGS)
     1384
     1385bin/umount.cifs@EXEEXT@: $(BINARY_PREREQS) $(CIFS_UMOUNT_OBJ)
     1386        @echo Linking $@
     1387        @$(CC) $(FLAGS) -o $@ $(CIFS_UMOUNT_OBJ) $(DYNEXP) $(LDFLAGS)
    13881388
    13891389bin/cifs.upcall@EXEEXT@: $(BINARY_PREREQS) $(CIFS_UPCALL_OBJ) $(LIBSMBCLIENT_OBJ1) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@
  • branches/samba-3.3.x/source/VERSION

    r338 r342  
    2626SAMBA_VERSION_MAJOR=3
    2727SAMBA_VERSION_MINOR=3
    28 SAMBA_VERSION_RELEASE=8
     28SAMBA_VERSION_RELEASE=9
    2929
    3030########################################################
  • branches/samba-3.3.x/source/auth/auth_domain.c

    r206 r342  
    176176                /* We also setup the creds chain in the open_schannel call. */
    177177                result = cli_rpc_pipe_open_schannel(
    178                         *cli, &ndr_table_netlogon.syntax_id,
     178                        *cli, &ndr_table_netlogon.syntax_id, NCACN_NP,
    179179                        PIPE_AUTH_LEVEL_PRIVACY, domain, &netlogon_pipe);
    180180        } else {
  • branches/samba-3.3.x/source/client/mount.cifs.c

    r338 r342  
    10371037}
    10381038
     1039static void print_cifs_mount_version(void)
     1040{
     1041        printf("mount.cifs version: %s.%s%s\n",
     1042                MOUNT_CIFS_VERSION_MAJOR,
     1043                MOUNT_CIFS_VERSION_MINOR,
     1044                MOUNT_CIFS_VENDOR_SUFFIX);
     1045}
     1046
    10391047int main(int argc, char ** argv)
    10401048{
     
    10981106                }
    10991107                mountpoint = argv[2];
     1108        } else if (argc == 2) {
     1109                if ((strcmp(argv[1], "-V") == 0) ||
     1110                    (strcmp(argv[1], "--version") == 0))
     1111                {
     1112                        print_cifs_mount_version();
     1113                        exit(0);
     1114                }
     1115
     1116                if ((strcmp(argv[1], "-h") == 0) ||
     1117                    (strcmp(argv[1], "-?") == 0) ||
     1118                    (strcmp(argv[1], "--help") == 0))
     1119                {
     1120                        mount_cifs_usage();
     1121                        exit(0);
     1122                }
     1123
     1124                mount_cifs_usage();
     1125                exit(EX_USAGE);
    11001126        } else {
    1101                 if ((strcmp (argv[1], "--version") == 0) ||
    1102                     ((strcmp (argv[1], "-V") == 0))) {
    1103                         printf ("mount.cifs version: %s.%s%s\n",
    1104                         MOUNT_CIFS_VERSION_MAJOR,
    1105                         MOUNT_CIFS_VERSION_MINOR,
    1106                         MOUNT_CIFS_VENDOR_SUFFIX);
    1107                         exit (0);
    1108                 }
    11091127                mount_cifs_usage();
    11101128                exit(EX_USAGE);
     
    11621180                        ++verboseflag;
    11631181                        break;
    1164                 case 'V':         
    1165                         printf ("mount.cifs version: %s.%s%s\n",
    1166                         MOUNT_CIFS_VERSION_MAJOR,
    1167                         MOUNT_CIFS_VERSION_MINOR,
    1168                         MOUNT_CIFS_VENDOR_SUFFIX);
     1182                case 'V':
     1183                        print_cifs_mount_version();
    11691184                        exit (0);
    11701185                case 'w':
  • branches/samba-3.3.x/source/include/proto.h

    r224 r342  
    68926892                                char ***pnames,
    68936893                                enum lsa_SidType **ptypes);
     6894NTSTATUS rpccli_lsa_lookup_sids3(struct rpc_pipe_client *cli,
     6895                                 TALLOC_CTX *mem_ctx,
     6896                                 struct policy_handle *pol,
     6897                                 int num_sids,
     6898                                 const DOM_SID *sids,
     6899                                 char ***pdomains,
     6900                                 char ***pnames,
     6901                                 enum lsa_SidType **ptypes);
    68946902NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli,
    68956903                                 TALLOC_CTX *mem_ctx,
     
    69006908                                 DOM_SID **sids,
    69016909                                 enum lsa_SidType **types);
     6910NTSTATUS rpccli_lsa_lookup_names4(struct rpc_pipe_client *cli,
     6911                                  TALLOC_CTX *mem_ctx,
     6912                                  struct policy_handle *pol, int num_names,
     6913                                  const char **names,
     6914                                  const char ***dom_names,
     6915                                  int level,
     6916                                  DOM_SID **sids,
     6917                                  enum lsa_SidType **types);
     6918
    69026919bool fetch_domain_sid( char *domain, char *remote_machine, DOM_SID *psid);
    69036920
     
    69897006                                  const struct ndr_syntax_id *interface,
    69907007                                  struct rpc_pipe_client **presult);
     7008NTSTATUS cli_rpc_pipe_open_noauth_transport(struct cli_state *cli,
     7009                                            enum dcerpc_transport_t transport,
     7010                                            const struct ndr_syntax_id *interface,
     7011                                            struct rpc_pipe_client **presult);
    69917012NTSTATUS cli_rpc_pipe_open_ntlmssp(struct cli_state *cli,
    69927013                                   const struct ndr_syntax_id *interface,
     7014                                   enum dcerpc_transport_t transport,
    69937015                                   enum pipe_auth_level auth_level,
    69947016                                   const char *domain,
     
    69987020NTSTATUS cli_rpc_pipe_open_spnego_ntlmssp(struct cli_state *cli,
    69997021                                          const struct ndr_syntax_id *interface,
     7022                                          enum dcerpc_transport_t transport,
    70007023                                          enum pipe_auth_level auth_level,
    70017024                                          const char *domain,
     
    70097032NTSTATUS cli_rpc_pipe_open_schannel_with_key(struct cli_state *cli,
    70107033                                             const struct ndr_syntax_id *interface,
     7034                                             enum dcerpc_transport_t transport,
    70117035                                             enum pipe_auth_level auth_level,
    70127036                                             const char *domain,
     
    70157039NTSTATUS cli_rpc_pipe_open_ntlmssp_auth_schannel(struct cli_state *cli,
    70167040                                                 const struct ndr_syntax_id *interface,
     7041                                                 enum dcerpc_transport_t transport,
    70177042                                                 enum pipe_auth_level auth_level,
    70187043                                                 const char *domain,
     
    70227047NTSTATUS cli_rpc_pipe_open_schannel(struct cli_state *cli,
    70237048                                    const struct ndr_syntax_id *interface,
     7049                                    enum dcerpc_transport_t transport,
    70247050                                    enum pipe_auth_level auth_level,
    70257051                                    const char *domain,
  • branches/samba-3.3.x/source/include/rpc_dce.h

    r206 r342  
    151151
    152152/* Maximum size of the signing data in a fragment. */
    153 #define RPC_MAX_SIGN_SIZE 0x20 /* 32 */
     153#define RPC_MAX_SIGN_SIZE 0x38 /* 56 */
    154154
    155155/* Maximum PDU fragment size. */
  • branches/samba-3.3.x/source/include/version.h

    r338 r342  
    22#define SAMBA_VERSION_MAJOR 3
    33#define SAMBA_VERSION_MINOR 3
    4 #define SAMBA_VERSION_RELEASE 8
    5 #define SAMBA_VERSION_OFFICIAL_STRING "3.3.8"
    6 #define SAMBA_VERSION_VENDOR_SUFFIX "eCS 1.1.x-TEST"
    7 #define SAMBA_VERSION_VENDOR_PATCH 20091006
    8 #define SAMBA_VERSION_VENDOR_PATCH_STRING "20091006"
     4#define SAMBA_VERSION_RELEASE 9
     5#define SAMBA_VERSION_OFFICIAL_STRING "3.3.9"
    96#define SAMBA_VERSION_STRING samba_version_string()
  • branches/samba-3.3.x/source/lib/smbldap.c

    r274 r342  
    14661466        }
    14671467
    1468         DEBUG(3,("smbldap_search_paged: search was successfull\n"));
     1468        DEBUG(3,("smbldap_search_paged: search was successful\n"));
    14691469
    14701470        rc = ldap_parse_result(ldap_state->ldap_struct, *res, NULL, NULL,
  • branches/samba-3.3.x/source/lib/system_smbd.c

    r206 r342  
    160160        int i;
    161161
    162         max_grp = MIN(32, groups_max());
     162        max_grp = MIN(128, groups_max());
    163163        temp_groups = SMB_MALLOC_ARRAY(gid_t, max_grp);
    164164        if (! temp_groups) {
  • branches/samba-3.3.x/source/libnet/libnet_join.c

    r309 r342  
    10711071
    10721072        status = cli_rpc_pipe_open_schannel_with_key(
    1073                 cli, &ndr_table_netlogon.syntax_id, PIPE_AUTH_LEVEL_PRIVACY,
     1073                cli, &ndr_table_netlogon.syntax_id, NCACN_NP,
     1074                PIPE_AUTH_LEVEL_PRIVACY,
    10741075                netbios_domain_name, netlogon_pipe->dc, &pipe_hnd);
    10751076
  • 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... ? */
  • branches/samba-3.3.x/source/locking/brlock.c

    r224 r342  
    372372****************************************************************************/
    373373
    374 static unsigned int brlock_posix_split_merge(struct lock_struct *lck_arr,               /* Output array. */
    375                                                 const struct lock_struct *ex,           /* existing lock. */
    376                                                 const struct lock_struct *plock,        /* proposed lock. */
    377                                                 bool *lock_was_added)
     374static unsigned int brlock_posix_split_merge(struct lock_struct *lck_arr,       /* Output array. */
     375                                                struct lock_struct *ex,         /* existing lock. */
     376                                                struct lock_struct *plock)      /* proposed lock. */
    378377{
    379378        bool lock_types_differ = (ex->lock_type != plock->lock_type);
     
    392391
    393392/*********************************************
    394                                              +---------+
    395                                              | ex      |
    396                                              +---------+
    397                               +-------+
    398                               | plock |
    399                               +-------+
     393                                        +---------+
     394                                        | ex      |
     395                                        +---------+
     396                         +-------+
     397                         | plock |
     398                         +-------+
    400399OR....
    401              +---------+
    402              |  ex     |
    403              +---------+
     400        +---------+
     401        |  ex     |
     402        +---------+
    404403**********************************************/
    405404
    406405        if ( (ex->start > (plock->start + plock->size)) ||
    407                         (plock->start > (ex->start + ex->size))) {
     406                (plock->start > (ex->start + ex->size))) {
     407
    408408                /* No overlap with this lock - copy existing. */
     409
    409410                memcpy(&lck_arr[0], ex, sizeof(struct lock_struct));
    410411                return 1;
     
    418419        |       plock               | -> replace with plock.
    419420        +---------------------------+
     421OR
     422             +---------------+
     423             |       ex      |
     424             +---------------+
     425        +---------------------------+
     426        |       plock               | -> replace with plock.
     427        +---------------------------+
     428
    420429**********************************************/
    421430
    422431        if ( (ex->start >= plock->start) &&
    423                         (ex->start + ex->size <= plock->start + plock->size) ) {
    424                 memcpy(&lck_arr[0], plock, sizeof(struct lock_struct));
    425                 *lock_was_added = True;
    426                 return 1;
     432                (ex->start + ex->size <= plock->start + plock->size) ) {
     433
     434                /* Replace - discard existing lock. */
     435
     436                return 0;
    427437        }
    428438
    429439/*********************************************
     440Adjacent after.
     441                        +-------+
     442                        |  ex   |
     443                        +-------+
     444        +---------------+
     445        |   plock       |
     446        +---------------+
     447
     448BECOMES....
     449        +---------------+-------+
     450        |   plock       | ex    | - different lock types.
     451        +---------------+-------+
     452OR.... (merge)
     453        +-----------------------+
     454        |   plock               | - same lock type.
     455        +-----------------------+
     456**********************************************/
     457
     458        if (plock->start + plock->size == ex->start) {
     459
     460                /* If the lock types are the same, we merge, if different, we
     461                   add the remainder of the old lock. */
     462
     463                if (lock_types_differ) {
     464                        /* Add existing. */
     465                        memcpy(&lck_arr[0], ex, sizeof(struct lock_struct));
     466                        return 1;
     467                } else {
     468                        /* Merge - adjust incoming lock as we may have more
     469                         * merging to come. */
     470                        plock->size += ex->size;
     471                        return 0;
     472                }
     473        }
     474
     475/*********************************************
     476Adjacent before.
     477        +-------+
     478        |  ex   |
     479        +-------+
     480                +---------------+
     481                |   plock       |
     482                +---------------+
     483BECOMES....
     484        +-------+---------------+
     485        | ex    |   plock       | - different lock types
     486        +-------+---------------+
     487
     488OR.... (merge)
     489        +-----------------------+
     490        |      plock            | - same lock type.
     491        +-----------------------+
     492
     493**********************************************/
     494
     495        if (ex->start + ex->size == plock->start) {
     496
     497                /* If the lock types are the same, we merge, if different, we
     498                   add the existing lock. */
     499
     500                if (lock_types_differ) {
     501                        memcpy(&lck_arr[0], ex, sizeof(struct lock_struct));
     502                        return 1;
     503                } else {
     504                        /* Merge - adjust incoming lock as we may have more
     505                         * merging to come. */
     506                        plock->start = ex->start;
     507                        plock->size += ex->size;
     508                        return 0;
     509                }
     510        }
     511
     512/*********************************************
     513Overlap after.
    430514        +-----------------------+
    431515        |          ex           |
     
    434518        |   plock       |
    435519        +---------------+
    436 OR....
    437                         +-------+
    438                         |  ex   |
    439                         +-------+
     520OR
     521               +----------------+
     522               |       ex       |
     523               +----------------+
    440524        +---------------+
    441525        |   plock       |
     
    448532OR.... (merge)
    449533        +-----------------------+
    450         |   ex                  | - same lock type.
     534        |   plock               | - same lock type.
    451535        +-----------------------+
    452536**********************************************/
    453537
    454538        if ( (ex->start >= plock->start) &&
    455                                 (ex->start <= plock->start + plock->size) &&
    456                                 (ex->start + ex->size > plock->start + plock->size) ) {
    457 
    458                 *lock_was_added = True;
     539                (ex->start <= plock->start + plock->size) &&
     540                (ex->start + ex->size > plock->start + plock->size) ) {
    459541
    460542                /* If the lock types are the same, we merge, if different, we
    461                    add the new lock before the old. */
     543                   add the remainder of the old lock. */
    462544
    463545                if (lock_types_differ) {
    464                         /* Add new. */
    465                         memcpy(&lck_arr[0], plock, sizeof(struct lock_struct));
    466                         memcpy(&lck_arr[1], ex, sizeof(struct lock_struct));
     546                        /* Add remaining existing. */
     547                        memcpy(&lck_arr[0], ex, sizeof(struct lock_struct));
    467548                        /* Adjust existing start and size. */
    468                         lck_arr[1].start = plock->start + plock->size;
    469                         lck_arr[1].size = (ex->start + ex->size) - (plock->start + plock->size);
    470                         return 2;
     549                        lck_arr[0].start = plock->start + plock->size;
     550                        lck_arr[0].size = (ex->start + ex->size) - (plock->start + plock->size);
     551                        return 1;
    471552                } else {
    472                         /* Merge. */
    473                         memcpy(&lck_arr[0], plock, sizeof(struct lock_struct));
    474                         /* Set new start and size. */
    475                         lck_arr[0].start = plock->start;
    476                         lck_arr[0].size = (ex->start + ex->size) - plock->start;
    477                         return 1;
     553                        /* Merge - adjust incoming lock as we may have more
     554                         * merging to come. */
     555                        plock->size += (ex->start + ex->size) - (plock->start + plock->size);
     556                        return 0;
    478557                }
    479558        }
    480559
    481560/*********************************************
    482    +-----------------------+
    483    |  ex                   |
    484    +-----------------------+
    485            +---------------+
    486            |   plock       |
    487            +---------------+
    488 OR....
    489    +-------+       
    490    |  ex   |
    491    +-------+
    492            +---------------+
    493            |   plock       |
    494            +---------------+
     561Overlap before.
     562        +-----------------------+
     563        |  ex                   |
     564        +-----------------------+
     565                +---------------+
     566                |   plock       |
     567                +---------------+
     568OR
     569        +-------------+
     570        |  ex         |
     571        +-------------+
     572                +---------------+
     573                |   plock       |
     574                +---------------+
     575
    495576BECOMES....
    496    +-------+---------------+
    497    | ex    |   plock       | - different lock types
    498    +-------+---------------+
     577        +-------+---------------+
     578        | ex    |   plock       | - different lock types
     579        +-------+---------------+
    499580
    500581OR.... (merge)
    501    +-----------------------+
    502    | ex                    | - same lock type.
    503    +-----------------------+
     582        +-----------------------+
     583        |      plock            | - same lock type.
     584        +-----------------------+
    504585
    505586**********************************************/
     
    509590                        (ex->start + ex->size <= plock->start + plock->size) ) {
    510591
    511                 *lock_was_added = True;
    512 
    513592                /* If the lock types are the same, we merge, if different, we
    514                    add the new lock after the old. */
     593                   add the truncated old lock. */
    515594
    516595                if (lock_types_differ) {
    517596                        memcpy(&lck_arr[0], ex, sizeof(struct lock_struct));
    518                         memcpy(&lck_arr[1], plock, sizeof(struct lock_struct));
    519597                        /* Adjust existing size. */
    520598                        lck_arr[0].size = plock->start - ex->start;
    521                         return 2;
     599                        return 1;
    522600                } else {
    523                         /* Merge. */
    524                         memcpy(&lck_arr[0], ex, sizeof(struct lock_struct));
    525                         /* Adjust existing size. */
    526                         lck_arr[0].size = (plock->start + plock->size) - ex->start;
    527                         return 1;
     601                        /* Merge - adjust incoming lock as we may have more
     602                         * merging to come. MUST ADJUST plock SIZE FIRST ! */
     603                        plock->size += (plock->start - ex->start);
     604                        plock->start = ex->start;
     605                        return 0;
    528606                }
    529607        }
    530608
    531609/*********************************************
     610Complete overlap.
    532611        +---------------------------+
    533612        |        ex                 |
     
    542621OR
    543622        +---------------------------+
    544         |        ex                 | - same lock type.
     623        |        plock              | - same lock type.
    545624        +---------------------------+
    546625**********************************************/
    547626
    548627        if ( (ex->start < plock->start) && (ex->start + ex->size > plock->start + plock->size) ) {
    549                 *lock_was_added = True;
    550628
    551629                if (lock_types_differ) {
     
    554632
    555633                        memcpy(&lck_arr[0], ex, sizeof(struct lock_struct));
    556                         memcpy(&lck_arr[1], plock, sizeof(struct lock_struct));
    557                         memcpy(&lck_arr[2], ex, sizeof(struct lock_struct));
     634                        memcpy(&lck_arr[1], ex, sizeof(struct lock_struct));
    558635
    559636                        /* Adjust first existing size. */
     
    561638
    562639                        /* Adjust second existing start and size. */
    563                         lck_arr[2].start = plock->start + plock->size;
    564                         lck_arr[2].size = (ex->start + ex->size) - (plock->start + plock->size);
    565                         return 3;
     640                        lck_arr[1].start = plock->start + plock->size;
     641                        lck_arr[1].size = (ex->start + ex->size) - (plock->start + plock->size);
     642                        return 2;
    566643                } else {
    567                         /* Just eat plock. */
    568                         memcpy(&lck_arr[0], ex, sizeof(struct lock_struct));
    569                         return 1;
     644                        /* Just eat the existing locks, merge them into plock. */
     645                        plock->start = ex->start;
     646                        plock->size = ex->size;
     647                        return 0;
    570648                }
    571649        }
     
    591669        struct lock_struct *locks = br_lck->lock_data;
    592670        struct lock_struct *tp;
    593         bool lock_was_added = False;
    594671        bool signal_pending_read = False;
    595672
     
    613690                return NT_STATUS_NO_MEMORY;
    614691        }
    615        
     692
    616693        count = 0;
     694
    617695        for (i=0; i < br_lck->num_locks; i++) {
    618696                struct lock_struct *curr_lock = &locks[i];
     
    649727
    650728                        /* Work out overlaps. */
    651                         count += brlock_posix_split_merge(&tp[count], curr_lock, plock, &lock_was_added);
    652                 }
    653         }
    654 
    655         if (!lock_was_added) {
    656                 memcpy(&tp[count], plock, sizeof(struct lock_struct));
    657                 count++;
    658         }
     729                        count += brlock_posix_split_merge(&tp[count], curr_lock, plock);
     730                }
     731        }
     732
     733        /* Try and add the lock in order, sorted by lock start. */
     734        for (i=0; i < count; i++) {
     735                struct lock_struct *curr_lock = &tp[i];
     736
     737                if (curr_lock->start <= plock->start) {
     738                        continue;
     739                }
     740        }
     741
     742        if (i < count) {
     743                memmove(&tp[i+1], &tp[i],
     744                        (count - i)*sizeof(struct lock_struct));
     745        }
     746        memcpy(&tp[i], plock, sizeof(struct lock_struct));
     747        count++;
    659748
    660749        /* We can get the POSIX lock, now see if it needs to
     
    688777        }
    689778
    690         /* Realloc so we don't leak entries per lock call. */
    691         tp = (struct lock_struct *)SMB_REALLOC(tp, count * sizeof(*locks));
    692         if (!tp) {
    693                 return NT_STATUS_NO_MEMORY;
    694         }
     779        /* If we didn't use all the allocated size,
     780         * Realloc so we don't leak entries per lock call. */
     781        if (count < br_lck->num_locks + 2) {
     782                tp = (struct lock_struct *)SMB_REALLOC(tp, count * sizeof(*locks));
     783                if (!tp) {
     784                        return NT_STATUS_NO_MEMORY;
     785                }
     786        }
     787
    695788        br_lck->num_locks = count;
    696789        SAFE_FREE(br_lck->lock_data);
     
    891984static bool brl_unlock_posix(struct messaging_context *msg_ctx,
    892985                             struct byte_range_lock *br_lck,
    893                              const struct lock_struct *plock)
     986                             struct lock_struct *plock)
    894987{
    895988        unsigned int i, j, count;
     
    9231016        for (i = 0; i < br_lck->num_locks; i++) {
    9241017                struct lock_struct *lock = &locks[i];
    925                 struct lock_struct tmp_lock[3];
    926                 bool lock_was_added = False;
    9271018                unsigned int tmp_count;
    9281019
     
    9351026                }
    9361027
    937                 /* Work out overlaps. */
    938                 tmp_count = brlock_posix_split_merge(&tmp_lock[0], &locks[i], plock, &lock_was_added);
    939 
    940                 if (tmp_count == 1) {
    941                         /* Ether the locks didn't overlap, or the unlock completely
    942                            overlapped this lock. If it didn't overlap, then there's
    943                            no change in the locks. */
    944                         if (tmp_lock[0].lock_type != UNLOCK_LOCK) {
    945                                 SMB_ASSERT(tmp_lock[0].lock_type == locks[i].lock_type);
    946                                 /* No change in this lock. */
    947                                 memcpy(&tp[count], &tmp_lock[0], sizeof(struct lock_struct));
    948                                 count++;
    949                         } else {
    950                                 SMB_ASSERT(tmp_lock[0].lock_type == UNLOCK_LOCK);
    951                                 overlap_found = True;
     1028                if (lock->lock_flav == WINDOWS_LOCK) {
     1029                        /* Do any Windows flavour locks conflict ? */
     1030                        if (brl_conflict(lock, plock)) {
     1031                                SAFE_FREE(tp);
     1032                                return false;
    9521033                        }
    953                         continue;
    954                 } else if (tmp_count == 2) {
    955                         /* The unlock overlapped an existing lock. Copy the truncated
    956                            lock into the lock array. */
    957                         if (tmp_lock[0].lock_type != UNLOCK_LOCK) {
    958                                 SMB_ASSERT(tmp_lock[0].lock_type == locks[i].lock_type);
    959                                 SMB_ASSERT(tmp_lock[1].lock_type == UNLOCK_LOCK);
    960                                 memcpy(&tp[count], &tmp_lock[0], sizeof(struct lock_struct));
    961                                 if (tmp_lock[0].size != locks[i].size) {
    962                                         overlap_found = True;
    963                                 }
    964                         } else {
    965                                 SMB_ASSERT(tmp_lock[0].lock_type == UNLOCK_LOCK);
    966                                 SMB_ASSERT(tmp_lock[1].lock_type == locks[i].lock_type);
    967                                 memcpy(&tp[count], &tmp_lock[1], sizeof(struct lock_struct));
    968                                 if (tmp_lock[1].start != locks[i].start) {
    969                                         overlap_found = True;
    970                                 }
    971                         }
     1034                        /* Just copy the Windows lock into the new array. */
     1035                        memcpy(&tp[count], lock, sizeof(struct lock_struct));
    9721036                        count++;
    9731037                        continue;
    974                 } else {
    975                         /* tmp_count == 3 - (we split a lock range in two). */
    976                         SMB_ASSERT(tmp_lock[0].lock_type == locks[i].lock_type);
    977                         SMB_ASSERT(tmp_lock[1].lock_type == UNLOCK_LOCK);
    978                         SMB_ASSERT(tmp_lock[2].lock_type == locks[i].lock_type);
    979 
    980                         memcpy(&tp[count], &tmp_lock[0], sizeof(struct lock_struct));
    981                         count++;
    982                         memcpy(&tp[count], &tmp_lock[2], sizeof(struct lock_struct));
    983                         count++;
    984                         overlap_found = True;
     1038                }
     1039
     1040                /* Work out overlaps. */
     1041                tmp_count = brlock_posix_split_merge(&tp[count], lock, plock);
     1042
     1043                if (tmp_count == 0) {
     1044                        /* plock overlapped the existing lock completely,
     1045                           or replaced it. Don't copy the existing lock. */
     1046                        overlap_found = true;
     1047                } else if (tmp_count == 1) {
     1048                        /* Either no overlap, (simple copy of existing lock) or
     1049                         * an overlap of an existing lock. */
     1050                        /* If the lock changed size, we had an overlap. */
     1051                        if (tp[count].size != lock->size) {
     1052                                overlap_found = true;
     1053                        }
     1054                        count += tmp_count;
     1055                } else if (tmp_count == 2) {
     1056                        /* We split a lock range in two. */
     1057                        overlap_found = true;
     1058                        count += tmp_count;
     1059
    9851060                        /* Optimisation... */
    9861061                        /* We know we're finished here as we can't overlap any
    9871062                           more POSIX locks. Copy the rest of the lock array. */
     1063
    9881064                        if (i < br_lck->num_locks - 1) {
    989                                 memcpy(&tp[count], &locks[i+1], 
     1065                                memcpy(&tp[count], &locks[i+1],
    9901066                                        sizeof(*locks)*((br_lck->num_locks-1) - i));
    9911067                                count += ((br_lck->num_locks-1) - i);
     
    9931069                        break;
    9941070                }
     1071
    9951072        }
    9961073
  • branches/samba-3.3.x/source/modules/vfs_default.c

    r221 r342  
    994994        }
    995995        else {
    996                 ret = SMB_VFS_STAT(handle->conn, fname, &sbuf);
     996                if (lp_posix_pathnames()) {
     997                        ret = SMB_VFS_LSTAT(handle->conn, fname, &sbuf);
     998                } else {
     999                        ret = SMB_VFS_STAT(handle->conn, fname, &sbuf);
     1000                }
    9971001        }
    9981002
  • branches/samba-3.3.x/source/nsswitch/libwbclient/wbc_pam.c

    r206 r342  
    440440                                MIN(params->password.response.lm_length,
    441441                                    sizeof(request.data.auth_crap.lm_resp));
    442                 request.data.auth_crap.nt_resp_len =
    443                                 MIN(params->password.response.nt_length,
    444                                     sizeof(request.data.auth_crap.nt_resp));
    445442                if (params->password.response.lm_data) {
    446443                        memcpy(request.data.auth_crap.lm_resp,
     
    448445                               request.data.auth_crap.lm_resp_len);
    449446                }
    450                 if (params->password.response.nt_data) {
     447                request.data.auth_crap.nt_resp_len = params->password.response.nt_length;
     448                if (params->password.response.nt_length > sizeof(request.data.auth_crap.nt_resp)) {
     449                        request.flags |= WBFLAG_BIG_NTLMV2_BLOB;
     450                        request.extra_len = params->password.response.nt_length;
     451                        request.extra_data.data = talloc_zero_array(NULL, char, request.extra_len);
     452                        if (request.extra_data.data == NULL) {
     453                                wbc_status = WBC_ERR_NO_MEMORY;
     454                                BAIL_ON_WBC_ERROR(wbc_status);
     455                        }
     456                        memcpy(request.extra_data.data,
     457                               params->password.response.nt_data,
     458                               request.data.auth_crap.nt_resp_len);
     459                } else if (params->password.response.nt_data) {
    451460                        memcpy(request.data.auth_crap.nt_resp,
    452461                               params->password.response.nt_data,
     
    493502        if (response.extra_data.data)
    494503                free(response.extra_data.data);
     504
     505        talloc_free(request.extra_data.data);
    495506
    496507        return wbc_status;
  • branches/samba-3.3.x/source/nsswitch/libwbclient/wbc_sid.c

    r206 r342  
    282282                if (pdomain != NULL) {
    283283                        *pdomain = domain;
     284                } else {
     285                        talloc_free(domain);
    284286                }
    285287                if (pname != NULL) {
    286288                        *pname = name;
     289                } else {
     290                        talloc_free(name);
    287291                }
    288292                if (pname_type != NULL) {
  • branches/samba-3.3.x/source/nsswitch/libwbclient/wbc_util.c

    r206 r342  
    285285                BAIL_ON_WBC_ERROR(wbc_status);
    286286        }
     287
     288        ZERO_STRUCTP(info);
    287289
    288290        r = info_string;
  • branches/samba-3.3.x/source/nsswitch/pam_winbind.c

    r309 r342  
    30573057                                                pass_new, pwdlastset_update);
    30583058                if (ret) {
    3059                         _pam_overwrite(pass_new);
    3060                         _pam_overwrite(pass_old);
    30613059                        pass_old = pass_new = NULL;
    30623060                        goto out;
     
    30873085                                                   &error, &info, &policy,
    30883086                                                   NULL, &username_ret);
    3089                         _pam_overwrite(pass_new);
    3090                         _pam_overwrite(pass_old);
    30913087                        pass_old = pass_new = NULL;
    30923088
  • branches/samba-3.3.x/source/pam_smbpass/pam_smb_auth.c

    r206 r342  
    180180        retval = PAM_SUCCESS;
    181181
    182         pam_get_data(pamh, "smb_setcred_return", (const void **) &pretval);
     182        _pam_get_data(pamh, "smb_setcred_return", &pretval);
    183183        if(pretval) {
    184184                retval = *pretval;
     
    200200
    201201        /* Get the authtok; if we don't have one, silently fail. */
    202         retval = pam_get_item( pamh, PAM_AUTHTOK, (const void **) &pass );
     202        retval = _pam_get_item( pamh, PAM_AUTHTOK, &pass );
    203203
    204204        if (retval != PAM_SUCCESS) {
  • branches/samba-3.3.x/source/pam_smbpass/pam_smb_passwd.c

    r206 r342  
    230230
    231231        if (off( SMB_NOT_SET_PASS, ctrl )) {
    232             retval = pam_get_item( pamh, PAM_OLDAUTHTOK,
    233                                    (const void **)&pass_old );
     232            retval = _pam_get_item( pamh, PAM_OLDAUTHTOK,
     233                                   &pass_old );
    234234        } else {
    235             retval = pam_get_data( pamh, _SMB_OLD_AUTHTOK,
    236                                    (const void **)&pass_old );
     235            retval = _pam_get_data( pamh, _SMB_OLD_AUTHTOK,
     236                                   &pass_old );
    237237            if (retval == PAM_NO_MODULE_DATA) {
    238238                pass_old = NULL;
  • branches/samba-3.3.x/source/pam_smbpass/support.c

    r206 r342  
    8484        struct pam_conv *conv;
    8585
    86         retval = pam_get_item(pamh, PAM_CONV, (const void **) &conv);
     86        retval = _pam_get_item(pamh, PAM_CONV, &conv);
    8787        if (retval == PAM_SUCCESS) {
    8888
     
    277277            /* log the number of authentication failures */
    278278            if (failure->count != 0) {
    279                 pam_get_item( pamh, PAM_SERVICE, (const void **) &service );
     279                _pam_get_item( pamh, PAM_SERVICE, &service );
    280280                _log_err( LOG_NOTICE
    281281                          , "%d authentication %s "
     
    333333            const char *service;
    334334
    335             pam_get_item( pamh, PAM_SERVICE, (const void **)&service );
     335            _pam_get_item( pamh, PAM_SERVICE, &service );
    336336            _log_err( LOG_NOTICE, "failed auth request by %s for service %s as %s",
    337337                      uidtoname(getuid()), service ? service : "**unknown**", name);
     
    368368        const char *service;
    369369
    370         pam_get_item( pamh, PAM_SERVICE, (const void **)&service );
     370        _pam_get_item( pamh, PAM_SERVICE, &service );
    371371
    372372        if (data_name != NULL) {
     
    381381
    382382                /* any previous failures for this user ? */
    383                 pam_get_data(pamh, data_name, (const void **) &old);
     383                _pam_get_data(pamh, data_name, &old);
    384384
    385385                if (old != NULL) {
     
    486486
    487487    if (on(SMB_TRY_FIRST_PASS, ctrl) || on(SMB_USE_FIRST_PASS, ctrl)) {
    488         retval = pam_get_item( pamh, authtok_flag, (const void **) &item );
     488        retval = _pam_get_item( pamh, authtok_flag, &item );
    489489        if (retval != PAM_SUCCESS) {
    490490            /* very strange. */
     
    579579        _pam_delete( token );           /* clean it up */
    580580        if (retval != PAM_SUCCESS
    581             || (retval = pam_get_item( pamh, authtok_flag
    582                             ,(const void **)&item )) != PAM_SUCCESS)
     581            || (retval = _pam_get_item( pamh, authtok_flag
     582                            ,&item )) != PAM_SUCCESS)
    583583        {
    584584            _log_err( LOG_CRIT, "error manipulating password" );
     
    593593        retval = pam_set_data( pamh, data_name, (void *) token, _cleanup );
    594594        if (retval != PAM_SUCCESS
    595             || (retval = pam_get_data( pamh, data_name, (const void **)&item ))
     595            || (retval = _pam_get_data( pamh, data_name, &item ))
    596596                             != PAM_SUCCESS)
    597597        {
     
    631631    return PAM_SUCCESS;
    632632}
     633
     634/*
     635 * Work around the pam API that has functions with void ** as parameters
     636 * These lead to strict aliasing warnings with gcc.
     637 */
     638int _pam_get_item(const pam_handle_t *pamh,
     639                  int item_type,
     640                  const void *_item)
     641{
     642        const void **item = (const void **)_item;
     643        return pam_get_item(pamh, item_type, item);
     644}
     645
     646int _pam_get_data(const pam_handle_t *pamh,
     647                  const char *module_data_name,
     648                  const void *_data)
     649{
     650        const void **data = (const void **)_data;
     651        return pam_get_data(pamh, module_data_name, data);
     652}
  • branches/samba-3.3.x/source/pam_smbpass/support.h

    r206 r342  
    4949extern int _pam_smb_approve_pass(pam_handle_t *, unsigned int, const char *,
    5050                                 const char *);
     51
     52int _pam_get_item(const pam_handle_t *pamh,
     53                  int item_type,
     54                  const void *_item);
     55int _pam_get_data(const pam_handle_t *pamh,
     56                  const char *module_data_name,
     57                  const void *_data);
  • branches/samba-3.3.x/source/passdb/lookup_sid.c

    r274 r342  
    10861086        DATA_BLOB cache_value;
    10871087
    1088         if (!memcache_lookup(NULL, SID_UID_CACHE,
     1088        if (!memcache_lookup(NULL, SID_GID_CACHE,
    10891089                             data_blob_const(psid, ndr_size_dom_sid(psid, 0)),
    10901090                             &cache_value)) {
  • branches/samba-3.3.x/source/passdb/pdb_ldap.c

    r274 r342  
    17011701                char *utf8_dn;
    17021702                size_t converted_size;
     1703                int ret;
    17031704
    17041705                if (!ldap_state->is_nds_ldap) {
     
    17321733
    17331734                if ((ber_printf (ber, "{") < 0) ||
    1734                     (ber_printf (ber, "ts", LDAP_TAG_EXOP_MODIFY_PASSWD_ID, utf8_dn) < 0) ||
    1735                     (ber_printf (ber, "ts", LDAP_TAG_EXOP_MODIFY_PASSWD_NEW, utf8_password) < 0) ||
    1736                     (ber_printf (ber, "n}") < 0)) {
    1737                         DEBUG(0,("ldapsam_modify_entry: ber_printf returns a value <0\n"));
    1738                        ber_free(ber,1);
    1739                        SAFE_FREE(utf8_dn);
    1740                        SAFE_FREE(utf8_password);
    1741                        return NT_STATUS_UNSUCCESSFUL;
     1735                    (ber_printf (ber, "ts", LDAP_TAG_EXOP_MODIFY_PASSWD_ID,
     1736                                 utf8_dn) < 0)) {
     1737                        DEBUG(0,("ldapsam_modify_entry: ber_printf returns a "
     1738                                 "value <0\n"));
     1739                        ber_free(ber,1);
     1740                        SAFE_FREE(utf8_dn);
     1741                        SAFE_FREE(utf8_password);
     1742                        return NT_STATUS_UNSUCCESSFUL;
     1743                }
     1744
     1745                if ((utf8_password != NULL) && (*utf8_password != '\0')) {
     1746                        ret = ber_printf(ber, "ts}",
     1747                                         LDAP_TAG_EXOP_MODIFY_PASSWD_NEW,
     1748                                         utf8_password);
     1749                } else {
     1750                        ret = ber_printf(ber, "}");
     1751                }
     1752
     1753                if (ret < 0) {
     1754                        DEBUG(0,("ldapsam_modify_entry: ber_printf returns a "
     1755                                 "value <0\n"));
     1756                        ber_free(ber,1);
     1757                        SAFE_FREE(utf8_dn);
     1758                        SAFE_FREE(utf8_password);
     1759                        return NT_STATUS_UNSUCCESSFUL;
    17421760                }
    17431761
  • branches/samba-3.3.x/source/profile/profile.c

    r206 r342  
    228228        profile_h = (struct profile_header *)shmat(shm_id, 0,
    229229                                                   read_only?SHM_RDONLY:0);
    230         if ((long)profile_p == -1) {
     230        if ((long)profile_h == -1) {
    231231                DEBUG(0,("Can't attach to IPC area. Error was %s\n",
    232232                         strerror(errno)));
  • branches/samba-3.3.x/source/rpc_client/cli_lsarpc.c

    r206 r342  
    127127                                               char **domains,
    128128                                               char **names,
    129                                                enum lsa_SidType *types)
     129                                               enum lsa_SidType *types,
     130                                               bool use_lookupsids3)
    130131{
    131132        NTSTATUS result = NT_STATUS_OK;
     
    160161        }
    161162
    162         result = rpccli_lsa_LookupSids(cli, mem_ctx,
    163                                        pol,
    164                                        &sid_array,
    165                                        &ref_domains,
    166                                        &lsa_names,
    167                                        level,
    168                                        &count);
     163        if (use_lookupsids3) {
     164                struct lsa_TransNameArray2 lsa_names2;
     165                uint32_t n;
     166
     167                ZERO_STRUCT(lsa_names2);
     168
     169                result = rpccli_lsa_LookupSids3(cli, mem_ctx,
     170                                                &sid_array,
     171                                                &ref_domains,
     172                                                &lsa_names2,
     173                                                level,
     174                                                &count,
     175                                                0,
     176                                                0);
     177
     178                if (!NT_STATUS_IS_ERR(result)) {
     179                        lsa_names.count = lsa_names2.count;
     180                        lsa_names.names = talloc_array(mem_ctx, struct lsa_TranslatedName, lsa_names.count);
     181                        if (!lsa_names.names) {
     182                                return NT_STATUS_NO_MEMORY;
     183                        }
     184                        for (n=0; n < lsa_names.count; n++) {
     185                                lsa_names.names[n].sid_type     = lsa_names2.names[n].sid_type;
     186                                lsa_names.names[n].name         = lsa_names2.names[n].name;
     187                                lsa_names.names[n].sid_index    = lsa_names2.names[n].sid_index;
     188                        }
     189                }
     190
     191        } else {
     192                result = rpccli_lsa_LookupSids(cli, mem_ctx,
     193                                               pol,
     194                                               &sid_array,
     195                                               &ref_domains,
     196                                               &lsa_names,
     197                                               level,
     198                                               &count);
     199        }
    169200
    170201        DEBUG(10, ("LSA_LOOKUPSIDS returned '%s', mapped count = %d'\n",
     
    246277#define LOOKUP_SIDS_HUNK_SIZE 1000
    247278
    248 NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
    249                                 TALLOC_CTX *mem_ctx,
    250                                 POLICY_HND *pol,
    251                                 int num_sids,
    252                                 const DOM_SID *sids,
    253                                 char ***pdomains,
    254                                 char ***pnames,
    255                                 enum lsa_SidType **ptypes)
     279static NTSTATUS rpccli_lsa_lookup_sids_generic(struct rpc_pipe_client *cli,
     280                                               TALLOC_CTX *mem_ctx,
     281                                               struct policy_handle *pol,
     282                                               int num_sids,
     283                                               const DOM_SID *sids,
     284                                               char ***pdomains,
     285                                               char ***pnames,
     286                                               enum lsa_SidType **ptypes,
     287                                               bool use_lookupsids3)
    256288{
    257289        NTSTATUS result = NT_STATUS_OK;
     
    312344                                                             hunk_domains,
    313345                                                             hunk_names,
    314                                                              hunk_types);
     346                                                             hunk_types,
     347                                                             use_lookupsids3);
    315348
    316349                if (!NT_STATUS_IS_OK(hunk_result) &&
     
    353386}
    354387
     388NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
     389                                TALLOC_CTX *mem_ctx,
     390                                struct policy_handle *pol,
     391                                int num_sids,
     392                                const DOM_SID *sids,
     393                                char ***pdomains,
     394                                char ***pnames,
     395                                enum lsa_SidType **ptypes)
     396{
     397        return rpccli_lsa_lookup_sids_generic(cli, mem_ctx, pol, num_sids, sids,
     398                                              pdomains, pnames, ptypes, false);
     399}
     400
     401NTSTATUS rpccli_lsa_lookup_sids3(struct rpc_pipe_client *cli,
     402                                 TALLOC_CTX *mem_ctx,
     403                                 struct policy_handle *pol,
     404                                 int num_sids,
     405                                 const DOM_SID *sids,
     406                                 char ***pdomains,
     407                                 char ***pnames,
     408                                 enum lsa_SidType **ptypes)
     409{
     410        return rpccli_lsa_lookup_sids_generic(cli, mem_ctx, pol, num_sids, sids,
     411                                              pdomains, pnames, ptypes, true);
     412}
     413
    355414/** Lookup a list of names */
    356415
    357 NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli,
    358                                  TALLOC_CTX *mem_ctx,
    359                                  POLICY_HND *pol, int num_names,
    360                                  const char **names,
    361                                  const char ***dom_names,
    362                                  int level,
    363                                  DOM_SID **sids,
    364                                  enum lsa_SidType **types)
     416static NTSTATUS rpccli_lsa_lookup_names_generic(struct rpc_pipe_client *cli,
     417                                                TALLOC_CTX *mem_ctx,
     418                                                struct policy_handle *pol, int num_names,
     419                                                const char **names,
     420                                                const char ***dom_names,
     421                                                int level,
     422                                                DOM_SID **sids,
     423                                                enum lsa_SidType **types,
     424                                                bool use_lookupnames4)
    365425{
    366426        NTSTATUS result;
     
    369429        struct lsa_RefDomainList *domains = NULL;
    370430        struct lsa_TransSidArray sid_array;
     431        struct lsa_TransSidArray3 sid_array3;
    371432        uint32_t count = 0;
    372433
    373434        ZERO_STRUCT(sid_array);
     435        ZERO_STRUCT(sid_array3);
    374436
    375437        lsa_names = TALLOC_ARRAY(mem_ctx, struct lsa_String, num_names);
     
    382444        }
    383445
    384         result = rpccli_lsa_LookupNames(cli, mem_ctx,
    385                                         pol,
    386                                         num_names,
    387                                         lsa_names,
    388                                         &domains,
    389                                         &sid_array,
    390                                         level,
    391                                         &count);
     446        if (use_lookupnames4) {
     447                result = rpccli_lsa_LookupNames4(cli, mem_ctx,
     448                                                 num_names,
     449                                                 lsa_names,
     450                                                 &domains,
     451                                                 &sid_array3,
     452                                                 level,
     453                                                 &count,
     454                                                 0,
     455                                                 0);
     456        } else {
     457                result = rpccli_lsa_LookupNames(cli, mem_ctx,
     458                                                pol,
     459                                                num_names,
     460                                                lsa_names,
     461                                                &domains,
     462                                                &sid_array,
     463                                                level,
     464                                                &count);
     465        }
    392466
    393467        if (!NT_STATUS_IS_OK(result) && NT_STATUS_V(result) !=
     
    436510
    437511        for (i = 0; i < num_names; i++) {
    438                 uint32_t dom_idx = sid_array.sids[i].sid_index;
    439                 uint32_t dom_rid = sid_array.sids[i].rid;
     512                uint32_t dom_idx;
    440513                DOM_SID *sid = &(*sids)[i];
     514
     515                if (use_lookupnames4) {
     516                        dom_idx         = sid_array3.sids[i].sid_index;
     517                        (*types)[i]     = sid_array3.sids[i].sid_type;
     518                } else {
     519                        dom_idx         = sid_array.sids[i].sid_index;
     520                        (*types)[i]     = sid_array.sids[i].sid_type;
     521                }
    441522
    442523                /* Translate optimised sid through domain index array */
     
    449530                }
    450531
    451                 sid_copy(sid, domains->domains[dom_idx].sid);
    452 
    453                 if (dom_rid != 0xffffffff) {
    454                         sid_append_rid(sid, dom_rid);
    455                 }
    456 
    457                 (*types)[i] = sid_array.sids[i].sid_type;
     532                if (use_lookupnames4) {
     533                        sid_copy(sid, sid_array3.sids[i].sid);
     534                } else {
     535                        sid_copy(sid, domains->domains[dom_idx].sid);
     536
     537                        if (sid_array.sids[i].rid != 0xffffffff) {
     538                                sid_append_rid(sid, sid_array.sids[i].rid);
     539                        }
     540                }
    458541
    459542                if (dom_names == NULL) {
     
    468551        return result;
    469552}
     553
     554NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli,
     555                                 TALLOC_CTX *mem_ctx,
     556                                 struct policy_handle *pol, int num_names,
     557                                 const char **names,
     558                                 const char ***dom_names,
     559                                 int level,
     560                                 DOM_SID **sids,
     561                                 enum lsa_SidType **types)
     562{
     563        return rpccli_lsa_lookup_names_generic(cli, mem_ctx, pol, num_names,
     564                                               names, dom_names, level, sids,
     565                                               types, false);
     566}
     567
     568NTSTATUS rpccli_lsa_lookup_names4(struct rpc_pipe_client *cli,
     569                                  TALLOC_CTX *mem_ctx,
     570                                  struct policy_handle *pol, int num_names,
     571                                  const char **names,
     572                                  const char ***dom_names,
     573                                  int level,
     574                                  DOM_SID **sids,
     575                                  enum lsa_SidType **types)
     576{
     577        return rpccli_lsa_lookup_names_generic(cli, mem_ctx, pol, num_names,
     578                                               names, dom_names, level, sids,
     579                                               types, true);
     580}
  • branches/samba-3.3.x/source/rpc_client/cli_netlogon.c

    r206 r342  
    602602                struct samr_Password new_password;
    603603
    604                 cred_hash3(new_password.hash,
    605                            new_trust_passwd_hash,
    606                            cli->dc->sess_key, 1);
     604                des_crypt112_16(new_password.hash,
     605                                new_trust_passwd_hash,
     606                                cli->dc->sess_key, 1);
    607607
    608608                result = rpccli_netr_ServerPasswordSet(cli, mem_ctx,
  • branches/samba-3.3.x/source/rpc_client/cli_pipe.c

    r206 r342  
    491491        }
    492492
    493         if (auth_len != RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN) {
     493        if (auth_len < RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN) {
    494494                DEBUG(0,("cli_pipe_verify_schannel: auth_len %u.\n", (unsigned int)auth_len ));
    495495                return NT_STATUS_INVALID_PARAMETER;
     
    23202320        return NT_STATUS_OK;
    23212321}
    2322 
    2323 unsigned int rpccli_set_timeout(struct rpc_pipe_client *cli,
     2322unsigned int rpccli_set_timeout(struct rpc_pipe_client *rpc_cli,
    23242323                                unsigned int timeout)
    23252324{
    2326         return cli_set_timeout(cli->trans.np.cli, timeout);
     2325        struct cli_state *cli = rpc_pipe_np_smb_conn(rpc_cli);
     2326
     2327        if (cli == NULL) {
     2328                return 0;
     2329        }
     2330        return cli_set_timeout(cli, timeout);
    23272331}
    23282332
     
    29322936
    29332937static NTSTATUS cli_rpc_pipe_open(struct cli_state *cli,
     2938                                  enum dcerpc_transport_t transport,
    29342939                                  const struct ndr_syntax_id *interface,
    29352940                                  struct rpc_pipe_client **presult)
    29362941{
    2937         if (ndr_syntax_id_equal(interface, &ndr_table_drsuapi.syntax_id)) {
    2938                 /*
    2939                  * We should have a better way to figure out this drsuapi
    2940                  * speciality...
    2941                  */
     2942        switch (transport) {
     2943        case NCACN_IP_TCP:
    29422944                return rpc_pipe_open_tcp(NULL, cli->desthost, interface,
    29432945                                         presult);
    2944         }
    2945 
    2946         return rpc_pipe_open_np(cli, interface, presult);
     2946        case NCACN_NP:
     2947                return rpc_pipe_open_np(cli, interface, presult);
     2948        default:
     2949                return NT_STATUS_NOT_IMPLEMENTED;
     2950        }
    29472951}
    29482952
     
    29512955 ****************************************************************************/
    29522956
    2953 NTSTATUS cli_rpc_pipe_open_noauth(struct cli_state *cli,
    2954                                   const struct ndr_syntax_id *interface,
    2955                                   struct rpc_pipe_client **presult)
     2957NTSTATUS cli_rpc_pipe_open_noauth_transport(struct cli_state *cli,
     2958                                            enum dcerpc_transport_t transport,
     2959                                            const struct ndr_syntax_id *interface,
     2960                                            struct rpc_pipe_client **presult)
    29562961{
    29572962        struct rpc_pipe_client *result;
     
    29592964        NTSTATUS status;
    29602965
    2961         status = cli_rpc_pipe_open(cli, interface, &result);
     2966        status = cli_rpc_pipe_open(cli, transport, interface, &result);
    29622967        if (!NT_STATUS_IS_OK(status)) {
    29632968                return status;
     
    30163021
    30173022/****************************************************************************
     3023 ****************************************************************************/
     3024
     3025NTSTATUS cli_rpc_pipe_open_noauth(struct cli_state *cli,
     3026                                  const struct ndr_syntax_id *interface,
     3027                                  struct rpc_pipe_client **presult)
     3028{
     3029        return cli_rpc_pipe_open_noauth_transport(cli, NCACN_NP,
     3030                                                  interface, presult);
     3031}
     3032
     3033/****************************************************************************
    30183034 Open a named pipe to an SMB server and bind using NTLMSSP or SPNEGO NTLMSSP
    30193035 ****************************************************************************/
     
    30213037static NTSTATUS cli_rpc_pipe_open_ntlmssp_internal(struct cli_state *cli,
    30223038                                                   const struct ndr_syntax_id *interface,
     3039                                                   enum dcerpc_transport_t transport,
    30233040                                                   enum pipe_auth_type auth_type,
    30243041                                                   enum pipe_auth_level auth_level,
     
    30323049        NTSTATUS status;
    30333050
    3034         status = cli_rpc_pipe_open(cli, interface, &result);
     3051        status = cli_rpc_pipe_open(cli, transport, interface, &result);
    30353052        if (!NT_STATUS_IS_OK(status)) {
    30363053                return status;
     
    30743091NTSTATUS cli_rpc_pipe_open_ntlmssp(struct cli_state *cli,
    30753092                                   const struct ndr_syntax_id *interface,
     3093                                   enum dcerpc_transport_t transport,
    30763094                                   enum pipe_auth_level auth_level,
    30773095                                   const char *domain,
     
    30823100        return cli_rpc_pipe_open_ntlmssp_internal(cli,
    30833101                                                interface,
     3102                                                transport,
    30843103                                                PIPE_AUTH_TYPE_NTLMSSP,
    30853104                                                auth_level,
     
    30973116NTSTATUS cli_rpc_pipe_open_spnego_ntlmssp(struct cli_state *cli,
    30983117                                          const struct ndr_syntax_id *interface,
     3118                                          enum dcerpc_transport_t transport,
    30993119                                          enum pipe_auth_level auth_level,
    31003120                                          const char *domain,
     
    31053125        return cli_rpc_pipe_open_ntlmssp_internal(cli,
    31063126                                                interface,
     3127                                                transport,
    31073128                                                PIPE_AUTH_TYPE_SPNEGO_NTLMSSP,
    31083129                                                auth_level,
     
    32023223NTSTATUS cli_rpc_pipe_open_schannel_with_key(struct cli_state *cli,
    32033224                                             const struct ndr_syntax_id *interface,
     3225                                             enum dcerpc_transport_t transport,
    32043226                                             enum pipe_auth_level auth_level,
    32053227                                             const char *domain,
     
    32113233        NTSTATUS status;
    32123234
    3213         status = cli_rpc_pipe_open(cli, interface, &result);
     3235        status = cli_rpc_pipe_open(cli, transport, interface, &result);
    32143236        if (!NT_STATUS_IS_OK(status)) {
    32153237                return status;
     
    32713293
    32723294        status = cli_rpc_pipe_open_spnego_ntlmssp(
    3273                 cli, &ndr_table_netlogon.syntax_id, PIPE_AUTH_LEVEL_PRIVACY,
     3295                cli, &ndr_table_netlogon.syntax_id, NCACN_NP,
     3296                PIPE_AUTH_LEVEL_PRIVACY,
    32743297                domain, username, password, &netlogon_pipe);
    32753298        if (!NT_STATUS_IS_OK(status)) {
     
    32963319NTSTATUS cli_rpc_pipe_open_ntlmssp_auth_schannel(struct cli_state *cli,
    32973320                                                 const struct ndr_syntax_id *interface,
     3321                                                 enum dcerpc_transport_t transport,
    32983322                                                 enum pipe_auth_level auth_level,
    32993323                                                 const char *domain,
     
    33173341
    33183342        status = cli_rpc_pipe_open_schannel_with_key(
    3319                 cli, interface, auth_level, domain, netlogon_pipe->dc,
     3343                cli, interface, transport, auth_level, domain, netlogon_pipe->dc,
    33203344                &result);
    33213345
     
    33363360NTSTATUS cli_rpc_pipe_open_schannel(struct cli_state *cli,
    33373361                                    const struct ndr_syntax_id *interface,
     3362                                    enum dcerpc_transport_t transport,
    33383363                                    enum pipe_auth_level auth_level,
    33393364                                    const char *domain,
     
    33553380
    33563381        status = cli_rpc_pipe_open_schannel_with_key(
    3357                 cli, interface, auth_level, domain, netlogon_pipe->dc,
     3382                cli, interface, transport, auth_level, domain, netlogon_pipe->dc,
    33583383                &result);
    33593384
     
    33873412        NTSTATUS status;
    33883413
    3389         status = cli_rpc_pipe_open(cli, interface, &result);
     3414        status = cli_rpc_pipe_open(cli, NCACN_NP, interface, &result);
    33903415        if (!NT_STATUS_IS_OK(status)) {
    33913416                return status;
  • branches/samba-3.3.x/source/rpc_client/init_netlogon.c

    r206 r342  
    297297                           NETLOGON_EXTRA_SIDS,
    298298                           user_session_key,
    299                            my_name,
     299                           talloc_strdup(sam3, my_name),
    300300                           talloc_strdup(sam3, pdb_get_domain(sampw)),
    301301                           sid,
  • branches/samba-3.3.x/source/rpc_server/srv_netlog_nt.c

    r274 r342  
    670670        }
    671671
    672         /* Woah - what does this to to the credential chain ? JRA */
    673         cred_hash3(pwd, r->in.new_password->hash, p->dc->sess_key, 0);
     672        des_crypt112_16(pwd, r->in.new_password->hash, p->dc->sess_key, 0);
    674673
    675674        DEBUG(100,("_netr_ServerPasswordSet: new given value was :\n"));
  • branches/samba-3.3.x/source/rpc_server/srv_samr_nt.c

    r274 r342  
    262262        *pacc_requested &= ~MAXIMUM_ALLOWED_ACCESS;
    263263
    264         /* At least try for generic read. */
    265         *pacc_requested = GENERIC_READ_ACCESS;
     264        /* At least try for generic read|execute - Everyone gets that. */
     265        *pacc_requested = GENERIC_READ_ACCESS|GENERIC_EXECUTE_ACCESS;
    266266
    267267        /* root gets anything. */
  • branches/samba-3.3.x/source/rpcclient/rpcclient.c

    r206 r342  
    588588                                ntresult = cli_rpc_pipe_open_spnego_ntlmssp(
    589589                                        cli, cmd_entry->interface,
     590                                        NCACN_NP,
    590591                                        pipe_default_auth_level,
    591592                                        lp_workgroup(),
     
    597598                                ntresult = cli_rpc_pipe_open_ntlmssp(
    598599                                        cli, cmd_entry->interface,
     600                                        NCACN_NP,
    599601                                        pipe_default_auth_level,
    600602                                        lp_workgroup(),
     
    606608                                ntresult = cli_rpc_pipe_open_schannel(
    607609                                        cli, cmd_entry->interface,
     610                                        NCACN_NP,
    608611                                        pipe_default_auth_level,
    609612                                        lp_workgroup(),
  • branches/samba-3.3.x/source/smbd/files.c

    r222 r342  
    408408                                        fsp->fsp_name);
    409409
    410                 if (strnequal(d_fullname, d1_fullname, dlen)) {
     410                /*
     411                 * If the open file has a path that is a longer
     412                 * component, then it's a subpath.
     413                 */
     414                if (strnequal(d_fullname, d1_fullname, dlen) &&
     415                                (d1_fullname[dlen] == '/')) {
    411416                        TALLOC_FREE(d_fullname);
    412417                        TALLOC_FREE(d1_fullname);
     
    414419                }
    415420                TALLOC_FREE(d1_fullname);
    416         } 
     421        }
    417422
    418423        TALLOC_FREE(d_fullname);
  • branches/samba-3.3.x/source/smbd/notify_inotify.c

    r206 r342  
    233233        struct inotify_event *e0, *e;
    234234        uint32_t prev_cookie=0;
     235        NTSTATUS status;
    235236
    236237        /*
     
    248249        if (e == NULL) return;
    249250
    250         if (sys_read(in->fd, e0, bufsize) != bufsize) {
    251                 DEBUG(0,("Failed to read all inotify data\n"));
     251        status = read_data(in->fd, (char *)e0, bufsize);
     252        if (!NT_STATUS_IS_OK(status)) {
     253                DEBUG(0,("Failed to read all inotify data - %s\n",
     254                        nt_errstr(status)));
    252255                talloc_free(e0);
     256                /* the inotify fd will now be out of sync,
     257                 * can't keep reading data off it */
     258                TALLOC_FREE(fde);
    253259                return;
    254260        }
  • branches/samba-3.3.x/source/smbd/posix_acls.c

    r285 r342  
    31793179        SMB_ACL_T def_acl = NULL;
    31803180        struct pai_val *pal;
     3181        int ret;
    31813182
    31823183        *ppdesc = NULL;
     
    31853186
    31863187        /* Get the stat struct for the owner info. */
    3187         if(SMB_VFS_STAT(conn, name, &sbuf) != 0) {
     3188        if (lp_posix_pathnames()) {
     3189                ret = SMB_VFS_LSTAT(conn, name, &sbuf);
     3190        } else {
     3191                ret = SMB_VFS_STAT(conn, name, &sbuf);
     3192        }
     3193        if(ret != 0) {
    31883194                return map_nt_error_from_unix(errno);
    31893195        }
     
    32193225        files_struct *fsp;
    32203226        SMB_STRUCT_STAT st;
     3227        bool posix_paths = lp_posix_pathnames();
    32213228
    32223229        if(!CAN_WRITE(conn)) {
     
    32263233        /* Case (1). */
    32273234        /* try the direct way first */
    3228         ret = SMB_VFS_CHOWN(conn, fname, uid, gid);
     3235        if (posix_paths) {
     3236                ret = SMB_VFS_LCHOWN(conn, fname, uid, gid);
     3237        } else {
     3238                ret = SMB_VFS_CHOWN(conn, fname, uid, gid);
     3239        }
    32293240        if (ret == 0)
    32303241                return 0;
     
    32663277        }
    32673278
    3268         if (SMB_VFS_STAT(conn,fname,&st)) {
     3279        if (posix_paths) {
     3280                ret = SMB_VFS_LSTAT(conn,fname,&st);
     3281        } else {
     3282                ret = SMB_VFS_STAT(conn,fname,&st);
     3283        }
     3284        if (ret != 0) {
    32693285                return -1;
    32703286        }
     
    34983514        bool acl_set_support = false;
    34993515        bool ret = false;
     3516        bool posix_paths = lp_posix_pathnames();
     3517        int sret;
    35003518
    35013519        DEBUG(10,("set_nt_acl: called for file %s\n", fsp->fsp_name ));
     
    35113529
    35123530        if(fsp->is_directory || fsp->fh->fd == -1) {
    3513                 if(SMB_VFS_STAT(fsp->conn,fsp->fsp_name, &sbuf) != 0)
     3531                if (posix_paths) {
     3532                        sret = SMB_VFS_LSTAT(fsp->conn,fsp->fsp_name, &sbuf);
     3533                } else {
     3534                        sret = SMB_VFS_STAT(fsp->conn,fsp->fsp_name, &sbuf);
     3535                }
     3536                if (sret != 0) {
    35143537                        return map_nt_error_from_unix(errno);
     3538                }
    35153539        } else {
    35163540                if(SMB_VFS_FSTAT(fsp, &sbuf) != 0)
     
    35563580
    35573581                if(fsp->is_directory) {
    3558                         if(SMB_VFS_STAT(fsp->conn, fsp->fsp_name, &sbuf) != 0) {
     3582                        if (posix_paths) {
     3583                                sret = SMB_VFS_LSTAT(fsp->conn, fsp->fsp_name, &sbuf);
     3584                        } else {
     3585                                sret = SMB_VFS_STAT(fsp->conn, fsp->fsp_name, &sbuf);
     3586                        }
     3587                        if (sret != 0) {
    35593588                                return map_nt_error_from_unix(errno);
    35603589                        }
    35613590                } else {
    3562 
    3563                         int sret;
    3564 
    3565                         if(fsp->fh->fd == -1)
    3566                                 sret = SMB_VFS_STAT(fsp->conn, fsp->fsp_name, &sbuf);
    3567                         else
     3591                        if(fsp->fh->fd == -1) {
     3592                                if (posix_paths) {
     3593                                        sret = SMB_VFS_LSTAT(fsp->conn, fsp->fsp_name, &sbuf);
     3594                                } else {
     3595                                        sret = SMB_VFS_STAT(fsp->conn, fsp->fsp_name, &sbuf);
     3596                                }
     3597                        } else {
    35683598                                sret = SMB_VFS_FSTAT(fsp, &sbuf);
     3599                        }
    35693600
    35703601                        if(sret != 0)
     
    36453676                        }
    36463677                } else {
    3647                         int sret = -1;
    3648 
    36493678                        /*
    36503679                         * No default ACL - delete one if it exists.
     
    37063735
    37073736                if (orig_mode != posix_perms) {
    3708                         int sret = -1;
    3709 
    37103737                        DEBUG(3,("set_nt_acl: chmod %s. perms = 0%o.\n",
    37113738                                fsp->fsp_name, (unsigned int)posix_perms ));
  • branches/samba-3.3.x/source/smbd/reply.c

    r242 r342  
    958958        }
    959959
    960         if (!VALID_STAT(sbuf) && (SMB_VFS_STAT(conn,name,&sbuf) != 0)) {
    961                 DEBUG(3,("reply_checkpath: stat of %s failed (%s)\n",name,strerror(errno)));
    962                 status = map_nt_error_from_unix(errno);
    963                 goto path_err;
     960        if (!VALID_STAT(sbuf)) {
     961                int ret;
     962
     963                if (lp_posix_pathnames()) {
     964                        ret = SMB_VFS_LSTAT(conn,name,&sbuf);
     965                } else {
     966                        ret = SMB_VFS_STAT(conn,name,&sbuf);
     967                }
     968                if (ret != 0) {
     969                        DEBUG(3,("reply_checkpath: stat of %s failed (%s)\n",name,strerror(errno)));
     970                        status = map_nt_error_from_unix(errno);
     971                        goto path_err;
     972                }
    964973        }
    965974
     
    10681077                        return;
    10691078                }
    1070                 if (!VALID_STAT(sbuf) && (SMB_VFS_STAT(conn,fname,&sbuf) != 0)) {
    1071                         DEBUG(3,("reply_getatr: stat of %s failed (%s)\n",fname,strerror(errno)));
    1072                         reply_unixerror(req, ERRDOS,ERRbadfile);
    1073                         END_PROFILE(SMBgetatr);
    1074                         return;
     1079                if (!VALID_STAT(sbuf)) {
     1080                        int ret;
     1081
     1082                        if (lp_posix_pathnames()) {
     1083                                ret = SMB_VFS_LSTAT(conn,fname,&sbuf);
     1084                        } else {
     1085                                ret = SMB_VFS_STAT(conn,fname,&sbuf);
     1086                        }
     1087                        if (ret != 0) {
     1088                                DEBUG(3,("reply_getatr: stat of %s failed (%s)\n",fname,strerror(errno)));
     1089                                reply_unixerror(req, ERRDOS,ERRbadfile);
     1090                                END_PROFILE(SMBgetatr);
     1091                                return;
     1092                        }
    10751093                }
    10761094
     
    23022320        files_struct *fsp;
    23032321        uint32 dirtype_orig = dirtype;
     2322        bool posix_paths = lp_posix_pathnames();
     2323        int ret;
    23042324        NTSTATUS status;
    23052325
     
    23102330        }
    23112331
    2312         if (SMB_VFS_LSTAT(conn,fname,&sbuf) != 0) {
     2332        if (posix_paths) {
     2333                ret = SMB_VFS_LSTAT(conn,fname,&sbuf);
     2334        } else {
     2335                ret = SMB_VFS_STAT(conn,fname,&sbuf);
     2336        }
     2337        if (ret != 0) {
    23132338                return map_nt_error_from_unix(errno);
    23142339        }
     
    23962421                 FILE_OPEN,             /* create_disposition*/
    23972422                 FILE_NON_DIRECTORY_FILE, /* create_options */
    2398                  FILE_ATTRIBUTE_NORMAL, /* file_attributes */
     2423                                        /* file_attributes */
     2424                 posix_paths ? FILE_FLAG_POSIX_SEMANTICS|0777 :
     2425                                FILE_ATTRIBUTE_NORMAL,
    23992426                 0,                     /* oplock_request */
    24002427                 0,                     /* allocation_size */
  • branches/samba-3.3.x/source/utils/net.h

    r224 r342  
    158158#define NET_FLAGS_SIGN                          0x00000040      /* sign RPC connection */
    159159#define NET_FLAGS_SEAL                          0x00000080      /* seal RPC connection */
     160#define NET_FLAGS_TCP                           0x00000100      /* use ncacn_ip_tcp */
    160161
    161162/* net share operation modes */
  • branches/samba-3.3.x/source/utils/net_join.c

    r206 r342  
    3535int net_join(struct net_context *c, int argc, const char **argv)
    3636{
    37         if (argc < 1)
    38                 return net_join_usage(c, argc, argv);
    39 
    40         if (StrCaseCmp(argv[0], "HELP") == 0) {
     37        if ((argc > 0) && (StrCaseCmp(argv[0], "HELP") == 0)) {
    4138                net_join_usage(c, argc, argv);
    4239                return 0;
  • branches/samba-3.3.x/source/utils/net_rpc.c

    r309 r342  
    158158                        /* Always try and create an schannel netlogon pipe. */
    159159                        nt_status = cli_rpc_pipe_open_schannel(
    160                                 cli, interface,
     160                                cli, interface, NCACN_NP,
    161161                                PIPE_AUTH_LEVEL_PRIVACY, domain_name,
    162162                                &pipe_hnd);
     
    170170                                nt_status = cli_rpc_pipe_open_ntlmssp(
    171171                                        cli, interface,
     172                                        (conn_flags & NET_FLAGS_TCP) ?
     173                                        NCACN_IP_TCP : NCACN_NP,
    172174                                        PIPE_AUTH_LEVEL_PRIVACY,
    173175                                        lp_workgroup(), c->opt_user_name,
     
    797799                                  argv[0],
    798800                                  0,
    799                                   (uint8_t **)&u0,
     801                                  (uint8_t **)(void *)&u0,
    800802                                  (uint32_t)-1,
    801803                                  &entries_read,
     
    29972999        status = NetShareEnum(c->opt_host,
    29983000                              level,
    2999                               (uint8_t **)&i1,
     3001                              (uint8_t **)(void *)&i1,
    30003002                              (uint32_t)-1,
    30013003                              &entries_read,
     
    47734775                             username,
    47744776                             3,
    4775                              (uint8_t **)&i3,
     4777                             (uint8_t **)(void *)&i3,
    47764778                             preferred_len,
    47774779                             &entries_read,
  • branches/samba-3.3.x/source/utils/net_rpc_join.c

    r224 r342  
    101101
    102102        ntret = cli_rpc_pipe_open_schannel_with_key(
    103                 cli, &ndr_table_netlogon.syntax_id, PIPE_AUTH_LEVEL_PRIVACY,
     103                cli, &ndr_table_netlogon.syntax_id, NCACN_NP,
     104                PIPE_AUTH_LEVEL_PRIVACY,
    104105                domain, netlogon_pipe->dc, &pipe_hnd);
    105106
     
    420421
    421422                result = cli_rpc_pipe_open_schannel_with_key(
    422                         cli, &ndr_table_netlogon.syntax_id,
     423                        cli, &ndr_table_netlogon.syntax_id, NCACN_NP,
    423424                        PIPE_AUTH_LEVEL_PRIVACY, domain, pipe_hnd->dc,
    424425                        &netlogon_schannel_pipe);
  • branches/samba-3.3.x/source/utils/net_rpc_samsync.c

    r206 r342  
    503503        } else {
    504504                ret = run_rpc_command(c, cli, &ndr_table_drsuapi.syntax_id,
    505                                       NET_FLAGS_SEAL,
     505                                      NET_FLAGS_SEAL | NET_FLAGS_TCP,
    506506                                      rpc_vampire_keytab_ds_internals, argc, argv);
    507507        }
  • branches/samba-3.3.x/source/winbindd/winbindd.c

    r274 r342  
    848848        message_dispatch(winbind_messaging_context());
    849849
    850         run_events(winbind_event_context(), 0, NULL, NULL);
     850        if (run_events(winbind_event_context(), 0, NULL, NULL)) {
     851                return;
     852        }
    851853
    852854        /* refresh the trusted domain cache */
     
    928930                if (FD_ISSET(ev->fd, &w_fds))
    929931                        flags |= EVENT_FD_WRITE;
    930                 if (flags)
     932                if (flags) {
    931933                        ev->handler(ev, flags);
     934                        return;
     935                }
    932936                ev = next;
    933937        }
  • branches/samba-3.3.x/source/winbindd/winbindd.h

    r206 r342  
    123123
    124124        struct rpc_pipe_client *lsa_pipe;
     125        struct rpc_pipe_client *lsa_pipe_tcp;
    125126        POLICY_HND lsa_policy;
    126127
     
    183184                                  * we don't have to try _ex every time. */
    184185
     186        bool can_do_ncacn_ip_tcp;
     187
    185188        /* Lookup methods for this domain (LDAP or RPC) */
    186189        struct winbindd_methods *methods;
  • branches/samba-3.3.x/source/winbindd/winbindd_ads.c

    r206 r342  
    978978        size_t num_members = 0;
    979979        ads_control args;
    980         struct rpc_pipe_client *cli;
    981         POLICY_HND lsa_policy;
    982980        DOM_SID *sid_mem_nocache = NULL;
    983981        char **names_nocache = NULL;
     
    11241122        if (num_nocache > 0) {
    11251123
    1126                 status = cm_connect_lsa(domain, tmp_ctx, &cli, &lsa_policy);
    1127 
    1128                 if (!NT_STATUS_IS_OK(status)) {
    1129                         goto done;
    1130                 }
    1131 
    1132                 status = rpccli_lsa_lookup_sids(cli, tmp_ctx,
    1133                                                 &lsa_policy,
    1134                                                 num_nocache,
    1135                                                 sid_mem_nocache,
    1136                                                 &domains_nocache,
    1137                                                 &names_nocache,
    1138                                                 &name_types_nocache);
     1124                status = winbindd_lookup_sids(tmp_ctx,
     1125                                              domain,
     1126                                              num_nocache,
     1127                                              sid_mem_nocache,
     1128                                              &domains_nocache,
     1129                                              &names_nocache,
     1130                                              &name_types_nocache);
    11391131
    11401132                if (!(NT_STATUS_IS_OK(status) ||
     
    11451137                                  "- retrying...\n", nt_errstr(status)));
    11461138
    1147                         status = cm_connect_lsa(domain, tmp_ctx, &cli,
    1148                                                 &lsa_policy);
    1149 
    1150                         if (!NT_STATUS_IS_OK(status)) {
    1151                                 goto done;
    1152                         }
    1153 
    1154                         status = rpccli_lsa_lookup_sids(cli, tmp_ctx,
    1155                                                         &lsa_policy,
    1156                                                         num_nocache,
    1157                                                         sid_mem_nocache,
    1158                                                         &domains_nocache,
    1159                                                         &names_nocache,
    1160                                                         &name_types_nocache);
     1139                        status = winbindd_lookup_sids(tmp_ctx,
     1140                                                      domain,
     1141                                                      num_nocache,
     1142                                                      sid_mem_nocache,
     1143                                                      &domains_nocache,
     1144                                                      &names_nocache,
     1145                                                      &name_types_nocache);
    11611146                }
    11621147
  • branches/samba-3.3.x/source/winbindd/winbindd_cm.c

    r223 r342  
    858858                                                              machine_password,
    859859                                                              lp_workgroup(),
    860                                                               domain->name);
     860                                                              domain->alt_name);
    861861
    862862                        if (!ADS_ERR_OK(ads_status)) {
     
    15431543        }
    15441544
     1545        if (conn->lsa_pipe_tcp != NULL) {
     1546                TALLOC_FREE(conn->lsa_pipe_tcp);
     1547                /* Ok, it must be dead. Drop timeout to 0.5 sec. */
     1548                if (conn->cli) {
     1549                        cli_set_timeout(conn->cli, 500);
     1550                }
     1551        }
     1552
    15451553        if (conn->netlogon_pipe != NULL) {
    15461554                TALLOC_FREE(conn->netlogon_pipe);
     
    19171925                  domain->name, domain->active_directory ? "" : "NOT "));
    19181926
     1927        domain->can_do_ncacn_ip_tcp = domain->active_directory;
     1928
    19191929        TALLOC_FREE(cli);
    19201930
     
    20392049        result = cli_rpc_pipe_open_spnego_ntlmssp(conn->cli,
    20402050                                                  &ndr_table_samr.syntax_id,
     2051                                                  NCACN_NP,
    20412052                                                  PIPE_AUTH_LEVEL_PRIVACY,
    20422053                                                  domain_name,
     
    20822093        }
    20832094        result = cli_rpc_pipe_open_schannel_with_key
    2084                 (conn->cli, &ndr_table_samr.syntax_id, PIPE_AUTH_LEVEL_PRIVACY,
     2095                (conn->cli, &ndr_table_samr.syntax_id, NCACN_NP,
     2096                PIPE_AUTH_LEVEL_PRIVACY,
    20852097                 domain->name, p_dcinfo, &conn->samr_pipe);
    20862098
     
    21372149 done:
    21382150
    2139         if (!NT_STATUS_IS_OK(result)) {
     2151        if (NT_STATUS_EQUAL(result, NT_STATUS_ACCESS_DENIED)) {
     2152                /*
     2153                 * if we got access denied, we might just have no access rights
     2154                 * to talk to the remote samr server server (e.g. when we are a
     2155                 * PDC and we are connecting a w2k8 pdc via an interdomain
     2156                 * trust). In that case do not invalidate the whole connection
     2157                 * stack
     2158                 */
     2159                TALLOC_FREE(conn->samr_pipe);
     2160                ZERO_STRUCT(conn->sam_domain_handle);
     2161                return result;
     2162        } else if (!NT_STATUS_IS_OK(result)) {
    21402163                invalidate_cm_connection(conn);
    21412164                return result;
     
    21472170        SAFE_FREE(machine_account);
    21482171        return result;
     2172}
     2173
     2174/**********************************************************************
     2175 open an schanneld ncacn_ip_tcp connection to LSA
     2176***********************************************************************/
     2177
     2178NTSTATUS cm_connect_lsa_tcp(struct winbindd_domain *domain,
     2179                            TALLOC_CTX *mem_ctx,
     2180                            struct rpc_pipe_client **cli)
     2181{
     2182        struct winbindd_cm_conn *conn;
     2183        NTSTATUS status;
     2184
     2185        DEBUG(10,("cm_connect_lsa_tcp\n"));
     2186
     2187        status = init_dc_connection(domain);
     2188        if (!NT_STATUS_IS_OK(status)) {
     2189                return status;
     2190        }
     2191
     2192        conn = &domain->conn;
     2193
     2194        if (conn->lsa_pipe_tcp &&
     2195            conn->lsa_pipe_tcp->transport_type == NCACN_IP_TCP &&
     2196            conn->lsa_pipe_tcp->auth->auth_level == PIPE_AUTH_LEVEL_PRIVACY) {
     2197                goto done;
     2198        }
     2199
     2200        TALLOC_FREE(conn->lsa_pipe_tcp);
     2201
     2202        status = cli_rpc_pipe_open_schannel(conn->cli,
     2203                                            &ndr_table_lsarpc.syntax_id,
     2204                                            NCACN_IP_TCP,
     2205                                            PIPE_AUTH_LEVEL_PRIVACY,
     2206                                            domain->name,
     2207                                            &conn->lsa_pipe_tcp);
     2208        if (!NT_STATUS_IS_OK(status)) {
     2209                DEBUG(10,("cli_rpc_pipe_open_schannel failed: %s\n",
     2210                        nt_errstr(status)));
     2211                goto done;
     2212        }
     2213
     2214 done:
     2215        if (!NT_STATUS_IS_OK(status)) {
     2216                TALLOC_FREE(conn->lsa_pipe_tcp);
     2217                return status;
     2218        }
     2219
     2220        *cli = conn->lsa_pipe_tcp;
     2221
     2222        return status;
    21492223}
    21502224
     
    21792253         * authenticated LSA pipe with sign & seal. */
    21802254        result = cli_rpc_pipe_open_spnego_ntlmssp
    2181                 (conn->cli, &ndr_table_lsarpc.syntax_id,
     2255                (conn->cli, &ndr_table_lsarpc.syntax_id, NCACN_NP,
    21822256                 PIPE_AUTH_LEVEL_PRIVACY,
    21832257                 conn->cli->domain, conn->cli->user_name, conn_pwd,
     
    22202294        }
    22212295        result = cli_rpc_pipe_open_schannel_with_key
    2222                 (conn->cli, &ndr_table_lsarpc.syntax_id,
     2296                (conn->cli, &ndr_table_lsarpc.syntax_id, NCACN_NP,
    22232297                 PIPE_AUTH_LEVEL_PRIVACY,
    22242298                 domain->name, p_dcinfo, &conn->lsa_pipe);
     
    23672441
    23682442        result = cli_rpc_pipe_open_schannel_with_key(
    2369                 conn->cli, &ndr_table_netlogon.syntax_id,
     2443                conn->cli, &ndr_table_netlogon.syntax_id, NCACN_NP,
    23702444                PIPE_AUTH_LEVEL_PRIVACY, domain->name, netlogon_pipe->dc,
    23712445                &conn->netlogon_pipe);
  • branches/samba-3.3.x/source/winbindd/winbindd_proto.h

    r222 r342  
    7474/* The following definitions come from winbindd/winbindd_ads.c  */
    7575
     76/* The following definitions come from winbindd/winbindd_rpc.c  */
     77
     78NTSTATUS winbindd_lookup_sids(TALLOC_CTX *mem_ctx,
     79                              struct winbindd_domain *domain,
     80                              uint32_t num_sids,
     81                              const struct dom_sid *sids,
     82                              char ***domains,
     83                              char ***names,
     84                              enum lsa_SidType **types);
     85NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
     86                               struct winbindd_domain *domain,
     87                               uint32_t num_names,
     88                               const char **names,
     89                               const char ***domains,
     90                               struct dom_sid **sids,
     91                               enum lsa_SidType **types);
    7692
    7793/* The following definitions come from winbindd/winbindd_async.c  */
     
    218234NTSTATUS cm_connect_lsa(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
    219235                        struct rpc_pipe_client **cli, POLICY_HND *lsa_policy);
     236NTSTATUS cm_connect_lsa_tcp(struct winbindd_domain *domain,
     237                            TALLOC_CTX *mem_ctx,
     238                            struct rpc_pipe_client **cli);
    220239NTSTATUS cm_connect_netlogon(struct winbindd_domain *domain,
    221240                             struct rpc_pipe_client **cli);
  • branches/samba-3.3.x/source/winbindd/winbindd_rpc.c

    r223 r342  
    278278        enum lsa_SidType *types = NULL;
    279279        char *full_name = NULL;
    280         struct rpc_pipe_client *cli;
    281         POLICY_HND lsa_policy;
    282280        NTSTATUS name_map_status = NT_STATUS_UNSUCCESSFUL;
    283281        char *mapped_name = NULL;
     
    311309                 full_name?full_name:"", domain_name ));
    312310
    313         result = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
    314         if (!NT_STATUS_IS_OK(result))
    315                 return result;
    316 
    317         result = rpccli_lsa_lookup_names(cli, mem_ctx, &lsa_policy, 1,
    318                                          (const char**) &full_name, NULL, 1, &sids, &types);
    319        
     311        result = winbindd_lookup_names(mem_ctx, domain, 1,
     312                                       (const char **)&full_name, NULL,
     313                                       &sids, &types);
    320314        if (!NT_STATUS_IS_OK(result))
    321315                return result;
     
    343337        enum lsa_SidType *types = NULL;
    344338        NTSTATUS result;
    345         struct rpc_pipe_client *cli;
    346         POLICY_HND lsa_policy;
    347339        NTSTATUS name_map_status = NT_STATUS_UNSUCCESSFUL;
    348340        char *mapped_name = NULL;
     
    351343                 domain->name ));
    352344
    353         result = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
     345        result = winbindd_lookup_sids(mem_ctx,
     346                                      domain,
     347                                      1,
     348                                      sid,
     349                                      &domains,
     350                                      &names,
     351                                      &types);
    354352        if (!NT_STATUS_IS_OK(result)) {
    355                 DEBUG(2,("msrpc_sid_to_name: cm_connect_lsa() failed (%s)\n",
    356                          nt_errstr(result)));           
     353                DEBUG(2,("msrpc_sid_to_name: failed to lookup sids: %s\n",
     354                        nt_errstr(result)));
    357355                return result;
    358356        }
    359357       
    360 
    361         result = rpccli_lsa_lookup_sids(cli, mem_ctx, &lsa_policy,
    362                                         1, sid, &domains, &names, &types);
    363         if (!NT_STATUS_IS_OK(result)) {         
    364                 DEBUG(2,("msrpc_sid_to_name: rpccli_lsa_lookup_sids()  failed (%s)\n",
    365                          nt_errstr(result)));           
    366                 return result;
    367         }
    368358
    369359        *type = (enum lsa_SidType)types[0];
     
    396386        char **domains;
    397387        NTSTATUS result;
    398         struct rpc_pipe_client *cli;
    399         POLICY_HND lsa_policy;
    400388        DOM_SID *sids;
    401389        size_t i;
     
    419407        }
    420408
    421         result = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
    422         if (!NT_STATUS_IS_OK(result)) {
    423                 return result;
    424         }
    425 
    426         result = rpccli_lsa_lookup_sids(cli, mem_ctx, &lsa_policy,
    427                                         num_rids, sids, &domains,
    428                                         names, types);
     409        result = winbindd_lookup_sids(mem_ctx,
     410                                      domain,
     411                                      num_rids,
     412                                      sids,
     413                                      &domains,
     414                                      names,
     415                                      types);
     416
    429417        if (!NT_STATUS_IS_OK(result) &&
    430418            !NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED)) {
     
    11861174}
    11871175
     1176typedef NTSTATUS (*lookup_sids_fn_t)(struct rpc_pipe_client *cli,
     1177                                     TALLOC_CTX *mem_ctx,
     1178                                     struct policy_handle *pol,
     1179                                     int num_sids,
     1180                                     const DOM_SID *sids,
     1181                                     char ***pdomains,
     1182                                     char ***pnames,
     1183                                     enum lsa_SidType **ptypes);
     1184
     1185NTSTATUS winbindd_lookup_sids(TALLOC_CTX *mem_ctx,
     1186                              struct winbindd_domain *domain,
     1187                              uint32_t num_sids,
     1188                              const struct dom_sid *sids,
     1189                              char ***domains,
     1190                              char ***names,
     1191                              enum lsa_SidType **types)
     1192{
     1193        NTSTATUS status;
     1194        struct rpc_pipe_client *cli = NULL;
     1195        struct policy_handle lsa_policy;
     1196        unsigned int orig_timeout;
     1197        lookup_sids_fn_t lookup_sids_fn = rpccli_lsa_lookup_sids;
     1198
     1199        if (domain->can_do_ncacn_ip_tcp) {
     1200                status = cm_connect_lsa_tcp(domain, mem_ctx, &cli);
     1201                if (NT_STATUS_IS_OK(status)) {
     1202                        lookup_sids_fn = rpccli_lsa_lookup_sids3;
     1203                        goto lookup;
     1204                }
     1205                domain->can_do_ncacn_ip_tcp = false;
     1206        }
     1207        status = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
     1208
     1209        if (!NT_STATUS_IS_OK(status)) {
     1210                return status;
     1211        }
     1212
     1213 lookup:
     1214        /*
     1215         * This call can take a long time
     1216         * allow the server to time out.
     1217         * 35 seconds should do it.
     1218         */
     1219        orig_timeout = rpccli_set_timeout(cli, 35000);
     1220
     1221        status = lookup_sids_fn(cli,
     1222                                mem_ctx,
     1223                                &lsa_policy,
     1224                                num_sids,
     1225                                sids,
     1226                                domains,
     1227                                names,
     1228                                types);
     1229
     1230        /* And restore our original timeout. */
     1231        rpccli_set_timeout(cli, orig_timeout);
     1232
     1233        if (!NT_STATUS_IS_OK(status)) {
     1234                return status;
     1235        }
     1236
     1237        return status;
     1238}
     1239
     1240typedef NTSTATUS (*lookup_names_fn_t)(struct rpc_pipe_client *cli,
     1241                                      TALLOC_CTX *mem_ctx,
     1242                                      struct policy_handle *pol,
     1243                                      int num_names,
     1244                                      const char **names,
     1245                                      const char ***dom_names,
     1246                                      int level,
     1247                                      struct dom_sid **sids,
     1248                                      enum lsa_SidType **types);
     1249
     1250NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
     1251                               struct winbindd_domain *domain,
     1252                               uint32_t num_names,
     1253                               const char **names,
     1254                               const char ***domains,
     1255                               struct dom_sid **sids,
     1256                               enum lsa_SidType **types)
     1257{
     1258        NTSTATUS status;
     1259        struct rpc_pipe_client *cli = NULL;
     1260        struct policy_handle lsa_policy;
     1261        unsigned int orig_timeout;
     1262        lookup_names_fn_t lookup_names_fn = rpccli_lsa_lookup_names;
     1263
     1264        if (domain->can_do_ncacn_ip_tcp) {
     1265                status = cm_connect_lsa_tcp(domain, mem_ctx, &cli);
     1266                if (NT_STATUS_IS_OK(status)) {
     1267                        lookup_names_fn = rpccli_lsa_lookup_names4;
     1268                        goto lookup;
     1269                }
     1270                domain->can_do_ncacn_ip_tcp = false;
     1271        }
     1272        status = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
     1273
     1274        if (!NT_STATUS_IS_OK(status)) {
     1275                return status;
     1276        }
     1277
     1278 lookup:
     1279
     1280        /*
     1281         * This call can take a long time
     1282         * allow the server to time out.
     1283         * 35 seconds should do it.
     1284         */
     1285        orig_timeout = rpccli_set_timeout(cli, 35000);
     1286
     1287        status = lookup_names_fn(cli,
     1288                                 mem_ctx,
     1289                                 &lsa_policy,
     1290                                 num_names,
     1291                                 (const char **) names,
     1292                                 domains,
     1293                                 1,
     1294                                 sids,
     1295                                 types);
     1296
     1297        /* And restore our original timeout. */
     1298        rpccli_set_timeout(cli, orig_timeout);
     1299
     1300        if (!NT_STATUS_IS_OK(status)) {
     1301                return status;
     1302        }
     1303
     1304        return status;
     1305}
    11881306
    11891307/* the rpc backend methods are exposed via this structure */
Note: See TracChangeset for help on using the changeset viewer.