Ignore:
Timestamp:
May 12, 2014, 8:58:38 PM (11 years ago)
Author:
Silvan Scherrer
Message:

Samba 3.6: updated vendor to latest version

Location:
vendor/current/source3/modules
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/modules/vfs_acl_common.c

    r746 r860  
    647647                                        fsp->access_mask,
    648648                                        &access_granted);
    649                 if (!NT_STATUS_IS_OK(status)) {
     649                /*
     650                 * Check if we need to override ACCESS_DENIED for DELETE_ACCESS.
     651                 * Do this if we only failed open on DELETE_ACCESS, and
     652                 * we have permission to delete from the parent directory.
     653                 */
     654                if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) &&
     655                        (fsp->access_mask & DELETE_ACCESS) &&
     656                        (access_granted == DELETE_ACCESS) &&
     657                        can_delete_file_in_directory(handle->conn, smb_fname)) {
     658                                DEBUG(10,("open_acl_xattr: "
     659                                        "overrode "
     660                                        "DELETE_ACCESS on "
     661                                        "file %s\n",
     662                                        smb_fname_str_dbg(smb_fname)));
     663                                status = NT_STATUS_OK;
     664                } else if (!NT_STATUS_IS_OK(status)) {
    650665                        DEBUG(10,("open_acl_xattr: %s open "
    651666                                "for access 0x%x (0x%x) "
  • vendor/current/source3/modules/vfs_aio_pthread.c

    r748 r860  
    7575        int ret = 0;
    7676        int num_threads;
     77        int fd;
    7778
    7879        if (pool) {
     
    8687                return false;
    8788        }
     89
     90        fd = pthreadpool_signal_fd(pool);
     91
     92        set_blocking(fd, false);
     93
    8894        sock_event = tevent_add_fd(server_event_context(),
    8995                                NULL,
    90                                 pthreadpool_signal_fd(pool),
     96                                fd,
    9197                                TEVENT_FD_READ,
    9298                                aio_pthread_handle_completion,
     
    291297        }
    292298
    293         ret = pthreadpool_finished_job(pool, &jobid);
    294         if (ret) {
    295                 smb_panic("aio_pthread_handle_completion");
    296                 return;
    297         }
    298 
    299         pd = find_private_data_by_jobid(jobid);
    300         if (pd == NULL) {
    301                 DEBUG(1, ("aio_pthread_handle_completion cannot find jobid %d\n",
    302                           jobid));
    303                 return;
    304         }
    305 
    306         aio_ex = (struct aio_extra *)pd->aiocb->aio_sigevent.sigev_value.sival_ptr;
    307         smbd_aio_complete_aio_ex(aio_ex);
    308 
    309         DEBUG(10,("aio_pthread_handle_completion: jobid %d completed\n",
    310                 jobid ));
    311         TALLOC_FREE(aio_ex);
     299        while (true) {
     300                ret = pthreadpool_finished_job(pool, &jobid);
     301
     302                if (ret == EINTR || ret == EAGAIN) {
     303                        return;
     304                }
     305#ifdef EWOULDBLOCK
     306                if (ret == EWOULDBLOCK) {
     307                        return;
     308                }
     309#endif
     310
     311                if (ret == ECANCELED) {
     312                        return;
     313                }
     314
     315                if (ret) {
     316                        smb_panic("aio_pthread_handle_completion");
     317                        return;
     318                }
     319
     320                pd = find_private_data_by_jobid(jobid);
     321                if (pd == NULL) {
     322                        DEBUG(1, ("aio_pthread_handle_completion cannot find "
     323                                  "jobid %d\n", jobid));
     324                        return;
     325                }
     326
     327                aio_ex = (struct aio_extra *)
     328                        pd->aiocb->aio_sigevent.sigev_value.sival_ptr;
     329
     330                smbd_aio_complete_aio_ex(aio_ex);
     331
     332                DEBUG(10,("aio_pthread_handle_completion: jobid %d "
     333                          "completed\n", jobid ));
     334                TALLOC_FREE(aio_ex);
     335        }
    312336}
    313337
  • vendor/current/source3/modules/vfs_catia.c

    r740 r860  
    1111 * Copyright (C) Volker Lendecke, 2005
    1212 * Copyright (C) Aravind Srinivasan, 2009
     13 * Copyright (C) Guenter Kukkukk, 2013
    1314 *
    1415 * This program is free software; you can redistribute it and/or modify
     
    2930#include "includes.h"
    3031#include "smbd/smbd.h"
     32
     33static int vfs_catia_debug_level = DBGC_VFS;
     34
     35#undef DBGC_CLASS
     36#define DBGC_CLASS vfs_catia_debug_level
    3137
    3238#define GLOBAL_SNUM     0xFFFFFFF
     
    296302        char *name = NULL;
    297303        char *mapped_name;
    298         NTSTATUS ret;
     304        NTSTATUS status, ret;
    299305
    300306        /*
     
    309315                return NT_STATUS_NO_MEMORY;
    310316        }
    311         ret = catia_string_replace_allocate(handle->conn, name,
     317        status = catia_string_replace_allocate(handle->conn, name,
    312318                        &mapped_name, direction);
    313319
    314320        TALLOC_FREE(name);
    315         if (!NT_STATUS_IS_OK(ret)) {
    316                 return ret;
     321        if (!NT_STATUS_IS_OK(status)) {
     322                return status;
    317323        }
    318324
     
    322328        if (NT_STATUS_EQUAL(ret, NT_STATUS_NONE_MAPPED)) {
    323329                *pmapped_name = talloc_move(mem_ctx, &mapped_name);
     330                /* we need to return the former translation result here */
     331                ret = status;
    324332        } else {
    325333                TALLOC_FREE(mapped_name);
     
    10211029NTSTATUS vfs_catia_init(void)
    10221030{
    1023         return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "catia",
     1031        NTSTATUS ret;
     1032
     1033        ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "catia",
    10241034                                &vfs_catia_fns);
    1025 }
     1035        if (!NT_STATUS_IS_OK(ret))
     1036                return ret;
     1037
     1038        vfs_catia_debug_level = debug_add_class("catia");
     1039        if (vfs_catia_debug_level == -1) {
     1040                vfs_catia_debug_level = DBGC_VFS;
     1041                DEBUG(0, ("vfs_catia: Couldn't register custom debugging "
     1042                          "class!\n"));
     1043        } else {
     1044                DEBUG(10, ("vfs_catia: Debug class number of "
     1045                           "'catia': %d\n", vfs_catia_debug_level));
     1046        }
     1047
     1048        return ret;
     1049
     1050}
  • vendor/current/source3/modules/vfs_dirsort.c

    r740 r860  
    3131        long pos;
    3232        SMB_STRUCT_DIRENT *directory_list;
    33         long number_of_entries;
    34         time_t mtime;
     33        unsigned int number_of_entries;
     34        struct timespec mtime;
    3535        SMB_STRUCT_DIR *source_directory;
    36         int fd;
     36        files_struct *fsp; /* If open via FDOPENDIR. */
     37        struct smb_filename *smb_fname; /* If open via OPENDIR */
    3738};
    3839
    3940static void free_dirsort_privates(void **datap) {
    40         struct dirsort_privates *data = (struct dirsort_privates *) *datap;
    41         SAFE_FREE(data->directory_list);
    42         SAFE_FREE(data);
    43         *datap = NULL;
    44 
    45         return;
    46 }
    47 
    48 static bool open_and_sort_dir (vfs_handle_struct *handle)
    49 {
    50         SMB_STRUCT_DIRENT *dp;
    51         struct stat dir_stat;
    52         long current_pos;
    53         struct dirsort_privates *data = NULL;
    54 
    55         SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates,
    56                                 return false);
     41        TALLOC_FREE(*datap);
     42}
     43
     44static bool get_sorted_dir_mtime(vfs_handle_struct *handle,
     45                                struct dirsort_privates *data,
     46                                struct timespec *ret_mtime)
     47{
     48        int ret;
     49        struct timespec mtime;
     50
     51        if (data->fsp) {
     52                ret = fsp_stat(data->fsp);
     53                mtime = data->fsp->fsp_name->st.st_ex_mtime;
     54        } else {
     55                ret = SMB_VFS_STAT(handle->conn, data->smb_fname);
     56                mtime = data->smb_fname->st.st_ex_mtime;
     57        }
     58
     59        if (ret == -1) {
     60                return false;
     61        }
     62
     63        *ret_mtime = mtime;
     64
     65        return true;
     66}
     67
     68static bool open_and_sort_dir(vfs_handle_struct *handle,
     69                                struct dirsort_privates *data)
     70{
     71        unsigned int i = 0;
     72        unsigned int total_count = 0;
    5773
    5874        data->number_of_entries = 0;
    5975
    60         if (fstat(data->fd, &dir_stat) == 0) {
    61                 data->mtime = dir_stat.st_mtime;
     76        if (get_sorted_dir_mtime(handle, data, &data->mtime) == false) {
     77                return false;
    6278        }
    6379
    6480        while (SMB_VFS_NEXT_READDIR(handle, data->source_directory, NULL)
    6581               != NULL) {
    66                 data->number_of_entries++;
     82                total_count++;
     83        }
     84
     85        if (total_count == 0) {
     86                return false;
    6787        }
    6888
     
    7292
    7393        /* Set up an array and read the directory entries into it */
    74         SAFE_FREE(data->directory_list); /* destroy previous cache if needed */
    75         data->directory_list = (SMB_STRUCT_DIRENT *)SMB_MALLOC(
    76                 data->number_of_entries * sizeof(SMB_STRUCT_DIRENT));
     94        TALLOC_FREE(data->directory_list); /* destroy previous cache if needed */
     95        data->directory_list = talloc_zero_array(data,
     96                                                 SMB_STRUCT_DIRENT,
     97                                                 total_count);
    7798        if (!data->directory_list) {
    7899                return false;
    79100        }
    80         current_pos = data->pos;
    81         data->pos = 0;
    82         while ((dp = SMB_VFS_NEXT_READDIR(handle, data->source_directory,
    83                                           NULL)) != NULL) {
    84                 data->directory_list[data->pos++] = *dp;
    85         }
     101        for (i = 0; i < total_count; i++) {
     102                SMB_STRUCT_DIRENT *dp = SMB_VFS_NEXT_READDIR(handle,
     103                                                data->source_directory,
     104                                                NULL);
     105                if (dp == NULL) {
     106                        break;
     107                }
     108                data->directory_list[i] = *dp;
     109        }
     110
     111        data->number_of_entries = i;
    86112
    87113        /* Sort the directory entries by name */
    88         data->pos = current_pos;
    89114        TYPESAFE_QSORT(data->directory_list, data->number_of_entries, compare_dirent);
    90115        return true;
     
    95120                                       uint32 attr)
    96121{
     122        NTSTATUS status;
    97123        struct dirsort_privates *data = NULL;
    98124
    99125        /* set up our private data about this directory */
    100         data = (struct dirsort_privates *)SMB_MALLOC(
    101                 sizeof(struct dirsort_privates));
    102 
     126        data = talloc_zero(handle->conn, struct dirsort_privates);
    103127        if (!data) {
    104128                return NULL;
    105129        }
    106130
    107         data->directory_list = NULL;
    108         data->pos = 0;
     131        status = create_synthetic_smb_fname(data,
     132                                        fname,
     133                                        NULL,
     134                                        NULL,
     135                                        &data->smb_fname);
     136        if (!NT_STATUS_IS_OK(status)) {
     137                TALLOC_FREE(data);
     138                return NULL;
     139        }
    109140
    110141        /* Open the underlying directory and count the number of entries */
     
    112143                                                      attr);
    113144
    114         data->fd = dirfd(data->source_directory);
     145        if (data->source_directory == NULL) {
     146                TALLOC_FREE(data);
     147                return NULL;
     148        }
     149
     150        if (!open_and_sort_dir(handle, data)) {
     151                SMB_VFS_NEXT_CLOSEDIR(handle,data->source_directory);
     152                TALLOC_FREE(data);
     153                return NULL;
     154        }
    115155
    116156        SMB_VFS_HANDLE_SET_DATA(handle, data, free_dirsort_privates,
    117157                                struct dirsort_privates, return NULL);
    118 
    119         if (!open_and_sort_dir(handle)) {
    120                 SMB_VFS_NEXT_CLOSEDIR(handle,data->source_directory);
    121                 return NULL;
    122         }
    123158
    124159        return data->source_directory;
     
    133168
    134169        /* set up our private data about this directory */
    135         data = (struct dirsort_privates *)SMB_MALLOC(
    136                 sizeof(struct dirsort_privates));
    137 
     170        data = talloc_zero(handle->conn, struct dirsort_privates);
    138171        if (!data) {
    139172                return NULL;
    140173        }
    141174
    142         data->directory_list = NULL;
    143         data->pos = 0;
     175        data->fsp = fsp;
    144176
    145177        /* Open the underlying directory and count the number of entries */
     
    148180
    149181        if (data->source_directory == NULL) {
    150                 SAFE_FREE(data);
    151                 return NULL;
    152         }
    153 
    154         data->fd = dirfd(data->source_directory);
     182                TALLOC_FREE(data);
     183                return NULL;
     184        }
     185
     186        if (!open_and_sort_dir(handle, data)) {
     187                SMB_VFS_NEXT_CLOSEDIR(handle,data->source_directory);
     188                TALLOC_FREE(data);
     189                /* fd is now closed. */
     190                fsp->fh->fd = -1;
     191                return NULL;
     192        }
    155193
    156194        SMB_VFS_HANDLE_SET_DATA(handle, data, free_dirsort_privates,
    157195                                struct dirsort_privates, return NULL);
    158 
    159         if (!open_and_sort_dir(handle)) {
    160                 SMB_VFS_NEXT_CLOSEDIR(handle,data->source_directory);
    161                 /* fd is now closed. */
    162                 fsp->fh->fd = -1;
    163                 return NULL;
    164         }
    165196
    166197        return data->source_directory;
     
    172203{
    173204        struct dirsort_privates *data = NULL;
    174         time_t current_mtime;
    175         struct stat dir_stat;
     205        struct timespec current_mtime;
    176206
    177207        SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates,
    178208                                return NULL);
    179209
    180         if (fstat(data->fd, &dir_stat) == -1) {
    181                 return NULL;
    182         }
    183 
    184         current_mtime = dir_stat.st_mtime;
     210        if (get_sorted_dir_mtime(handle, data, &current_mtime) == false) {
     211                return NULL;
     212        }
    185213
    186214        /* throw away cache and re-read the directory if we've changed */
    187         if (current_mtime > data->mtime) {
    188                 open_and_sort_dir(handle);
     215        if (timespec_compare(&current_mtime, &data->mtime) > 1) {
     216                open_and_sort_dir(handle, data);
    189217        }
    190218
  • vendor/current/source3/modules/vfs_fake_perms.c

    r740 r860  
    3030#define DBGC_CLASS DBGC_VFS
    3131
     32extern struct current_user current_user;
     33
    3234static int fake_perms_stat(vfs_handle_struct *handle,
    3335                           struct smb_filename *smb_fname)
     
    4244                        smb_fname->st.st_ex_mode = S_IRWXU;
    4345                }
    44                 smb_fname->st.st_ex_uid = handle->conn->session_info->utok.uid;
    45                 smb_fname->st.st_ex_gid = handle->conn->session_info->utok.gid;
     46                if (handle->conn->session_info != NULL) {
     47                        smb_fname->st.st_ex_uid =
     48                                handle->conn->session_info->utok.uid;
     49                        smb_fname->st.st_ex_gid =
     50                                handle->conn->session_info->utok.gid;
     51                } else {
     52                        /*
     53                         * Sucks, but current_user is the best we can do here.
     54                         */
     55                        smb_fname->st.st_ex_uid = current_user.ut.uid;
     56                        smb_fname->st.st_ex_gid = current_user.ut.gid;
     57                }
    4658        }
    4759
     
    6072                        sbuf->st_ex_mode = S_IRWXU;
    6173                }
    62                 sbuf->st_ex_uid = handle->conn->session_info->utok.uid;
    63                 sbuf->st_ex_gid = handle->conn->session_info->utok.gid;
     74                if (handle->conn->session_info != NULL) {
     75                        sbuf->st_ex_uid =
     76                                handle->conn->session_info->utok.uid;
     77                        sbuf->st_ex_gid =
     78                                handle->conn->session_info->utok.gid;
     79                } else {
     80                        /*
     81                         * Sucks, but current_user is the best we can do here.
     82                         */
     83                        sbuf->st_ex_uid = current_user.ut.uid;
     84                        sbuf->st_ex_gid = current_user.ut.gid;
     85                }
    6486        }
    6587        return ret;
  • vendor/current/source3/modules/vfs_gpfs.c

    r746 r860  
    9898
    9999        if (config->leases) {
     100                /*
     101                 * Ensure the lease owner is root to allow
     102                 * correct delivery of lease-break signals.
     103                 */
     104                become_root();
    100105                ret = set_gpfs_lease(fsp->fh->fd,leasetype);
     106                unbecome_root();
    101107        }
    102108
Note: See TracChangeset for help on using the changeset viewer.