From d2da9dee686881106678d50a96713f0632dcdf10 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Jun 2009 15:07:14 -0700 Subject: Add some const to the stat struct in the dosmode calls. Fix a couple more unix_convert uses to filename_convert. Fix bug in acl_group_override() where an uninitialized struct could be used. Move unix_convert with wildcard use in SMBsearch reply to boilerplate code. Jeremy. --- source3/smbd/posix_acls.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'source3/smbd/posix_acls.c') diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c index 2d0062ab94..6eed92cb3e 100644 --- a/source3/smbd/posix_acls.c +++ b/source3/smbd/posix_acls.c @@ -2548,9 +2548,8 @@ static bool current_user_in_group(gid_t gid) static bool acl_group_override(connection_struct *conn, gid_t prim_gid, - const char *fname) + files_struct *fsp) { - SMB_STRUCT_STAT sbuf; if ((errno != EPERM) && (errno != EACCES)) { return false; @@ -2563,9 +2562,23 @@ static bool acl_group_override(connection_struct *conn, } /* user has writeable permission */ - if (lp_dos_filemode(SNUM(conn)) && - can_write_to_file(conn, fname, &sbuf)) { - return true; + if (lp_dos_filemode(SNUM(conn))) { + SMB_STRUCT_STAT sbuf; + int ret; + + if (fsp->posix_open) { + ret = SMB_VFS_LSTAT(conn,fsp->fsp_name,&sbuf); + } else { + ret = SMB_VFS_STAT(conn,fsp->fsp_name,&sbuf); + } + + if (ret == -1) { + return false; + } + + if (can_write_to_file(conn, fsp->fsp_name, &sbuf)) { + return true; + } } return false; @@ -2754,7 +2767,7 @@ static bool set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, bool defau *pacl_set_support = False; } - if (acl_group_override(conn, prim_gid, fsp->fsp_name)) { + if (acl_group_override(conn, prim_gid, fsp)) { int sret; DEBUG(5,("set_canon_ace_list: acl group control on and current user in file %s primary group.\n", @@ -2785,7 +2798,7 @@ static bool set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, bool defau *pacl_set_support = False; } - if (acl_group_override(conn, prim_gid, fsp->fsp_name)) { + if (acl_group_override(conn, prim_gid, fsp)) { int sret; DEBUG(5,("set_canon_ace_list: acl group control on and current user in file %s primary group.\n", @@ -3831,7 +3844,7 @@ NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, const SEC_DESC unbecome_root(); } if (sret == -1) { - if (acl_group_override(conn, sbuf.st_ex_gid, fsp->fsp_name)) { + if (acl_group_override(conn, sbuf.st_ex_gid, fsp)) { DEBUG(5,("set_nt_acl: acl group control on and " "current user in file %s primary group. Override delete_def_acl\n", fsp->fsp_name )); @@ -3893,7 +3906,7 @@ NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, const SEC_DESC unbecome_root(); } if(sret == -1) { - if (acl_group_override(conn, sbuf.st_ex_gid, fsp->fsp_name)) { + if (acl_group_override(conn, sbuf.st_ex_gid, fsp)) { DEBUG(5,("set_nt_acl: acl group control on and " "current user in file %s primary group. Override chmod\n", fsp->fsp_name )); -- cgit