diff options
Diffstat (limited to 'source3/modules')
-rw-r--r-- | source3/modules/nfs4_acls.c | 2 | ||||
-rw-r--r-- | source3/modules/onefs_acl.c | 10 | ||||
-rw-r--r-- | source3/modules/onefs_open.c | 13 | ||||
-rw-r--r-- | source3/modules/perfcount_onefs.c | 52 | ||||
-rw-r--r-- | source3/modules/perfcount_test.c | 9 | ||||
-rw-r--r-- | source3/modules/vfs_dirsort.c | 194 | ||||
-rw-r--r-- | source3/modules/vfs_streams_depot.c | 4 |
7 files changed, 242 insertions, 42 deletions
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c index 7756f8f3ab..462e59313a 100644 --- a/source3/modules/nfs4_acls.c +++ b/source3/modules/nfs4_acls.c @@ -315,7 +315,7 @@ static NTSTATUS smb_get_nt_acl_nfs4_common(const SMB_STRUCT_STAT *sbuf, } DEBUG(10, ("smb_get_nt_acl_nfs4_common successfully exited with sd_size %d\n", - ndr_size_security_descriptor(*ppdesc, 0))); + ndr_size_security_descriptor(*ppdesc, NULL, 0))); return NT_STATUS_OK; } diff --git a/source3/modules/onefs_acl.c b/source3/modules/onefs_acl.c index 6f23d608d4..8ee31abc88 100644 --- a/source3/modules/onefs_acl.c +++ b/source3/modules/onefs_acl.c @@ -825,7 +825,7 @@ NTSTATUS onefs_samba_sd_to_sd(uint32 security_info_sent, SEC_DESC *psd, /* Setup owner */ if (security_info_sent & OWNER_SECURITY_INFORMATION) { if (!onefs_og_to_identity(psd->owner_sid, &owner, false, snum)) - return NT_STATUS_UNSUCCESSFUL; + return NT_STATUS_ACCESS_DENIED; SMB_ASSERT(owner.id.uid >= 0); @@ -835,7 +835,7 @@ NTSTATUS onefs_samba_sd_to_sd(uint32 security_info_sent, SEC_DESC *psd, /* Setup group */ if (security_info_sent & GROUP_SECURITY_INFORMATION) { if (!onefs_og_to_identity(psd->group_sid, &group, true, snum)) - return NT_STATUS_UNSUCCESSFUL; + return NT_STATUS_ACCESS_DENIED; SMB_ASSERT(group.id.gid >= 0); @@ -846,7 +846,7 @@ NTSTATUS onefs_samba_sd_to_sd(uint32 security_info_sent, SEC_DESC *psd, if ((security_info_sent & DACL_SECURITY_INFORMATION) && (psd->dacl)) { if (!onefs_samba_acl_to_acl(psd->dacl, &daclp, &ignore_aces, snum)) - return NT_STATUS_UNSUCCESSFUL; + return NT_STATUS_ACCESS_DENIED; if (ignore_aces == true) security_info_sent &= ~DACL_SECURITY_INFORMATION; @@ -863,7 +863,7 @@ NTSTATUS onefs_samba_sd_to_sd(uint32 security_info_sent, SEC_DESC *psd, if (psd->sacl) { if (!onefs_samba_acl_to_acl(psd->sacl, &saclp, &ignore_aces, snum)) - return NT_STATUS_UNSUCCESSFUL; + return NT_STATUS_ACCESS_DENIED; if (ignore_aces == true) { security_info_sent &= @@ -877,7 +877,7 @@ NTSTATUS onefs_samba_sd_to_sd(uint32 security_info_sent, SEC_DESC *psd, DEBUG(5,("Setting up SD\n")); if (aclu_initialize_sd(sd, psd->type, ownerp, groupp, (daclp ? &daclp : NULL), (saclp ? &saclp : NULL), false)) - return NT_STATUS_UNSUCCESSFUL; + return NT_STATUS_ACCESS_DENIED; return NT_STATUS_OK; } diff --git a/source3/modules/onefs_open.c b/source3/modules/onefs_open.c index c5030f4ab8..c23c176b79 100644 --- a/source3/modules/onefs_open.c +++ b/source3/modules/onefs_open.c @@ -208,14 +208,14 @@ static NTSTATUS onefs_open_file(files_struct *fsp, if ((oplock_request & ~SAMBA_PRIVATE_OPLOCK_MASK) != NO_OPLOCK) { DEBUG(0,("Oplock(%d) being requested on a stream! " - "Ignoring oplock request: base=%s, stream=%s", + "Ignoring oplock request: base=%s, stream=%s\n", oplock_request & ~SAMBA_PRIVATE_OPLOCK_MASK, base, stream)); /* Recover by requesting NO_OPLOCK instead. */ oplock_request &= SAMBA_PRIVATE_OPLOCK_MASK; } - DEBUG(10,("Opening a stream: base=%s(%d), stream=%s", + DEBUG(10,("Opening a stream: base=%s(%d), stream=%s\n", base, fsp->base_fsp->fh->fd, stream)); base_fd = fsp->base_fsp->fh->fd; @@ -386,15 +386,6 @@ static void defer_open(struct share_mode_lock *lck, exit_server("push_deferred_smb_message failed"); } add_deferred_open(lck, req->mid, request_time, state->id); - - /* - * Push the MID of this packet on the signing queue. - * We only do this once, the first time we push the packet - * onto the deferred open queue, as this has a side effect - * of incrementing the response sequence number. - */ - - srv_defer_sign_response(req->mid); } static void schedule_defer_open(struct share_mode_lock *lck, diff --git a/source3/modules/perfcount_onefs.c b/source3/modules/perfcount_onefs.c index 9b35af699a..066a7f1fe4 100644 --- a/source3/modules/perfcount_onefs.c +++ b/source3/modules/perfcount_onefs.c @@ -20,8 +20,11 @@ #include "includes.h" #include <sys/isi_stats_protocol.h> +#include <sys/isi_stats_client.h> #include <sys/isi_stats_cifs.h> +extern struct current_user current_user; + struct onefs_op_counter { struct isp_op_delta iod; struct onefs_op_counter *next; @@ -282,42 +285,64 @@ static void onefs_smb_statistics_defer_op(struct smb_perfcount_data *pcd, pcd->context = NULL; } -static void onefs_smb_statistics_set_client(struct smb_perfcount_data *pcd, - uid_t uid, const char *user, - const char *domain) -{ - // not implemented... - return; -} - static void onefs_smb_statistics_end(struct smb_perfcount_data *pcd) { struct onefs_stats_context *ctxt = pcd->context; struct onefs_op_counter *tmp; + uint64_t uid; + + static in_addr_t rem_addr = 0; + static in_addr_t loc_addr = 0; /* not enabled */ if (pcd->context == NULL) return; + uid = current_user.ut.uid ? current_user.ut.uid : ISC_UNKNOWN_CLIENT_ID; + + /* get address info once, doesn't change for process */ + if (rem_addr == 0) { + struct sockaddr_storage sa; + socklen_t sa_len; + int fd = smbd_server_fd(); + + sa_len = sizeof sa; + if (getpeername(fd, (struct sockaddr *)&sa, &sa_len) == 0 && + sa.ss_family == AF_INET) + rem_addr = ((struct sockaddr_in *)&sa)->sin_addr.s_addr; + else + rem_addr = ISC_MASKED_ADDR; + + sa_len = sizeof sa; + if (getsockname(fd, (struct sockaddr *)&sa, &sa_len) == 0 && + sa.ss_family == AF_INET) + loc_addr = ((struct sockaddr_in *)&sa)->sin_addr.s_addr; + else + loc_addr = ISC_MASKED_ADDR; + } + /* * bug here - we aren't getting the outlens right, * when dealing w/ chained requests. */ for (tmp = ctxt->ops_chain; tmp; tmp = tmp->next) { tmp->iod.out_bytes = ctxt->iod.out_bytes; + isc_cookie_init(&tmp->iod.cookie, rem_addr, loc_addr, uid); ISP_OP_END(&tmp->iod); #ifdef ONEFS_PERF_DEBUG - DEBUG(0,("******** Finalized CHAIN op %s in:%llu, out:%llu\n", - onefs_stat_debug(&tmp->iod), + DEBUG(0,("******** Finalized CHAIN op %s uid %llu in:%llu" + ", out:%llu\n", + onefs_stat_debug(&tmp->iod), uid, tmp->iod.in_bytes, tmp->iod.out_bytes)); #endif SAFE_FREE(tmp->prev); } - ISP_OP_END(&ctxt->iod); + isc_cookie_init(&ctxt->iod.cookie, rem_addr, loc_addr, uid); + ISP_OP_END(&ctxt->iod); #ifdef ONEFS_PERF_DEBUG - DEBUG(0,("******** Finalized op %s in:%llu, out:%llu\n", - onefs_stat_debug(&ctxt->iod), + DEBUG(0,("******** Finalized op %s uid %llu in:%llu, out:%llu\n", + onefs_stat_debug(&ctxt->iod), uid, ctxt->iod.in_bytes, ctxt->iod.out_bytes)); #endif @@ -338,7 +363,6 @@ static struct smb_perfcount_handlers onefs_pc_handlers = { onefs_smb_statistics_set_ioctl, onefs_smb_statistics_set_msglen_in, onefs_smb_statistics_set_msglen_out, - onefs_smb_statistics_set_client, onefs_smb_statistics_copy_context, onefs_smb_statistics_defer_op, onefs_smb_statistics_end diff --git a/source3/modules/perfcount_test.c b/source3/modules/perfcount_test.c index 418d83ace5..b72ac9f7b5 100644 --- a/source3/modules/perfcount_test.c +++ b/source3/modules/perfcount_test.c @@ -351,14 +351,6 @@ static void perfcount_test_defer_op(struct smb_perfcount_data *pcd, return; } -static void perfcount_test_set_client(struct smb_perfcount_data *pcd, - uid_t uid, const char *user, - const char *domain) -{ - /* WIP */ - return; -} - static void perfcount_test_end(struct smb_perfcount_data *pcd) { struct perfcount_test_context *ctxt = @@ -382,7 +374,6 @@ static struct smb_perfcount_handlers perfcount_test_handlers = { perfcount_test_set_ioctl, perfcount_test_set_msglen_in, perfcount_test_set_msglen_out, - perfcount_test_set_client, perfcount_test_copy_context, perfcount_test_defer_op, perfcount_test_end diff --git a/source3/modules/vfs_dirsort.c b/source3/modules/vfs_dirsort.c new file mode 100644 index 0000000000..53d1820c11 --- /dev/null +++ b/source3/modules/vfs_dirsort.c @@ -0,0 +1,194 @@ +/* + * VFS module to provide a sorted directory list. + * + * Copyright (C) Andy Kelk (andy@mopoke.co.uk), 2009 + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <http://www.gnu.org/licenses/>. + */ + +#include "includes.h" + +static int compare_dirent (const void *a, const void *b) { + const SMB_STRUCT_DIRENT *da = (const SMB_STRUCT_DIRENT *) a; + const SMB_STRUCT_DIRENT *db = (const SMB_STRUCT_DIRENT *) b; + return StrCaseCmp(da->d_name, db->d_name); +} + +struct dirsort_privates { + long pos; + SMB_STRUCT_DIRENT *directory_list; + long number_of_entries; + time_t mtime; + SMB_STRUCT_DIR *source_directory; + int fd; +}; + +static void free_dirsort_privates(void **datap) { + struct dirsort_privates *data = (struct dirsort_privates *) *datap; + SAFE_FREE(data->directory_list); + SAFE_FREE(data); + *datap = NULL; + + return; +} + +static void open_and_sort_dir (vfs_handle_struct *handle) +{ + SMB_STRUCT_DIRENT *dp; + struct stat dir_stat; + long current_pos; + struct dirsort_privates *data = NULL; + + SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates, return); + + data->number_of_entries = 0; + + if (fstat(data->fd, &dir_stat) == 0) { + data->mtime = dir_stat.st_mtime; + } + + while (SMB_VFS_NEXT_READDIR(handle, data->source_directory, NULL) + != NULL) { + data->number_of_entries++; + } + + /* Open the underlying directory and count the number of entries + Skip back to the beginning as we'll read it again */ + SMB_VFS_NEXT_REWINDDIR(handle, data->source_directory); + + /* Set up an array and read the directory entries into it */ + SAFE_FREE(data->directory_list); /* destroy previous cache if needed */ + data->directory_list = (SMB_STRUCT_DIRENT *)SMB_MALLOC( + data->number_of_entries * sizeof(SMB_STRUCT_DIRENT)); + current_pos = data->pos; + data->pos = 0; + while ((dp = SMB_VFS_NEXT_READDIR(handle, data->source_directory, + NULL)) != NULL) { + data->directory_list[data->pos++] = *dp; + } + + /* Sort the directory entries by name */ + data->pos = current_pos; + qsort(data->directory_list, data->number_of_entries, + sizeof(SMB_STRUCT_DIRENT), compare_dirent); +} + +static SMB_STRUCT_DIR *dirsort_opendir(vfs_handle_struct *handle, + const char *fname, const char *mask, + uint32 attr) +{ + struct dirsort_privates *data = NULL; + + /* set up our private data about this directory */ + data = (struct dirsort_privates *)SMB_MALLOC( + sizeof(struct dirsort_privates)); + + data->directory_list = NULL; + data->pos = 0; + + /* Open the underlying directory and count the number of entries */ + data->source_directory = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, + attr); + + data->fd = dirfd(data->source_directory); + + SMB_VFS_HANDLE_SET_DATA(handle, data, free_dirsort_privates, + struct dirsort_privates, return NULL); + + open_and_sort_dir(handle); + + return data->source_directory; +} + +static SMB_STRUCT_DIRENT *dirsort_readdir(vfs_handle_struct *handle, + SMB_STRUCT_DIR *dirp) +{ + struct dirsort_privates *data = NULL; + time_t current_mtime; + struct stat dir_stat; + + SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates, + return NULL); + + if (fstat(data->fd, &dir_stat) == -1) { + return NULL; + } + + current_mtime = dir_stat.st_mtime; + + /* throw away cache and re-read the directory if we've changed */ + if (current_mtime > data->mtime) { + open_and_sort_dir(handle); + } + + if (data->pos >= data->number_of_entries) { + return NULL; + } + + return &data->directory_list[data->pos++]; +} + +static void dirsort_seekdir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp, + long offset) +{ + struct dirsort_privates *data = NULL; + SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates, return); + + data->pos = offset; +} + +static long dirsort_telldir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp) +{ + struct dirsort_privates *data = NULL; + SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates, + return -1); + + return data->pos; +} + +static void dirsort_rewinddir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp) +{ + struct dirsort_privates *data = NULL; + SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates, return); + + data->pos = 0; +} + +/* VFS operations structure */ + +static vfs_op_tuple dirsort_op_tuples[] = { + + /* Directory operations */ + + {SMB_VFS_OP(dirsort_opendir), SMB_VFS_OP_OPENDIR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(dirsort_readdir), SMB_VFS_OP_READDIR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(dirsort_seekdir), SMB_VFS_OP_SEEKDIR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(dirsort_telldir), SMB_VFS_OP_TELLDIR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(dirsort_rewinddir), SMB_VFS_OP_REWINDDIR, + SMB_VFS_LAYER_TRANSPARENT}, + + {NULL, SMB_VFS_OP_NOOP, + SMB_VFS_LAYER_NOOP} +}; + +NTSTATUS vfs_dirsort_init(void) +{ + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "dirsort", + dirsort_op_tuples); +} diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c index 023d2b9ec0..e5a70b1a49 100644 --- a/source3/modules/vfs_streams_depot.c +++ b/source3/modules/vfs_streams_depot.c @@ -78,7 +78,7 @@ static bool file_is_valid(vfs_handle_struct *handle, const char *path, DEBUG(10, ("file_is_valid (%s) called\n", path)); - if (SMB_VFS_NEXT_GETXATTR(handle, path, SAMBA_XATTR_MARKER, + if (SMB_VFS_GETXATTR(handle->conn, path, SAMBA_XATTR_MARKER, &buf, sizeof(buf)) != sizeof(buf)) { DEBUG(10, ("GETXATTR failed: %s\n", strerror(errno))); return false; @@ -104,7 +104,7 @@ static bool mark_file_valid(vfs_handle_struct *handle, const char *path, DEBUG(10, ("marking file %s as valid\n", path)); - ret = SMB_VFS_NEXT_SETXATTR(handle, path, SAMBA_XATTR_MARKER, + ret = SMB_VFS_SETXATTR(handle->conn, path, SAMBA_XATTR_MARKER, &buf, sizeof(buf), 0); if (ret == -1) { |