Ignore:
Timestamp:
Jul 6, 2011, 8:21:13 PM (14 years ago)
Author:
Herwig Bauernfeind
Message:

Samba 3.5: Update trunk to 3.5.9

Location:
trunk/server/source3/modules
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/source3/modules/gpfs.c

    r414 r599  
    2525#include "vfs_gpfs.h"
    2626
    27 static bool gpfs_share_modes;
    28 static bool gpfs_leases;
    2927static bool gpfs_getrealfilename;
    3028static bool gpfs_winattr;
     29static bool gpfs_do_ftruncate;
    3130
    3231static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny);
     
    3938static int (*gpfs_get_winattrs_path_fn)(char *pathname, struct gpfs_winattr *attrs);
    4039static int (*gpfs_get_winattrs_fn)(int fd, struct gpfs_winattr *attrs);
    41 
     40static int (*gpfs_ftruncate_fn)(int fd, gpfs_off64_t length);
    4241
    4342bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
     
    4746        unsigned int deny = GPFS_DENY_NONE;
    4847        int result;
    49 
    50         if (!gpfs_share_modes) {
    51                 return True;
    52         }
    5348
    5449        if (gpfs_set_share_fn == NULL) {
     
    9792        int gpfs_type = GPFS_LEASE_NONE;
    9893
    99         if (!gpfs_leases) {
    100                 return True;
    101         }
    102 
    10394        if (gpfs_set_lease_fn == NULL) {
    10495                errno = EINVAL;
     
    140131
    141132        return gpfs_putacl_fn(pathname, flags, acl);
     133}
     134
     135int smbd_gpfs_ftrunctate(int fd, gpfs_off64_t length)
     136{
     137       if (!gpfs_do_ftruncate || (gpfs_ftruncate_fn == NULL)) {
     138               errno = ENOSYS;
     139               return -1;
     140       }
     141
     142       return gpfs_ftruncate_fn(fd, length);
    142143}
    143144
     
    248249        init_gpfs_function(&gpfs_set_winattrs_path_fn,"gpfs_set_winattrs_path");
    249250        init_gpfs_function(&gpfs_get_winattrs_fn,"gpfs_get_winattrs");
    250 
    251 
    252         gpfs_share_modes = lp_parm_bool(-1, "gpfs", "sharemodes", True);
    253         gpfs_leases      = lp_parm_bool(-1, "gpfs", "leases", True);
     251        init_gpfs_function(&gpfs_ftruncate_fn,"gpfs_ftruncate");
     252
    254253        gpfs_getrealfilename = lp_parm_bool(-1, "gpfs", "getrealfilename",
    255254                                            True);
    256255        gpfs_winattr = lp_parm_bool(-1, "gpfs", "winattr", False);
     256
     257        gpfs_do_ftruncate = lp_parm_bool(-1, "gpfs", "ftruncate", True);
    257258
    258259        return;
  • trunk/server/source3/modules/vfs_acl_common.c

    r596 r599  
    442442        NTSTATUS status = NT_STATUS_OK;
    443443        struct security_descriptor *psd = NULL;
     444        struct dom_sid *owner_sid = NULL;
     445        struct dom_sid *group_sid = NULL;
     446        uint32_t security_info_sent = (OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION);
    444447        size_t size;
    445 
    446         if (!sd_has_inheritable_components(parent_desc, is_directory)) {
     448        bool inherit_owner = lp_inherit_owner(SNUM(handle->conn));
     449        bool inheritable_components = sd_has_inheritable_components(parent_desc,
     450                                        is_directory);
     451
     452        if (!inheritable_components && !inherit_owner) {
     453                /* Nothing to inherit and not setting owner. */
    447454                return NT_STATUS_OK;
    448455        }
     
    456463        }
    457464
     465        /* Inherit from parent descriptor if "inherit owner" set. */
     466        if (inherit_owner) {
     467                owner_sid = parent_desc->owner_sid;
     468                group_sid = parent_desc->group_sid;
     469        }
     470
     471        if (owner_sid == NULL) {
     472                owner_sid = &handle->conn->server_info->ptok->user_sids[PRIMARY_USER_SID_INDEX];
     473        }
     474        if (group_sid == NULL) {
     475                group_sid = &handle->conn->server_info->ptok->user_sids[PRIMARY_GROUP_SID_INDEX];
     476        }
     477
    458478        status = se_create_child_secdesc(ctx,
    459479                        &psd,
    460480                        &size,
    461481                        parent_desc,
    462                         &handle->conn->server_info->ptok->user_sids[PRIMARY_USER_SID_INDEX],
    463                         &handle->conn->server_info->ptok->user_sids[PRIMARY_GROUP_SID_INDEX],
     482                        owner_sid,
     483                        group_sid,
    464484                        is_directory);
    465485        if (!NT_STATUS_IS_OK(status)) {
    466486                return status;
     487        }
     488
     489        /* If inheritable_components == false,
     490           se_create_child_secdesc()
     491           creates a security desriptor with a NULL dacl
     492           entry, but with SEC_DESC_DACL_PRESENT. We need
     493           to remove that flag. */
     494
     495        if (!inheritable_components) {
     496                security_info_sent &= ~SECINFO_DACL;
     497                psd->type &= ~SEC_DESC_DACL_PRESENT;
    467498        }
    468499
     
    470501                DEBUG(10,("inherit_new_acl: child acl for %s is:\n",
    471502                        fsp_str_dbg(fsp) ));
    472                 NDR_PRINT_DEBUG(security_descriptor, parent_desc);
    473         }
    474 
    475         return SMB_VFS_FSET_NT_ACL(fsp,
    476                                 (OWNER_SECURITY_INFORMATION |
    477                                  GROUP_SECURITY_INFORMATION |
    478                                  DACL_SECURITY_INFORMATION),
     503                NDR_PRINT_DEBUG(security_descriptor, psd);
     504        }
     505
     506        if (inherit_owner) {
     507                /* We need to be root to force this. */
     508                become_root();
     509        }
     510        status = SMB_VFS_FSET_NT_ACL(fsp,
     511                                security_info_sent,
    479512                                psd);
    480 }
    481 
    482 static NTSTATUS check_parent_acl_common(vfs_handle_struct *handle,
     513        if (inherit_owner) {
     514                unbecome_root();
     515        }
     516        return status;
     517}
     518
     519static NTSTATUS get_parent_acl_common(vfs_handle_struct *handle,
    483520                                const char *path,
    484                                 uint32_t access_mask,
    485521                                struct security_descriptor **pp_parent_desc)
    486522{
    487523        char *parent_name = NULL;
    488         struct security_descriptor *parent_desc = NULL;
    489         uint32_t access_granted = 0;
    490524        NTSTATUS status;
    491525
     
    497531                                        NULL,
    498532                                        parent_name,
    499                                         (OWNER_SECURITY_INFORMATION |
    500                                          GROUP_SECURITY_INFORMATION |
    501                                          DACL_SECURITY_INFORMATION),
    502                                         &parent_desc);
    503 
    504         if (!NT_STATUS_IS_OK(status)) {
    505                 DEBUG(10,("check_parent_acl_common: get_nt_acl_internal "
     533                                        (SECINFO_OWNER |
     534                                         SECINFO_GROUP |
     535                                         SECINFO_DACL),
     536                                        pp_parent_desc);
     537
     538        if (!NT_STATUS_IS_OK(status)) {
     539                DEBUG(10,("get_parent_acl_common: get_nt_acl_internal "
    506540                        "on directory %s for "
    507541                        "path %s returned %s\n",
     
    509543                        path,
    510544                        nt_errstr(status) ));
     545        }
     546        return status;
     547}
     548
     549static NTSTATUS check_parent_acl_common(vfs_handle_struct *handle,
     550                                const char *path,
     551                                uint32_t access_mask,
     552                                struct security_descriptor **pp_parent_desc)
     553{
     554        char *parent_name = NULL;
     555        struct security_descriptor *parent_desc = NULL;
     556        uint32_t access_granted = 0;
     557        NTSTATUS status;
     558
     559        status = get_parent_acl_common(handle, path, &parent_desc);
     560        if (!NT_STATUS_IS_OK(status)) {
    511561                return status;
     562        }
     563        if (pp_parent_desc) {
     564                *pp_parent_desc = parent_desc;
    512565        }
    513566        status = smb1_file_se_access_check(handle->conn,
     
    526579                return status;
    527580        }
    528         if (pp_parent_desc) {
    529                 *pp_parent_desc = parent_desc;
    530         }
    531581        return NT_STATUS_OK;
    532 }
    533 
    534 static void free_sd_common(void **ptr)
    535 {
    536         TALLOC_FREE(*ptr);
    537582}
    538583
     
    549594        uint32_t access_granted = 0;
    550595        struct security_descriptor *pdesc = NULL;
    551         struct security_descriptor *parent_desc = NULL;
    552596        bool file_existed = true;
    553597        char *fname = NULL;
     
    595639                 */
    596640                if (flags & O_CREAT) {
    597                         struct security_descriptor *psd = NULL;
     641                        struct security_descriptor *parent_desc = NULL;
     642                        struct security_descriptor **pp_psd = NULL;
    598643
    599644                        status = check_parent_acl_common(handle, fname,
     
    602647                                goto err;
    603648                        }
     649
    604650                        /* Cache the parent security descriptor for
    605                          * later use. We do have an fsp here, but to
    606                          * keep the code consistent with the directory
    607                          * case which doesn't, use the handle. */
    608 
    609                         /* Attach this to the conn, move from talloc_tos(). */
    610                         psd = (struct security_descriptor *)talloc_move(handle->conn,
    611                                 &parent_desc);
    612 
    613                         if (!psd) {
     651                         * later use. */
     652
     653                        pp_psd = VFS_ADD_FSP_EXTENSION(handle,
     654                                        fsp,
     655                                        struct security_descriptor *,
     656                                        NULL);
     657                        if (!pp_psd) {
    614658                                status = NT_STATUS_NO_MEMORY;
    615659                                goto err;
    616660                        }
    617                         status = NT_STATUS_NO_MEMORY;
    618                         SMB_VFS_HANDLE_SET_DATA(handle, psd, free_sd_common,
    619                                 struct security_descriptor *, goto err);
     661
     662                        *pp_psd = parent_desc;
    620663                        status = NT_STATUS_OK;
    621664                }
     
    644687        ret = vfs_stat_smb_fname(handle->conn, path, &sbuf);
    645688        if (ret == -1 && errno == ENOENT) {
    646                 struct security_descriptor *parent_desc = NULL;
    647                 struct security_descriptor *psd = NULL;
    648 
    649689                /* We're creating a new directory. */
    650690                status = check_parent_acl_common(handle, path,
    651                                 SEC_DIR_ADD_SUBDIR, &parent_desc);
     691                                SEC_DIR_ADD_SUBDIR, NULL);
    652692                if (!NT_STATUS_IS_OK(status)) {
    653693                        errno = map_errno_from_nt_status(status);
    654694                        return -1;
    655695                }
    656 
    657                 /* Cache the parent security descriptor for
    658                  * later use. We don't have an fsp here so
    659                  * use the handle. */
    660 
    661                 /* Attach this to the conn, move from talloc_tos(). */
    662                 psd = (struct security_descriptor *)talloc_move(handle->conn,
    663                                 &parent_desc);
    664 
    665                 if (!psd) {
    666                         return -1;
    667                 }
    668                 SMB_VFS_HANDLE_SET_DATA(handle, psd, free_sd_common,
    669                         struct security_descriptor *, return -1);
    670696        }
    671697
     
    910936        int info;
    911937        struct security_descriptor *parent_sd = NULL;
     938        struct security_descriptor **pp_parent_sd = NULL;
    912939
    913940        status = SMB_VFS_NEXT_CREATE_FILE(handle,
     
    953980        }
    954981
    955 
    956         /* We must have a cached parent sd in this case.
    957          * attached to the handle. */
    958 
    959         SMB_VFS_HANDLE_GET_DATA(handle, parent_sd,
    960                 struct security_descriptor,
    961                 goto err);
     982        /* See if we have a cached parent sd, if so, use it. */
     983        pp_parent_sd = (struct security_descriptor **)VFS_FETCH_FSP_EXTENSION(handle, fsp);
     984        if (!pp_parent_sd) {
     985                /* Must be a directory, fetch again (sigh). */
     986                status = get_parent_acl_common(handle,
     987                                fsp->fsp_name->base_name,
     988                                &parent_sd);
     989                if (!NT_STATUS_IS_OK(status)) {
     990                        goto out;
     991                }
     992        } else {
     993                parent_sd = *pp_parent_sd;
     994        }
    962995
    963996        if (!parent_sd) {
     
    9771010  out:
    9781011
    979         /* Ensure we never leave attached data around. */
    980         SMB_VFS_HANDLE_FREE_DATA(handle);
     1012        if (fsp) {
     1013                VFS_REMOVE_FSP_EXTENSION(handle, fsp);
     1014        }
    9811015
    9821016        if (NT_STATUS_IS_OK(status) && pinfo) {
     
    10131047                                        false);
    10141048}
     1049
     1050static int chmod_acl_module_common(struct vfs_handle_struct *handle,
     1051                        const char *path, mode_t mode)
     1052{
     1053        if (lp_posix_pathnames()) {
     1054                /* Only allow this on POSIX pathnames. */
     1055                return SMB_VFS_NEXT_CHMOD(handle, path, mode);
     1056        }
     1057        return 0;
     1058}
     1059
     1060static int fchmod_acl_module_common(struct vfs_handle_struct *handle,
     1061                        struct files_struct *fsp, mode_t mode)
     1062{
     1063        if (fsp->posix_open) {
     1064                /* Only allow this on POSIX opens. */
     1065                return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
     1066        }
     1067        return 0;
     1068}
     1069
     1070static int chmod_acl_acl_module_common(struct vfs_handle_struct *handle,
     1071                        const char *name, mode_t mode)
     1072{
     1073        if (lp_posix_pathnames()) {
     1074                /* Only allow this on POSIX pathnames. */
     1075                return SMB_VFS_NEXT_CHMOD_ACL(handle, name, mode);
     1076        }
     1077        return 0;
     1078}
     1079
     1080static int fchmod_acl_acl_module_common(struct vfs_handle_struct *handle,
     1081                        struct files_struct *fsp, mode_t mode)
     1082{
     1083        if (fsp->posix_open) {
     1084                /* Only allow this on POSIX opens. */
     1085                return SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
     1086        }
     1087        return 0;
     1088}
  • trunk/server/source3/modules/vfs_acl_tdb.c

    r596 r599  
    398398        .opendir = opendir_acl_common,
    399399        .mkdir = mkdir_acl_common,
     400        .rmdir = rmdir_acl_tdb,
    400401        .open = open_acl_common,
    401402        .create_file = create_file_acl_common,
    402403        .unlink = unlink_acl_tdb,
    403         .rmdir = rmdir_acl_tdb,
     404        .chmod = chmod_acl_module_common,
     405        .fchmod = fchmod_acl_module_common,
    404406        .fget_nt_acl = fget_nt_acl_common,
    405407        .get_nt_acl = get_nt_acl_common,
    406408        .fset_nt_acl = fset_nt_acl_common,
     409        .chmod_acl = chmod_acl_acl_module_common,
     410        .fchmod_acl = fchmod_acl_acl_module_common,
    407411        .sys_acl_set_file = sys_acl_set_file_tdb,
    408412        .sys_acl_set_fd = sys_acl_set_fd_tdb
  • trunk/server/source3/modules/vfs_acl_xattr.c

    r596 r599  
    208208        .create_file = create_file_acl_common,
    209209        .unlink = unlink_acl_common,
     210        .chmod = chmod_acl_module_common,
     211        .fchmod = fchmod_acl_module_common,
    210212        .fget_nt_acl = fget_nt_acl_common,
    211213        .get_nt_acl = get_nt_acl_common,
    212214        .fset_nt_acl = fset_nt_acl_common,
     215        .chmod_acl = chmod_acl_acl_module_common,
     216        .fchmod_acl = fchmod_acl_acl_module_common,
    213217        .sys_acl_set_file = sys_acl_set_file_xattr,
    214218        .sys_acl_set_fd = sys_acl_set_fd_xattr
  • trunk/server/source3/modules/vfs_gpfs.c

    r596 r599  
    3131#include "vfs_gpfs.h"
    3232
     33struct gpfs_config_data {
     34        bool sharemodes;
     35        bool leases;
     36};
     37
     38
    3339static int vfs_gpfs_kernel_flock(vfs_handle_struct *handle, files_struct *fsp,
    3440                                 uint32 share_mode, uint32 access_mask)
    3541{
    3642
     43        struct gpfs_config_data *config;
     44
     45        SMB_VFS_HANDLE_GET_DATA(handle, config,
     46                                struct gpfs_config_data,
     47                                return -1);
     48
    3749        START_PROFILE(syscall_kernel_flock);
    3850
    3951        kernel_flock(fsp->fh->fd, share_mode, access_mask);
    4052
    41         if (!set_gpfs_sharemode(fsp, access_mask, fsp->share_access)) {
    42 
    43                 return -1;
    44 
     53        if (config->sharemodes
     54                && !set_gpfs_sharemode(fsp, access_mask, fsp->share_access)) {
     55                return -1;
    4556        }
    4657
     
    5263static int vfs_gpfs_close(vfs_handle_struct *handle, files_struct *fsp)
    5364{
    54         if ((fsp->fh != NULL) && (fsp->fh->fd != -1)) {
     65
     66        struct gpfs_config_data *config;
     67
     68        SMB_VFS_HANDLE_GET_DATA(handle, config,
     69                                struct gpfs_config_data,
     70                                return -1);
     71
     72        if (config->sharemodes && (fsp->fh != NULL) && (fsp->fh->fd != -1)) {
    5573                set_gpfs_sharemode(fsp, 0, 0);
    5674        }
     
    6280                             int leasetype)
    6381{
    64         int ret;
     82        struct gpfs_config_data *config;
     83        int ret=0;
     84
     85        SMB_VFS_HANDLE_GET_DATA(handle, config,
     86                                struct gpfs_config_data,
     87                                return -1);
    6588
    6689        START_PROFILE(syscall_linux_setlease);
    6790
    68         if ( linux_set_lease_sighandler(fsp->fh->fd) == -1)
    69                 return -1;
    70 
    71         ret = set_gpfs_lease(fsp->fh->fd,leasetype);
    72 
    73         if ( ret < 0 ) {
     91        if (linux_set_lease_sighandler(fsp->fh->fd) == -1)
     92                return -1;
     93
     94        if (config->leases) {
     95                ret = set_gpfs_lease(fsp->fh->fd,leasetype);
     96        }
     97
     98        if (ret < 0) {
    7499                /* This must have come from GPFS not being available */
    75100                /* or some other error, hence call the default */
     
    959984        struct gpfs_winattr attrs;
    960985        int ret = 0;
     986        ssize_t result;
    961987
    962988        DEBUG(10, ("gpfs_get_xattr: %s \n",path));
     
    9951021        }
    9961022
    997         snprintf(attrstr, size, "0x%x", dosmode & SAMBA_ATTRIBUTES_MASK);
     1023        result = snprintf(attrstr, size, "0x%x",
     1024                          dosmode & SAMBA_ATTRIBUTES_MASK) + 1;
     1025
    9981026        DEBUG(10, ("gpfs_get_xattr: returning %s\n",attrstr));
    999         return size;
     1027        return result;
    10001028}
    10011029
     
    11141142}
    11151143
     1144int vfs_gpfs_connect(struct vfs_handle_struct *handle, const char *service,
     1145                        const char *user)
     1146{
     1147        struct gpfs_config_data *config;
     1148        int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
     1149
     1150        if (ret < 0) {
     1151                return ret;
     1152        }
     1153
     1154        config = talloc_zero(handle->conn, struct gpfs_config_data);
     1155        if (!config) {
     1156                SMB_VFS_NEXT_DISCONNECT(handle);
     1157                DEBUG(0, ("talloc_zero() failed\n")); return -1;
     1158        }
     1159
     1160        config->sharemodes = lp_parm_bool(SNUM(handle->conn), "gpfs",
     1161                                        "sharemodes", true);
     1162
     1163        config->leases = lp_parm_bool(SNUM(handle->conn), "gpfs",
     1164                                        "leases", true);
     1165
     1166        SMB_VFS_HANDLE_SET_DATA(handle, config,
     1167                                NULL, struct gpfs_config_data,
     1168                                return -1);
     1169
     1170        return 0;
     1171}
     1172
     1173
     1174static int vfs_gpfs_ftruncate(struct vfs_handle_struct *handle,
     1175                              struct files_struct *fsp,
     1176                              SMB_OFF_T len)
     1177{
     1178       int result;
     1179
     1180       result = smbd_gpfs_ftrunctate(fsp->fh->fd, len);
     1181       if ((result == -1) && (errno == ENOSYS)) {
     1182               return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
     1183       }
     1184       return result;
     1185}
     1186
    11161187static struct vfs_fn_pointers vfs_gpfs_fns = {
     1188        .connect_fn = vfs_gpfs_connect,
    11171189        .kernel_flock = vfs_gpfs_kernel_flock,
    11181190        .linux_setlease = vfs_gpfs_setlease,
     
    11351207        .lstat = vfs_gpfs_lstat,
    11361208        .ntimes = vfs_gpfs_ntimes,
     1209        .ftruncate = vfs_gpfs_ftruncate,
    11371210};
    11381211
  • trunk/server/source3/modules/vfs_gpfs.h

    r414 r599  
    3535int get_gpfs_winattrs(char * pathname,struct gpfs_winattr *attrs);
    3636int set_gpfs_winattrs(char * pathname,int flags,struct gpfs_winattr *attrs);
     37int smbd_gpfs_ftrunctate(int fd, gpfs_off64_t length);
    3738void init_gpfs(void);
  • trunk/server/source3/modules/vfs_shadow_copy2.c

    r414 r599  
    583583                                            const char *fname)
    584584{
    585         TALLOC_CTX *tmp_ctx = talloc_stackframe();
     585        TALLOC_CTX *tmp_ctx;
    586586        const char *snapdir, *baseoffset, *basedir, *gmt_start;
    587587        size_t baselen;
     
    594594        }
    595595
    596         fname = shadow_copy2_normalise_path(talloc_tos(), fname, gmt_start);
     596        /*
     597         * We have to create a real temporary context because we have
     598         * to put our result on talloc_tos(). Thus we can't use a
     599         * talloc_stackframe() here.
     600         */
     601        tmp_ctx = talloc_new(talloc_tos());
     602
     603        fname = shadow_copy2_normalise_path(tmp_ctx, fname, gmt_start);
    597604        if (fname == NULL) {
    598605                TALLOC_FREE(tmp_ctx);
Note: See TracChangeset for help on using the changeset viewer.