summaryrefslogtreecommitdiff
path: root/source3/modules
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-05-23 23:55:12 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:22:46 -0500
commit57d6318a0b5ecc0154547a04acef8ac222c1d28f (patch)
treec87905c626d1c6cac32ba8b4b3f6948484b5acd7 /source3/modules
parentdbfd6bf8c8cc9945c4ba7e22ac44b1f33f9c7ce6 (diff)
downloadsamba-57d6318a0b5ecc0154547a04acef8ac222c1d28f.tar.gz
samba-57d6318a0b5ecc0154547a04acef8ac222c1d28f.tar.bz2
samba-57d6318a0b5ecc0154547a04acef8ac222c1d28f.zip
r23105: Add lchown to the vfs layer. We need this in the POSIX code.
Jeremy. (This used to be commit 932523cbb508db869b726768e86bfa8e248f768b)
Diffstat (limited to 'source3/modules')
-rw-r--r--source3/modules/vfs_cap.c8
-rw-r--r--source3/modules/vfs_catia.c12
-rw-r--r--source3/modules/vfs_default.c14
-rw-r--r--source3/modules/vfs_full_audit.c18
-rw-r--r--source3/modules/vfs_netatalk.c33
5 files changed, 84 insertions, 1 deletions
diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c
index d495ed5d14..ab99031e4d 100644
--- a/source3/modules/vfs_cap.c
+++ b/source3/modules/vfs_cap.c
@@ -123,6 +123,13 @@ static int cap_chown(vfs_handle_struct *handle, const char *path, uid_t uid, gid
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);
+ return SMB_VFS_NEXT_LCHOWN(handle, cappath, uid, gid);
+}
+
static int cap_chdir(vfs_handle_struct *handle, const char *path)
{
pstring cappath;
@@ -326,6 +333,7 @@ static vfs_op_tuple cap_op_tuples[] = {
{SMB_VFS_OP(cap_unlink), SMB_VFS_OP_UNLINK, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(cap_chmod), SMB_VFS_OP_CHMOD, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(cap_chown), SMB_VFS_OP_CHOWN, SMB_VFS_LAYER_TRANSPARENT},
+ {SMB_VFS_OP(cap_lchown), SMB_VFS_OP_LCHOWN, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(cap_chdir), SMB_VFS_OP_CHDIR, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(cap_ntimes), SMB_VFS_OP_NTIMES, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(cap_symlink), SMB_VFS_OP_SYMLINK, SMB_VFS_LAYER_TRANSPARENT},
diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c
index fe1ce830f7..d9a5cbd0f0 100644
--- a/source3/modules/vfs_catia.c
+++ b/source3/modules/vfs_catia.c
@@ -169,6 +169,16 @@ static int catia_chown(vfs_handle_struct *handle,
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);
+
+ return SMB_VFS_NEXT_LCHOWN(handle, name, uid, gid);
+}
+
static int catia_chdir(vfs_handle_struct *handle,
const char *path)
{
@@ -274,6 +284,8 @@ SMB_VFS_LAYER_TRANSPARENT},
SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(catia_chown), SMB_VFS_OP_CHOWN,
SMB_VFS_LAYER_TRANSPARENT},
+ {SMB_VFS_OP(catia_lchown), SMB_VFS_OP_LCHOWN,
+SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(catia_chdir), SMB_VFS_OP_CHDIR,
SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(catia_getwd), SMB_VFS_OP_GETWD,
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 1fc03e046f..28fe4d4ea7 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -568,7 +568,7 @@ static int vfswrap_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd,
return result;
}
-static int vfswrap_chown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
+static int vfswrap_chown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
{
int result;
@@ -593,6 +593,16 @@ static int vfswrap_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd,
#endif
}
+static int vfswrap_lchown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
+{
+ int result;
+
+ START_PROFILE(syscall_lchown);
+ result = sys_lchown(path, uid, gid);
+ END_PROFILE(syscall_lchown);
+ return result;
+}
+
static int vfswrap_chdir(vfs_handle_struct *handle, const char *path)
{
int result;
@@ -1272,6 +1282,8 @@ static vfs_op_tuple vfs_default_ops[] = {
SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(vfswrap_fchown), SMB_VFS_OP_FCHOWN,
SMB_VFS_LAYER_OPAQUE},
+ {SMB_VFS_OP(vfswrap_lchown), SMB_VFS_OP_LCHOWN,
+ SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(vfswrap_chdir), SMB_VFS_OP_CHDIR,
SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(vfswrap_getwd), SMB_VFS_OP_GETWD,
diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c
index 62530fb09c..cd434f1951 100644
--- a/source3/modules/vfs_full_audit.c
+++ b/source3/modules/vfs_full_audit.c
@@ -147,6 +147,8 @@ static int smb_full_audit_chown(vfs_handle_struct *handle,
const char *path, uid_t uid, gid_t gid);
static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd,
uid_t uid, gid_t gid);
+static int smb_full_audit_lchown(vfs_handle_struct *handle,
+ const char *path, uid_t uid, gid_t gid);
static int smb_full_audit_chdir(vfs_handle_struct *handle,
const char *path);
static char *smb_full_audit_getwd(vfs_handle_struct *handle,
@@ -380,6 +382,8 @@ static vfs_op_tuple audit_op_tuples[] = {
SMB_VFS_LAYER_LOGGER},
{SMB_VFS_OP(smb_full_audit_fchown), SMB_VFS_OP_FCHOWN,
SMB_VFS_LAYER_LOGGER},
+ {SMB_VFS_OP(smb_full_audit_lchown), SMB_VFS_OP_LCHOWN,
+ SMB_VFS_LAYER_LOGGER},
{SMB_VFS_OP(smb_full_audit_chdir), SMB_VFS_OP_CHDIR,
SMB_VFS_LAYER_LOGGER},
{SMB_VFS_OP(smb_full_audit_getwd), SMB_VFS_OP_GETWD,
@@ -560,6 +564,7 @@ static struct {
{ SMB_VFS_OP_FCHMOD, "fchmod" },
{ SMB_VFS_OP_CHOWN, "chown" },
{ SMB_VFS_OP_FCHOWN, "fchown" },
+ { SMB_VFS_OP_LCHOWN, "lchown" },
{ SMB_VFS_OP_CHDIR, "chdir" },
{ SMB_VFS_OP_GETWD, "getwd" },
{ SMB_VFS_OP_NTIMES, "ntimes" },
@@ -1258,6 +1263,19 @@ static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp, i
return result;
}
+static int smb_full_audit_lchown(vfs_handle_struct *handle,
+ const char *path, uid_t uid, gid_t gid)
+{
+ int result;
+
+ result = SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
+
+ do_log(SMB_VFS_OP_LCHOWN, (result >= 0), handle, "%s|%ld|%ld",
+ path, (long int)uid, (long int)gid);
+
+ return result;
+}
+
static int smb_full_audit_chdir(vfs_handle_struct *handle,
const char *path)
{
diff --git a/source3/modules/vfs_netatalk.c b/source3/modules/vfs_netatalk.c
index efcc981679..6ff53760f5 100644
--- a/source3/modules/vfs_netatalk.c
+++ b/source3/modules/vfs_netatalk.c
@@ -375,6 +375,38 @@ exit_chown:
return ret;
}
+static int atalk_lchown(struct vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
+{
+ int ret = 0;
+ char *adbl_path = 0;
+ char *orig_path = 0;
+ SMB_STRUCT_STAT adbl_info;
+ SMB_STRUCT_STAT orig_info;
+ TALLOC_CTX *ctx;
+
+ ret = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
+
+ if (!path) return ret;
+
+ if (!(ctx = talloc_init("lchown_file")))
+ return ret;
+
+ if (atalk_build_paths(ctx, handle->conn->origpath, path, &adbl_path, &orig_path,
+ &adbl_info, &orig_info) != 0)
+ goto exit_lchown;
+
+ if (!S_ISDIR(orig_info.st_mode) && !S_ISREG(orig_info.st_mode)) {
+ DEBUG(3, ("ATALK: %s has passed..\n", orig_path));
+ goto exit_lchown;
+ }
+
+ sys_lchown(adbl_path, uid, gid);
+
+exit_lchown:
+ talloc_destroy(ctx);
+ return ret;
+}
+
static vfs_op_tuple atalk_ops[] = {
/* Directory operations */
@@ -388,6 +420,7 @@ static vfs_op_tuple atalk_ops[] = {
{SMB_VFS_OP(atalk_unlink), SMB_VFS_OP_UNLINK, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(atalk_chmod), SMB_VFS_OP_CHMOD, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(atalk_chown), SMB_VFS_OP_CHOWN, SMB_VFS_LAYER_TRANSPARENT},
+ {SMB_VFS_OP(atalk_lchown), SMB_VFS_OP_LCHOWN, SMB_VFS_LAYER_TRANSPARENT},
/* Finish VFS operations definition */