summaryrefslogtreecommitdiff
path: root/source3/smbd/dosmode.c
diff options
context:
space:
mode:
authorTim Prouty <tprouty@samba.org>2009-07-07 19:20:22 -0700
committerTim Prouty <tprouty@samba.org>2009-07-08 21:36:03 -0700
commit69c8795b672054cb6b5a85cc5f8961099425bd7a (patch)
tree1484215b8c1b9778d8079d53863ff5557e753614 /source3/smbd/dosmode.c
parent400c18a8c4098b4ba86d32a236e5d89014774f3f (diff)
downloadsamba-69c8795b672054cb6b5a85cc5f8961099425bd7a.tar.gz
samba-69c8795b672054cb6b5a85cc5f8961099425bd7a.tar.bz2
samba-69c8795b672054cb6b5a85cc5f8961099425bd7a.zip
s3: convert unix_mode to take an smb_filename
Diffstat (limited to 'source3/smbd/dosmode.c')
-rw-r--r--source3/smbd/dosmode.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c
index 9d44eeec7d..9bd097c0bb 100644
--- a/source3/smbd/dosmode.c
+++ b/source3/smbd/dosmode.c
@@ -64,7 +64,8 @@ static int set_link_read_only_flag(const SMB_STRUCT_STAT *const sbuf)
}
****************************************************************************/
-mode_t unix_mode(connection_struct *conn, int dosmode, const char *fname,
+mode_t unix_mode(connection_struct *conn, int dosmode,
+ const struct smb_filename *smb_fname,
const char *inherit_from_dir)
{
mode_t result = (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP | S_IWOTH);
@@ -75,23 +76,39 @@ mode_t unix_mode(connection_struct *conn, int dosmode, const char *fname,
result &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
}
- if (fname && (inherit_from_dir != NULL)
- && lp_inherit_perms(SNUM(conn))) {
- SMB_STRUCT_STAT sbuf;
+ if ((inherit_from_dir != NULL) && lp_inherit_perms(SNUM(conn))) {
+ struct smb_filename *smb_fname_parent = NULL;
+ NTSTATUS status;
- DEBUG(2, ("unix_mode(%s) inheriting from %s\n", fname,
+ DEBUG(2, ("unix_mode(%s) inheriting from %s\n",
+ smb_fname_str_dbg(smb_fname),
inherit_from_dir));
- if (vfs_stat_smb_fname(conn, inherit_from_dir, &sbuf) != 0) {
- DEBUG(4,("unix_mode(%s) failed, [dir %s]: %s\n", fname,
+
+ status = create_synthetic_smb_fname(talloc_tos(),
+ inherit_from_dir, NULL,
+ NULL, &smb_fname_parent);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1,("unix_mode(%s) failed, [dir %s]: %s\n",
+ smb_fname_str_dbg(smb_fname),
+ inherit_from_dir, nt_errstr(status)));
+ return(0);
+ }
+
+ if (SMB_VFS_STAT(conn, smb_fname_parent) != 0) {
+ DEBUG(4,("unix_mode(%s) failed, [dir %s]: %s\n",
+ smb_fname_str_dbg(smb_fname),
inherit_from_dir, strerror(errno)));
+ TALLOC_FREE(smb_fname_parent);
return(0); /* *** shouldn't happen! *** */
}
/* Save for later - but explicitly remove setuid bit for safety. */
- dir_mode = sbuf.st_ex_mode & ~S_ISUID;
- DEBUG(2,("unix_mode(%s) inherit mode %o\n",fname,(int)dir_mode));
+ dir_mode = smb_fname_parent->st.st_ex_mode & ~S_ISUID;
+ DEBUG(2,("unix_mode(%s) inherit mode %o\n",
+ smb_fname_str_dbg(smb_fname), (int)dir_mode));
/* Clear "result" */
result = 0;
+ TALLOC_FREE(smb_fname_parent);
}
if (IS_DOS_DIR(dosmode)) {
@@ -132,7 +149,8 @@ mode_t unix_mode(connection_struct *conn, int dosmode, const char *fname,
}
}
- DEBUG(3,("unix_mode(%s) returning 0%o\n",fname,(int)result ));
+ DEBUG(3,("unix_mode(%s) returning 0%o\n", smb_fname_str_dbg(smb_fname),
+ (int)result));
return(result);
}
@@ -635,7 +653,7 @@ int file_set_dosmode(connection_struct *conn, struct smb_filename *smb_fname,
return 0;
}
- unixmode = unix_mode(conn,dosmode,fname, parent_dir);
+ unixmode = unix_mode(conn, dosmode, smb_fname, parent_dir);
/* preserve the s bits */
mask |= (S_ISUID | S_ISGID);