Ignore:
Timestamp:
Jan 15, 2010, 8:23:30 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update Samba 3.3 to 3.3.10 (source)

Location:
branches/samba-3.3.x/source/smbd
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.3.x/source/smbd/aio.c

    r222 r370  
    427427*****************************************************************************/
    428428
    429 static int handle_aio_read_complete(struct aio_extra *aio_ex)
    430 {
    431         int ret = 0;
     429static int handle_aio_read_complete(struct aio_extra *aio_ex, int errcode)
     430{
    432431        int outsize;
    433432        char *outbuf = aio_ex->outbuf;
     
    441440                   true.... JRA. */
    442441
    443                 /* If errno is ECANCELED then don't return anything to the
    444                  * client. */
    445                 if (errno == ECANCELED) {
    446                         srv_cancel_sign_response(aio_ex->mid, false);
    447                         return 0;
    448                 }
    449 
    450                 DEBUG( 3,( "handle_aio_read_complete: file %s nread == -1. "
     442                DEBUG( 3,( "handle_aio_read_complete: file %s nread == %d. "
    451443                           "Error = %s\n",
    452                            aio_ex->fsp->fsp_name, strerror(errno) ));
    453 
    454                 ret = errno;
    455                 ERROR_NT(map_nt_error_from_unix(ret));
     444                           aio_ex->fsp->fsp_name, (int)nread, strerror(errcode) ));
     445
     446                ERROR_NT(map_nt_error_from_unix(errcode));
    456447                outsize = srv_set_message(outbuf,0,0,true);
    457448        } else {
     
    485476                  (unsigned int)nread ));
    486477
    487         return ret;
     478        return errcode;
    488479}
    489480
     
    493484*****************************************************************************/
    494485
    495 static int handle_aio_write_complete(struct aio_extra *aio_ex)
    496 {
    497         int ret = 0;
     486static int handle_aio_write_complete(struct aio_extra *aio_ex, int errcode)
     487{
    498488        files_struct *fsp = aio_ex->fsp;
    499489        char *outbuf = aio_ex->outbuf;
     
    507497                                         "aio_write_behind failed ! File %s "
    508498                                         "is corrupt ! Error %s\n",
    509                                          fsp->fsp_name, strerror(errno) ));
    510                                 ret = errno;
     499                                         fsp->fsp_name, strerror(errcode) ));
    511500                        } else {
    512501                                DEBUG(0,("handle_aio_write_complete: "
     
    516505                                         (unsigned int)numtowrite,
    517506                                         (int)nwritten ));
    518                                 ret = EIO;
     507                                errcode = EIO;
    519508                        }
    520509                } else {
     
    523512                                  fsp->fsp_name ));
    524513                }
     514                /* TODO: should no return 0 in case of an error !!! */
    525515                return 0;
    526516        }
     
    535525                           (int)nwritten, strerror(errno) ));
    536526
    537                 /* If errno is ECANCELED then don't return anything to the
    538                  * client. */
    539                 if (errno == ECANCELED) {
    540                         srv_cancel_sign_response(aio_ex->mid, false);
    541                         return 0;
    542                 }
    543 
    544                 ret = errno;
    545                 ERROR_BOTH(map_nt_error_from_unix(ret), ERRHRD, ERRdiskfull);
     527                ERROR_NT(map_nt_error_from_unix(errcode));
    546528                srv_set_message(outbuf,0,0,true);
    547529        } else {
     
    560542                status = sync_file(fsp->conn,fsp, write_through);
    561543                if (!NT_STATUS_IS_OK(status)) {
    562                         ret = errno;
    563                         ERROR_BOTH(map_nt_error_from_unix(ret),
     544                        errcode = errno;
     545                        ERROR_BOTH(map_nt_error_from_unix(errcode),
    564546                                   ERRHRD, ERRdiskfull);
    565547                        srv_set_message(outbuf,0,0,true);
     
    581563                  (unsigned int)numtowrite, (unsigned int)nwritten ));
    582564
    583         return ret;
     565        return errcode;
    584566}
    585567
     
    599581
    600582        /* Ensure the operation has really completed. */
    601         if (SMB_VFS_AIO_ERROR(aio_ex->fsp, &aio_ex->acb) == EINPROGRESS) {
     583        err = SMB_VFS_AIO_ERROR(aio_ex->fsp, &aio_ex->acb);
     584        if (err == EINPROGRESS) {
    602585                DEBUG(10,( "handle_aio_completed: operation mid %u still in "
    603586                           "process for file %s\n",
    604587                           aio_ex->mid, aio_ex->fsp->fsp_name ));
    605588                return False;
    606         }
     589        } else if (err == ECANCELED) {
     590                /* If error is ECANCELED then don't return anything to the
     591                 * client. */
     592                DEBUG(10,( "handle_aio_completed: operation mid %u"
     593                        " canceled\n", aio_ex->mid));
     594                srv_cancel_sign_response(aio_ex->mid, false);
     595                return True;
     596        }
     597
    607598
    608599        if (aio_ex->read_req) {
    609                 err = handle_aio_read_complete(aio_ex);
     600                err = handle_aio_read_complete(aio_ex, err);
    610601        } else {
    611                 err = handle_aio_write_complete(aio_ex);
     602                err = handle_aio_write_complete(aio_ex, err);
    612603        }
    613604
  • branches/samba-3.3.x/source/smbd/blocking.c

    r206 r370  
    9595
    9696/****************************************************************************
     97 We need a version of timeval_min that treats zero timval as infinite.
     98****************************************************************************/
     99
     100static struct timeval timeval_brl_min(const struct timeval *tv1,
     101                                        const struct timeval *tv2)
     102{
     103        if (timeval_is_zero(tv1)) {
     104                return *tv2;
     105        }
     106        if (timeval_is_zero(tv2)) {
     107                return *tv1;
     108        }
     109        return timeval_min(tv1, tv2);
     110}
     111
     112/****************************************************************************
    97113 After a change to blocking_lock_queue, recalculate the timed_event for the
    98114 next processing.
     
    117133                        if (brl->blocking_pid == 0xFFFFFFFF) {
    118134                                struct timeval psx_to = timeval_current_ofs(10, 0);
    119                                 next_timeout = timeval_min(&next_timeout, &psx_to);
     135                                next_timeout = timeval_brl_min(&next_timeout, &psx_to);
    120136                        }
    121137
     
    123139                }
    124140
    125                 if (timeval_is_zero(&next_timeout)) {
    126                         next_timeout = brl->expire_time;
    127                 }
    128                 else {
    129                         next_timeout = timeval_min(&next_timeout,
    130                                                    &brl->expire_time);
    131                 }
     141                next_timeout = timeval_brl_min(&next_timeout, &brl->expire_time);
    132142        }
    133143
     
    687697        struct timeval tv_curr = timeval_current();
    688698        blocking_lock_record *blr, *next = NULL;
    689         bool recalc_timeout = False;
    690699
    691700        /*
     
    737746                        DLIST_REMOVE(blocking_lock_queue, blr);
    738747                        free_blocking_lock_record(blr);
    739                         recalc_timeout = True;
    740748                        continue;
    741749                }
     
    762770                        DLIST_REMOVE(blocking_lock_queue, blr);
    763771                        free_blocking_lock_record(blr);
    764                         recalc_timeout = True;
    765772                        change_to_root_user();
    766773                        continue;
     
    788795                        DLIST_REMOVE(blocking_lock_queue, blr);
    789796                        free_blocking_lock_record(blr);
    790                         recalc_timeout = True;
    791797                        change_to_root_user();
    792798                        continue;
     
    824830                        DLIST_REMOVE(blocking_lock_queue, blr);
    825831                        free_blocking_lock_record(blr);
    826                         recalc_timeout = True;
    827                 }
    828         }
    829 
    830         if (recalc_timeout) {
    831                 recalc_brl_timeout();
    832         }
     832                }
     833        }
     834
     835        recalc_brl_timeout();
    833836}
    834837
  • branches/samba-3.3.x/source/smbd/dnsregister.c

    r222 r370  
    169169        int mdnsd_conn_fd = -1;
    170170
    171         if (dns_state->srv_ref == NULL) {
     171        if ((dns_state == NULL) || (dns_state->srv_ref == NULL)) {
    172172                return false;
    173173        }
  • branches/samba-3.3.x/source/smbd/dosmode.c

    r244 r370  
    2020
    2121#include "includes.h"
     22
     23extern enum protocol_types Protocol;
     24
     25static uint32_t filter_mode_by_protocol(uint32_t mode)
     26{
     27        if (Protocol <= PROTOCOL_LANMAN2) {
     28                DEBUG(10,("filter_mode_by_protocol: "
     29                        "filtering result 0x%x to 0x%x\n",
     30                        (unsigned int)mode,
     31                        (unsigned int)(mode & 0x3f) ));
     32                mode &= 0x3f;
     33        }
     34        return mode;
     35}
    2236
    2337static int set_sparse_flag(const SMB_STRUCT_STAT * const sbuf)
     
    361375        }
    362376
     377        if (result == 0) {
     378                result = FILE_ATTRIBUTE_NORMAL;
     379        }
     380
     381        result = filter_mode_by_protocol(result);
     382
    363383        DEBUG(8,("dos_mode_msdfs returning "));
    364384
     
    425445                result |= aHIDDEN;
    426446        }
     447
     448        if (result == 0) {
     449                result = FILE_ATTRIBUTE_NORMAL;
     450        }
     451
     452        result = filter_mode_by_protocol(result);
    427453
    428454        DEBUG(8,("dos_mode returning "));
  • branches/samba-3.3.x/source/smbd/mangle_hash.c

    r206 r370  
    433433                        /* Truncate at the '.' */
    434434                        *s1 = '\0';
     435                        /*
     436                         * DANGER WILL ROBINSON - this
     437                         * is changing a const string via
     438                         * an aliased pointer ! Remember to
     439                         * put it back once we've used it.
     440                         * JRA
     441                         */
    435442                        *s2 = '\0';
    436443                }
     
    444451                DEBUG(5,("cache_mangled_name: Stored entry %s -> %s\n", mangled_name_key, raw_name));
    445452        }
     453        /* Restore the change we made to the const string. */
     454        *s2 = '.';
    446455}
    447456
     
    614623        status = is_valid_name(name_ucs2, False, False);
    615624        SAFE_FREE(name_ucs2);
    616         return NT_STATUS_IS_OK(status);
     625        /* We return true if we *must* mangle, so if it's
     626         * a valid name (status == OK) then we must return
     627         * false. Bug #6939. */
     628        return !NT_STATUS_IS_OK(status);
    617629}
    618630
  • branches/samba-3.3.x/source/smbd/nttrans.c

    r222 r370  
    19051905
    19061906                /* needed_data_count 4 bytes */
    1907                 SIVAL(pdata,8,labels_data_count);
     1907                SIVAL(pdata, 8, labels_data_count+4);
    19081908
    19091909                cur_pdata+=12;
  • branches/samba-3.3.x/source/smbd/posix_acls.c

    r342 r370  
    930930                        nt_mask |= ((perms & S_IWUSR) ? UNIX_ACCESS_W : 0 );
    931931                        nt_mask |= ((perms & S_IXUSR) ? UNIX_ACCESS_X : 0 );
     932                }
     933                if ((perms & S_IWUSR) && lp_dos_filemode(snum)) {
     934                        nt_mask |= (WRITE_DAC_ACCESS|WRITE_OWNER_ACCESS);
    932935                }
    933936        }
  • branches/samba-3.3.x/source/smbd/reply.c

    r342 r370  
    5151        char *d = path;
    5252        const char *s = path;
    53         NTSTATUS ret = NT_STATUS_OK;
    5453        bool start_of_name_component = True;
    5554        bool stream_started = false;
     55        bool check_quota = false;
    5656
    5757        *p_last_component_contains_wcard = False;
     
    7171                                }
    7272                                if (StrCaseCmp(s, ":$DATA") != 0) {
    73                                         return NT_STATUS_INVALID_PARAMETER;
     73                                        check_quota = true;
    7474                                }
    7575                                break;
     
    132132                                /* Are we at the start ? Can't go back further if so. */
    133133                                if (d <= path) {
    134                                         ret = NT_STATUS_OBJECT_PATH_SYNTAX_BAD;
    135                                         break;
     134                                        return NT_STATUS_OBJECT_PATH_SYNTAX_BAD;
    136135                                }
    137136                                /* Go back one level... */
     
    206205        *d = '\0';
    207206
    208         return ret;
     207        if (check_quota) {
     208                if (StrCaseCmp(path, FAKE_FILE_NAME_QUOTA_UNIX) != 0) {
     209                        return NT_STATUS_INVALID_PARAMETER;
     210                }
     211        }
     212
     213        return NT_STATUS_OK;
    209214}
    210215
  • branches/samba-3.3.x/source/smbd/server.c

    r309 r370  
    652652                FD_ZERO(&w_fds);
    653653                GetTimeOfDay(&now);
     654
     655                /* Kick off our mDNS registration. */
     656                if (dns_port != 0) {
     657                        dns_register_smbd(&dns_reg, dns_port, &maxfd,
     658                                        &r_fds, &idle_timeout);
     659                }
    654660
    655661                event_add_to_select_args(smbd_event_context(), &now,
  • branches/samba-3.3.x/source/smbd/trans2.c

    r309 r370  
    12801280        char *last_entry_ptr;
    12811281        bool was_8_3;
    1282         uint32 nt_extmode; /* Used for NT connections instead of mode */
    12831282        bool needslash = ( conn->dirpath[strlen(conn->dirpath) -1] != '/');
    12841283        bool check_mangled_names = lp_manglednames(conn->params);
     
    14661465        p = pdata;
    14671466        last_entry_ptr = p;
    1468 
    1469         nt_extmode = mode ? mode : FILE_ATTRIBUTE_NORMAL;
    14701467
    14711468        switch (info_level) {
     
    16151612                        SOFF_T(p,0,file_size); p += 8;
    16161613                        SOFF_T(p,0,allocation_size); p += 8;
    1617                         SIVAL(p,0,nt_extmode); p += 4;
     1614                        SIVAL(p,0,mode); p += 4;
    16181615                        q = p; p += 4; /* q is placeholder for name length. */
    16191616                        {
     
    16661663                        SOFF_T(p,0,file_size); p += 8;
    16671664                        SOFF_T(p,0,allocation_size); p += 8;
    1668                         SIVAL(p,0,nt_extmode); p += 4;
     1665                        SIVAL(p,0,mode); p += 4;
    16691666                        len = srvstr_push(base_data, flags2,
    16701667                                          p + 4, fname, PTR_DIFF(end_data, p+4),
     
    16891686                        SOFF_T(p,0,file_size); p += 8;
    16901687                        SOFF_T(p,0,allocation_size); p += 8;
    1691                         SIVAL(p,0,nt_extmode); p += 4;
     1688                        SIVAL(p,0,mode); p += 4;
    16921689                        q = p; p += 4; /* q is placeholder for name length. */
    16931690                        {
     
    17381735                        SOFF_T(p,0,file_size); p += 8;
    17391736                        SOFF_T(p,0,allocation_size); p += 8;
    1740                         SIVAL(p,0,nt_extmode); p += 4;
     1737                        SIVAL(p,0,mode); p += 4;
    17411738                        q = p; p += 4; /* q is placeholder for name length. */
    17421739                        {
     
    17711768                        SOFF_T(p,0,file_size); p += 8;
    17721769                        SOFF_T(p,0,allocation_size); p += 8;
    1773                         SIVAL(p,0,nt_extmode); p += 4;
     1770                        SIVAL(p,0,mode); p += 4;
    17741771                        q = p; p += 4; /* q is placeholder for name length */
    17751772                        {
     
    22702267        continue_bit = (findnext_flags & FLAG_TRANS2_FIND_CONTINUE);
    22712268
    2272         srvstr_get_path_wcard(ctx, params, req->flags2, &resume_name,
     2269        if (!continue_bit) {
     2270                /* We only need resume_name if continue_bit is zero. */
     2271                srvstr_get_path_wcard(ctx, params, req->flags2, &resume_name,
    22732272                              params+12,
    22742273                              total_params - 12, STR_TERMINATE, &ntstatus,
    22752274                              &mask_contains_wcard);
    2276         if (!NT_STATUS_IS_OK(ntstatus)) {
    2277                 /* Win9x or OS/2 can send a resume name of ".." or ".". This will cause the parser to
    2278                    complain (it thinks we're asking for the directory above the shared
    2279                    path or an invalid name). Catch this as the resume name is only compared, never used in
    2280                    a file access. JRA. */
    2281                 srvstr_pull_talloc(ctx, params, req->flags2,
     2275                if (!NT_STATUS_IS_OK(ntstatus)) {
     2276                        /* Win9x or OS/2 can send a resume name of ".." or ".". This will cause the parser to
     2277                           complain (it thinks we're asking for the directory above the shared
     2278                           path or an invalid name). Catch this as the resume name is only compared, never used in
     2279                           a file access. JRA. */
     2280                        srvstr_pull_talloc(ctx, params, req->flags2,
    22822281                                &resume_name, params+12,
    22832282                                total_params - 12,
    22842283                                STR_TERMINATE);
    22852284
    2286                 if (!resume_name || !(ISDOT(resume_name) || ISDOTDOT(resume_name))) {
    2287                         reply_nterror(req, ntstatus);
    2288                         return;
     2285                        if (!resume_name || !(ISDOT(resume_name) || ISDOTDOT(resume_name))) {
     2286                                reply_nterror(req, ntstatus);
     2287                                return;
     2288                        }
    22892289                }
    22902290        }
     
    22942294resume_key = %d resume name = %s continue=%d level = %d\n",
    22952295                dptr_num, max_data_bytes, maxentries, close_after_request, close_if_end,
    2296                 requires_resume_key, resume_key, resume_name, continue_bit, info_level));
     2296                requires_resume_key, resume_key,
     2297                resume_name ? resume_name : "(NULL)", continue_bit, info_level));
    22972298
    22982299        if (!maxentries) {
     
    24162417         */
    24172418
    2418         if(*resume_name && !continue_bit) {
     2419        if(!continue_bit && resume_name && *resume_name) {
    24192420                SMB_STRUCT_STAT st;
    24202421
     
    40784079                mode = dos_mode(conn,fname,&sbuf);
    40794080        }
    4080         if (!mode)
    4081                 mode = FILE_ATTRIBUTE_NORMAL;
    40824081
    40834082        nlink = sbuf.st_nlink;
Note: See TracChangeset for help on using the changeset viewer.