summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-01-16 11:21:33 +0000
committerAndrew Tridgell <tridge@samba.org>2000-01-16 11:21:33 +0000
commit2d96e58287a89d6f2cf584ada6154eca83cf1e6b (patch)
tree3854d54f30b2f5273bd668ff574c070eb228e764
parentb3b634ff4251cca647e1e545fe1e4160736d96b9 (diff)
downloadsamba-2d96e58287a89d6f2cf584ada6154eca83cf1e6b.tar.gz
samba-2d96e58287a89d6f2cf584ada6154eca83cf1e6b.tar.bz2
samba-2d96e58287a89d6f2cf584ada6154eca83cf1e6b.zip
rewrote the access_table() code to get it right for *.exe, *.dll,
*.sym and *.com files. I still find it incredible that SMB treats file locking differently depending on the file name - that is so ugly it stinks. anyway, we now behave the same way as NT, except for the same-connection case which I'm still working on. (This used to be commit 5b9be3feca26f1f20fe3f32ba90769cc78f9bb6b)
-rw-r--r--source3/smbd/open.c68
1 files changed, 41 insertions, 27 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index ad208005a0..7558954ec6 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -620,34 +620,50 @@ enum {AFAIL,AREAD,AWRITE,AALL};
/*******************************************************************
reproduce the share mode access table
********************************************************************/
-
static int access_table(int new_deny,int old_deny,int old_mode,
pid_t share_pid,char *fname)
{
if (new_deny == DENY_ALL || old_deny == DENY_ALL) return(AFAIL);
- if (new_deny == DENY_DOS || old_deny == DENY_DOS) {
- pid_t pid = getpid();
- if (old_deny == new_deny && share_pid == pid)
- return(AALL);
-
- /* the new smbpub.zip spec says that if the file extension is
- .com, .dll, .exe or .sym then allow the open. I will force
- it to read-only as this seems sensible although the spec is
- a little unclear on this. */
- if ((fname = strrchr(fname,'.'))) {
- if (strequal(fname,".com") ||
- strequal(fname,".dll") ||
- strequal(fname,".exe") ||
- strequal(fname,".sym"))
- return(AALL);
- }
-
- if (old_deny == DENY_READ || new_deny == DENY_READ) return AFAIL;
- if (old_mode == DOS_OPEN_RDONLY) return(AREAD);
-
-
- return(AFAIL);
+ if (old_deny == DENY_DOS || new_deny == DENY_DOS ||
+ old_deny == DENY_FCB || new_deny == DENY_FCB) {
+ if ((fname = strrchr(fname,'.'))) {
+ if (strequal(fname,".com") ||
+ strequal(fname,".dll") ||
+ strequal(fname,".exe") ||
+ strequal(fname,".sym")) {
+ if (old_deny == DENY_FCB || new_deny == DENY_FCB) {
+ return AFAIL;
+ }
+ if (old_deny == DENY_DOS) {
+ if (new_deny == DENY_READ &&
+ (old_mode == DOS_OPEN_RDONLY ||
+ old_mode == DOS_OPEN_RDWR)) {
+ return AFAIL;
+ }
+ if (new_deny == DENY_WRITE &&
+ (old_mode == DOS_OPEN_WRONLY ||
+ old_mode == DOS_OPEN_RDWR)) {
+ return AFAIL;
+ }
+ return AALL;
+ }
+ if (old_deny == DENY_NONE) return AALL;
+ if (old_deny == DENY_READ) return AWRITE;
+ if (old_deny == DENY_WRITE) return AREAD;
+ }
+ }
+ /* it isn't a exe, dll, sym or com file */
+ {
+ pid_t pid = getpid();
+ if (old_deny == new_deny && share_pid == pid)
+ return(AALL);
+
+ if (old_deny == DENY_READ || new_deny == DENY_READ) return AFAIL;
+ if (old_mode == DOS_OPEN_RDONLY) return(AREAD);
+
+ return(AFAIL);
+ }
}
switch (new_deny)
@@ -848,9 +864,6 @@ void open_file_shared(files_struct *fsp,connection_struct *conn,char *fname,int
return;
}
- if (deny_mode == DENY_FCB)
- deny_mode = DENY_DOS;
-
if (lp_share_modes(SNUM(conn)))
{
int i;
@@ -1338,7 +1351,8 @@ dev = %x, inode = %.0f\n", old_shares[i].op_type, fname, (unsigned int)dev, (dou
* if we can too.
*/
- if ((GET_DENY_MODE(share_entry->share_mode) != DENY_DOS) || (share_entry->pid != pid))
+ if ((GET_DENY_MODE(share_entry->share_mode) != DENY_DOS) ||
+ (share_entry->pid != pid))
goto free_and_exit;
} /* end for */