summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-09-05 03:14:40 +0000
committerJeremy Allison <jra@samba.org>1998-09-05 03:14:40 +0000
commit98f524bde4801bd0b013a6bc79c5552ef62b59f8 (patch)
tree1c42d63977a2a82aa87228ecf1d57742ac8f6fb0 /source3
parent1546ccfd24a712973c82fcd2064d3c48381f1360 (diff)
downloadsamba-98f524bde4801bd0b013a6bc79c5552ef62b59f8.tar.gz
samba-98f524bde4801bd0b013a6bc79c5552ef62b59f8.tar.bz2
samba-98f524bde4801bd0b013a6bc79c5552ef62b59f8.zip
Bugfix for leak in reference counted file struct.
Added "nt smb support" parameter to allow NT SMB's to be turned off. Jeremy. (This used to be commit 63f65f5027d5022153fa2757b49c56829db1725b)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/param/loadparm.c4
-rw-r--r--source3/smbd/close.c3
-rw-r--r--source3/smbd/files.c6
-rw-r--r--source3/smbd/negprot.c3
-rw-r--r--source3/smbd/open.c16
6 files changed, 19 insertions, 15 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 7ef9cbb677..d5cfb28166 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -981,6 +981,7 @@ BOOL lp_net_wksta_user_logon(void);
BOOL lp_unix_password_sync(void);
BOOL lp_passwd_chat_debug(void);
BOOL lp_ole_locking_compat(void);
+BOOL lp_nt_smb_support(void);
int lp_os_level(void);
int lp_max_ttl(void);
int lp_max_wins_ttl(void);
@@ -2034,6 +2035,7 @@ void file_close_user(int vuid);
files_struct *file_find_dit(SMB_DEV_T dev, SMB_INO_T inode, struct timeval *tval);
files_struct *file_find_print(void);
void file_sync_all(connection_struct *conn);
+void fd_ptr_free(file_fd_struct *fd_ptr);
void file_free(files_struct *fsp);
files_struct *file_fsp(char *buf, int where);
void file_chain_reset(void);
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 44db306d1b..9bf3dce6fb 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -227,6 +227,7 @@ typedef struct
BOOL bPasswdChatDebug;
BOOL bOleLockingCompat;
BOOL bTimestampLogs;
+ BOOL bNTSmbSupport;
} global;
static global Globals;
@@ -566,6 +567,7 @@ static struct parm_struct parm_table[] =
{"read raw", P_BOOL, P_GLOBAL, &Globals.bReadRaw, NULL, NULL, 0},
{"write raw", P_BOOL, P_GLOBAL, &Globals.bWriteRaw, NULL, NULL, 0},
{"networkstation user login", P_BOOL,P_GLOBAL, &Globals.bNetWkstaUserLogon,NULL, NULL, 0},
+ {"nt smb support", P_BOOL, P_GLOBAL, &Globals.bNTSmbSupport, NULL, NULL, 0},
{"announce version", P_STRING, P_GLOBAL, &Globals.szAnnounceVersion, NULL, NULL, 0},
{"announce as", P_ENUM, P_GLOBAL, &Globals.announce_as, NULL, enum_announce_as, 0},
{"max mux", P_INTEGER, P_GLOBAL, &Globals.max_mux, NULL, NULL, 0},
@@ -848,6 +850,7 @@ static void init_globals(void)
Globals.bUnixPasswdSync = False;
Globals.bPasswdChatDebug = False;
Globals.bOleLockingCompat = True;
+ Globals.bNTSmbSupport = True; /* Do NT SMB's by default. */
#ifdef WITH_LDAP
/* default values for ldap */
@@ -1139,6 +1142,7 @@ FN_GLOBAL_BOOL(lp_net_wksta_user_logon,&Globals.bNetWkstaUserLogon)
FN_GLOBAL_BOOL(lp_unix_password_sync,&Globals.bUnixPasswdSync)
FN_GLOBAL_BOOL(lp_passwd_chat_debug,&Globals.bPasswdChatDebug)
FN_GLOBAL_BOOL(lp_ole_locking_compat,&Globals.bOleLockingCompat)
+FN_GLOBAL_BOOL(lp_nt_smb_support,&Globals.bNTSmbSupport)
FN_GLOBAL_INTEGER(lp_os_level,&Globals.os_level)
FN_GLOBAL_INTEGER(lp_max_ttl,&Globals.max_ttl)
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 42b16bc7ac..e9606cdfbe 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -117,7 +117,8 @@ void close_file(files_struct *fsp, BOOL normal_close)
del_share_mode(token, fsp);
}
- fd_attempt_close(fsp->fd_ptr);
+ if(fd_attempt_close(fsp->fd_ptr) == 0)
+ fsp->fd_ptr = NULL;
if (lp_share_modes(SNUM(conn)))
unlock_share_entry(conn, dev, inode, token);
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index 163e4f0cf2..0b72bcf0fa 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -133,8 +133,8 @@ file_fd_struct *fd_get_already_open(SMB_STRUCT_STAT *sbuf)
(unsigned int)fd_ptr->dev, (double)fd_ptr->inode,
fd_ptr->ref_count));
#else /* LARGE_SMB_INO_T */
- DEBUG(3,("Re-used file_fd_struct dev = %x, inode = %x, ref_count = %d\n",
- (unsigned int)fd_ptr->dev, fd_ptr->inode,
+ DEBUG(3,("Re-used file_fd_struct dev = %x, inode = %lx, ref_count = %d\n",
+ (unsigned int)fd_ptr->dev, (unsigned long)fd_ptr->inode,
fd_ptr->ref_count));
#endif /* LARGE_SMB_INO_T */
return fd_ptr;
@@ -315,7 +315,7 @@ void file_sync_all(connection_struct *conn)
/****************************************************************************
free up a fd_ptr
****************************************************************************/
-static void fd_ptr_free(file_fd_struct *fd_ptr)
+void fd_ptr_free(file_fd_struct *fd_ptr)
{
DLIST_REMOVE(FileFd, fd_ptr);
diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c
index 8e996cac21..b1e8a65c94 100644
--- a/source3/smbd/negprot.c
+++ b/source3/smbd/negprot.c
@@ -156,7 +156,8 @@ reply for the nt protocol
static int reply_nt1(char *outbuf)
{
/* dual names + lock_and_read + nt SMBs + remote API calls */
- int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|CAP_RPC_REMOTE_APIS |CAP_NT_SMBS;
+ int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|CAP_RPC_REMOTE_APIS |
+ lp_nt_smb_support() ? CAP_NT_SMBS : 0;
/*
other valid capabilities which we may support at some time...
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 45d919187f..a72469f2b2 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -170,13 +170,10 @@ int fd_attempt_close(file_fd_struct *fd_ptr)
close(fd_ptr->fd_readonly);
if(fd_ptr->fd_writeonly != -1)
close(fd_ptr->fd_writeonly);
- fd_ptr->fd = -1;
- fd_ptr->fd_readonly = -1;
- fd_ptr->fd_writeonly = -1;
- fd_ptr->real_open_flags = -1;
- fd_ptr->dev = (SMB_DEV_T)-1;
- fd_ptr->inode = (SMB_INO_T)-1;
- fd_ptr->uid_cache_count = 0;
+ /*
+ * Delete this fd_ptr.
+ */
+ fd_ptr_free(fd_ptr);
} else {
fd_remove_from_uid_cache(fd_ptr, (uid_t)current_user.uid);
}
@@ -457,10 +454,9 @@ static void open_file(files_struct *fsp,connection_struct *conn,
if (p) *p = 0;
if (sys_disk_free(dname,&dum1,&dum2,&dum3) <
lp_minprintspace(SNUM(conn))) {
- fd_attempt_close(fd_ptr);
- fsp->fd_ptr = 0;
- if(fd_ptr->ref_count == 0)
+ if(fd_attempt_close(fd_ptr) == 0)
dos_unlink(fname);
+ fsp->fd_ptr = 0;
errno = ENOSPC;
return;
}