summaryrefslogtreecommitdiff
path: root/source3/smbd/dir.c
diff options
context:
space:
mode:
authorTim Prouty <tprouty@samba.org>2009-06-25 18:19:09 -0700
committerTim Prouty <tprouty@samba.org>2009-06-25 18:25:48 -0700
commiteb8c658fcdda5d1337605ed5e2e8da15bc51ba20 (patch)
tree1c010444ff42dd73afc0e1ad3cd8140dff168fd0 /source3/smbd/dir.c
parent9001c53406241aeab4a3cfe0f663b71f67611cde (diff)
downloadsamba-eb8c658fcdda5d1337605ed5e2e8da15bc51ba20.tar.gz
samba-eb8c658fcdda5d1337605ed5e2e8da15bc51ba20.tar.bz2
samba-eb8c658fcdda5d1337605ed5e2e8da15bc51ba20.zip
s3 file_access: Convert some more functions over to use smb_filneame
Diffstat (limited to 'source3/smbd/dir.c')
-rw-r--r--source3/smbd/dir.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index aff30a6967..723fb6fd6f 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -1007,7 +1007,8 @@ static bool user_can_read_file(connection_struct *conn,
use it for anything security sensitive.
********************************************************************/
-static bool user_can_write_file(connection_struct *conn, char *name, SMB_STRUCT_STAT *pst)
+static bool user_can_write_file(connection_struct *conn,
+ const struct smb_filename *smb_fname)
{
/*
* If user is a member of the Admin group
@@ -1018,22 +1019,23 @@ static bool user_can_write_file(connection_struct *conn, char *name, SMB_STRUCT_
return True;
}
- SMB_ASSERT(VALID_STAT(*pst));
+ SMB_ASSERT(VALID_STAT(smb_fname->st));
/* Pseudo-open the file */
- if(S_ISDIR(pst->st_ex_mode)) {
+ if(S_ISDIR(smb_fname->st.st_ex_mode)) {
return True;
}
- return can_write_to_file(conn, name, pst);
+ return can_write_to_file(conn, smb_fname);
}
/*******************************************************************
Is a file a "special" type ?
********************************************************************/
-static bool file_is_special(connection_struct *conn, char *name, SMB_STRUCT_STAT *pst)
+static bool file_is_special(connection_struct *conn,
+ const struct smb_filename *smb_fname)
{
/*
* If user is a member of the Admin group
@@ -1043,9 +1045,11 @@ static bool file_is_special(connection_struct *conn, char *name, SMB_STRUCT_STAT
if (conn->admin_user)
return False;
- SMB_ASSERT(VALID_STAT(*pst));
+ SMB_ASSERT(VALID_STAT(smb_fname->st));
- if (S_ISREG(pst->st_ex_mode) || S_ISDIR(pst->st_ex_mode) || S_ISLNK(pst->st_ex_mode))
+ if (S_ISREG(smb_fname->st.st_ex_mode) ||
+ S_ISDIR(smb_fname->st.st_ex_mode) ||
+ S_ISLNK(smb_fname->st.st_ex_mode))
return False;
return True;
@@ -1094,7 +1098,7 @@ bool is_visible_file(connection_struct *conn, const char *dir_path,
/* Create an smb_filename with stream_name == NULL. */
status = create_synthetic_smb_fname(talloc_tos(), entry, NULL,
- NULL, &smb_fname_base);
+ pst, &smb_fname_base);
if (!NT_STATUS_IS_OK(status)) {
ret = false;
goto out;
@@ -1104,15 +1108,15 @@ bool is_visible_file(connection_struct *conn, const char *dir_path,
* the configuration options. We succeed, on the basis that the
* checks *might* have passed if the file was present.
*/
- if (!VALID_STAT(*pst) &&
- (SMB_VFS_STAT(conn, smb_fname_base) != 0))
- {
- ret = true;
- goto out;
+ if (!VALID_STAT(*pst)) {
+ if (SMB_VFS_STAT(conn, smb_fname_base) != 0) {
+ ret = true;
+ goto out;
+ } else {
+ *pst = smb_fname_base->st;
+ }
}
- *pst = smb_fname_base->st;
-
/* Honour _hide unreadable_ option */
if (hide_unreadable &&
!user_can_read_file(conn, smb_fname_base)) {
@@ -1122,14 +1126,15 @@ bool is_visible_file(connection_struct *conn, const char *dir_path,
goto out;
}
/* Honour _hide unwriteable_ option */
- if (hide_unwriteable && !user_can_write_file(conn, entry, pst)) {
+ if (hide_unwriteable && !user_can_write_file(conn,
+ smb_fname_base)) {
DEBUG(10,("is_visible_file: file %s is unwritable.\n",
entry ));
ret = false;
goto out;
}
/* Honour _hide_special_ option */
- if (hide_special && file_is_special(conn, entry, pst)) {
+ if (hide_special && file_is_special(conn, smb_fname_base)) {
DEBUG(10,("is_visible_file: file %s is special.\n",
entry ));
ret = false;