Ignore:
Timestamp:
Mar 11, 2009, 9:14:55 AM (16 years ago)
Author:
Paul Smedley
Message:

Add 'missing' 3.0.34 diffs

Location:
branches/samba-3.0/source/libsmb
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.0/source/libsmb/cliconnect.c

    r140 r165  
    539539#define BASE_SESSSETUP_BLOB_PACKET_SIZE (35 + 24 + 22)
    540540
    541 static BOOL cli_session_setup_blob(struct cli_state *cli, DATA_BLOB blob, DATA_BLOB session_key_krb5)
     541static BOOL cli_session_setup_blob(struct cli_state *cli, DATA_BLOB blob)
    542542{
    543543        int32 remaining = blob.length;
     
    563563                        remaining -= max_blob_size;
    564564                } else {
    565                         DATA_BLOB null_blob = data_blob(NULL, 0);
    566 
    567565                        send_blob.length = remaining;
    568566                        remaining = 0;
    569 
    570                         /* This is the last packet in the sequence - turn signing on. */
    571                         cli_simple_set_signing(cli, session_key_krb5, null_blob);
    572567                }
    573568
     
    617612        DATA_BLOB negTokenTarg;
    618613        DATA_BLOB session_key_krb5;
     614        DATA_BLOB null_blob = data_blob(NULL, 0);
     615        NTSTATUS nt_status;
     616        BOOL res;
    619617        int rc;
     618
     619        cli_temp_set_signing(cli);
    620620
    621621        DEBUG(2,("Doing kerberos session setup\n"));
     
    634634#endif
    635635
    636         if (!cli_session_setup_blob(cli, negTokenTarg, session_key_krb5)) {
    637                 data_blob_free(&negTokenTarg);
    638                 data_blob_free(&session_key_krb5);
    639                 return ADS_ERROR_NT(cli_nt_error(cli));
     636        if (!cli_session_setup_blob(cli, negTokenTarg)) {
     637                nt_status = cli_nt_error(cli);
     638                goto nt_error;
     639        }
     640
     641        if (cli_is_error(cli)) {
     642                nt_status = cli_nt_error(cli);
     643                if (NT_STATUS_IS_OK(nt_status)) {
     644                        nt_status = NT_STATUS_UNSUCCESSFUL;
     645                }
     646                goto nt_error;
    640647        }
    641648
    642649        cli_set_session_key(cli, session_key_krb5);
     650
     651        res = cli_simple_set_signing(cli, session_key_krb5, null_blob);
     652        if (res) {
     653                /* 'resign' the last message, so we get the right sequence numbers
     654                   for checking the first reply from the server */
     655                cli_calculate_sign_mac(cli);
     656
     657                if (!cli_check_sign_mac(cli)) {
     658                        nt_status = NT_STATUS_ACCESS_DENIED;
     659                        goto nt_error;
     660                }
     661        }
    643662
    644663        data_blob_free(&negTokenTarg);
    645664        data_blob_free(&session_key_krb5);
    646665
    647         if (cli_is_error(cli)) {
    648                 if (NT_STATUS_IS_OK(cli_nt_error(cli))) {
    649                         return ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL);
    650                 }
    651         }
    652         return ADS_ERROR_NT(cli_nt_error(cli));
     666        return ADS_ERROR_NT(NT_STATUS_OK);
     667
     668nt_error:
     669        data_blob_free(&negTokenTarg);
     670        data_blob_free(&session_key_krb5);
     671        cli->vuid = 0;
     672        return ADS_ERROR_NT(nt_status);
    653673}
    654674#endif  /* HAVE_KRB5 */
  • branches/samba-3.0/source/libsmb/libsmbclient.c

    r134 r165  
    45274527         */
    45284528        if (ipc_cli && (all || some_nt || all_nt_acls)) {
     4529                pstring targetpath;
     4530                struct cli_state *targetcli;
     4531
    45294532                /* Point to the portion after "system.nt_sec_desc." */
    45304533                name += 19;     /* if (all) this will be invalid but unused */
    45314534
     4535                if (!cli_resolve_path("", cli, filename,
     4536                                      &targetcli, targetpath))
     4537                {
     4538                        d_printf("Could not resolve %s\n", filename);
     4539                        return -1;
     4540                }
     4541
    45324542                /* ... then obtain any NT attributes which were requested */
    4533                 fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ);
     4543                fnum = cli_nt_create(targetcli, targetpath, CREATE_ACCESS_READ);
    45344544
    45354545                if (fnum == -1) {
    45364546                        DEBUG(5, ("cacl_get failed to open %s: %s\n",
    4537                                   filename, cli_errstr(cli)));
     4547                                  targetpath, cli_errstr(targetcli)));
    45384548                        errno = 0;
    45394549                        return -1;
    45404550                }
    45414551
    4542                 sd = cli_query_secdesc(cli, fnum, ctx);
     4552                sd = cli_query_secdesc(targetcli, fnum, ctx);
    45434553
    45444554                if (!sd) {
     
    45494559                }
    45504560
    4551                 cli_close(cli, fnum);
     4561                cli_close(targetcli, fnum);
    45524562
    45534563                if (! exclude_nt_revision) {
     
    51495159        BOOL numeric = True;
    51505160
     5161        pstring targetpath;
     5162        struct cli_state *targetcli;
     5163
    51515164        /* the_acl will be null for REMOVE_ALL operations */
    51525165        if (the_acl) {
     
    51785191        }
    51795192
     5193        if (!cli_resolve_path("", cli, filename,
     5194                              &targetcli, targetpath))
     5195        {
     5196                d_printf("Could not resolve %s\n", filename);
     5197                errno = ENOENT;
     5198                return -1;
     5199        }
     5200
    51805201        /* The desired access below is the only one I could find that works
    51815202           with NT4, W2KP and Samba */
    51825203
    5183         fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ);
     5204        fnum = cli_nt_create(targetcli, targetpath, CREATE_ACCESS_READ);
    51845205
    51855206        if (fnum == -1) {
    51865207                DEBUG(5, ("cacl_set failed to open %s: %s\n",
    5187                           filename, cli_errstr(cli)));
     5208                          targetpath, cli_errstr(targetcli)));
    51885209                errno = 0;
    51895210                return -1;
    51905211        }
    51915212
    5192         old = cli_query_secdesc(cli, fnum, ctx);
     5213        old = cli_query_secdesc(targetcli, fnum, ctx);
    51935214
    51945215        if (!old) {
     
    51985219        }
    51995220
    5200         cli_close(cli, fnum);
     5221        cli_close(targetcli, fnum);
    52015222
    52025223        switch (mode) {
     
    52875308                           owner_sid, group_sid, NULL, dacl, &sd_size);
    52885309
    5289         fnum = cli_nt_create(cli, filename,
     5310        fnum = cli_nt_create(targetcli, targetpath,
    52905311                             WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS);
    52915312
    52925313        if (fnum == -1) {
    52935314                DEBUG(5, ("cacl_set failed to open %s: %s\n",
    5294                           filename, cli_errstr(cli)));
     5315                          targetpath, cli_errstr(targetcli)));
    52955316                errno = 0;
    52965317                return -1;
    52975318        }
    52985319
    5299         if (!cli_set_secdesc(cli, fnum, sd)) {
    5300                 DEBUG(5, ("ERROR: secdesc set failed: %s\n", cli_errstr(cli)));
     5320        if (!cli_set_secdesc(targetcli, fnum, sd)) {
     5321                DEBUG(5, ("ERROR: secdesc set failed: %s\n", cli_errstr(targetcli)));
    53015322                ret = -1;
    53025323        }
     
    53055326
    53065327 failed:
    5307         cli_close(cli, fnum);
     5328        cli_close(targetcli, fnum);
    53085329
    53095330        if (err != 0) {
  • branches/samba-3.0/source/libsmb/namequery.c

    r140 r165  
    3535#define SAFKEY_FMT      "SAF/DOMAIN/%s"
    3636#define SAF_TTL         900
     37#define SAFJOINKEY_FMT  "SAFJOIN/DOMAIN/%s"
     38#define SAFJOIN_TTL     3600
    3739
    3840static char *saf_key(const char *domain)
     
    4143       
    4244        asprintf( &keystr, SAFKEY_FMT, strupper_static(domain) );
     45
     46        return keystr;
     47}
     48
     49static char *saf_join_key(const char *domain)
     50{
     51        char *keystr;
     52
     53        asprintf( &keystr, SAFJOINKEY_FMT, strupper_static(domain) );
    4354
    4455        return keystr;
     
    6879       
    6980        key = saf_key( domain );
    70         expire = time( NULL ) + SAF_TTL;
     81        expire = time( NULL ) + lp_parm_int(-1, "saf","ttl", SAF_TTL);
    7182       
    7283       
     
    8192}
    8293
     94BOOL saf_join_store( const char *domain, const char *servername )
     95{
     96        char *key;
     97        time_t expire;
     98        BOOL ret = False;
     99
     100        if ( !domain || !servername ) {
     101                DEBUG(2,("saf_join_store: Refusing to store empty domain or servername!\n"));
     102                return False;
     103        }
     104
     105        if ( (strlen(domain) == 0) || (strlen(servername) == 0) ) {
     106                DEBUG(0,("saf_join_store: refusing to store 0 length domain or servername!\n"));
     107                return False;
     108        }
     109
     110        if ( !gencache_init() )
     111                return False;
     112
     113        key = saf_join_key( domain );
     114        expire = time( NULL ) + lp_parm_int(-1, "saf","join ttl", SAFJOIN_TTL);
     115
     116        DEBUG(10,("saf_join_store: domain = [%s], server = [%s], expire = [%u]\n",
     117                domain, servername, (unsigned int)expire ));
     118
     119        ret = gencache_set( key, servername, expire );
     120
     121        SAFE_FREE( key );
     122
     123        return ret;
     124}
     125
    83126BOOL saf_delete( const char *domain )
    84127{
     
    94137                return False;
    95138       
     139        key = saf_join_key(domain);
     140        ret = gencache_del(key);
     141        SAFE_FREE(key);
     142
     143        if (ret) {
     144                DEBUG(10,("saf_delete[join]: domain = [%s]\n", domain ));
     145        }
     146
    96147        key = saf_key(domain);
    97148        ret = gencache_del(key);
    98        
     149        SAFE_FREE(key);
     150
    99151        if (ret) {
    100152                DEBUG(10,("saf_delete: domain = [%s]\n", domain ));             
    101153        }
    102 
    103         SAFE_FREE( key );
    104154
    105155        return ret;
     
    123173        if ( !gencache_init() )
    124174                return False;
    125        
     175
     176        key = saf_join_key( domain );
     177
     178        ret = gencache_get( key, &server, &timeout );
     179
     180        SAFE_FREE( key );
     181
     182        if ( ret ) {
     183                DEBUG(5,("saf_fetch[join]: Returning \"%s\" for \"%s\" domain\n",
     184                        server, domain ));
     185                return server;
     186        }
     187
    126188        key = saf_key( domain );
    127189       
     
    16491711
    16501712        status = get_dc_list(domain, sitename, ip_list, count, lookup_type, &ordered);
     1713        if (NT_STATUS_EQUAL(status, NT_STATUS_NO_LOGON_SERVERS) && sitename) {
     1714                DEBUG(3,("get_sorted_dc_list: no server for name %s available"
     1715                         " in site %s, fallback to all servers\n",
     1716                         domain, sitename));
     1717                status = get_dc_list(domain, NULL, ip_list, count,
     1718                                     lookup_type, &ordered);
     1719        }
     1720
    16511721        if (!NT_STATUS_IS_OK(status)) {
    16521722                return status;
  • branches/samba-3.0/source/libsmb/trusts_util.c

    r134 r165  
    3333static NTSTATUS just_change_the_password(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
    3434                                         const unsigned char orig_trust_passwd_hash[16],
     35                                         const char *new_trust_pwd_cleartext,
    3536                                         const unsigned char new_trust_passwd_hash[16],
    3637                                         uint32 sec_channel_type)
    3738{
    3839        NTSTATUS result;
    39 
    40         /* Check if the netlogon pipe is open using schannel. If so we
    41            already have valid creds. If not we must set them up. */
    42 
    43         if (cli->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) {
    44                 uint32_t neg_flags = NETLOGON_NEG_AUTH2_ADS_FLAGS;
    45 
    46                 result = rpccli_netlogon_setup_creds(cli,
     40        uint32_t neg_flags = NETLOGON_NEG_AUTH2_ADS_FLAGS;
     41
     42        result = rpccli_netlogon_setup_creds(cli,
    4743                                        cli->cli->desthost, /* server name */
    4844                                        lp_workgroup(), /* domain */
     
    5349                                        &neg_flags);
    5450
    55                 if (!NT_STATUS_IS_OK(result)) {
    56                         DEBUG(3,("just_change_the_password: unable to setup creds (%s)!\n",
    57                                  nt_errstr(result)));
    58                         return result;
    59                 }
    60         }
    61 
    62         result = rpccli_net_srv_pwset(cli, mem_ctx, global_myname(), new_trust_passwd_hash);
     51        if (!NT_STATUS_IS_OK(result)) {
     52                DEBUG(3,("just_change_the_password: unable to setup creds (%s)!\n",
     53                         nt_errstr(result)));
     54                return result;
     55        }
     56
     57        if (neg_flags & NETLOGON_NEG_PASSWORD_SET2) {
     58                result = rpccli_net_srv_pwset2(cli, mem_ctx, global_myname(),
     59                                               new_trust_pwd_cleartext);
     60        } else {
     61                result = rpccli_net_srv_pwset(cli, mem_ctx, global_myname(),
     62                                              new_trust_passwd_hash);
     63        }
    6364
    6465        if (!NT_STATUS_IS_OK(result)) {
     
    9697
    9798        nt_status = just_change_the_password(cli, mem_ctx, orig_trust_passwd_hash,
     99                                             new_trust_passwd,
    98100                                             new_trust_passwd_hash, sec_channel_type);
    99101       
Note: See TracChangeset for help on using the changeset viewer.