Ignore:
Timestamp:
May 20, 2009, 6:46:53 PM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.2 branch to 3.2.4

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

Legend:

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

    r149 r204  
    320320        struct cli_state *cli = (struct cli_state *)p;
    321321        struct cli_request *req;
     322        NTSTATUS status;
    322323
    323324        DEBUG(11, ("cli_state_handler called with flags %d\n", flags));
     
    332333                        DEBUG(10, ("ioctl(FIONREAD) failed: %s\n",
    333334                                   strerror(errno)));
     335                        status = map_nt_error_from_unix(errno);
    334336                        goto sock_error;
    335337                }
     
    337339                if (available == 0) {
    338340                        /* EOF */
     341                        status = NT_STATUS_END_OF_FILE;
    339342                        goto sock_error;
    340343                }
     
    345348                if (new_size < old_size) {
    346349                        /* wrap */
     350                        status = NT_STATUS_UNEXPECTED_IO_ERROR;
    347351                        goto sock_error;
    348352                }
     
    352356                if (tmp == NULL) {
    353357                        /* nomem */
     358                        status = NT_STATUS_NO_MEMORY;
    354359                        goto sock_error;
    355360                }
     
    359364                if (res == -1) {
    360365                        DEBUG(10, ("recv failed: %s\n", strerror(errno)));
     366                        status = map_nt_error_from_unix(errno);
    361367                        goto sock_error;
    362368                }
     
    403409
    404410                if (sent < 0) {
     411                        status = map_nt_error_from_unix(errno);
    405412                        goto sock_error;
    406413                }
     
    416423 sock_error:
    417424        for (req = cli->outstanding_requests; req; req = req->next) {
    418                 req->async->state = ASYNC_REQ_ERROR;
    419                 req->async->status = map_nt_error_from_unix(errno);
     425                async_req_error(req->async, status);
    420426        }
    421427        TALLOC_FREE(cli->fd_event);
  • branches/samba-3.2.x/source/libsmb/clikrb5.c

    r149 r204  
    744744                                                &in_data );
    745745                if (retval) {
    746                         DEBUG( 1, ("ads_krb5_get_fwd_ticket failed (%s)\n", error_message( retval ) ) );
    747                         goto cleanup_creds;
    748                 }
    749 
    750                 if (retval) {
    751                         DEBUG( 1, ("krb5_auth_con_set_req_cksumtype failed (%s)\n",
    752                                 error_message( retval ) ) );
    753                         goto cleanup_creds;
    754                 }
    755 
     746                        DEBUG( 3, ("ads_krb5_get_fwd_ticket failed (%s)\n", error_message( retval ) ) );
     747
     748                        /*
     749                         * This is not fatal. Delete the *auth_context and continue
     750                         * with krb5_mk_req_extended to get a non-forwardable ticket.
     751                         */
     752
     753                        if (in_data.data) {
     754                                free( in_data.data );
     755                                in_data.data = NULL;
     756                                in_data.length = 0;
     757                        }
     758                        krb5_auth_con_free(context, *auth_context);
     759                        *auth_context = NULL;
     760                }
    756761        }
    757762#endif
  • branches/samba-3.2.x/source/libsmb/libsmb_xattr.c

    r133 r204  
    747747        uint16 mode = 0;
    748748        SMB_INO_T ino = 0;
    749         struct cli_state *cli = srv->cli;
     749        struct cli_state *cli = srv->cli;
    750750        struct {
    751751                const char * create_time_attr;
     
    884884         */
    885885        if (ipc_cli && (all || some_nt || all_nt_acls)) {
     886                char *targetpath = NULL;
     887                struct cli_state *targetcli = NULL;
     888
    886889                /* Point to the portion after "system.nt_sec_desc." */
    887890                name += 19;     /* if (all) this will be invalid but unused */
    888                
     891
     892                if (!cli_resolve_path(ctx, "", cli, filename,
     893                                &targetcli, &targetpath)) {
     894                        DEBUG(5, ("cacl_get Could not resolve %s\n",
     895                                filename));
     896                        errno = ENOENT;
     897                        return -1;
     898                }
     899
    889900                /* ... then obtain any NT attributes which were requested */
    890                 fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ);
    891                
     901                fnum = cli_nt_create(targetcli, targetpath, CREATE_ACCESS_READ);
     902
    892903                if (fnum == -1) {
    893                         DEBUG(5, ("cacl_get failed to open %s: %s\n",
    894                                   filename, cli_errstr(cli)));
    895                         errno = 0;
    896                         return -1;
    897                 }
    898                
    899                 sd = cli_query_secdesc(cli, fnum, ctx);
    900                
     904                        DEBUG(5, ("cacl_get failed to open %s: %s\n",
     905                                targetpath, cli_errstr(targetcli)));
     906                        errno = 0;
     907                        return -1;
     908                }
     909
     910                sd = cli_query_secdesc(targetcli, fnum, ctx);
     911
    901912                if (!sd) {
    902913                        DEBUG(5,
     
    905916                        return -1;
    906917                }
    907                
    908                 cli_close(cli, fnum);
    909                
     918
     919                cli_close(targetcli, fnum);
     920
    910921                if (! exclude_nt_revision) {
    911922                        if (all || all_nt) {
     
    15041515        char *p;
    15051516        bool numeric = True;
    1506        
     1517        char *targetpath = NULL;
     1518        struct cli_state *targetcli = NULL;
     1519
    15071520        /* the_acl will be null for REMOVE_ALL operations */
    15081521        if (the_acl) {
     
    15331546                return -1;
    15341547        }
    1535        
     1548
     1549        if (!cli_resolve_path(ctx, "", cli, filename,
     1550                                &targetcli, &targetpath)) {
     1551                DEBUG(5,("cacl_set: Could not resolve %s\n", filename));
     1552                errno = ENOENT;
     1553                return -1;
     1554        }
     1555
    15361556        /* The desired access below is the only one I could find that works
    15371557           with NT4, W2KP and Samba */
    1538        
    1539         fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ);
    1540        
     1558
     1559        fnum = cli_nt_create(targetcli, targetpath, CREATE_ACCESS_READ);
     1560
    15411561        if (fnum == -1) {
    15421562                DEBUG(5, ("cacl_set failed to open %s: %s\n",
    1543                           filename, cli_errstr(cli)));
     1563                          targetpath, cli_errstr(targetcli)));
    15441564                errno = 0;
    15451565                return -1;
    15461566        }
    1547        
    1548         old = cli_query_secdesc(cli, fnum, ctx);
    1549        
     1567
     1568        old = cli_query_secdesc(targetcli, fnum, ctx);
     1569
    15501570        if (!old) {
    15511571                DEBUG(5, ("cacl_set Failed to query old descriptor\n"));
     
    15531573                return -1;
    15541574        }
    1555        
    1556         cli_close(cli, fnum);
    1557        
     1575
     1576        cli_close(targetcli, fnum);
     1577
    15581578        switch (mode) {
    15591579        case SMBC_XATTR_MODE_REMOVE_ALL:
     
    15611581                dacl = old->dacl;
    15621582                break;
    1563                
     1583
    15641584        case SMBC_XATTR_MODE_REMOVE:
    15651585                for (i=0;sd->dacl && i<sd->dacl->num_aces;i++) {
    15661586                        bool found = False;
    1567                        
     1587
    15681588                        for (j=0;old->dacl && j<old->dacl->num_aces;j++) {
    15691589                                if (sec_ace_equal(&sd->dacl->aces[i],
     
    16431663                           owner_sid, group_sid, NULL, dacl, &sd_size);
    16441664       
    1645         fnum = cli_nt_create(cli, filename,
     1665        fnum = cli_nt_create(targetcli, targetpath,
    16461666                             WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS);
    16471667       
    16481668        if (fnum == -1) {
    16491669                DEBUG(5, ("cacl_set failed to open %s: %s\n",
    1650                           filename, cli_errstr(cli)));
     1670                          targetpath, cli_errstr(targetcli)));
    16511671                errno = 0;
    16521672                return -1;
    16531673        }
    16541674       
    1655         if (!cli_set_secdesc(cli, fnum, sd)) {
    1656                 DEBUG(5, ("ERROR: secdesc set failed: %s\n", cli_errstr(cli)));
     1675        if (!cli_set_secdesc(targetcli, fnum, sd)) {
     1676                DEBUG(5, ("ERROR: secdesc set failed: %s\n",
     1677                        cli_errstr(targetcli)));
    16571678                ret = -1;
    16581679        }
     
    16611682       
    16621683failed:
    1663         cli_close(cli, fnum);
     1684        cli_close(targetcli, fnum);
    16641685       
    16651686        if (err != 0) {
  • branches/samba-3.2.x/source/libsmb/samlogon_cache.c

    r136 r204  
    6060***********************************************************************/
    6161
    62 void netsamlogon_clear_cached_user(TDB_CONTEXT *tdb, struct netr_SamInfo3 *info3)
    63 {
    64         bool got_tdb = false;
    65         DOM_SID sid;
    66         fstring key_str, sid_string;
    67 
    68         /* We may need to call this function from smbd which will not have
    69            winbindd_cache.tdb open.  Open the tdb if a NULL is passed. */
    70 
    71         if (!tdb) {
    72                 tdb = tdb_open_log(lock_path("winbindd_cache.tdb"),
    73                                    WINBINDD_CACHE_TDB_DEFAULT_HASH_SIZE,
    74                                    TDB_DEFAULT, O_RDWR, 0600);
    75                 if (!tdb) {
    76                         DEBUG(5, ("netsamlogon_clear_cached_user: failed to open cache\n"));
    77                         return;
    78                 }
    79                 got_tdb = true;
    80         }
    81 
    82         sid_copy(&sid, info3->base.domain_sid);
    83         sid_append_rid(&sid, info3->base.rid);
    84 
    85         /* Clear U/SID cache entry */
    86 
    87         fstr_sprintf(key_str, "U/%s", sid_to_fstring(sid_string, &sid));
    88 
    89         DEBUG(10, ("netsamlogon_clear_cached_user: clearing %s\n", key_str));
    90 
    91         tdb_delete(tdb, string_tdb_data(key_str));
    92 
    93         /* Clear UG/SID cache entry */
    94 
    95         fstr_sprintf(key_str, "UG/%s", sid_to_fstring(sid_string, &sid));
    96 
    97         DEBUG(10, ("netsamlogon_clear_cached_user: clearing %s\n", key_str));
    98 
    99         tdb_delete(tdb, string_tdb_data(key_str));
    100 
    101         if (got_tdb) {
    102                 tdb_close(tdb);
    103         }
     62void netsamlogon_clear_cached_user(struct netr_SamInfo3 *info3)
     63{
     64        DOM_SID user_sid;
     65        fstring keystr, tmp;
     66
     67        if (!info3) {
     68                return;
     69        }
     70
     71        if (!netsamlogon_cache_init()) {
     72                DEBUG(0,("netsamlogon_clear_cached_user: cannot open "
     73                        "%s for write!\n",
     74                        NETSAMLOGON_TDB));
     75                return;
     76        }
     77        sid_copy(&user_sid, info3->base.domain_sid);
     78        sid_append_rid(&user_sid, info3->base.rid);
     79
     80        /* Prepare key as DOMAIN-SID/USER-RID string */
     81        slprintf(keystr, sizeof(keystr), "%s", sid_to_fstring(tmp, &user_sid));
     82
     83        DEBUG(10,("netsamlogon_clear_cached_user: SID [%s]\n", keystr));
     84
     85        tdb_delete_bystring(netsamlogon_tdb, keystr);
    10486}
    10587
  • branches/samba-3.2.x/source/libsmb/trusts_util.c

    r133 r204  
    3232static NTSTATUS just_change_the_password(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
    3333                                         const unsigned char orig_trust_passwd_hash[16],
     34                                         const char *new_trust_pwd_cleartext,
    3435                                         const unsigned char new_trust_passwd_hash[16],
    3536                                         uint32 sec_channel_type)
    3637{
    3738        NTSTATUS result;
    38 
    39         /* Check if the netlogon pipe is open using schannel. If so we
    40            already have valid creds. If not we must set them up. */
    41 
    42         if (cli->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) {
    43                 uint32_t neg_flags = NETLOGON_NEG_AUTH2_ADS_FLAGS;
    44 
    45                 result = rpccli_netlogon_setup_creds(cli,
    46                                         cli->cli->desthost, /* server name */
    47                                         lp_workgroup(), /* domain */
    48                                         global_myname(), /* client name */
    49                                         global_myname(), /* machine account name */
    50                                         orig_trust_passwd_hash,
    51                                         sec_channel_type,
    52                                         &neg_flags);
    53 
    54                 if (!NT_STATUS_IS_OK(result)) {
    55                         DEBUG(3,("just_change_the_password: unable to setup creds (%s)!\n",
    56                                  nt_errstr(result)));
    57                         return result;
     39        uint32_t neg_flags = NETLOGON_NEG_AUTH2_ADS_FLAGS;
     40
     41        result = rpccli_netlogon_setup_creds(cli,
     42                                             cli->cli->desthost, /* server name */
     43                                             lp_workgroup(), /* domain */
     44                                             global_myname(), /* client name */
     45                                             global_myname(), /* machine account name */
     46                                             orig_trust_passwd_hash,
     47                                             sec_channel_type,
     48                                             &neg_flags);
     49
     50        if (!NT_STATUS_IS_OK(result)) {
     51                DEBUG(3,("just_change_the_password: unable to setup creds (%s)!\n",
     52                         nt_errstr(result)));
     53                return result;
     54        }
     55
     56        if (neg_flags & NETLOGON_NEG_PASSWORD_SET2) {
     57
     58                struct netr_Authenticator clnt_creds, srv_cred;
     59                struct netr_CryptPassword new_password;
     60                struct samr_CryptPassword password_buf;
     61
     62                netlogon_creds_client_step(cli->dc, &clnt_creds);
     63
     64                encode_pw_buffer(password_buf.data, new_trust_pwd_cleartext, STR_UNICODE);
     65
     66                SamOEMhash(password_buf.data, cli->dc->sess_key, 516);
     67                memcpy(new_password.data, password_buf.data, 512);
     68                new_password.length = IVAL(password_buf.data, 512);
     69
     70                result = rpccli_netr_ServerPasswordSet2(cli, mem_ctx,
     71                                                       cli->dc->remote_machine,
     72                                                       cli->dc->mach_acct,
     73                                                       sec_channel_type,
     74                                                       global_myname(),
     75                                                       &clnt_creds,
     76                                                       &srv_cred,
     77                                                       &new_password);
     78
     79                /* Always check returned credentials. */
     80                if (!netlogon_creds_client_check(cli->dc, &srv_cred.cred)) {
     81                        DEBUG(0,("rpccli_netr_ServerPasswordSet2: "
     82                                "credentials chain check failed\n"));
     83                        return NT_STATUS_ACCESS_DENIED;
    5884                }
    59         }
    60 
    61         {
     85
     86        } else {
     87
    6288                struct netr_Authenticator clnt_creds, srv_cred;
    6389                struct samr_Password new_password;
     
    119145        E_md4hash(new_trust_passwd, new_trust_passwd_hash);
    120146
    121         nt_status = just_change_the_password(cli, mem_ctx, orig_trust_passwd_hash,
    122                                              new_trust_passwd_hash, sec_channel_type);
     147        nt_status = just_change_the_password(cli, mem_ctx,
     148                                             orig_trust_passwd_hash,
     149                                             new_trust_passwd,
     150                                             new_trust_passwd_hash,
     151                                             sec_channel_type);
    123152       
    124153        if (NT_STATUS_IS_OK(nt_status)) {
Note: See TracChangeset for help on using the changeset viewer.