summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-04-11 21:38:45 +0000
committerJeremy Allison <jra@samba.org>2000-04-11 21:38:45 +0000
commit2311ecab4c8aa4026d2ac609f439b90834ff96e2 (patch)
treeea051058e96026575e2c9be9e25ea7bcc36f73f1 /source3
parentf6be38cae223f1ad3f4ecc5b81d14c44d92f58ba (diff)
downloadsamba-2311ecab4c8aa4026d2ac609f439b90834ff96e2.tar.gz
samba-2311ecab4c8aa4026d2ac609f439b90834ff96e2.tar.bz2
samba-2311ecab4c8aa4026d2ac609f439b90834ff96e2.zip
The latest open() code changes broke the NT directory opens. Detect if a
read-only open on a directory was done and return an EISDIR from open_file(). Changed interface to fd_close to return error. Jeremy. (This used to be commit df4302f3911447fcebe9342f6cbf3b89bd3bafba)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/smbd/close.c2
-rw-r--r--source3/smbd/open.c34
3 files changed, 28 insertions, 10 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index f6d387d19e..b7cfb83501 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -3055,7 +3055,7 @@ int reply_nttrans(connection_struct *conn,
/*The following definitions come from smbd/open.c */
-void fd_close(files_struct *fsp, int *err_ret);
+int fd_close(struct connection_struct *conn, files_struct *fsp);
void open_file_shared(files_struct *fsp,connection_struct *conn,char *fname,int share_mode,int ofun,
mode_t mode,int oplock_request, int *Access,int *action);
int open_file_stat(files_struct *fsp,connection_struct *conn,
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 61e8264159..4358f8fc2f 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -113,7 +113,7 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close)
if (lp_share_modes(SNUM(conn)))
unlock_share_entry_fsp(fsp);
- fd_close(fsp, &err);
+ err = fd_close(conn, fsp);
/* NT uses smbclose to start a print - weird */
if (normal_close && fsp->print_file)
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 4c5605fb3b..02832308c6 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -28,8 +28,9 @@ extern uint16 global_oplock_port;
extern BOOL global_client_failed_oplock_break;
/****************************************************************************
-fd support routines - attempt to do a dos_open
+ fd support routines - attempt to do a dos_open.
****************************************************************************/
+
static int fd_open(struct connection_struct *conn, char *fname,
int flags, mode_t mode)
{
@@ -42,21 +43,26 @@ static int fd_open(struct connection_struct *conn, char *fname,
fd = conn->vfs_ops.open(dos_to_unix(fname,False),flags,mode);
}
+ DEBUG(10,("fd_open: name %s, mode = %d, fd = %d. %s\n", fname, (int)mode, fd,
+ (fd == -1) ? strerror(errno) : "" ));
+
return fd;
}
/****************************************************************************
-close the file associated with a fsp
+ Close the file associated with a fsp.
****************************************************************************/
-void fd_close(files_struct *fsp, int *err_ret)
+
+int fd_close(struct connection_struct *conn, files_struct *fsp)
{
- fsp->conn->vfs_ops.close(fsp->fd);
+ int ret = conn->vfs_ops.close(fsp->fd);
fsp->fd = -1;
+ return ret;
}
/****************************************************************************
-check a filename for the pipe string
+ Check a filename for the pipe string.
****************************************************************************/
static void check_for_pipe(char *fname)
@@ -73,7 +79,7 @@ static void check_for_pipe(char *fname)
}
/****************************************************************************
-open a file
+ Open a file.
****************************************************************************/
static void open_file(files_struct *fsp,connection_struct *conn,
@@ -91,7 +97,7 @@ static void open_file(files_struct *fsp,connection_struct *conn,
pstrcpy(fname,fname1);
- /* check permissions */
+ /* Check permissions */
/*
* This code was changed after seeing a client open request
@@ -121,7 +127,7 @@ static void open_file(files_struct *fsp,connection_struct *conn,
/* actually do the open */
fsp->fd = fd_open(conn, fname, flags, mode);
- if (fsp->fd == -1) {
+ if (fsp->fd == -1) {
DEBUG(3,("Error opening file %s (%s) (flags=%d)\n",
fname,strerror(errno),flags));
check_for_pipe(fname);
@@ -130,6 +136,18 @@ static void open_file(files_struct *fsp,connection_struct *conn,
conn->vfs_ops.fstat(fsp->fd, &sbuf);
+ /*
+ * POSIX allows read-only opens of directories. We don't
+ * want to do this (we use a different code path for this)
+ * so catch a directory open and return an EISDIR. JRA.
+ */
+
+ if(S_ISDIR(sbuf.st_mode)) {
+ fd_close(conn, fsp);
+ errno = EISDIR;
+ return;
+ }
+
conn->num_files_open++;
fsp->mode = sbuf.st_mode;
fsp->inode = sbuf.st_ino;