Ignore:
Timestamp:
May 24, 2009, 7:17:10 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update Samba 3.3 to 3.3.1

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

Legend:

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

    r206 r221  
    168168****************************************************************************/
    169169
    170 static NTSTATUS delete_all_streams(connection_struct *conn, const char *fname)
     170NTSTATUS delete_all_streams(connection_struct *conn, const char *fname)
    171171{
    172172        struct stream_struct *stream_info;
  • branches/samba-3.3.x/source/smbd/connection.c

    r206 r221  
    242242
    243243        snprintf( key_string, sizeof(key_string), "%s/%d/%d",
    244                 prec->name, procid_to_pid(&prec->pid), prec->pnum );
     244                prec->name, (int)procid_to_pid(&prec->pid), prec->pnum );
    245245
    246246        *kbuf = string_term_tdb_data(talloc_strdup(prec, key_string));
  • branches/samba-3.3.x/source/smbd/dnsregister.c

    r206 r221  
    6666static void dns_register_smbd_retry(struct event_context *ctx,
    6767                                   struct timed_event *te,
    68                                    const struct timeval *now,
     68                                   struct timeval now,
    6969                                   void *private_data)
    7070{
     
    8686                        NULL,
    8787                        timeval_current_ofs(DNS_REG_RETRY_INTERVAL, 0),
    88                         "DNS registration handler",
    8988                        dns_register_smbd_retry,
    9089                        dns_state);
  • branches/samba-3.3.x/source/smbd/file_access.c

    r206 r221  
    117117         * not help, by the DELETE_CHILD bit on the containing directory.
    118118         *
    119          * Here we check the other way round because with just posix
    120          * permissions looking at the file itself will never grant DELETE, so
    121          * by looking at the directory first we save one get_acl call.
     119         * Here we only check the directory permissions, we will
     120         * check the file DELETE permission separately.
    122121         */
    123122
    124         if (can_access_file_acl(conn, dname, FILE_DELETE_CHILD)) {
    125                 return true;
    126         }
    127 
    128         return can_access_file_acl(conn, fname, DELETE_ACCESS);
     123        return can_access_file_acl(conn, dname, FILE_DELETE_CHILD);
    129124}
    130125
  • branches/samba-3.3.x/source/smbd/filename.c

    r206 r221  
    127127        bool component_was_mangled = False;
    128128        bool name_has_wildcard = False;
     129        bool posix_pathnames = false;
    129130        NTSTATUS result;
     131        int ret = -1;
    130132
    131133        SET_STAT_INVALID(*pst);
     
    226228        }
    227229
    228         if (!lp_posix_pathnames()) {
     230        posix_pathnames = lp_posix_pathnames();
     231
     232        if (!posix_pathnames) {
    229233                stream = strchr_m(name, ':');
    230234
     
    269273         */
    270274
    271         if (SMB_VFS_STAT(conn,name,&st) == 0) {
     275        if (posix_pathnames) {
     276                ret = SMB_VFS_LSTAT(conn,name,&st);
     277        } else {
     278                ret = SMB_VFS_STAT(conn,name,&st);
     279        }
     280
     281        if (ret == 0) {
    272282                /* Ensure we catch all names with in "/."
    273283                   this is disallowed under Windows. */
     
    381391                 */
    382392
    383                 if (SMB_VFS_STAT(conn,name, &st) == 0) {
     393                if (posix_pathnames) {
     394                        ret = SMB_VFS_LSTAT(conn,name, &st);
     395                } else {
     396                        ret = SMB_VFS_STAT(conn,name, &st);
     397                }
     398
     399                if (ret == 0) {
    384400                        /*
    385401                         * It exists. it must either be a directory or this must
     
    599615                                 */
    600616
    601                                 if (SMB_VFS_STAT(conn,name, &st) == 0) {
     617                                if (posix_pathnames) {
     618                                        ret = SMB_VFS_LSTAT(conn,name, &st);
     619                                } else {
     620                                        ret = SMB_VFS_STAT(conn,name, &st);
     621                                }
     622
     623                                if (ret == 0) {
    602624                                        *pst = st;
    603625                                } else {
  • branches/samba-3.3.x/source/smbd/open.c

    r206 r221  
    5151static NTSTATUS check_open_rights(struct connection_struct *conn,
    5252                                const char *fname,
    53                                 uint32_t access_mask)
     53                                uint32_t access_mask,
     54                                uint32_t *access_granted)
    5455{
    5556        /* Check if we have rights to open. */
    5657        NTSTATUS status;
    57         uint32_t access_granted = 0;
    5858        struct security_descriptor *sd;
     59
     60        *access_granted = 0;
    5961
    6062        status = SMB_VFS_GET_NT_ACL(conn, fname,
     
    7476                                conn->server_info->ptok,
    7577                                access_mask,
    76                                 &access_granted);
     78                                access_granted);
    7779
    7880        TALLOC_FREE(sd);
     81
     82        DEBUG(10,("check_open_rights: file %s requesting "
     83                "0x%x returning 0x%x (%s)\n",
     84                fname,
     85                (unsigned int)access_mask,
     86                (unsigned int)*access_granted,
     87                nt_errstr(status) ));
     88
    7989        return status;
    8090}
     
    399409                fsp->fh->fd = -1; /* What we used to call a stat open. */
    400410                if (file_existed) {
     411                        uint32_t access_granted = 0;
     412
    401413                        status = check_open_rights(conn,
    402414                                        path,
    403                                         access_mask);
     415                                        access_mask,
     416                                        &access_granted);
    404417                        if (!NT_STATUS_IS_OK(status)) {
    405                                 DEBUG(10, ("open_file: Access denied on "
    406                                         "file %s\n",
    407                                         path));
    408                                 return status;
     418                                if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
     419                                        if ((access_mask & DELETE_ACCESS) &&
     420                                                        (access_granted == DELETE_ACCESS) &&
     421                                                        can_delete_file_in_directory(conn, path)) {
     422                                                /* Were we trying to do a stat open
     423                                                 * for delete and didn't get DELETE
     424                                                 * access (only) ? Check if the
     425                                                 * directory allows DELETE_CHILD.
     426                                                 * See here:
     427                                                 * http://blogs.msdn.com/oldnewthing/archive/2004/06/04/148426.aspx
     428                                                 * for details. */
     429
     430                                                DEBUG(10,("open_file: overrode ACCESS_DENIED "
     431                                                        "on file %s\n",
     432                                                        path ));
     433                                        } else {
     434                                                DEBUG(10, ("open_file: Access denied on "
     435                                                        "file %s\n",
     436                                                        path));
     437                                                return status;
     438                                        }
     439                                } else if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND) &&
     440                                                        fsp->posix_open &&
     441                                                        S_ISLNK(psbuf->st_mode)) {
     442                                        /* This is a POSIX stat open for delete
     443                                         * or rename on a symlink that points
     444                                         * nowhere. Allow. */
     445                                        DEBUG(10, ("open_file: allowing POSIX open "
     446                                                "on bad symlink %s\n",
     447                                                path ));
     448                                } else {
     449                                        DEBUG(10, ("open_file: check_open_rights "
     450                                                "on file %s returned %s\n",
     451                                                path, nt_errstr(status) ));
     452                                        return status;
     453                                }
    409454                        }
    410455                }
     
    13141359        bool posix_open = False;
    13151360        bool new_file_created = False;
     1361        bool clear_ads = false;
    13161362        struct file_id id;
    13171363        NTSTATUS fsp_open = NT_STATUS_ACCESS_DENIED;
     
    13671413                   "unix mode=0%o oplock_request=%d\n",
    13681414                   fname, new_dos_attributes, access_mask, share_access,
    1369                    create_disposition, create_options, unx_mode,
     1415                   create_disposition, create_options, (unsigned int)unx_mode,
    13701416                   oplock_request));
    13711417
     
    14461492                         * exist create. */
    14471493                        flags2 |= (O_CREAT | O_TRUNC);
     1494                        clear_ads = true;
    14481495                        break;
    14491496
     
    14521499                         * exist create. */
    14531500                        flags2 |= (O_CREAT | O_TRUNC);
     1501                        clear_ads = true;
    14541502                        break;
    14551503
     
    14761524                        }
    14771525                        flags2 |= O_TRUNC;
     1526                        clear_ads = true;
    14781527                        break;
    14791528
     
    19081957
    19091958        SMB_ASSERT(lck != NULL);
     1959
     1960        /* Delete streams if create_disposition requires it */
     1961        if (file_existed && clear_ads && !is_ntfs_stream_name(fname)) {
     1962                status = delete_all_streams(conn, fname);
     1963                if (!NT_STATUS_IS_OK(status)) {
     1964                        TALLOC_FREE(lck);
     1965                        fd_close(fsp);
     1966                        return status;
     1967                }
     1968        }
    19101969
    19111970        /* note that we ignore failure for the following. It is
     
    23992458
    24002459        if (info == FILE_WAS_OPENED) {
     2460                uint32_t access_granted = 0;
    24012461                status = check_open_rights(conn,
    24022462                                        fname,
    2403                                         access_mask);
     2463                                        access_mask,
     2464                                        &access_granted);
    24042465                if (!NT_STATUS_IS_OK(status)) {
    24052466                        DEBUG(10, ("open_directory: check_open_rights on "
     
    28202881            && (share_access & FILE_SHARE_DELETE)
    28212882            && (access_mask & DELETE_ACCESS)
    2822             && (!can_delete_file_in_directory(conn, fname))) {
     2883            && (!(can_delete_file_in_directory(conn, fname) ||
     2884                 can_access_file_acl(conn, fname, DELETE_ACCESS)))) {
    28232885                status = NT_STATUS_ACCESS_DENIED;
     2886                DEBUG(10,("create_file_unixpath: open file %s "
     2887                        "for delete ACCESS_DENIED\n", fname ));
    28242888                goto fail;
    28252889        }
  • branches/samba-3.3.x/source/smbd/posix_acls.c

    r206 r221  
    564564****************************************************************************/
    565565
    566 static size_t count_canon_ace_list( canon_ace *list_head )
     566static size_t count_canon_ace_list( canon_ace *l_head )
    567567{
    568568        size_t count = 0;
    569569        canon_ace *ace;
    570570
    571         for (ace = list_head; ace; ace = ace->next)
     571        for (ace = l_head; ace; ace = ace->next)
    572572                count++;
    573573
     
    579579****************************************************************************/
    580580
    581 static void free_canon_ace_list( canon_ace *list_head )
     581static void free_canon_ace_list( canon_ace *l_head )
    582582{
    583583        canon_ace *list, *next;
    584584
    585         for (list = list_head; list; list = next) {
     585        for (list = l_head; list; list = next) {
    586586                next = list->next;
    587                 DLIST_REMOVE(list_head, list);
     587                DLIST_REMOVE(l_head, list);
    588588                SAFE_FREE(list);
    589589        }
     
    761761static void merge_aces( canon_ace **pp_list_head )
    762762{
    763         canon_ace *list_head = *pp_list_head;
     763        canon_ace *l_head = *pp_list_head;
    764764        canon_ace *curr_ace_outer;
    765765        canon_ace *curr_ace_outer_next;
     
    770770         */
    771771
    772         for (curr_ace_outer = list_head; curr_ace_outer; curr_ace_outer = curr_ace_outer_next) {
     772        for (curr_ace_outer = l_head; curr_ace_outer; curr_ace_outer = curr_ace_outer_next) {
    773773                canon_ace *curr_ace;
    774774                canon_ace *curr_ace_next;
     
    792792
    793793                                curr_ace_outer->perms |= curr_ace->perms;
    794                                 DLIST_REMOVE(list_head, curr_ace);
     794                                DLIST_REMOVE(l_head, curr_ace);
    795795                                SAFE_FREE(curr_ace);
    796796                                curr_ace_outer_next = curr_ace_outer->next; /* We may have deleted the link. */
     
    805805         */
    806806
    807         for (curr_ace_outer = list_head; curr_ace_outer; curr_ace_outer = curr_ace_outer_next) {
     807        for (curr_ace_outer = l_head; curr_ace_outer; curr_ace_outer = curr_ace_outer_next) {
    808808                canon_ace *curr_ace;
    809809                canon_ace *curr_ace_next;
     
    837837                                         */
    838838
    839                                         DLIST_REMOVE(list_head, curr_ace);
     839                                        DLIST_REMOVE(l_head, curr_ace);
    840840                                        SAFE_FREE(curr_ace);
    841841                                        curr_ace_outer_next = curr_ace_outer->next; /* We may have deleted the link. */
     
    853853                                         */
    854854
    855                                         DLIST_REMOVE(list_head, curr_ace_outer);
     855                                        DLIST_REMOVE(l_head, curr_ace_outer);
    856856                                        SAFE_FREE(curr_ace_outer);
    857857                                        break;
     
    864864        /* We may have modified the list. */
    865865
    866         *pp_list_head = list_head;
     866        *pp_list_head = l_head;
    867867}
    868868
     
    21482148static void arrange_posix_perms(const char *filename, canon_ace **pp_list_head)
    21492149{
    2150         canon_ace *list_head = *pp_list_head;
     2150        canon_ace *l_head = *pp_list_head;
    21512151        canon_ace *owner_ace = NULL;
    21522152        canon_ace *other_ace = NULL;
    21532153        canon_ace *ace = NULL;
    21542154
    2155         for (ace = list_head; ace; ace = ace->next) {
     2155        for (ace = l_head; ace; ace = ace->next) {
    21562156                if (ace->type == SMB_ACL_USER_OBJ)
    21572157                        owner_ace = ace;
     
    21742174
    21752175        if (owner_ace) {
    2176                 DLIST_PROMOTE(list_head, owner_ace);
     2176                DLIST_PROMOTE(l_head, owner_ace);
    21772177        }
    21782178
    21792179        if (other_ace) {
    2180                 DLIST_DEMOTE(list_head, other_ace, canon_ace *);
     2180                DLIST_DEMOTE(l_head, other_ace, canon_ace *);
    21812181        }
    21822182
    21832183        /* We have probably changed the head of the list. */
    21842184
    2185         *pp_list_head = list_head;
     2185        *pp_list_head = l_head;
    21862186}
    21872187               
     
    21962196{
    21972197        mode_t acl_mask = (S_IRUSR|S_IWUSR|S_IXUSR);
    2198         canon_ace *list_head = NULL;
     2198        canon_ace *l_head = NULL;
    21992199        canon_ace *ace = NULL;
    22002200        canon_ace *next_ace = NULL;
     
    23002300                ace->inherited = get_inherited_flag(pal, ace, (the_acl_type == SMB_ACL_TYPE_DEFAULT));
    23012301
    2302                 DLIST_ADD(list_head, ace);
     2302                DLIST_ADD(l_head, ace);
    23032303        }
    23042304
     
    23072307         */
    23082308
    2309         if (!ensure_canon_entry_valid(&list_head, conn->params,
     2309        if (!ensure_canon_entry_valid(&l_head, conn->params,
    23102310                                      S_ISDIR(psbuf->st_mode), powner, pgroup,
    23112311                                      psbuf, False))
     
    23192319        DEBUG(10,("canonicalise_acl: %s ace entries before arrange :\n", the_acl_type == SMB_ACL_TYPE_ACCESS ? "Access" : "Default" ));
    23202320
    2321         for ( ace_count = 0, ace = list_head; ace; ace = next_ace, ace_count++) {
     2321        for ( ace_count = 0, ace = l_head; ace; ace = next_ace, ace_count++) {
    23222322                next_ace = ace->next;
    23232323
     
    23272327
    23282328                if (ace->perms == 0) {
    2329                         DLIST_PROMOTE(list_head, ace);
     2329                        DLIST_PROMOTE(l_head, ace);
    23302330                }
    23312331
     
    23352335        }
    23362336
    2337         arrange_posix_perms(fname,&list_head );
    2338 
    2339         print_canon_ace_list( "canonicalise_acl: ace entries after arrange", list_head );
    2340 
    2341         return list_head;
     2337        arrange_posix_perms(fname,&l_head );
     2338
     2339        print_canon_ace_list( "canonicalise_acl: ace entries after arrange", l_head );
     2340
     2341        return l_head;
    23422342
    23432343  fail:
    23442344
    2345         free_canon_ace_list(list_head);
     2345        free_canon_ace_list(l_head);
    23462346        return NULL;
    23472347}
     
    40464046        SMB_ACL_T def_acl = NULL;
    40474047
    4048         if (num_def_acls && !S_ISDIR(psbuf->st_mode)) {
    4049                 DEBUG(5,("set_unix_posix_default_acl: Can't set default ACL on non-directory file %s\n", fname ));
    4050                 errno = EISDIR;
    4051                 return False;
     4048        if (!S_ISDIR(psbuf->st_mode)) {
     4049                if (num_def_acls) {
     4050                        DEBUG(5,("set_unix_posix_default_acl: Can't set default ACL on non-directory file %s\n", fname ));
     4051                        errno = EISDIR;
     4052                        return False;
     4053                } else {
     4054                        return True;
     4055                }
    40524056        }
    40534057
  • branches/samba-3.3.x/source/smbd/reply.c

    r206 r221  
    56155615                }
    56165616        } else {
    5617                 if (SMB_VFS_STAT(conn,fsp->fsp_name,&sbuf) == -1) {
     5617                int ret = -1;
     5618                if (fsp->posix_open) {
     5619                        ret = SMB_VFS_LSTAT(conn,fsp->fsp_name,&sbuf);
     5620                } else {
     5621                        ret = SMB_VFS_STAT(conn,fsp->fsp_name,&sbuf);
     5622                }
     5623                if (ret == -1) {
    56185624                        return map_nt_error_from_unix(errno);
    56195625                }
     
    57195725        const char *dname;
    57205726        long offset = 0;
     5727        bool posix_pathnames = lp_posix_pathnames();
    57215728
    57225729        ZERO_STRUCT(sbuf1);
     
    58305837
    58315838                ZERO_STRUCT(sbuf1);
    5832                 SMB_VFS_STAT(conn, directory, &sbuf1);
     5839                if (posix_pathnames) {
     5840                        SMB_VFS_LSTAT(conn, directory, &sbuf1);
     5841                } else {
     5842                        SMB_VFS_STAT(conn, directory, &sbuf1);
     5843                }
    58335844
    58345845                status = S_ISDIR(sbuf1.st_mode) ?
    58355846                        open_directory(conn, req, directory, &sbuf1,
    5836                                        access_mask,
    5837                                        FILE_SHARE_READ|FILE_SHARE_WRITE,
    5838                                        FILE_OPEN, 0, 0, NULL,
    5839                                        &fsp)
     5847                                        access_mask,
     5848                                        FILE_SHARE_READ|FILE_SHARE_WRITE,
     5849                                        FILE_OPEN,
     5850                                        0,
     5851                                        posix_pathnames ? FILE_FLAG_POSIX_SEMANTICS|0777 : 0,
     5852                                        NULL,
     5853                                        &fsp)
    58405854                        : open_file_ntcreate(conn, req, directory, &sbuf1,
    5841                                              access_mask,
    5842                                              FILE_SHARE_READ|FILE_SHARE_WRITE,
    5843                                              FILE_OPEN, 0, 0, 0, NULL,
    5844                                              &fsp);
     5855                                        access_mask,
     5856                                        FILE_SHARE_READ|FILE_SHARE_WRITE,
     5857                                        FILE_OPEN,
     5858                                        0,
     5859                                        posix_pathnames ? FILE_FLAG_POSIX_SEMANTICS|0777 : 0,
     5860                                        0,
     5861                                        NULL,
     5862                                        &fsp);
    58455863
    58465864                if (!NT_STATUS_IS_OK(status)) {
     
    59345952
    59355953                ZERO_STRUCT(sbuf1);
    5936                 SMB_VFS_STAT(conn, fname, &sbuf1);
     5954                if (posix_pathnames) {
     5955                        SMB_VFS_LSTAT(conn, fname, &sbuf1);
     5956                } else {
     5957                        SMB_VFS_STAT(conn, fname, &sbuf1);
     5958                }
    59375959
    59385960                status = S_ISDIR(sbuf1.st_mode) ?
    59395961                        open_directory(conn, req, fname, &sbuf1,
    5940                                        access_mask,
    5941                                        FILE_SHARE_READ|FILE_SHARE_WRITE,
    5942                                        FILE_OPEN, 0, 0, NULL,
    5943                                        &fsp)
     5962                                        access_mask,
     5963                                        FILE_SHARE_READ|FILE_SHARE_WRITE,
     5964                                        FILE_OPEN,
     5965                                        0,
     5966                                        posix_pathnames ? FILE_FLAG_POSIX_SEMANTICS|0777 : 0,
     5967                                        NULL,
     5968                                        &fsp)
    59445969                        : open_file_ntcreate(conn, req, fname, &sbuf1,
    5945                                              access_mask,
    5946                                              FILE_SHARE_READ|FILE_SHARE_WRITE,
    5947                                              FILE_OPEN, 0, 0, 0, NULL,
    5948                                              &fsp);
     5970                                        access_mask,
     5971                                        FILE_SHARE_READ|FILE_SHARE_WRITE,
     5972                                        FILE_OPEN,
     5973                                        0,
     5974                                        posix_pathnames ? FILE_FLAG_POSIX_SEMANTICS|0777 : 0,
     5975                                        0,
     5976                                        NULL,
     5977                                        &fsp);
    59495978
    59505979                if (!NT_STATUS_IS_OK(status)) {
     
    71247153                }
    71257154        } else {
    7126                 if (SMB_VFS_STAT(conn, fsp->fsp_name, &sbuf) == -1) {
     7155                int ret = -1;
     7156
     7157                if (fsp->posix_open) {
     7158                        ret = SMB_VFS_LSTAT(conn, fsp->fsp_name, &sbuf);
     7159                } else {
     7160                        ret = SMB_VFS_STAT(conn, fsp->fsp_name, &sbuf);
     7161                }
     7162                if (ret == -1) {
    71277163                        status = map_nt_error_from_unix(errno);
    71287164                        reply_nterror(req, status);
  • branches/samba-3.3.x/source/smbd/server.c

    r206 r221  
    300300                   if they can grab any of the pending locks
    301301                */
    302                 DEBUG(3,(__location__ " Unclean shutdown of pid %u\n", pid));
     302                DEBUG(3,(__location__ " Unclean shutdown of pid %u\n", (unsigned int)pid));
    303303                messaging_send_buf(smbd_messaging_context(), procid_self(),
    304304                                   MSG_SMB_BRL_VALIDATE, NULL, 0);
     
    14391439
    14401440        if (*lp_rootdir()) {
    1441                 if (sys_chroot(lp_rootdir()) == 0)
    1442                         DEBUG(2,("Changed root to %s\n", lp_rootdir()));
     1441                if (sys_chroot(lp_rootdir()) != 0) {
     1442                        DEBUG(0,("Failed to change root to %s\n", lp_rootdir()));
     1443                        exit(1);
     1444                }
     1445                if (chdir("/") == -1) {
     1446                        DEBUG(0,("Failed to chdir to / on chroot to %s\n", lp_rootdir()));
     1447                        exit(1);
     1448                }
     1449                DEBUG(0,("Changed root to %s\n", lp_rootdir()));
    14431450        }
    14441451
  • branches/samba-3.3.x/source/smbd/sesssetup.c

    r206 r221  
    13571357        }
    13581358
    1359         DEBUG(0,("shutdown_other_smbds: shutting down pid %d "
    1360                  "(IP %s)\n", procid_to_pid(&crec->pid), ip));
     1359        DEBUG(0,("shutdown_other_smbds: shutting down pid %u "
     1360                 "(IP %s)\n", (unsigned int)procid_to_pid(&crec->pid), ip));
    13611361
    13621362        messaging_send(smbd_messaging_context(), crec->pid, MSG_SHUTDOWN,
Note: See TracChangeset for help on using the changeset viewer.