summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-11-16 17:07:11 -0800
committerJeremy Allison <jra@samba.org>2007-11-16 17:07:11 -0800
commit882987594455c6676d0b01618d91bdbfc5e3b267 (patch)
tree337e4e0c37bf067e13f52827e6cd8d7bd37ec05a
parentb059e2cbf1d6190c996a1ff6b8f426a493ae937c (diff)
downloadsamba-882987594455c6676d0b01618d91bdbfc5e3b267.tar.gz
samba-882987594455c6676d0b01618d91bdbfc5e3b267.tar.bz2
samba-882987594455c6676d0b01618d91bdbfc5e3b267.zip
Remove pstring from modules directory.
Jeremy. (This used to be commit 977dc3accb3d440e5fd19591c425da7dc3718d94)
-rw-r--r--source3/modules/vfs_afsacl.c14
-rw-r--r--source3/modules/vfs_cap.c489
-rw-r--r--source3/modules/vfs_catia.c269
-rw-r--r--source3/modules/vfs_expand_msdfs.c89
-rw-r--r--source3/modules/vfs_full_audit.c38
5 files changed, 589 insertions, 310 deletions
diff --git a/source3/modules/vfs_afsacl.c b/source3/modules/vfs_afsacl.c
index eac70f4f20..3e57a88ed3 100644
--- a/source3/modules/vfs_afsacl.c
+++ b/source3/modules/vfs_afsacl.c
@@ -891,7 +891,7 @@ static NTSTATUS afs_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
char acl_string[2049];
struct afs_iob iob;
int ret = -1;
- pstring name;
+ char *name = NULL;
const char *fileacls;
fileacls = lp_parm_const_string(SNUM(handle->conn), "afsacl", "fileacls",
@@ -904,7 +904,10 @@ static NTSTATUS afs_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
ZERO_STRUCT(dir_acl);
ZERO_STRUCT(file_acl);
- pstrcpy(name, fsp->fsp_name);
+ name = talloc_strdup(talloc_tos(), fsp->fsp_name);
+ if (!name) {
+ return NT_STATUS_NO_MEMORY;
+ }
if (!fsp->is_directory) {
/* We need to get the name of the directory containing the
@@ -913,7 +916,10 @@ static NTSTATUS afs_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
if (p != NULL) {
*p = '\0';
} else {
- pstrcpy(name, ".");
+ name = talloc_strdup(talloc_tos(), ".");
+ if (!name) {
+ return NT_STATUS_NO_MEMORY;
+ }
}
}
@@ -1017,7 +1023,7 @@ static int afsacl_connect(vfs_handle_struct *handle,
const char *service,
const char *user)
{
- const char *spc;
+ const char *spc;
spc = lp_parm_const_string(SNUM(handle->conn), "afsacl", "space", "%");
diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c
index 7dfbed0691..f99891cb32 100644
--- a/source3/modules/vfs_cap.c
+++ b/source3/modules/vfs_cap.c
@@ -1,21 +1,22 @@
-/*
+/*
* CAP VFS module for Samba 3.x Version 0.3
*
* Copyright (C) Tim Potter, 1999-2000
* Copyright (C) Alexander Bokovoy, 2002-2003
* Copyright (C) Stefan (metze) Metzmacher, 2003
* Copyright (C) TAKAHASHI Motonobu (monyo), 2003
+ * Copyright (C) Jeremy Allison, 2007
*
* 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/>.
*/
@@ -24,288 +25,445 @@
#include "includes.h"
/* cap functions */
-static char *capencode(char *to, const char *from);
-static char *capdecode(char *to, const char *from);
+static char *capencode(TALLOC_CTX *ctx, const char *from);
+static char *capdecode(TALLOC_CTX *ctx, const char *from);
static SMB_BIG_UINT cap_disk_free(vfs_handle_struct *handle, const char *path,
bool small_query, SMB_BIG_UINT *bsize,
SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
{
- pstring cappath;
- capencode(cappath, path);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return (SMB_BIG_UINT)-1;
+ }
return SMB_VFS_NEXT_DISK_FREE(handle, cappath, small_query, bsize,
- dfree, dsize);
+ dfree, dsize);
}
static SMB_STRUCT_DIR *cap_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr)
{
- pstring capname;
- capencode(capname, fname);
+ char *capname = capencode(talloc_tos(), fname);
+
+ if (!capname) {
+ errno = ENOMEM;
+ return NULL;
+ }
return SMB_VFS_NEXT_OPENDIR(handle, capname, mask, attr);
}
static SMB_STRUCT_DIRENT *cap_readdir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp)
{
- SMB_STRUCT_DIRENT *result;
+ SMB_STRUCT_DIRENT *result;
+ SMB_STRUCT_DIRENT *newdirent;
+ char *newname;
+ size_t newnamelen;
DEBUG(3,("cap: cap_readdir\n"));
+
result = SMB_VFS_NEXT_READDIR(handle, dirp);
- if (result) {
- DEBUG(3,("cap: cap_readdir: %s\n", result->d_name));
- capdecode(result->d_name, result->d_name);
- }
- return result;
+ if (!result) {
+ return NULL;
+ }
+
+ newname = capdecode(talloc_tos(), result->d_name);
+ if (!newname) {
+ return NULL;
+ }
+ DEBUG(3,("cap: cap_readdir: %s\n", newname));
+ newnamelen = strlen(newname)+1;
+ newdirent = (SMB_STRUCT_DIRENT *)TALLOC_ARRAY(talloc_tos(),
+ char,
+ sizeof(SMB_STRUCT_DIRENT)+
+ newnamelen);
+ if (!newdirent) {
+ return NULL;
+ }
+ memcpy(newdirent, result, sizeof(SMB_STRUCT_DIRENT));
+ memcpy(&newdirent->d_name, newname, newnamelen);
+ return newdirent;
}
static int cap_mkdir(vfs_handle_struct *handle, const char *path, mode_t mode)
{
- pstring cappath;
- capencode(cappath, path);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_MKDIR(handle, cappath, mode);
}
static int cap_rmdir(vfs_handle_struct *handle, const char *path)
{
- pstring cappath;
- capencode(cappath, path);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_RMDIR(handle, cappath);
}
static int cap_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode)
{
- pstring capname;
+ char *cappath = capencode(talloc_tos(), fname);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
DEBUG(3,("cap: cap_open for %s\n", fname));
- capencode(capname, fname);
- return SMB_VFS_NEXT_OPEN(handle, capname, fsp, flags, mode);
+ return SMB_VFS_NEXT_OPEN(handle, cappath, fsp, flags, mode);
}
static int cap_rename(vfs_handle_struct *handle, const char *oldname, const char *newname)
{
- pstring capold, capnew;
- capencode(capold, oldname);
- capencode(capnew, newname);
+ char *capold = capencode(talloc_tos(), oldname);
+ char *capnew = capencode(talloc_tos(), newname);
+ if (!capold || !capnew) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_RENAME(handle, capold, capnew);
}
-static int cap_stat(vfs_handle_struct *handle, const char *fname, SMB_STRUCT_STAT *sbuf)
+static int cap_stat(vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf)
{
- pstring capname;
- capencode(capname, fname);
- return SMB_VFS_NEXT_STAT(handle, capname, sbuf);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
+ return SMB_VFS_NEXT_STAT(handle, cappath, sbuf);
}
static int cap_lstat(vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf)
{
- pstring cappath;
- capencode(cappath, path);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_LSTAT(handle, cappath, sbuf);
}
static int cap_unlink(vfs_handle_struct *handle, const char *path)
{
- pstring cappath;
- capencode(cappath, path);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_UNLINK(handle, cappath);
}
static int cap_chmod(vfs_handle_struct *handle, const char *path, mode_t mode)
{
- pstring cappath;
- capencode(cappath, path);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_CHMOD(handle, cappath, mode);
}
static int cap_chown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
{
- pstring cappath;
- capencode(cappath, path);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_CHOWN(handle, cappath, uid, gid);
}
static int cap_lchown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
{
- pstring cappath;
- capencode(cappath, path);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_LCHOWN(handle, cappath, uid, gid);
}
static int cap_chdir(vfs_handle_struct *handle, const char *path)
{
- pstring cappath;
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
DEBUG(3,("cap: cap_chdir for %s\n", path));
- capencode(cappath, path);
return SMB_VFS_NEXT_CHDIR(handle, cappath);
}
static int cap_ntimes(vfs_handle_struct *handle, const char *path, const struct timespec ts[2])
{
- pstring cappath;
- capencode(cappath, path);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_NTIMES(handle, cappath, ts);
}
static bool cap_symlink(vfs_handle_struct *handle, const char *oldpath, const char *newpath)
{
- pstring capoldpath, capnewpath;
- capencode(capoldpath, oldpath);
- capencode(capnewpath, newpath);
- return SMB_VFS_NEXT_SYMLINK(handle, capoldpath, capnewpath);
+ char *capold = capencode(talloc_tos(), oldpath);
+ char *capnew = capencode(talloc_tos(), newpath);
+
+ if (!capold || !capnew) {
+ errno = ENOMEM;
+ return -1;
+ }
+ return SMB_VFS_NEXT_SYMLINK(handle, capold, capnew);
}
static bool cap_readlink(vfs_handle_struct *handle, const char *path, char *buf, size_t bufsiz)
{
- pstring cappath;
- capencode(cappath, path);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_READLINK(handle, cappath, buf, bufsiz);
}
static int cap_link(vfs_handle_struct *handle, const char *oldpath, const char *newpath)
{
- pstring capoldpath, capnewpath;
- capencode(capoldpath, oldpath);
- capencode(capnewpath, newpath);
- return SMB_VFS_NEXT_LINK(handle, capoldpath, capnewpath);
+ char *capold = capencode(talloc_tos(), oldpath);
+ char *capnew = capencode(talloc_tos(), newpath);
+
+ if (!capold || !capnew) {
+ errno = ENOMEM;
+ return -1;
+ }
+ return SMB_VFS_NEXT_LINK(handle, capold, capnew);
}
static int cap_mknod(vfs_handle_struct *handle, const char *path, mode_t mode, SMB_DEV_T dev)
{
- pstring cappath;
- capencode(cappath, path);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_MKNOD(handle, cappath, mode, dev);
}
static char *cap_realpath(vfs_handle_struct *handle, const char *path, char *resolved_path)
{
/* monyo need capencode'ed and capdecode'ed? */
- pstring cappath;
- capencode(cappath, path);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return NULL;
+ }
return SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);
}
-static NTSTATUS cap_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info_sent, struct security_descriptor *psd)
+static NTSTATUS cap_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *path, uint32 security_info_sent, struct security_descriptor *psd)
{
- pstring capname;
- capencode(capname, name);
- return SMB_VFS_NEXT_SET_NT_ACL(handle, fsp, capname, security_info_sent, psd);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return NT_STATUS_NO_MEMORY;
+ }
+ return SMB_VFS_NEXT_SET_NT_ACL(handle, fsp, cappath, security_info_sent, psd);
}
-static int cap_chmod_acl(vfs_handle_struct *handle, const char *name, mode_t mode)
+static int cap_chmod_acl(vfs_handle_struct *handle, const char *path, mode_t mode)
{
- pstring capname;
- capencode(capname, name);
+ char *cappath = capencode(talloc_tos(), path);
/* If the underlying VFS doesn't have ACL support... */
if (!handle->vfs_next.ops.chmod_acl) {
errno = ENOSYS;
return -1;
}
- return SMB_VFS_NEXT_CHMOD_ACL(handle, capname, mode);
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
+ return SMB_VFS_NEXT_CHMOD_ACL(handle, cappath, mode);
}
-static SMB_ACL_T cap_sys_acl_get_file(vfs_handle_struct *handle, const char *path_p, SMB_ACL_TYPE_T type)
+static SMB_ACL_T cap_sys_acl_get_file(vfs_handle_struct *handle, const char *path, SMB_ACL_TYPE_T type)
{
- pstring cappath_p;
- capencode(cappath_p, path_p);
- return SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, cappath_p, type);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return (SMB_ACL_T)NULL;
+ }
+ return SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, cappath, type);
}
-static int cap_sys_acl_set_file(vfs_handle_struct *handle, const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
+static int cap_sys_acl_set_file(vfs_handle_struct *handle, const char *path, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
{
- pstring capname;
- capencode(capname, name);
- return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, capname, acltype, theacl);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
+ return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, cappath, acltype, theacl);
}
static int cap_sys_acl_delete_def_file(vfs_handle_struct *handle, const char *path)
{
- pstring cappath;
- capencode(cappath, path);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, cappath);
}
static ssize_t cap_getxattr(vfs_handle_struct *handle, const char *path, const char *name, void *value, size_t size)
{
- pstring cappath, capname;
- capencode(cappath, path);
- capencode(capname, name);
+ char *cappath = capencode(talloc_tos(), path);
+ char *capname = capencode(talloc_tos(), name);
+
+ if (!cappath || !capname) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_GETXATTR(handle, cappath, capname, value, size);
}
static ssize_t cap_lgetxattr(vfs_handle_struct *handle, const char *path, const char *name, void *value, size_t
size)
{
- pstring cappath, capname;
- capencode(cappath, path);
- capencode(capname, name);
+ char *cappath = capencode(talloc_tos(), path);
+ char *capname = capencode(talloc_tos(), name);
+
+ if (!cappath || !capname) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_LGETXATTR(handle, cappath, capname, value, size);
}
-static ssize_t cap_fgetxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name, void *value, size_t size)
+static ssize_t cap_fgetxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *path, void *value, size_t size)
{
- pstring capname;
- capencode(capname, name);
- return SMB_VFS_NEXT_FGETXATTR(handle, fsp, fd, capname, value, size);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
+ return SMB_VFS_NEXT_FGETXATTR(handle, fsp, fd, cappath, value, size);
}
static ssize_t cap_listxattr(vfs_handle_struct *handle, const char *path, char *list, size_t size)
{
- pstring cappath;
- capencode(cappath, path);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_LISTXATTR(handle, cappath, list, size);
}
static ssize_t cap_llistxattr(vfs_handle_struct *handle, const char *path, char *list, size_t size)
{
- pstring cappath;
- capencode(cappath, path);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_LLISTXATTR(handle, cappath, list, size);
}
static int cap_removexattr(vfs_handle_struct *handle, const char *path, const char *name)
{
- pstring cappath, capname;
- capencode(cappath, path);
- capencode(capname, name);
+ char *cappath = capencode(talloc_tos(), path);
+ char *capname = capencode(talloc_tos(), name);
+
+ if (!cappath || !capname) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_REMOVEXATTR(handle, cappath, capname);
}
static int cap_lremovexattr(vfs_handle_struct *handle, const char *path, const char *name)
{
- pstring cappath, capname;
- capencode(cappath, path);
- capencode(capname, name);
+ char *cappath = capencode(talloc_tos(), path);
+ char *capname = capencode(talloc_tos(), name);
+
+ if (!cappath || !capname) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_LREMOVEXATTR(handle, cappath, capname);
}
-static int cap_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name)
+static int cap_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *path)
{
- pstring capname;
- capencode(capname, name);
- return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, fd, capname);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
+ return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, fd, cappath);
}
static int cap_setxattr(vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags)
{
- pstring cappath, capname;
- capencode(cappath, path);
- capencode(capname, name);
+ char *cappath = capencode(talloc_tos(), path);
+ char *capname = capencode(talloc_tos(), name);
+
+ if (!cappath || !capname) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_SETXATTR(handle, cappath, capname, value, size, flags);
}
static int cap_lsetxattr(vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags)
{
- pstring cappath, capname;
- capencode(cappath, path);
- capencode(capname, name);
+ char *cappath = capencode(talloc_tos(), path);
+ char *capname = capencode(talloc_tos(), name);
+
+ if (!cappath || !capname) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_LSETXATTR(handle, cappath, capname, value, size, flags);
}
-static int cap_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name, const void *value, size_t size, int flags)
+static int cap_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *path, const void *value, size_t size, int flags)
{
- pstring capname;
- capencode(capname, name);
- return SMB_VFS_NEXT_FSETXATTR(handle, fsp, fd, capname, value, size, flags);
+ char *cappath = capencode(talloc_tos(), path);
+
+ if (!cappath) {
+ errno = ENOMEM;
+ return -1;
+ }
+ return SMB_VFS_NEXT_FSETXATTR(handle, fsp, fd, cappath, value, size, flags);
}
/* VFS operations structure */
@@ -315,7 +473,7 @@ static vfs_op_tuple cap_op_tuples[] = {
/* Disk operations */
{SMB_VFS_OP(cap_disk_free), SMB_VFS_OP_DISK_FREE, SMB_VFS_LAYER_TRANSPARENT},
-
+
/* Directory operations */
{SMB_VFS_OP(cap_opendir), SMB_VFS_OP_OPENDIR, SMB_VFS_LAYER_TRANSPARENT},
@@ -352,7 +510,7 @@ static vfs_op_tuple cap_op_tuples[] = {
{SMB_VFS_OP(cap_sys_acl_get_file), SMB_VFS_OP_SYS_ACL_GET_FILE, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(cap_sys_acl_set_file), SMB_VFS_OP_SYS_ACL_SET_FILE, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(cap_sys_acl_delete_def_file), SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, SMB_VFS_LAYER_TRANSPARENT},
-
+
/* EA operations. */
{SMB_VFS_OP(cap_getxattr), SMB_VFS_OP_GETXATTR, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(cap_lgetxattr), SMB_VFS_OP_LGETXATTR, SMB_VFS_LAYER_TRANSPARENT},
@@ -406,51 +564,76 @@ static unsigned char bin2hex_table[256] = "0123456789abcdef";
/*******************************************************************
original code -> ":xx" - CAP format
********************************************************************/
-static char *capencode(char *to, const char *from)
-{
- pstring cvtbuf;
- char *out;
-
- if (to == from) {
- from = pstrcpy ((char *) cvtbuf, from);
- }
-
- for (out = to; *from && (out - to < sizeof(pstring)-7);) {
- /* buffer husoku error */
- if ((unsigned char)*from >= 0x80) {
- *out++ = hex_tag;
- *out++ = bin2hex (((*from)>>4)&0x0f);
- *out++ = bin2hex ((*from)&0x0f);
- from++;
- }
- else {
- *out++ = *from++;
- }
- }
- *out = '\0';
- return to;
+
+static char *capencode(TALLOC_CTX *ctx, const char *from)
+{
+ char *out = NULL;
+ const char *p1;
+ char *to = NULL;
+ size_t len = 0;
+
+ for (p1 = from; *p1; p1++) {
+ if ((unsigned char)*p1 >= 0x80) {
+ len += 3;
+ } else {
+ len++;
+ }
+ }
+ len++;
+
+ to = TALLOC_ARRAY(ctx, char, len);
+ if (!to) {
+ return NULL;
+ }
+
+ for (out = to; *from;) {
+ /* buffer husoku error */
+ if ((unsigned char)*from >= 0x80) {
+ *out++ = hex_tag;
+ *out++ = bin2hex (((*from)>>4)&0x0f);
+ *out++ = bin2hex ((*from)&0x0f);
+ from++;
+ } else {
+ *out++ = *from++;
+ }
+ }
+ *out = '\0';
+ return to;
}
/*******************************************************************
CAP -> original code
********************************************************************/
/* ":xx" -> a byte */
-static char *capdecode(char *to, const char *from)
-{
- pstring cvtbuf;
- char *out;
-
- if (to == from) {
- from = pstrcpy ((char *) cvtbuf, from);
- }
- for (out = to; *from && (out - to < sizeof(pstring)-3);) {
- if (is_hex(from)) {
- *out++ = (hex2bin (from[1])<<4) | (hex2bin (from[2]));
- from += 3;
- } else {
- *out++ = *from++;
- }
- }
- *out = '\0';
- return to;
+
+static char *capdecode(TALLOC_CTX *ctx, const char *from)
+{
+ const char *p1;
+ char *out = NULL;
+ char *to = NULL;
+ size_t len = 0;
+
+ for (p1 = from; *p1; len++) {
+ if (is_hex(from)) {
+ p1 += 3;
+ } else {
+ p1++;
+ }
+ }
+
+ to = TALLOC_ARRAY(ctx, char, len);
+ if (!to) {
+ return NULL;
+ }
+
+ for (out = to; *from;) {
+ if (is_hex(from)) {
+ *out++ = (hex2bin(from[1])<<4) | (hex2bin(from[2]));
+ from += 3;
+ } else {
+ *out++ = *from++;
+ }
+ }
+ *out = '\0';
+ return to;
}
diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c
index dbb9550dbf..71f478a8a9 100644
--- a/source3/modules/vfs_catia.c
+++ b/source3/modules/vfs_catia.c
@@ -1,4 +1,4 @@
-/*
+/*
* Catia VFS module
*
* Implement a fixed mapping of forbidden NT characters in filenames that are
@@ -14,12 +14,12 @@
* 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/>.
*/
@@ -27,164 +27,221 @@
#include "includes.h"
-static void catia_string_replace(char *s, unsigned char oldc, unsigned
- char newc)
+static char *catia_string_replace(TALLOC_CTX *ctx,
+ const char *s,
+ unsigned char oldc,
+ unsigned char newc)
{
- static smb_ucs2_t tmpbuf[sizeof(pstring)];
- smb_ucs2_t *ptr = tmpbuf;
- smb_ucs2_t old = oldc;
-
- push_ucs2(NULL, tmpbuf, s, sizeof(tmpbuf), STR_TERMINATE);
-
- for (;*ptr;ptr++)
- if (*ptr==old) *ptr=newc;
-
- pull_ucs2(NULL, s, tmpbuf, sizeof(pstring), sizeof(tmpbuf), STR_TERMINATE);
+ smb_ucs2_t *tmpbuf = NULL;
+ smb_ucs2_t *ptr = NULL;
+ smb_ucs2_t old = oldc;
+ char *ret = NULL;
+
+ if (!s) {
+ return NULL;
+ }
+
+ if (push_ucs2_talloc(ctx, &tmpbuf, s) == -1) {
+ return NULL;
+ }
+
+ ptr = tmpbuf;
+
+ for (;*ptr;ptr++) {
+ if (*ptr==old) {
+ *ptr=newc;
+ }
+ }
+
+ if (pull_ucs2_talloc(ctx, &ret, tmpbuf) == -1) {
+ TALLOC_FREE(tmpbuf);
+ return NULL;
+ }
+ TALLOC_FREE(tmpbuf);
+ return ret;
}
-static void from_unix(char *s)
+static char *from_unix(TALLOC_CTX *ctx, const char *s)
{
- catia_string_replace(s, '\x22', '\xa8');
- catia_string_replace(s, '\x2a', '\xa4');
- catia_string_replace(s, '\x2f', '\xf8');
- catia_string_replace(s, '\x3a', '\xf7');
- catia_string_replace(s, '\x3c', '\xab');
- catia_string_replace(s, '\x3e', '\xbb');
- catia_string_replace(s, '\x3f', '\xbf');
- catia_string_replace(s, '\x5c', '\xff');
- catia_string_replace(s, '\x7c', '\xa6');
- catia_string_replace(s, ' ', '\xb1');
+ char *ret = catia_string_replace(ctx, s, '\x22', '\xa8');
+ ret = catia_string_replace(ctx, ret, '\x2a', '\xa4');
+ ret = catia_string_replace(ctx, ret, '\x2f', '\xf8');
+ ret = catia_string_replace(ctx, ret, '\x3a', '\xf7');
+ ret = catia_string_replace(ctx, ret, '\x3c', '\xab');
+ ret = catia_string_replace(ctx, ret, '\x3e', '\xbb');
+ ret = catia_string_replace(ctx, ret, '\x3f', '\xbf');
+ ret = catia_string_replace(ctx, ret, '\x5c', '\xff');
+ ret = catia_string_replace(ctx, ret, '\x7c', '\xa6');
+ return catia_string_replace(ctx, ret, ' ', '\xb1');
}
-static void to_unix(char *s)
+static char *to_unix(TALLOC_CTX *ctx, const char *s)
{
- catia_string_replace(s, '\xa8', '\x22');
- catia_string_replace(s, '\xa4', '\x2a');
- catia_string_replace(s, '\xf8', '\x2f');
- catia_string_replace(s, '\xf7', '\x3a');
- catia_string_replace(s, '\xab', '\x3c');
- catia_string_replace(s, '\xbb', '\x3e');
- catia_string_replace(s, '\xbf', '\x3f');
- catia_string_replace(s, '\xff', '\x5c');
- catia_string_replace(s, '\xa6', '\x7c');
- catia_string_replace(s, '\xb1', ' ');
+ char *ret = catia_string_replace(ctx, s, '\xa8', '\x22');
+ ret = catia_string_replace(ctx, ret, '\xa4', '\x2a');
+ ret = catia_string_replace(ctx, ret, '\xf8', '\x2f');
+ ret = catia_string_replace(ctx, ret, '\xf7', '\x3a');
+ ret = catia_string_replace(ctx, ret, '\xab', '\x3c');
+ ret = catia_string_replace(ctx, ret, '\xbb', '\x3e');
+ ret = catia_string_replace(ctx, ret, '\xbf', '\x3f');
+ ret = catia_string_replace(ctx, ret, '\xff', '\x5c');
+ ret = catia_string_replace(ctx, ret, '\xa6', '\x7c');
+ return catia_string_replace(ctx, ret, '\xb1', ' ');
}
static SMB_STRUCT_DIR *catia_opendir(vfs_handle_struct *handle,
const char *fname, const char *mask, uint32 attr)
{
- pstring name;
- pstrcpy(name, fname);
- to_unix(name);
+ char *name = to_unix(talloc_tos(), fname);
+ if (!name) {
+ errno = ENOMEM;
+ return NULL;
+ }
return SMB_VFS_NEXT_OPENDIR(handle, name, mask, attr);
}
-static SMB_STRUCT_DIRENT *catia_readdir(vfs_handle_struct *handle,
+static SMB_STRUCT_DIRENT *catia_readdir(vfs_handle_struct *handle,
SMB_STRUCT_DIR *dirp)
{
- SMB_STRUCT_DIRENT *result = SMB_VFS_NEXT_READDIR(handle, dirp);
-
- if (result == NULL)
- return result;
-
- from_unix(result->d_name);
- return result;
+ SMB_STRUCT_DIRENT *result = SMB_VFS_NEXT_READDIR(handle, dirp);
+ SMB_STRUCT_DIRENT *newdirent;
+ char *newname;
+ size_t newnamelen;
+
+ if (result == NULL) {
+ return result;
+ }
+
+ newname = from_unix(talloc_tos(), result->d_name);
+ if (!newname) {
+ return NULL;
+ }
+ newnamelen = strlen(newname)+1;
+ newdirent = (SMB_STRUCT_DIRENT *)TALLOC_ARRAY(talloc_tos(),
+ char,
+ sizeof(SMB_STRUCT_DIRENT)+
+ newnamelen);
+ if (!newdirent) {
+ return NULL;
+ }
+ memcpy(newdirent, result, sizeof(SMB_STRUCT_DIRENT));
+ memcpy(&newdirent->d_name, newname, newnamelen);
+ return newdirent;
}
static int catia_open(vfs_handle_struct *handle,
- const char *fname, files_struct *fsp, int flags, mode_t mode)
+ const char *fname,
+ files_struct *fsp,
+ int flags,
+ mode_t mode)
{
- pstring name;
+ char *name = to_unix(talloc_tos(), fname);
- pstrcpy(name, fname);
- to_unix(name);
-
+ if (!name) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_OPEN(handle, name, fsp, flags, mode);
}
static int catia_rename(vfs_handle_struct *handle,
const char *oldname, const char *newname)
{
- pstring oname, nname;
+ TALLOC_CTX *ctx = talloc_tos();
+ char *oname = to_unix(ctx, oldname);
+ char *nname = to_unix(ctx, newname);
- pstrcpy(oname, oldname);
- to_unix(oname);
- pstrcpy(nname, newname);
- to_unix(nname);
+ if (!oname || !nname) {
+ errno = ENOMEM;
+ return -1;
+ }
+ DEBUG(10, ("converted old name: %s\n", oname));
+ DEBUG(10, ("converted new name: %s\n", nname));
- DEBUG(10, ("converted old name: %s\n", oname));
- DEBUG(10, ("converted new name: %s\n", nname));
-
return SMB_VFS_NEXT_RENAME(handle, oname, nname);
}
static int catia_stat(vfs_handle_struct *handle,
const char *fname, SMB_STRUCT_STAT *sbuf)
{
- pstring name;
- pstrcpy(name, fname);
- to_unix(name);
+ char *name = to_unix(talloc_tos(), fname);
+ if (!name) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_STAT(handle, name, sbuf);
}
static int catia_lstat(vfs_handle_struct *handle,
const char *path, SMB_STRUCT_STAT *sbuf)
{
- pstring name;
- pstrcpy(name, path);
- to_unix(name);
+ char *name = to_unix(talloc_tos(), path);
+ if (!name) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_LSTAT(handle, name, sbuf);
}
static int catia_unlink(vfs_handle_struct *handle, const char *path)
{
- pstring name;
- pstrcpy(name, path);
- to_unix(name);
+ char *name = to_unix(talloc_tos(), path);
+ if (!name) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_UNLINK(handle, name);
}
static int catia_chmod(vfs_handle_struct *handle,
const char *path, mode_t mode)
{
- pstring name;
- pstrcpy(name, path);
- to_unix(name);
+ char *name = to_unix(talloc_tos(), path);
+ if (!name) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_CHMOD(handle, name, mode);
}
static int catia_chown(vfs_handle_struct *handle,
const char *path, uid_t uid, gid_t gid)
{
- pstring name;
- pstrcpy(name, path);
- to_unix(name);
+ char *name = to_unix(talloc_tos(), path);
+ if (!name) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_CHOWN(handle, name, uid, gid);
}
static int catia_lchown(vfs_handle_struct *handle,
const char *path, uid_t uid, gid_t gid)
{
- pstring name;
- pstrcpy(name, path);
- to_unix(name);
+ char *name = to_unix(talloc_tos(), path);
+ if (!name) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_LCHOWN(handle, name, uid, gid);
}
static int catia_chdir(vfs_handle_struct *handle,
const char *path)
{
- pstring name;
- pstrcpy(name, path);
- to_unix(name);
+ char *name = to_unix(talloc_tos(), path);
+ if (!name) {
+ errno = ENOMEM;
+ return -1;
+ }
return SMB_VFS_NEXT_CHDIR(handle, name);
}
@@ -237,7 +294,7 @@ static NTSTATUS catia_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
ppdesc);
}
-static NTSTATUS catia_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
+static NTSTATUS catia_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
const char *name, uint32 security_info_sent,
struct security_descriptor *psd)
{
@@ -262,66 +319,66 @@ static vfs_op_tuple catia_op_tuples[] = {
/* Directory operations */
- {SMB_VFS_OP(catia_opendir), SMB_VFS_OP_OPENDIR,
+ {SMB_VFS_OP(catia_opendir), SMB_VFS_OP_OPENDIR,
SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(catia_readdir), SMB_VFS_OP_READDIR,
+ {SMB_VFS_OP(catia_readdir), SMB_VFS_OP_READDIR,
SMB_VFS_LAYER_TRANSPARENT},
/* File operations */
- {SMB_VFS_OP(catia_open), SMB_VFS_OP_OPEN,
+ {SMB_VFS_OP(catia_open), SMB_VFS_OP_OPEN,
SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(catia_rename), SMB_VFS_OP_RENAME,
+ {SMB_VFS_OP(catia_rename), SMB_VFS_OP_RENAME,
SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(catia_stat), SMB_VFS_OP_STAT,
+ {SMB_VFS_OP(catia_stat), SMB_VFS_OP_STAT,
SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(catia_lstat), SMB_VFS_OP_LSTAT,
+ {SMB_VFS_OP(catia_lstat), SMB_VFS_OP_LSTAT,
SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(catia_unlink), SMB_VFS_OP_UNLINK,
+ {SMB_VFS_OP(catia_unlink), SMB_VFS_OP_UNLINK,
SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(catia_chmod), SMB_VFS_OP_CHMOD,
+ {SMB_VFS_OP(catia_chmod), SMB_VFS_OP_CHMOD,
SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(catia_chown), SMB_VFS_OP_CHOWN,
+ {SMB_VFS_OP(catia_chown), SMB_VFS_OP_CHOWN,
SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(catia_lchown), SMB_VFS_OP_LCHOWN,
+ {SMB_VFS_OP(catia_lchown), SMB_VFS_OP_LCHOWN,
SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(catia_chdir), SMB_VFS_OP_CHDIR,
+ {SMB_VFS_OP(catia_chdir), SMB_VFS_OP_CHDIR,
SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(catia_getwd), SMB_VFS_OP_GETWD,
+ {SMB_VFS_OP(catia_getwd), SMB_VFS_OP_GETWD,
SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(catia_ntimes), SMB_VFS_OP_NTIMES,
+ {SMB_VFS_OP(catia_ntimes), SMB_VFS_OP_NTIMES,
SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(catia_symlink), SMB_VFS_OP_SYMLINK,
+ {SMB_VFS_OP(catia_symlink), SMB_VFS_OP_SYMLINK,
SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(catia_readlink), SMB_VFS_OP_READLINK,
+ {SMB_VFS_OP(catia_readlink), SMB_VFS_OP_READLINK,
SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(catia_link), SMB_VFS_OP_LINK,
+ {SMB_VFS_OP(catia_link), SMB_VFS_OP_LINK,
SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(catia_mknod), SMB_VFS_OP_MKNOD,
+ {SMB_VFS_OP(catia_mknod), SMB_VFS_OP_MKNOD,
SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(catia_realpath), SMB_VFS_OP_REALPATH,
+ {SMB_VFS_OP(catia_realpath), SMB_VFS_OP_REALPATH,
SMB_VFS_LAYER_TRANSPARENT},
/* NT File ACL operations */
- {SMB_VFS_OP(catia_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
+ {SMB_VFS_OP(catia_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
SMB_VFS_LAYER_TRANSPARENT},
- {SMB_VFS_OP(catia_set_nt_acl), SMB_VFS_OP_SET_NT_ACL,
+ {SMB_VFS_OP(catia_set_nt_acl), SMB_VFS_OP_SET_NT_ACL,
SMB_VFS_LAYER_TRANSPARENT},
/* POSIX ACL operations */
- {SMB_VFS_OP(catia_chmod_acl), SMB_VFS_OP_CHMOD_ACL,
+ {SMB_VFS_OP(catia_chmod_acl), SMB_VFS_OP_CHMOD_ACL,
SMB_VFS_LAYER_TRANSPARENT},
- {NULL, SMB_VFS_OP_NOOP,
+ {NULL, SMB_VFS_OP_NOOP,
SMB_VFS_LAYER_NOOP}
};
NTSTATUS vfs_catia_init(void);
NTSTATUS vfs_catia_init(void)
{
- return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "catia",
+ return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "catia",
catia_op_tuples);
}
diff --git a/source3/modules/vfs_expand_msdfs.c b/source3/modules/vfs_expand_msdfs.c
index 2a16b5a731..9d4883c085 100644
--- a/source3/modules/vfs_expand_msdfs.c
+++ b/source3/modules/vfs_expand_msdfs.c
@@ -37,19 +37,19 @@ extern userdom_struct current_user_info;
This is to redirect a DFS client to a host close to it.
***********************************************************/
-static bool read_target_host(const char *mapfile, pstring targethost)
+static char *read_target_host(TALLOC_CTX *ctx, const char *mapfile)
{
XFILE *f;
- pstring buf;
+ char buf[1024];
char *space = buf;
- bool found = False;
-
+ bool found = false;
+
f = x_fopen(mapfile, O_RDONLY, 0);
if (f == NULL) {
DEBUG(0,("can't open IP map %s. Error %s\n",
mapfile, strerror(errno) ));
- return False;
+ return NULL;
}
DEBUG(10, ("Scanning mapfile [%s]\n", mapfile));
@@ -73,23 +73,23 @@ static bool read_target_host(const char *mapfile, pstring targethost)
if (strncmp(client_addr(get_client_fd(),addr,sizeof(addr)),
buf, strlen(buf)) == 0) {
- found = True;
+ found = true;
break;
}
}
x_fclose(f);
- if (!found)
- return False;
+ if (!found) {
+ return NULL;
+ }
space += 1;
while (isspace(*space))
space += 1;
- pstrcpy(targethost, space);
- return True;
+ return talloc_strdup(ctx, space);
}
/**********************************************************
@@ -105,65 +105,83 @@ static bool read_target_host(const char *mapfile, pstring targethost)
***********************************************************/
-static bool expand_msdfs_target(connection_struct* conn, pstring target)
+static char *expand_msdfs_target(TALLOC_CTX *ctx,
+ connection_struct *conn,
+ char *target)
{
- pstring mapfilename;
+ char *mapfilename = NULL;
char *filename_start = strchr_m(target, '@');
- char *filename_end;
- int filename_len;
- pstring targethost;
- pstring new_target;
+ char *filename_end = NULL;
+ int filename_len = 0;
+ char *targethost = NULL;
+ char *new_target = NULL;
if (filename_start == NULL) {
DEBUG(10, ("No filename start in %s\n", target));
- return False;
+ return NULL;
}
filename_end = strchr_m(filename_start+1, '@');
if (filename_end == NULL) {
DEBUG(10, ("No filename end in %s\n", target));
- return False;
+ return NULL;
}
filename_len = PTR_DIFF(filename_end, filename_start+1);
- pstrcpy(mapfilename, filename_start+1);
+ mapfilename = talloc_strdup(ctx, filename_start+1);
+ if (!mapfilename) {
+ return NULL;
+ }
mapfilename[filename_len] = '\0';
DEBUG(10, ("Expanding from table [%s]\n", mapfilename));
- if (!read_target_host(mapfilename, targethost)) {
+ if ((targethost = read_target_host(ctx, mapfilename)) == NULL) {
DEBUG(1, ("Could not expand target host from file %s\n",
mapfilename));
- return False;
+ return NULL;
}
- standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user,
- conn->connectpath, conn->gid,
- get_current_username(),
- current_user_info.domain,
- mapfilename, sizeof(mapfilename));
+ targethost = talloc_sub_advanced(ctx,
+ lp_servicename(SNUM(conn)),
+ conn->user,
+ conn->connectpath,
+ conn->gid,
+ get_current_username(),
+ current_user_info.domain,
+ targethost);
DEBUG(10, ("Expanded targethost to %s\n", targethost));
+ /* Replace the part between '@...@' */
*filename_start = '\0';
- pstrcpy(new_target, target);
- pstrcat(new_target, targethost);
- pstrcat(new_target, filename_end+1);
+ new_target = talloc_asprintf(ctx,
+ "%s%s%s",
+ target,
+ targethost,
+ filename_end+1);
+ if (!new_target) {
+ return NULL;
+ }
DEBUG(10, ("New DFS target: %s\n", new_target));
- pstrcpy(target, new_target);
- return True;
+ return new_target;
}
static int expand_msdfs_readlink(struct vfs_handle_struct *handle,
const char *path, char *buf, size_t bufsiz)
{
- pstring target;
+ TALLOC_CTX *ctx = talloc_tos();
int result;
+ char *target = TALLOC_ARRAY(ctx, char, PATH_MAX+1);
+ if (!target) {
+ errno = ENOMEM;
+ return -1;
+ }
result = SMB_VFS_NEXT_READLINK(handle, path, target,
- sizeof(target));
+ PATH_MAX);
if (result < 0)
return result;
@@ -172,7 +190,8 @@ static int expand_msdfs_readlink(struct vfs_handle_struct *handle,
if ((strncmp(target, "msdfs:", strlen("msdfs:")) == 0) &&
(strchr_m(target, '@') != NULL)) {
- if (!expand_msdfs_target(handle->conn, target)) {
+ target = expand_msdfs_target(ctx, handle->conn, target);
+ if (!target) {
errno = ENOENT;
return -1;
}
@@ -184,7 +203,7 @@ static int expand_msdfs_readlink(struct vfs_handle_struct *handle,
/* VFS operations structure */
-static vfs_op_tuple expand_msdfs_ops[] = {
+static vfs_op_tuple expand_msdfs_ops[] = {
{SMB_VFS_OP(expand_msdfs_readlink), SMB_VFS_OP_READLINK,
SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP}
diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c
index 0f84c4de17..533ac712ca 100644
--- a/source3/modules/vfs_full_audit.c
+++ b/source3/modules/vfs_full_audit.c
@@ -681,18 +681,22 @@ static int audit_syslog_priority(vfs_handle_struct *handle)
return priority;
}
-static char *audit_prefix(connection_struct *conn)
+static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn)
{
- static pstring prefix;
+ char *prefix = NULL;
- pstrcpy(prefix, lp_parm_const_string(SNUM(conn), "full_audit",
+ prefix = talloc_strdup(ctx,
+ lp_parm_const_string(SNUM(conn), "full_audit",
"prefix", "%u|%I"));
- standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user,
- conn->connectpath, conn->gid,
- get_current_username(),
- current_user_info.domain,
- prefix, sizeof(prefix));
- return prefix;
+ if (!prefix) {
+ return NULL;
+ }
+ return talloc_sub_advanced(ctx,
+ lp_servicename(SNUM(conn)), conn->user,
+ conn->connectpath, conn->gid,
+ get_current_username(),
+ current_user_info.domain,
+ prefix);
}
static bool log_success(vfs_handle_struct *handle, vfs_op_type op)
@@ -790,8 +794,9 @@ static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
const char *format, ...)
{
fstring err_msg;
- pstring op_msg;
+ char *audit_pre = NULL;
va_list ap;
+ char *op_msg = NULL;
if (success && (!log_success(handle, op)))
return;
@@ -805,11 +810,20 @@ static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
va_start(ap, format);
- vsnprintf(op_msg, sizeof(op_msg), format, ap);
+ op_msg = talloc_vasprintf(NULL, format, ap);
va_end(ap);
+ if (!op_msg) {
+ return;
+ }
+
+ audit_pre = audit_prefix(NULL, handle->conn);
syslog(audit_syslog_priority(handle), "%s|%s|%s|%s\n",
- audit_prefix(handle->conn), audit_opname(op), err_msg, op_msg);
+ audit_pre ? audit_pre : "",
+ audit_opname(op), err_msg, op_msg);
+
+ TALLOC_FREE(audit_pre);
+ TALLOC_FREE(op_msg);
return;
}