Ignore:
Timestamp:
Nov 12, 2012, 5:09:31 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server 3.5: update branche to 3.5.13

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

Legend:

Unmodified
Added
Removed
  • branches/samba-3.5.x/source3/VERSION

    r732 r733  
    2626SAMBA_VERSION_MAJOR=3
    2727SAMBA_VERSION_MINOR=5
    28 SAMBA_VERSION_RELEASE=12
     28SAMBA_VERSION_RELEASE=13
    2929
    3030########################################################
  • branches/samba-3.5.x/source3/client/client.c

    r732 r733  
    44834483                status = cli_echo(cli, 1, data_blob_const(garbage, sizeof(garbage)));
    44844484
    4485                 if (!NT_STATUS_IS_OK(status)) {
    4486                         DEBUG(0, ("SMBecho failed. Maybe server has closed "
    4487                                 "the connection\n"));
     4485                if (NT_STATUS_IS_OK(status)) {
     4486                        return;
     4487                }
     4488
     4489                if (!cli_state_is_connected(cli)) {
     4490                        DEBUG(0, ("SMBecho failed (%s). The connection is "
     4491                                "disconnected now\n", nt_errstr(status)));
    44884492                        finished = true;
    44894493                        smb_readline_done();
  • branches/samba-3.5.x/source3/client/clitar.c

    r414 r733  
    205205                memset(hb.dbuf.size, 0, 4);
    206206                hb.dbuf.size[0]=128;
    207                 for (i = 8, jp=(char*)&size; i; i--)
    208                         hb.dbuf.size[i+3] = *(jp++);
     207                for (i = 8; i; i--) {
     208                        hb.dbuf.size[i+3] = size & 0xff;
     209                        size >>= 8;
     210                }
    209211        }
    210212        oct_it((uint64_t) mtime, 13, hb.dbuf.mtime);
     
    308310                convert_time_t_to_timespec((time_t)strtol(hb->dbuf.mtime, NULL, 8));
    309311        finfo->atime_ts = convert_time_t_to_timespec(time(NULL));
    310         finfo->size = unoct(hb->dbuf.size, sizeof(hb->dbuf.size));
     312        if ((hb->dbuf.size[0] & 0xff) == 0x80) {
     313                /* This is a non-POSIX compatible extention to extract files
     314                        greater than 8GB. */
     315                finfo->size = 0;
     316                for (i = 0; i < 8; i++) {
     317                        finfo->size <<= 8;
     318                        finfo->size |= hb->dbuf.size[i+4] & 0xff;
     319                }
     320        } else {
     321                finfo->size = unoct(hb->dbuf.size, sizeof(hb->dbuf.size));
     322        }
    311323
    312324        return True;
     
    10001012{
    10011013        uint16_t fnum;
    1002         int pos = 0, dsize = 0, bpos = 0;
    1003         uint64_t rsize = 0;
     1014        int dsize = 0, bpos = 0;
     1015        uint64_t rsize = 0, pos = 0;
    10041016
    10051017        DEBUG(5, ("get_file: file: %s, size %.0f\n", finfo.name, (double)finfo.size));
  • branches/samba-3.5.x/source3/include/proto.h

    r732 r733  
    44934493/* The following definitions come from passdb/pdb_get_set.c  */
    44944494
     4495bool pdb_is_password_change_time_max(time_t test_time);
    44954496uint32 pdb_get_acct_ctrl(const struct samu *sampass);
    44964497time_t pdb_get_logon_time(const struct samu *sampass);
  • branches/samba-3.5.x/source3/lib/ctdbd_conn.c

    r429 r733  
    11321132        struct ctdbd_traverse_state state;
    11331133
     1134        become_root();
    11341135        status = ctdbd_init_connection(NULL, &conn);
     1136        unbecome_root();
    11351137        if (!NT_STATUS_IS_OK(status)) {
    11361138                DEBUG(0, ("ctdbd_init_connection failed: %s\n",
  • branches/samba-3.5.x/source3/lib/recvfile.c

    r664 r733  
    3333 * as we're below the Samba vfs layer.
    3434 *
    35  * If tofd is -1 we just drain the incoming socket of count
    36  * bytes without writing to the outgoing fd.
    37  * If a write fails we do the same (to cope with disk full)
    38  * errors.
    39  *
    4035 * Returns -1 on short reads from fromfd (read error)
    4136 * and sets errno.
    4237 *
    4338 * Returns number of bytes written to 'tofd'
    44  * or thrown away if 'tofd == -1'.
    4539 * return != count then sets errno.
    4640 * Returns count if complete success.
     
    9993                num_written = 0;
    10094
    101                 while (num_written < read_ret) {
     95                /* Don't write any more after a write error. */
     96                while (tofd != -1 && (num_written < read_ret)) {
    10297                        ssize_t write_ret;
    10398
    104                         if (tofd == -1) {
    105                                 write_ret = read_ret;
    106                         } else {
    107                                 /* Write to file - ignore EINTR. */
    108                                 write_ret = sys_write(tofd,
    109                                                 buffer + num_written,
    110                                                 read_ret - num_written);
    111 
    112                                 if (write_ret <= 0) {
    113                                         /* write error - stop writing. */
    114                                         tofd = -1;
    115                                         saved_errno = errno;
    116                                         continue;
    117                                 }
     99                        /* Write to file - ignore EINTR. */
     100                        write_ret = sys_write(tofd,
     101                                        buffer + num_written,
     102                                        read_ret - num_written);
     103
     104                        if (write_ret <= 0) {
     105                                /* write error - stop writing. */
     106                                tofd = -1;
     107                                if (total_written == 0) {
     108                                        /* Ensure we return
     109                                           -1 if the first
     110                                           write failed. */
     111                                        total_written = -1;
     112                                }
     113                                saved_errno = errno;
     114                                break;
    118115                        }
    119116
     
    217214
    218215 done:
    219         if (total_written < count) {
     216        if (count) {
    220217                int saved_errno = errno;
    221                 if (drain_socket(fromfd, count-total_written) !=
    222                                 count-total_written) {
     218                if (drain_socket(fromfd, count) != count) {
    223219                        /* socket is dead. */
    224220                        return -1;
     
    246242/*****************************************************************
    247243 Throw away "count" bytes from the client socket.
     244 Returns count or -1 on error.
    248245*****************************************************************/
    249246
    250247ssize_t drain_socket(int sockfd, size_t count)
    251248{
    252         return default_sys_recvfile(sockfd, -1, (SMB_OFF_T)-1, count);
    253 }
     249        size_t total = 0;
     250        size_t bufsize = MIN(TRANSFER_BUF_SIZE,count);
     251        char *buffer = NULL;
     252
     253        if (count == 0) {
     254                return 0;
     255        }
     256
     257        buffer = SMB_MALLOC_ARRAY(char, bufsize);
     258        if (buffer == NULL) {
     259                return -1;
     260        }
     261
     262        while (total < count) {
     263                ssize_t read_ret;
     264                size_t toread = MIN(bufsize,count - total);
     265
     266                /* Read from socket - ignore EINTR. */
     267                read_ret = sys_read(sockfd, buffer, toread);
     268                if (read_ret <= 0) {
     269                        /* EOF or socket error. */
     270                        free(buffer);
     271                        return -1;
     272                }
     273                total += read_ret;
     274        }
     275
     276        free(buffer);
     277        return count;
     278}
  • branches/samba-3.5.x/source3/lib/util_seaccess.c

    r599 r733  
    159159        int i;
    160160        uint32_t bits_remaining;
     161        uint32_t explicitly_denied_bits = 0;
    161162
    162163        *access_granted = access_desired;
     
    224225                case SEC_ACE_TYPE_ACCESS_DENIED:
    225226                case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT:
    226                         if (bits_remaining & ace->access_mask) {
    227                                 return NT_STATUS_ACCESS_DENIED;
    228                         }
     227                        explicitly_denied_bits |= (bits_remaining & ace->access_mask);
    229228                        break;
    230229                default:        /* Other ACE types not handled/supported */
     
    232231                }
    233232        }
     233
     234        bits_remaining |= explicitly_denied_bits;
    234235
    235236done:
  • branches/samba-3.5.x/source3/libads/kerberos_verify.c

    r480 r733  
    269269        }
    270270
    271         SAFE_FREE(entry_princ_s);
     271        TALLOC_FREE(entry_princ_s);
    272272
    273273        {
  • branches/samba-3.5.x/source3/libsmb/clikrb5.c

    r596 r733  
    20892089        }
    20902090
    2091         ret = krb5_cc_store_cred(context, ccache, creds);
    2092         if (ret) {
    2093                 goto done;
    2094         }
    2095 
    20962091        if (out_creds) {
    20972092                *out_creds = creds;
  • branches/samba-3.5.x/source3/libsmb/clireadwrite.c

    r668 r733  
    200200        state->buf = (uint8_t *)smb_base(inbuf) + SVAL(vwv+6, 0);
    201201
    202         if (trans_oob(smb_len(inbuf), SVAL(vwv+6, 0), state->received)
     202        if (trans_oob(smb_len_large(inbuf), SVAL(vwv+6, 0), state->received)
    203203            || ((state->received != 0) && (state->buf < bytes))) {
    204204                DEBUG(5, ("server returned invalid read&x data offset\n"));
     
    945945        }
    946946
    947         size = MIN(size, max_write);
     947        state->size = MIN(size, max_write);
    948948
    949949        vwv = state->vwv;
     
    957957        SSVAL(vwv+7, 0, mode);
    958958        SSVAL(vwv+8, 0, 0);
    959         SSVAL(vwv+9, 0, (size>>16));
    960         SSVAL(vwv+10, 0, size);
     959        SSVAL(vwv+9, 0, (state->size>>16));
     960        SSVAL(vwv+10, 0, state->size);
    961961
    962962        SSVAL(vwv+11, 0,
     
    975975        state->iov[0].iov_len = 1;
    976976        state->iov[1].iov_base = CONST_DISCARD(void *, buf);
    977         state->iov[1].iov_len = size;
     977        state->iov[1].iov_len = state->size;
    978978
    979979        subreq = cli_smb_req_create(state, ev, cli, SMBwriteX, 0, wct, vwv,
     
    10271027        }
    10281028        state->written = SVAL(vwv+2, 0);
    1029         state->written |= SVAL(vwv+4, 0)<<16;
     1029        if (state->size > UINT16_MAX) {
     1030                /*
     1031                 * It is important that we only set the
     1032                 * high bits only if we asked for a large write.
     1033                 *
     1034                 * OS/2 print shares get this wrong and may send
     1035                 * invalid values.
     1036                 *
     1037                 * See bug #5326.
     1038                 */
     1039                state->written |= SVAL(vwv+4, 0)<<16;
     1040        }
    10301041        tevent_req_done(req);
    10311042}
  • branches/samba-3.5.x/source3/modules/vfs_acl_common.c

    r732 r733  
    374374                        }
    375375                }
    376                 is_directory = S_ISDIR(sbuf.st_ex_mode);
     376                is_directory = S_ISDIR(psbuf->st_ex_mode);
    377377
    378378                if (ignore_file_system_acl) {
     
    409409        }
    410410        if (!(security_info & DACL_SECURITY_INFORMATION)) {
     411                psd->type &= ~SEC_DESC_DACL_PRESENT;
    411412                psd->dacl = NULL;
    412413        }
    413414        if (!(security_info & SACL_SECURITY_INFORMATION)) {
     415                psd->type &= ~SEC_DESC_SACL_PRESENT;
    414416                psd->sacl = NULL;
    415417        }
     
    533535                                        (SECINFO_OWNER |
    534536                                         SECINFO_GROUP |
    535                                          SECINFO_DACL),
     537                                         SECINFO_DACL  |
     538                                         SECINFO_SACL),
    536539                                        pp_parent_desc);
    537540
     
    616619                                (OWNER_SECURITY_INFORMATION |
    617620                                 GROUP_SECURITY_INFORMATION |
    618                                  DACL_SECURITY_INFORMATION),
     621                                 DACL_SECURITY_INFORMATION  |
     622                                 SACL_SECURITY_INFORMATION),
    619623                                &pdesc);
    620624        if (NT_STATUS_IS_OK(status)) {
     
    627631                if (!NT_STATUS_IS_OK(status)) {
    628632                        DEBUG(10,("open_acl_xattr: %s open "
     633                                "for access 0x%x (0x%x) "
    629634                                "refused with error %s\n",
    630635                                fsp_str_dbg(fsp),
     636                                (unsigned int)fsp->access_mask,
     637                                (unsigned int)access_granted,
    631638                                nt_errstr(status) ));
    632639                        goto err;
     
    912919        int ret;
    913920
     921        /* Try the normal rmdir first. */
    914922        ret = SMB_VFS_NEXT_RMDIR(handle, path);
    915         if (!(ret == -1 && (errno == EACCES || errno == EPERM))) {
    916                 DEBUG(10,("rmdir_acl_common: unlink of %s failed %s\n",
    917                         path,
    918                         strerror(errno) ));
    919                 return ret;
    920         }
    921 
    922         return acl_common_remove_object(handle,
    923                                         path,
    924                                         true);
     923        if (ret == 0) {
     924                return 0;
     925        }
     926        if (errno == EACCES || errno == EPERM) {
     927                /* Failed due to access denied,
     928                   see if we need to root override. */
     929                return acl_common_remove_object(handle,
     930                                                path,
     931                                                true);
     932        }
     933
     934        DEBUG(10,("rmdir_acl_common: unlink of %s failed %s\n",
     935                path,
     936                strerror(errno) ));
     937        return -1;
    925938}
    926939
     
    10401053        int ret;
    10411054
     1055        /* Try the normal unlink first. */
    10421056        ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
    1043         if (!(ret == -1 && (errno == EACCES || errno == EPERM))) {
    1044                 DEBUG(10,("unlink_acl_common: unlink of %s failed %s\n",
    1045                         smb_fname->base_name,
    1046                         strerror(errno) ));
    1047                 return ret;
    1048         }
    1049         /* Don't do anything fancy for streams. */
    1050         if (smb_fname->stream_name) {
    1051                 return ret;
    1052         }
    1053 
    1054         return acl_common_remove_object(handle,
     1057        if (ret == 0) {
     1058                return 0;
     1059        }
     1060        if (errno == EACCES || errno == EPERM) {
     1061                /* Failed due to access denied,
     1062                   see if we need to root override. */
     1063
     1064                /* Don't do anything fancy for streams. */
     1065                if (smb_fname->stream_name) {
     1066                        return -1;
     1067                }
     1068                return acl_common_remove_object(handle,
    10551069                                        smb_fname->base_name,
    10561070                                        false);
     1071        }
     1072
     1073        DEBUG(10,("unlink_acl_common: unlink of %s failed %s\n",
     1074                smb_fname->base_name,
     1075                strerror(errno) ));
     1076        return -1;
    10571077}
    10581078
  • branches/samba-3.5.x/source3/modules/vfs_commit.c

    r414 r733  
    232232        }
    233233
    234         return 0;
     234        return fd;
    235235}
    236236
  • branches/samba-3.5.x/source3/param/loadparm.c

    r732 r733  
    71047104}
    71057105
     7106/**
     7107 * reload those shares from registry that are already
     7108 * activated in the services array.
     7109 */
     7110static bool reload_registry_shares(void)
     7111{
     7112        int i;
     7113        bool ret = true;
     7114
     7115        for (i = 0; i < iNumServices; i++) {
     7116                if (!VALID(i)) {
     7117                        continue;
     7118                }
     7119
     7120                if (ServicePtrs[i]->usershare == USERSHARE_VALID) {
     7121                        continue;
     7122                }
     7123
     7124                ret = process_registry_service(ServicePtrs[i]->szService);
     7125                if (!ret) {
     7126                        goto done;
     7127                }
     7128        }
     7129
     7130done:
     7131        return ret;
     7132}
     7133
     7134
    71067135#define MAX_INCLUDE_DEPTH 100
    71077136
     
    92929321        }
    92939322
    9294         if (bRetval && lp_registry_shares() && allow_registry_shares) {
    9295                 bRetval = process_registry_shares();
     9323        if (bRetval && lp_registry_shares()) {
     9324                if (allow_registry_shares) {
     9325                        bRetval = process_registry_shares();
     9326                } else {
     9327                        bRetval = reload_registry_shares();
     9328                }
    92969329        }
    92979330
  • branches/samba-3.5.x/source3/passdb/pdb_get_set.c

    r414 r733  
    3838
    3939/*********************************************************************
     40 Test if a change time is a max value. Copes with old and new values
     41 of max.
     42 ********************************************************************/
     43
     44bool pdb_is_password_change_time_max(time_t test_time)
     45{
     46        if (test_time == get_time_t_max()) {
     47                return true;
     48        }
     49#if (defined(SIZEOF_TIME_T) && (SIZEOF_TIME_T == 8))
     50        if (test_time == 0x7FFFFFFFFFFFFFFFLL) {
     51                return true;
     52        }
     53#endif
     54        if (test_time == 0x7FFFFFFF) {
     55                return true;
     56        }
     57        return false;
     58}
     59
     60/*********************************************************************
     61 Return an unchanging version of max password change time - 0x7FFFFFFF.
     62 ********************************************************************/
     63
     64time_t pdb_password_change_time_max(void)
     65{
     66        return 0x7FFFFFFF;
     67}
     68
     69/*********************************************************************
    4070 Collection of get...() functions for struct samu.
    4171 ********************************************************************/
     
    85115           to indicate that the user cannot change their password.  jmcd
    86116        */
    87         if (sampass->pass_can_change_time == get_time_t_max() &&
     117        if (pdb_is_password_change_time_max(sampass->pass_can_change_time) &&
    88118            pdb_get_init_flags(sampass, PDB_CANCHANGETIME) == PDB_CHANGED)
    89119                return sampass->pass_can_change_time;
     
    111141
    112142        if (sampass->acct_ctrl & ACB_PWNOEXP)
    113                 return get_time_t_max();
     143                return pdb_password_change_time_max();
    114144
    115145        if (!pdb_get_account_policy(PDB_POLICY_MAX_PASSWORD_AGE, &expire)
    116146            || expire == (uint32)-1 || expire == 0)
    117                 return get_time_t_max();
     147                return pdb_password_change_time_max();
    118148
    119149        return sampass->pass_last_set_time + expire;
     
    122152bool pdb_get_pass_can_change(const struct samu *sampass)
    123153{
    124         if (sampass->pass_can_change_time == get_time_t_max() &&
     154        if (pdb_is_password_change_time_max(sampass->pass_can_change_time) &&
    125155            sampass->pass_last_set_time != 0)
    126156                return False;
     
    10021032{
    10031033        return pdb_set_pass_can_change_time(sampass,
    1004                                      canchange ? 0 : get_time_t_max(),
     1034                                     canchange ? 0 : pdb_password_change_time_max(),
    10051035                                     PDB_CHANGED);
    10061036}
  • branches/samba-3.5.x/source3/rpc_server/srv_netlog_nt.c

    r429 r733  
    978978{
    979979        NTSTATUS status;
    980         struct netlogon_creds_CredentialState *creds;
     980        struct netlogon_creds_CredentialState *creds = NULL;
    981981        struct samu *sampass;
    982982        DATA_BLOB plaintext;
     
    993993
    994994        if (!NT_STATUS_IS_OK(status)) {
     995                const char *computer_name = "<unknown>";
     996
     997                if (creds && creds->computer_name) {
     998                        computer_name = creds->computer_name;
     999                }
     1000
    9951001                DEBUG(2,("_netr_ServerPasswordSet2: netlogon_creds_server_step "
    9961002                        "failed. Rejecting auth request from client %s machine account %s\n",
    997                         r->in.computer_name, creds->computer_name));
     1003                        r->in.computer_name, computer_name));
    9981004                TALLOC_FREE(creds);
    9991005                return status;
     
    10051011
    10061012        if (!extract_pw_from_buffer(p->mem_ctx, password_buf.data, &plaintext)) {
     1013                TALLOC_FREE(creds);
    10071014                return NT_STATUS_WRONG_PASSWORD;
    10081015        }
     
    10131020                                           creds->account_name,
    10141021                                           &sampass);
     1022        TALLOC_FREE(creds);
    10151023        if (!NT_STATUS_IS_OK(status)) {
    10161024                return status;
  • branches/samba-3.5.x/source3/rpc_server/srv_samr_nt.c

    r480 r733  
    28782878
    28792879        must_change_time = pdb_get_pass_must_change_time(pw);
    2880         if (must_change_time == get_time_t_max()) {
     2880        if (pdb_is_password_change_time_max(must_change_time)) {
    28812881                unix_to_nt_time_abs(&force_password_change, must_change_time);
    28822882        } else {
  • branches/samba-3.5.x/source3/smbd/file_access.c

    r620 r733  
    3838        if (conn->server_info->utok.uid == 0 || conn->admin_user) {
    3939                /* I'm sorry sir, I didn't know you were root... */
     40                return true;
     41        }
     42
     43        if (access_mask == DELETE_ACCESS &&
     44                        VALID_STAT(smb_fname->st) &&
     45                        S_ISLNK(smb_fname->st.st_ex_mode)) {
     46                /* We can always delete a symlink. */
    4047                return true;
    4148        }
     
    116123         * by owner of directory. */
    117124        if (smb_fname_parent->st.st_ex_mode & S_ISVTX) {
    118                 if(SMB_VFS_STAT(conn, smb_fname) != 0) {
    119                         if (errno == ENOENT) {
    120                                 /* If the file doesn't already exist then
    121                                  * yes we'll be able to delete it. */
    122                                 ret = true;
    123                                 goto out;
    124                         }
    125                         DEBUG(10,("can_delete_file_in_directory: can't "
    126                                   "stat file %s (%s)",
    127                                   smb_fname_str_dbg(smb_fname),
    128                                   strerror(errno) ));
    129                         ret = false;
     125                if (!VALID_STAT(smb_fname->st)) {
     126                        /* If the file doesn't already exist then
     127                         * yes we'll be able to delete it. */
     128                        ret = true;
    130129                        goto out;
    131130                }
  • branches/samba-3.5.x/source3/smbd/nttrans.c

    r732 r733  
    18841884        }
    18851885        if (!(security_info_wanted & SECINFO_DACL)) {
     1886                psd->type &= ~SEC_DESC_DACL_PRESENT;
    18861887                psd->dacl = NULL;
    18871888        }
    18881889        if (!(security_info_wanted & SECINFO_SACL)) {
     1890                psd->type &= ~SEC_DESC_SACL_PRESENT;
    18891891                psd->sacl = NULL;
    18901892        }
  • branches/samba-3.5.x/source3/smbd/open.c

    r732 r733  
    9494                        smb_fname_str_dbg(smb_fname),
    9595                        (unsigned int)*access_granted ));
     96                return NT_STATUS_OK;
     97        }
     98
     99        if (access_mask == DELETE_ACCESS &&
     100                        VALID_STAT(smb_fname->st) &&
     101                        S_ISLNK(smb_fname->st.st_ex_mode)) {
     102                /* We can always delete a symlink. */
     103                DEBUG(10,("smbd_check_open_rights: not checking ACL "
     104                        "on DELETE_ACCESS on symlink %s.\n",
     105                        smb_fname_str_dbg(smb_fname) ));
    96106                return NT_STATUS_OK;
    97107        }
     
    14321442        }
    14331443
    1434         status = check_name(conn, smb_fname->base_name);
    1435         if (!NT_STATUS_IS_OK(status)) {
    1436                 return status;
    1437         }
    1438 
    14391444        if (!posix_open) {
    14401445                new_dos_attributes &= SAMBA_ATTRIBUTES_MASK;
     
    33093314        }
    33103315
    3311         /* All file access must go through check_name() */
    3312 
    3313         status = check_name(conn, smb_fname->base_name);
    3314         if (!NT_STATUS_IS_OK(status)) {
    3315                 goto fail;
    3316         }
    3317 
    33183316        status = create_file_unixpath(
    33193317                conn, req, smb_fname, access_mask, share_access,
  • branches/samba-3.5.x/source3/smbd/posix_acls.c

    r732 r733  
    11241124****************************************************************************/
    11251125
    1126 #define FILE_SPECIFIC_READ_BITS (FILE_READ_DATA|FILE_READ_EA|FILE_READ_ATTRIBUTES)
    1127 #define FILE_SPECIFIC_WRITE_BITS (FILE_WRITE_DATA|FILE_APPEND_DATA|FILE_WRITE_EA|FILE_WRITE_ATTRIBUTES)
     1126#define FILE_SPECIFIC_READ_BITS (FILE_READ_DATA|FILE_READ_EA)
     1127#define FILE_SPECIFIC_WRITE_BITS (FILE_WRITE_DATA|FILE_APPEND_DATA|FILE_WRITE_EA)
    11281128#define FILE_SPECIFIC_EXECUTE_BITS (FILE_EXECUTE)
    11291129
  • branches/samba-3.5.x/source3/smbd/process.c

    r732 r733  
    12741274        /* Make sure this is an SMB packet. smb_size contains NetBIOS header
    12751275         * so subtract 4 from it. */
    1276         if (!valid_smb_header(req->inbuf)
    1277             || (size < (smb_size - 4))) {
     1276        if ((size < (smb_size - 4)) ||
     1277            !valid_smb_header(req->inbuf)) {
    12781278                DEBUG(2,("Non-SMB packet of length %d. Terminating server\n",
    12791279                         smb_len(req->inbuf)));
  • branches/samba-3.5.x/source3/smbd/reply.c

    r732 r733  
    44304430        SSVAL(req->outbuf,smb_vwv4,nwritten>>16);
    44314431
    4432         if (nwritten < (ssize_t)numtowrite) {
    4433                 SCVAL(req->outbuf,smb_rcls,ERRHRD);
    4434                 SSVAL(req->outbuf,smb_err,ERRdiskfull);
    4435         }
    4436 
    44374432        DEBUG(3,("writeX fnum=%d num=%d wrote=%d\n",
    44384433                fsp->fnum, (int)numtowrite, (int)nwritten));
     
    62916286        struct smb_filename *smb_fname_src = NULL;
    62926287        struct smb_filename *smb_fname_dst = NULL;
     6288        uint32_t src_ucf_flags = lp_posix_pathnames() ? UCF_UNIX_NAME_LOOKUP : UCF_COND_ALLOW_WCARD_LCOMP;
     6289        uint32_t dst_ucf_flags = UCF_SAVE_LCOMP | (lp_posix_pathnames() ? 0 : UCF_COND_ALLOW_WCARD_LCOMP);
    62936290
    62946291        START_PROFILE(SMBmv);
     
    63206317                                  req->flags2 & FLAGS2_DFS_PATHNAMES,
    63216318                                  name,
    6322                                   UCF_COND_ALLOW_WCARD_LCOMP,
     6319                                  src_ucf_flags,
    63236320                                  &src_has_wcard,
    63246321                                  &smb_fname_src);
     
    63386335                                  req->flags2 & FLAGS2_DFS_PATHNAMES,
    63396336                                  newname,
    6340                                   UCF_COND_ALLOW_WCARD_LCOMP | UCF_SAVE_LCOMP,
     6337                                  dst_ucf_flags,
    63416338                                  &dest_has_wcard,
    63426339                                  &smb_fname_dst);
  • branches/samba-3.5.x/source3/smbd/trans2.c

    r732 r733  
    77367736        } else {
    77377737                char *fname = NULL;
     7738                uint32_t ucf_flags = 0;
    77387739
    77397740                /* set path info */
     
    77527753                }
    77537754
     7755                if (info_level == SMB_SET_FILE_UNIX_BASIC ||
     7756                                info_level == SMB_SET_FILE_UNIX_INFO2 ||
     7757                                info_level == SMB_FILE_RENAME_INFORMATION ||
     7758                                info_level == SMB_POSIX_PATH_UNLINK) {
     7759                        ucf_flags |= UCF_UNIX_NAME_LOOKUP;
     7760                }
     7761
    77547762                status = filename_convert(req, conn,
    77557763                                         req->flags2 & FLAGS2_DFS_PATHNAMES,
    77567764                                         fname,
    7757                                          0,
     7765                                         ucf_flags,
    77587766                                         NULL,
    77597767                                         &smb_fname);
  • branches/samba-3.5.x/source3/utils/net_groupmap.c

    r414 r733  
    824824                d_printf("%s\n%s",
    825825                         _("Usage:"),
    826                          _("net groupmap memberof sid\n"));
     826                         _("net groupmap memberships sid\n"));
    827827                return -1;
    828828        }
  • branches/samba-3.5.x/source3/winbindd/wb_next_pwent.c

    r414 r733  
    3131static void wb_next_pwent_fill_done(struct tevent_req *subreq);
    3232
     33static struct winbindd_domain *wb_next_find_domain(struct winbindd_domain *domain)
     34{
     35        if (domain == NULL) {
     36                domain = domain_list();
     37        } else {
     38                domain = domain->next;
     39        }
     40
     41        if ((domain != NULL)
     42            && sid_check_is_domain(&domain->sid)) {
     43                domain = domain->next;
     44        }
     45
     46        if (domain == NULL) {
     47                return NULL;
     48        }
     49
     50        return domain;
     51}
     52
    3353struct tevent_req *wb_next_pwent_send(TALLOC_CTX *mem_ctx,
    3454                                      struct tevent_context *ev,
     
    5070                TALLOC_FREE(state->gstate->users);
    5171
    52                 if (state->gstate->domain == NULL) {
    53                         state->gstate->domain = domain_list();
    54                 } else {
    55                         state->gstate->domain = state->gstate->domain->next;
    56                 }
    57 
    58                 if ((state->gstate->domain != NULL)
    59                     && sid_check_is_domain(&state->gstate->domain->sid)) {
    60                         state->gstate->domain = state->gstate->domain->next;
    61                 }
    62 
     72                state->gstate->domain = wb_next_find_domain(state->gstate->domain);
    6373                if (state->gstate->domain == NULL) {
    6474                        tevent_req_nterror(req, NT_STATUS_NO_MORE_ENTRIES);
     
    148158        status = wb_fill_pwent_recv(subreq);
    149159        TALLOC_FREE(subreq);
    150         if (!NT_STATUS_IS_OK(status)) {
     160        /*
     161         * When you try to enumerate users with 'getent passwd' and the user
     162         * doesn't have a uid set we should just move on.
     163         */
     164        if (NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED)) {
     165                state->gstate->next_user += 1;
     166
     167                if (state->gstate->next_user >= state->gstate->num_users) {
     168                        TALLOC_FREE(state->gstate->users);
     169
     170                        state->gstate->domain = wb_next_find_domain(state->gstate->domain);
     171                        if (state->gstate->domain == NULL) {
     172                                tevent_req_nterror(req, NT_STATUS_NO_MORE_ENTRIES);
     173                                return;
     174                        }
     175
     176                        subreq = wb_query_user_list_send(state, state->ev,
     177                                        state->gstate->domain);
     178                        if (tevent_req_nomem(subreq, req)) {
     179                                return;
     180                        }
     181                        tevent_req_set_callback(subreq, wb_next_pwent_fetch_done, req);
     182                        return;
     183                }
     184
     185                subreq = wb_fill_pwent_send(state,
     186                                            state->ev,
     187                                            &state->gstate->users[state->gstate->next_user],
     188                                            state->pw);
     189                if (tevent_req_nomem(subreq, req)) {
     190                        return;
     191                }
     192                tevent_req_set_callback(subreq, wb_next_pwent_fill_done, req);
     193
     194                return;
     195        } else if (!NT_STATUS_IS_OK(status)) {
    151196                tevent_req_nterror(req, status);
    152197                return;
  • branches/samba-3.5.x/source3/winbindd/winbindd_cache.c

    r599 r733  
    3333#define DBGC_CLASS DBGC_WINBIND
    3434
    35 #define WINBINDD_CACHE_VERSION 1
     35#define WINBINDD_CACHE_VER1 1 /* initial db version */
     36#define WINBINDD_CACHE_VER2 2 /* second version with timeouts for NDR entries */
     37
     38#define WINBINDD_CACHE_VERSION WINBINDD_CACHE_VER2
    3639#define WINBINDD_CACHE_VERSION_KEYSTR "WINBINDD_CACHE_VERSION"
    3740
     
    9396        NTSTATUS status;
    9497        uint32 sequence_number;
     98        uint64 timeout;
    9599        uint8 *data;
    96100        uint32 len, ofs;
     
    224228
    225229/*
     230  pull a uint64 from a cache entry
     231*/
     232static uint64 centry_uint64(struct cache_entry *centry)
     233{
     234        uint64 ret;
     235
     236        if (!centry_check_bytes(centry, 8)) {
     237                smb_panic_fn("centry_uint64");
     238        }
     239        ret = BVAL(centry->data, centry->ofs);
     240        centry->ofs += 8;
     241        return ret;
     242}
     243
     244/*
    226245  pull a uint32 from a cache entry
    227246*/
     
    615634
    616635        /* if the server is down or the cache entry is not older than the
    617            current sequence number then it is OK */
    618         if (wcache_server_down(domain) ||
    619             centry->sequence_number == domain->sequence_number) {
     636           current sequence number or it did not timeout then it is OK */
     637        if (wcache_server_down(domain)
     638            || (centry->sequence_number == domain->sequence_number
     639                && centry->timeout > time(NULL))) {
    620640                DEBUG(10,("centry_expired: Key %s for domain %s is good.\n",
    621641                        keystr, domain->name ));
     
    648668        centry->ofs = 0;
    649669
    650         if (centry->len < 8) {
     670        if (centry->len < 16) {
    651671                /* huh? corrupt cache? */
    652                 DEBUG(10,("wcache_fetch_raw: Corrupt cache for key %s (len < 8) ?\n", kstr));
     672                DEBUG(10,("wcache_fetch_raw: Corrupt cache for key %s "
     673                          "(len < 16)?\n", kstr));
    653674                centry_free(centry);
    654675                return NULL;
     
    657678        centry->status = centry_ntstatus(centry);
    658679        centry->sequence_number = centry_uint32(centry);
     680        centry->timeout = centry_uint64(centry);
    659681
    660682        return centry;
     
    743765
    744766/*
     767  push a uint64 into a centry
     768*/
     769static void centry_put_uint64(struct cache_entry *centry, uint64 v)
     770{
     771        centry_expand(centry, 8);
     772        SBVAL(centry->data, centry->ofs, v);
     773        centry->ofs += 8;
     774}
     775
     776/*
    745777  push a uint32 into a centry
    746778*/
     
    863895        centry->ofs = 0;
    864896        centry->sequence_number = domain->sequence_number;
     897        centry->timeout = lp_winbind_cache_time() + time(NULL);
    865898        centry_put_ntstatus(centry, status);
    866899        centry_put_uint32(centry, centry->sequence_number);
     900        centry_put_uint64(centry, centry->timeout);
    867901        return centry;
    868902}
     
    34493483        centry->ofs = 0;
    34503484
    3451         if (centry->len < 8) {
     3485        if (centry->len < 16) {
    34523486                /* huh? corrupt cache? */
    3453                 DEBUG(0,("create_centry_validate: Corrupt cache for key %s (len < 8) ?\n", kstr));
     3487                DEBUG(0,("create_centry_validate: Corrupt cache for key %s "
     3488                         "(len < 16) ?\n", kstr));
    34543489                centry_free(centry);
    34553490                state->bad_entry = true;
     
    34603495        centry->status = NT_STATUS(centry_uint32(centry));
    34613496        centry->sequence_number = centry_uint32(centry);
     3497        centry->timeout = centry_uint64(centry);
    34623498        return centry;
    34633499}
     
    40124048}
    40134049
     4050static int wbcache_update_centry_fn(TDB_CONTEXT *tdb,
     4051                                    TDB_DATA key,
     4052                                    TDB_DATA data,
     4053                                    void *state)
     4054{
     4055        uint64_t ctimeout;
     4056        TDB_DATA blob;
     4057
     4058        if (is_non_centry_key(key)) {
     4059                return 0;
     4060        }
     4061
     4062        if (data.dptr == NULL || data.dsize == 0) {
     4063                if (tdb_delete(tdb, key) < 0) {
     4064                        DEBUG(0, ("tdb_delete for [%s] failed!\n",
     4065                                  key.dptr));
     4066                        return 1;
     4067                }
     4068        }
     4069
     4070        /* add timeout to blob (uint64_t) */
     4071        blob.dsize = data.dsize + 8;
     4072
     4073        blob.dptr = SMB_XMALLOC_ARRAY(uint8_t, blob.dsize);
     4074        if (blob.dptr == NULL) {
     4075                return 1;
     4076        }
     4077        memset(blob.dptr, 0, blob.dsize);
     4078
     4079        /* copy status and seqnum */
     4080        memcpy(blob.dptr, data.dptr, 8);
     4081
     4082        /* add timeout */
     4083        ctimeout = lp_winbind_cache_time() + time(NULL);
     4084        SBVAL(blob.dptr, 8, ctimeout);
     4085
     4086        /* copy the rest */
     4087        memcpy(blob.dptr + 16, data.dptr + 8, data.dsize - 8);
     4088
     4089        if (tdb_store(tdb, key, blob, TDB_REPLACE) < 0) {
     4090                DEBUG(0, ("tdb_store to update [%s] failed!\n",
     4091                          key.dptr));
     4092                SAFE_FREE(blob.dptr);
     4093                return 1;
     4094        }
     4095
     4096        SAFE_FREE(blob.dptr);
     4097        return 0;
     4098}
     4099
     4100static bool wbcache_upgrade_v1_to_v2(TDB_CONTEXT *tdb)
     4101{
     4102        int rc;
     4103
     4104        DEBUG(1, ("Upgrade to version 2 of the winbindd_cache.tdb\n"));
     4105
     4106        rc = tdb_traverse(tdb, wbcache_update_centry_fn, NULL);
     4107        if (rc < 0) {
     4108                return false;
     4109        }
     4110
     4111        return true;
     4112}
     4113
    40144114/***********************************************************************
    40154115 Try and validate every entry in the winbindd cache. If we fail here,
     
    40224122        const char *tdb_path = cache_path("winbindd_cache.tdb");
    40234123        TDB_CONTEXT *tdb = NULL;
     4124        uint32_t vers_id;
     4125        bool ok;
    40244126
    40254127        DEBUG(10, ("winbindd_validate_cache: replacing panic function\n"));
    40264128        smb_panic_fn = validate_panic;
    4027 
    40284129
    40294130        tdb = tdb_open_log(tdb_path,
     
    40394140                goto done;
    40404141        }
     4142
     4143        /* Version check and upgrade code. */
     4144        if (!tdb_fetch_uint32(tdb, WINBINDD_CACHE_VERSION_KEYSTR, &vers_id)) {
     4145                DEBUG(10, ("Fresh database\n"));
     4146                tdb_store_uint32(tdb, WINBINDD_CACHE_VERSION_KEYSTR, WINBINDD_CACHE_VERSION);
     4147                vers_id = WINBINDD_CACHE_VERSION;
     4148        }
     4149
     4150        if (vers_id != WINBINDD_CACHE_VERSION) {
     4151                if (vers_id == WINBINDD_CACHE_VER1) {
     4152                        ok = wbcache_upgrade_v1_to_v2(tdb);
     4153                        if (!ok) {
     4154                                DEBUG(10, ("winbindd_validate_cache: upgrade to version 2 failed.\n"));
     4155                                unlink(tdb_path);
     4156                                goto done;
     4157                        }
     4158
     4159                        tdb_store_uint32(tdb,
     4160                                         WINBINDD_CACHE_VERSION_KEYSTR,
     4161                                         WINBINDD_CACHE_VERSION);
     4162                        vers_id = WINBINDD_CACHE_VER2;
     4163                }
     4164        }
     4165
    40414166        tdb_close(tdb);
    40424167
     
    46584783                return false;
    46594784        }
    4660         if (data.dsize < 4) {
     4785        if (data.dsize < 12) {
    46614786                goto fail;
    46624787        }
     
    46644789        if (!is_domain_offline(domain)) {
    46654790                uint32_t entry_seqnum, dom_seqnum, last_check;
     4791                uint64_t entry_timeout;
    46664792
    46674793                if (!wcache_fetch_seqnum(domain->name, &dom_seqnum,
     
    46754801                        goto fail;
    46764802                }
    4677         }
    4678 
    4679         resp->data = (uint8_t *)talloc_memdup(mem_ctx, data.dptr + 4,
    4680                                               data.dsize - 4);
     4803                entry_timeout = BVAL(data.dptr, 4);
     4804                if (time(NULL) > entry_timeout) {
     4805                        DEBUG(10, ("Entry has timed out\n"));
     4806                        goto fail;
     4807                }
     4808        }
     4809
     4810        resp->data = (uint8_t *)talloc_memdup(mem_ctx, data.dptr + 12,
     4811                                              data.dsize - 12);
    46814812        if (resp->data == NULL) {
    46824813                DEBUG(10, ("talloc failed\n"));
    46834814                goto fail;
    46844815        }
    4685         resp->length = data.dsize - 4;
     4816        resp->length = data.dsize - 12;
    46864817
    46874818        ret = true;
     
    46964827        TDB_DATA key, data;
    46974828        uint32_t dom_seqnum, last_check;
     4829        uint64_t timeout;
    46984830
    46994831        if (!wcache_opnum_cacheable(opnum)) {
     
    47154847        }
    47164848
    4717         data.dsize = resp->length + 4;
     4849        timeout = time(NULL) + lp_winbind_cache_time();
     4850
     4851        data.dsize = resp->length + 12;
    47184852        data.dptr = talloc_array(key.dptr, uint8_t, data.dsize);
    47194853        if (data.dptr == NULL) {
     
    47224856
    47234857        SIVAL(data.dptr, 0, dom_seqnum);
    4724         memcpy(data.dptr+4, resp->data, resp->length);
     4858        SBVAL(data.dptr, 4, timeout);
     4859        memcpy(data.dptr + 12, resp->data, resp->length);
    47254860
    47264861        tdb_store(wcache->tdb, key, data, 0);
  • branches/samba-3.5.x/source3/winbindd/winbindd_cm.c

    r596 r733  
    17671767                                 domain->active_directory ? "" : "NOT "));
    17681768
     1769                        domain->can_do_ncacn_ip_tcp = domain->active_directory;
     1770                        domain->can_do_validation6 = domain->active_directory;
    17691771
    17701772                        domain->initialized = True;
  • branches/samba-3.5.x/source3/winbindd/winbindd_pam.c

    r732 r733  
    21022102done:
    21032103
     2104        if (NT_STATUS_EQUAL(result, NT_STATUS_IO_TIMEOUT)) {
     2105                DEBUG(3,("winbindd_dual_pam_auth_crap: sam_network_logon(ex) "
     2106                                "returned NT_STATUS_IO_TIMEOUT after the retry."
     2107                                "We didn't know what's going on killing "
     2108                                "connections to domain %s\n",
     2109                                name_domain));
     2110                invalidate_cm_connection(&contact_domain->conn);
     2111        }
     2112
    21042113        /* give us a more useful (more correct?) error code */
    21052114        if ((NT_STATUS_EQUAL(result, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND) ||
Note: See TracChangeset for help on using the changeset viewer.