summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/close.c7
-rw-r--r--source3/smbd/connection.c27
-rw-r--r--source3/smbd/fileio.c6
-rw-r--r--source3/smbd/open.c33
-rw-r--r--source3/smbd/oplock.c15
-rw-r--r--source3/smbd/trans2.c11
6 files changed, 38 insertions, 61 deletions
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index d06cb3b5bb..bfef7c5235 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -94,7 +94,6 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close)
{
SMB_DEV_T dev = fsp->fd_ptr->dev;
SMB_INO_T inode = fsp->fd_ptr->inode;
- int token;
BOOL last_reference = False;
BOOL delete_on_close = fsp->fd_ptr->delete_on_close;
connection_struct *conn = fsp->conn;
@@ -109,8 +108,8 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close)
#endif
if (lp_share_modes(SNUM(conn))) {
- lock_share_entry(conn, dev, inode, &token);
- del_share_mode(token, fsp);
+ lock_share_entry(conn, dev, inode);
+ del_share_mode(fsp);
}
if(EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type))
@@ -122,7 +121,7 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close)
fsp->fd_ptr = NULL;
if (lp_share_modes(SNUM(conn)))
- unlock_share_entry(conn, dev, inode, token);
+ unlock_share_entry(conn, dev, inode);
/* NT uses smbclose to start a print - weird */
if (normal_close && fsp->print_file)
diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c
index f88d707983..5b5ab005c8 100644
--- a/source3/smbd/connection.c
+++ b/source3/smbd/connection.c
@@ -27,27 +27,6 @@ extern fstring remote_machine;
extern int DEBUGLEVEL;
/****************************************************************************
-open the connections database
-****************************************************************************/
-TDB_CONTEXT *open_db(char *name)
-{
- pstring fname;
-
- pstrcpy(fname,lp_lockdir());
- trim_string(fname,"","/");
-
- if (!directory_exist(fname,NULL)) {
- mkdir(fname,0755);
- }
-
- pstrcat(fname,"/connections.tdb");
-
- return tdb_open(fname, 0, O_RDWR | O_CREAT, 0644);
-}
-
-
-
-/****************************************************************************
delete a connection record
****************************************************************************/
BOOL yield_connection(connection_struct *conn,char *name,int max_connections)
@@ -56,7 +35,8 @@ BOOL yield_connection(connection_struct *conn,char *name,int max_connections)
TDB_DATA kbuf;
TDB_CONTEXT *tdb;
- if (!(tdb = open_db(name))) return False;
+ tdb = tdb_open(lock_path("connections.tdb"), 0, O_RDWR | O_CREAT, 0644);
+ if (!tdb) return False;
DEBUG(3,("Yielding connection to %s\n",name));
@@ -100,7 +80,8 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO
if (max_connections <= 0)
return(True);
- if (!(tdb = open_db(name))) return False;
+ tdb = tdb_open(lock_path("connections.tdb"), 0, O_RDWR | O_CREAT, 0644);
+ if (!tdb) return False;
DEBUG(5,("claiming %s %d\n",name,max_connections));
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index 8b48a921fd..fa04e671f8 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -213,11 +213,11 @@ ssize_t write_file(files_struct *fsp, char *data, SMB_OFF_T pos, size_t n)
int num_share_modes = 0;
int i;
- if (lock_share_entry(fsp->conn, dev, inode, &token) == False) {
+ if (lock_share_entry(fsp->conn, dev, inode) == False) {
DEBUG(0,("write_file: failed to lock share mode entry for file %s.\n", fsp->fsp_name ));
}
- num_share_modes = get_share_modes(fsp->conn, token, dev, inode, &share_list);
+ num_share_modes = get_share_modes(fsp->conn, dev, inode, &share_list);
for(i = 0; i < num_share_modes; i++) {
share_mode_entry *share_entry = &share_list[i];
@@ -268,7 +268,7 @@ ssize_t write_file(files_struct *fsp, char *data, SMB_OFF_T pos, size_t n)
}
free((char *)share_list);
- unlock_share_entry(fsp->conn, dev, inode, token);
+ unlock_share_entry(fsp->conn, dev, inode);
}
/* Paranoia check... */
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 4491082b2c..a940eda85d 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -602,7 +602,7 @@ static void truncate_unless_locked(files_struct *fsp, connection_struct *conn, i
have the share entry locked. Unlock it before closing. */
if (*share_locked && lp_share_modes(SNUM(conn)))
unlock_share_entry( conn, fsp->fd_ptr->dev,
- fsp->fd_ptr->inode, token);
+ fsp->fd_ptr->inode);
close_file(fsp,False);
/* Share mode no longer locked. */
*share_locked = False;
@@ -858,9 +858,9 @@ void open_file_shared(files_struct *fsp,connection_struct *conn,char *fname,int
{
dev = sbuf.st_dev;
inode = sbuf.st_ino;
- lock_share_entry(conn, dev, inode, &token);
+ lock_share_entry(conn, dev, inode);
share_locked = True;
- num_share_modes = get_share_modes(conn, token, dev, inode, &old_shares);
+ num_share_modes = get_share_modes(conn, dev, inode, &old_shares);
}
/*
@@ -896,7 +896,7 @@ void open_file_shared(files_struct *fsp,connection_struct *conn,char *fname,int
dev = %x, inode = %.0f\n", share_entry->op_type, fname, (unsigned int)dev, (double)inode));
/* Oplock break.... */
- unlock_share_entry(conn, dev, inode, token);
+ unlock_share_entry(conn, dev, inode);
if(request_oplock_break(share_entry, dev, inode) == False)
{
free((char *)old_shares);
@@ -909,7 +909,7 @@ dev = %x, inode = %.0f\n", old_shares[i].op_type, fname, (unsigned int)dev, (dou
unix_ERR_code = ERRbadshare;
return;
}
- lock_share_entry(conn, dev, inode, &token);
+ lock_share_entry(conn, dev, inode);
broke_oplock = True;
all_current_opens_are_level_II = False;
break;
@@ -922,7 +922,7 @@ dev = %x, inode = %.0f\n", old_shares[i].op_type, fname, (unsigned int)dev, (dou
if(check_share_mode(share_entry, deny_mode, fname, fcbopen, &flags) == False)
{
free((char *)old_shares);
- unlock_share_entry(conn, dev, inode, token);
+ unlock_share_entry(conn, dev, inode);
errno = EACCES;
return;
}
@@ -932,7 +932,7 @@ dev = %x, inode = %.0f\n", old_shares[i].op_type, fname, (unsigned int)dev, (dou
if(broke_oplock)
{
free((char *)old_shares);
- num_share_modes = get_share_modes(conn, token, dev, inode, &old_shares);
+ num_share_modes = get_share_modes(conn, dev, inode, &old_shares);
oplock_contention_count++;
}
} while(broke_oplock);
@@ -973,7 +973,7 @@ dev = %x, inode = %.0f\n", old_shares[i].op_type, fname, (unsigned int)dev, (dou
/* We created the file - thus we must now lock the share entry before creating it. */
dev = fsp->fd_ptr->dev;
inode = fsp->fd_ptr->inode;
- lock_share_entry(conn, dev, inode, &token);
+ lock_share_entry(conn, dev, inode);
share_locked = True;
}
@@ -1028,7 +1028,7 @@ dev = %x, inode = %.0f\n", old_shares[i].op_type, fname, (unsigned int)dev, (dou
oplock_request = 0;
}
- set_share_mode(token, fsp, port, oplock_request);
+ set_share_mode(fsp, port, oplock_request);
}
if ((flags2&O_TRUNC) && file_existed)
@@ -1036,7 +1036,7 @@ dev = %x, inode = %.0f\n", old_shares[i].op_type, fname, (unsigned int)dev, (dou
}
if (share_locked && lp_share_modes(SNUM(conn)))
- unlock_share_entry( conn, dev, inode, token);
+ unlock_share_entry( conn, dev, inode);
}
/****************************************************************************
@@ -1224,7 +1224,6 @@ BOOL check_file_sharing(connection_struct *conn,char *fname, BOOL rename_op)
share_mode_entry *old_shares = 0;
int num_share_modes;
SMB_STRUCT_STAT sbuf;
- int token;
pid_t pid = getpid();
SMB_DEV_T dev;
SMB_INO_T inode;
@@ -1237,8 +1236,8 @@ BOOL check_file_sharing(connection_struct *conn,char *fname, BOOL rename_op)
dev = sbuf.st_dev;
inode = sbuf.st_ino;
- lock_share_entry(conn, dev, inode, &token);
- num_share_modes = get_share_modes(conn, token, dev, inode, &old_shares);
+ lock_share_entry(conn, dev, inode);
+ num_share_modes = get_share_modes(conn, dev, inode, &old_shares);
/*
* Check if the share modes will give us access.
@@ -1308,7 +1307,7 @@ batch oplocked file %s, dev = %x, inode = %.0f\n", fname, (unsigned int)dev, (do
dev = %x, inode = %.0f\n", share_entry->op_type, fname, (unsigned int)dev, (double)inode));
/* Oplock break.... */
- unlock_share_entry(conn, dev, inode, token);
+ unlock_share_entry(conn, dev, inode);
if(request_oplock_break(share_entry, dev, inode) == False)
{
free((char *)old_shares);
@@ -1318,7 +1317,7 @@ dev = %x, inode = %.0f\n", old_shares[i].op_type, fname, (unsigned int)dev, (dou
return False;
}
- lock_share_entry(conn, dev, inode, &token);
+ lock_share_entry(conn, dev, inode);
broke_oplock = True;
break;
}
@@ -1345,7 +1344,7 @@ dev = %x, inode = %.0f\n", old_shares[i].op_type, fname, (unsigned int)dev, (dou
if(broke_oplock)
{
free((char *)old_shares);
- num_share_modes = get_share_modes(conn, token, dev, inode, &old_shares);
+ num_share_modes = get_share_modes(conn, dev, inode, &old_shares);
}
} while(broke_oplock);
}
@@ -1364,7 +1363,7 @@ dev = %x, inode = %.0f\n", old_shares[i].op_type, fname, (unsigned int)dev, (dou
free_and_exit:
- unlock_share_entry(conn, dev, inode, token);
+ unlock_share_entry(conn, dev, inode);
if(old_shares != NULL)
free((char *)old_shares);
return(ret);
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index a64dd2d0ef..c5cab8c225 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -406,13 +406,12 @@ static void downgrade_file_oplock(files_struct *fsp)
BOOL remove_oplock(files_struct *fsp)
{
- int token;
SMB_DEV_T dev = fsp->fd_ptr->dev;
SMB_INO_T inode = fsp->fd_ptr->inode;
BOOL ret = True;
/* Remove the oplock flag from the sharemode. */
- if (lock_share_entry(fsp->conn, dev, inode, &token) == False) {
+ if (lock_share_entry(fsp->conn, dev, inode) == False) {
DEBUG(0,("remove_oplock: failed to lock share entry for file %s\n",
fsp->fsp_name ));
ret = False;
@@ -424,7 +423,7 @@ BOOL remove_oplock(files_struct *fsp)
* Deal with a reply when a break-to-none was sent.
*/
- if(remove_share_oplock(token, fsp)==False) {
+ if(remove_share_oplock(fsp)==False) {
DEBUG(0,("remove_oplock: failed to remove share oplock for file %s fnum %d, \
dev = %x, inode = %.0f\n", fsp->fsp_name, fsp->fnum, (unsigned int)dev, (double)inode));
ret = False;
@@ -438,7 +437,7 @@ dev = %x, inode = %.0f\n", fsp->fsp_name, fsp->fnum, (unsigned int)dev, (double)
* Deal with a reply when a break-to-level II was sent.
*/
- if(downgrade_share_oplock(token, fsp)==False) {
+ if(downgrade_share_oplock(fsp)==False) {
DEBUG(0,("remove_oplock: failed to downgrade share oplock for file %s fnum %d, \
dev = %x, inode = %.0f\n", fsp->fsp_name, fsp->fnum, (unsigned int)dev, (double)inode));
ret = False;
@@ -447,7 +446,7 @@ dev = %x, inode = %.0f\n", fsp->fsp_name, fsp->fnum, (unsigned int)dev, (double)
downgrade_file_oplock(fsp);
}
- unlock_share_entry(fsp->conn, dev, inode, token);
+ unlock_share_entry(fsp->conn, dev, inode);
return ret;
}
@@ -792,18 +791,18 @@ BOOL oplock_break_level2(files_struct *fsp, BOOL local_request, int token)
* the existing lock on the shared memory area.
*/
- if(!local_request && lock_share_entry(fsp->conn, dev, inode, &token) == False) {
+ if(!local_request && lock_share_entry(fsp->conn, dev, inode) == False) {
DEBUG(0,("oplock_break_level2: unable to lock share entry for file %s\n", fsp->fsp_name ));
} else {
got_lock = True;
}
- if(remove_share_oplock(token, fsp)==False) {
+ if(remove_share_oplock(fsp)==False) {
DEBUG(0,("oplock_break_level2: unable to remove level II oplock for file %s\n", fsp->fsp_name ));
}
if (!local_request && got_lock)
- unlock_share_entry(fsp->conn, dev, inode, token);
+ unlock_share_entry(fsp->conn, dev, inode);
fsp->oplock_type = NO_OPLOCK;
level_II_oplocks_open--;
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 5a8db7efda..bbbfda7468 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -1800,7 +1800,6 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
if(delete_on_close && !GET_DELETE_ON_CLOSE_FLAG(fsp->share_mode))
{
- int token;
int i;
files_struct *iterate_fsp;
SMB_DEV_T dev = fsp->fd_ptr->dev;
@@ -1808,7 +1807,7 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
int num_share_modes;
share_mode_entry *current_shares = NULL;
- if(lock_share_entry(fsp->conn, dev, inode, &token) == False)
+ if(lock_share_entry(fsp->conn, dev, inode) == False)
return(ERROR(ERRDOS,ERRnoaccess));
/*
@@ -1818,7 +1817,7 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
* file at this point.
*/
- num_share_modes = get_share_modes(conn, token, dev, inode, &current_shares);
+ num_share_modes = get_share_modes(conn, dev, inode, &current_shares);
for(i = 0; i < num_share_modes; i++)
{
if(!GET_ALLOW_SHARE_DELETE(current_shares[i].share_mode))
@@ -1830,7 +1829,7 @@ file %s as a share exists that was not opened with FILE_DELETE access.\n",
* Release the lock.
*/
- unlock_share_entry(fsp->conn, dev, inode, token);
+ unlock_share_entry(fsp->conn, dev, inode);
/*
* current_shares was malloced by get_share_modes - free it here.
@@ -1875,7 +1874,7 @@ dev = %x, inode = %.0f from %x to %x\n",
iterate_fsp->fnum, iterate_fsp->fsp_name, (unsigned int)dev,
(double)inode, iterate_fsp->share_mode, new_share_mode ));
- if(modify_share_mode(token, iterate_fsp, new_share_mode, iterate_fsp->oplock_type)==False)
+ if(modify_share_mode(iterate_fsp, new_share_mode, iterate_fsp->oplock_type)==False)
DEBUG(0,("call_trans2setfilepathinfo: failed to change delete on close for fnum %d, \
dev = %x, inode = %.0f\n", iterate_fsp->fnum, (unsigned int)dev, (double)inode));
}
@@ -1887,7 +1886,7 @@ dev = %x, inode = %.0f\n", iterate_fsp->fnum, (unsigned int)dev, (double)inode))
*/
fsp->fd_ptr->delete_on_close = delete_on_close;
- unlock_share_entry(fsp->conn, dev, inode, token);
+ unlock_share_entry(fsp->conn, dev, inode);
DEBUG(10, ("call_trans2setfilepathinfo: %s delete on close flag for fnum = %d, file %s\n",
delete_on_close ? "Added" : "Removed", fsp->fnum, fsp->fsp_name ));