silently deny access. Log them if they occur.
smbd/close.c smbd/oplock.c smbd/reply.c: Removed a global oplock variable (hurrah!).
Removal of the oplocks flags and any kernel oplocks is now done in
either close() or in reply_locking() by calling release_file_oplock().
Jeremy.
BOOL open_oplock_ipc(void);
BOOL receive_local_message(fd_set *fds, char *buffer, int buffer_len, int timeout);
BOOL set_file_oplock(files_struct *fsp);
+void release_file_oplock(files_struct *fsp);
int setup_oplock_select_set( fd_set *fds);
BOOL process_local_message(char *buffer, int buf_size);
BOOL request_oplock_break(share_mode_entry *share_entry,
}
/* string_match - match string against token */
-static int string_match(char *tok,char *s)
+static int string_match(char *tok,char *s, char *invalid_char)
{
- int tok_len;
- int str_len;
+ size_t tok_len;
+ size_t str_len;
char *cut;
+ *invalid_char = '\0';
+
/* Return True if a token has the magic value "ALL". Return
* FAIL if the token is "FAIL". If the token starts with a "."
* (domain name), return True if it matches the last fields of
} else if ((cut = strchr(tok, '/')) != 0) { /* netnumber/netmask */
if (isdigit((int)s[0]) && masked_match(tok, cut, s))
return (True);
+ } else if (strchr(tok, '*') != 0) {
+ *invalid_char = '*';
+ } else if (strchr(tok, '?') != 0) {
+ *invalid_char = '?';
}
return (False);
}
{
char **client = (char **)item;
int match;
+ char invalid_char = '\0';
/*
* Try to match the address first. If that fails, try to match the host
* name if available.
*/
- if ((match = string_match(tok, client[1])) == 0)
- if (client[0][0] != 0)
- match = string_match(tok, client[0]);
+ if ((match = string_match(tok, client[1], &invalid_char)) == 0) {
+ if(invalid_char)
+ DEBUG(0,("client_match: address match failing due to invalid character '%c' found in \
+token '%s' in an allow/deny hosts line.\n", invalid_char, tok ));
+
+ if (client[0][0] != 0)
+ match = string_match(tok, client[0], &invalid_char);
+
+ if(invalid_char)
+ DEBUG(0,("client_match: address match failing due to invalid character '%c' found in \
+token '%s' in an allow/deny hosts line.\n", invalid_char, tok ));
+ }
+
return (match);
}
extern int DEBUGLEVEL;
-extern int32 global_oplocks_open;
-
-
/****************************************************************************
run a file if it is a magic script
****************************************************************************/
del_share_mode(token, fsp);
}
+ if(fsp->granted_oplock == True)
+ release_file_oplock(fsp);
+
if(fd_attempt_close(fsp->fd_ptr) == 0)
last_reference = True;
}
}
- if(fsp->granted_oplock == True)
- global_oplocks_open--;
-
- fsp->sent_oplock_break = False;
-
DEBUG(2,("%s closed file %s (numopen=%d)\n",
conn->user,fsp->fsp_name,
conn->num_files_open));
#endif /* HAVE_KERNEL_OPLOCKS */
/* Current number of oplocks we have outstanding. */
-int32 global_oplocks_open = 0;
+static int32 global_oplocks_open = 0;
BOOL global_oplock_break = False;
extern int smb_read_error;
disabled (just clears flags).
****************************************************************************/
-static void release_file_oplock(files_struct *fsp)
+void release_file_oplock(files_struct *fsp)
{
#if defined(HAVE_KERNEL_OPLOCKS)
exit_server("oplock break failure");
}
- if(OPEN_FSP(fsp))
- {
- /* The lockingX reply will have removed the oplock flag
- from the sharemode. */
- release_file_oplock(fsp);
- }
-
/* Santity check - remove this later. JRA */
if(global_oplocks_open < 0)
{
}
count = (SMB_OFF_T)IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(data_offset));
+
#endif /* LARGE_SMB_OFF_T */
}
return count;
}
offset = (SMB_OFF_T)IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset));
+
#endif /* LARGE_SMB_OFF_T */
}
return offset;
{
DEBUG(0,("reply_lockingX: Error : oplock break from client for fnum = %d and \
no oplock granted on this file.\n", fsp->fnum));
- return ERROR(ERRDOS,ERRlock);
+
+ /* if this is a pure oplock break request then don't send a reply */
+ if (num_locks == 0 && num_ulocks == 0)
+ return -1;
+ else
+ return ERROR(ERRDOS,ERRlock);
}
/* Remove the oplock flag from the sharemode. */
lock_share_entry(fsp->conn, dev, inode, &token);
if(remove_share_oplock(token, fsp)==False) {
-
- DEBUG(0,("reply_lockingX: failed to remove share oplock for fnum %d, \
+ DEBUG(0,("reply_lockingX: failed to remove share oplock for fnum %d, \
dev = %x, inode = %.0f\n", fsp->fnum, (unsigned int)dev, (double)inode));
-
- unlock_share_entry(fsp->conn, dev, inode, token);
- } else {
- unlock_share_entry(fsp->conn, dev, inode, token);
-
- /* Clear the granted flag and return. */
- fsp->granted_oplock = False;
}
+ release_file_oplock(fsp);
+ unlock_share_entry(fsp->conn, dev, inode, token);
+
/* if this is a pure oplock break request then don't send a reply */
if (num_locks == 0 && num_ulocks == 0)
{