1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-22 22:04:08 +03:00

lib/param: Normalise "read raw" and "write raw" parameters

They have been changed to function like normal parameters,
removing a special case in the loadparm system.

Andrew Bartlett

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Michael Adam <obnox@samba.org>
This commit is contained in:
Andrew Bartlett 2014-01-15 14:48:40 +13:00
parent aea623e050
commit 86850860f8
8 changed files with 61 additions and 44 deletions

View File

@ -2,15 +2,13 @@
context="G"
type="boolean"
developer="1"
generated_function="0"
xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
<description>
<para>This parameter controls whether or not the server
will support the raw read SMB requests when transferring data
to clients.</para>
<para>This is ignored if <smbconfoption name="async echo handler"/> is set,
because this feature is incompatible with raw read SMB requests</para>
<para>If enabled, raw reads allow reads of 65535 bytes in
one packet. This typically provides a major performance benefit.
one packet. This typically provides a major performance benefit for some very, very old clients.
</para>
<para>However, some clients either negotiate the allowable
@ -24,4 +22,5 @@
<value type="default">yes</value>
<related>write raw</related>
<related>async echo handler</related>
</samba:parameter>

View File

@ -2,13 +2,25 @@
context="G"
type="boolean"
developer="1"
generated_function="0"
xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
<description>
<para>This parameter controls whether or not the server
will support raw write SMB's when transferring data from clients.
You should never need to change this parameter.</para>
<para>This is ignored if <smbconfoption name="async echo handler"/> is set,
because this feature is incompatible with raw write SMB requests</para>
<para>If enabled, raw writes allow writes of 65535 bytes in
one packet. This typically provides a major performance benefit for some very, very old clients.
</para>
<para>However, some clients either negotiate the allowable
block size incorrectly or are incapable of supporting larger block
sizes, and for these clients you may need to disable raw writes.</para>
<para>In general this parameter should be viewed as a system tuning
tool and left severely alone.</para>
</description>
<value type="default">yes</value>
<related>read raw</related>
<related>async echo handler</related>
</samba:parameter>

View File

@ -319,8 +319,6 @@ static struct loadparm_context *global_loadparm_context;
#include "lib/param/param_functions.c"
/* These functions remain only in lib/param for now */
FN_GLOBAL_BOOL(readraw, bReadRaw)
FN_GLOBAL_BOOL(writeraw, bWriteRaw)
FN_GLOBAL_CONST_STRING(cachedir, szCacheDir)
FN_GLOBAL_CONST_STRING(statedir, szStateDir)

View File

@ -1402,7 +1402,7 @@ static struct parm_struct parm_table[] = {
.label = "read raw",
.type = P_BOOL,
.p_class = P_GLOBAL,
.offset = GLOBAL_VAR(bReadRaw),
.offset = GLOBAL_VAR(read_raw),
.special = NULL,
.enum_list = NULL,
.flags = FLAG_ADVANCED,
@ -1411,7 +1411,7 @@ static struct parm_struct parm_table[] = {
.label = "write raw",
.type = P_BOOL,
.p_class = P_GLOBAL,
.offset = GLOBAL_VAR(bWriteRaw),
.offset = GLOBAL_VAR(write_raw),
.special = NULL,
.enum_list = NULL,
.flags = FLAG_ADVANCED,

View File

@ -994,8 +994,6 @@ bool lp_idmap_range(const char *domain_name, uint32_t *low, uint32_t *high);
bool lp_idmap_default_range(uint32_t *low, uint32_t *high);
const char *lp_idmap_backend(const char *domain_name);
const char *lp_idmap_default_backend (void);
bool lp_readraw(void);
bool lp_writeraw(void);
int lp_security(void);
int lp_smb2_max_credits(void);
int lp_cups_encrypt(void);

View File

@ -827,8 +827,8 @@ static void init_globals(bool reinit_globals)
Globals.winbind_sealed_pipes = true;
Globals.require_strong_key = true;
Globals.server_schannel = Auto;
Globals.bReadRaw = true;
Globals.bWriteRaw = true;
Globals.read_raw = true;
Globals.write_raw = true;
Globals.null_passwords = false;
Globals.obey_pam_restrictions = false;
Globals.syslog = 1;
@ -1165,9 +1165,6 @@ char *lp_ ## fn_name(TALLOC_CTX *ctx,int i) {return(lp_string((ctx), (LP_SNUM_OK
char lp_ ## fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
static FN_GLOBAL_BOOL(_readraw, bReadRaw)
static FN_GLOBAL_BOOL(_writeraw, bWriteRaw)
/* If lp_statedir() and lp_cachedir() are explicitely set during the
* build process or in smb.conf, we use that value. Otherwise they
* default to the value of lp_lock_directory(). */
@ -5301,22 +5298,6 @@ bool lp_widelinks(int snum)
return lp_widelinks_internal(snum);
}
bool lp_writeraw(void)
{
if (lp_async_smb_echo_handler()) {
return false;
}
return lp__writeraw();
}
bool lp_readraw(void)
{
if (lp_async_smb_echo_handler()) {
return false;
}
return lp__readraw();
}
int lp_server_role(void)
{
return lp_find_server_role(lp__server_role(),

View File

@ -62,10 +62,15 @@ static void get_challenge(struct smbd_server_connection *sconn, uint8 buff[8])
static void reply_lanman1(struct smb_request *req, uint16 choice)
{
int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0);
int secword=0;
time_t t = time(NULL);
struct smbd_server_connection *sconn = req->sconn;
uint16_t raw;
if (lp_async_smb_echo_handler()) {
raw = 0;
} else {
raw = (lp_read_raw()?1:0) | (lp_write_raw()?2:0);
}
sconn->smb1.negprot.encrypted_passwords = lp_encrypt_passwords();
@ -107,10 +112,15 @@ static void reply_lanman1(struct smb_request *req, uint16 choice)
static void reply_lanman2(struct smb_request *req, uint16 choice)
{
int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0);
int secword=0;
time_t t = time(NULL);
struct smbd_server_connection *sconn = req->sconn;
uint16_t raw;
if (lp_async_smb_echo_handler()) {
raw = 0;
} else {
raw = (lp_read_raw()?1:0) | (lp_write_raw()?2:0);
}
sconn->smb1.negprot.encrypted_passwords = lp_encrypt_passwords();
@ -289,7 +299,7 @@ static void reply_nt1(struct smb_request *req, uint16 choice)
capabilities |= CAP_LARGE_FILES;
if (lp_readraw() && lp_writeraw())
if (!lp_async_smb_echo_handler() && lp_read_raw() && lp_write_raw())
capabilities |= CAP_RAW_MODE;
if (lp_nt_status_support())

View File

@ -88,7 +88,13 @@ this any more it probably doesn't matter
****************************************************************************/
static void reply_coreplus(struct smbsrv_request *req, uint16_t choice)
{
uint16_t raw = (lpcfg_readraw(req->smb_conn->lp_ctx)?1:0) | (lpcfg_writeraw(req->smb_conn->lp_ctx)?2:0);
uint16_t raw;
if (lpcfg_async_smb_echo_handler(req->smb_conn->lp_ctx)) {
raw = 0;
} else {
raw = (lpcfg_read_raw(req->smb_conn->lp_ctx)?1:0) |
(lpcfg_write_raw(req->smb_conn->lp_ctx)?2:0);
}
smbsrv_setup_reply(req, 13, 0);
@ -119,7 +125,13 @@ static void reply_coreplus(struct smbsrv_request *req, uint16_t choice)
****************************************************************************/
static void reply_lanman1(struct smbsrv_request *req, uint16_t choice)
{
int raw = (lpcfg_readraw(req->smb_conn->lp_ctx)?1:0) | (lpcfg_writeraw(req->smb_conn->lp_ctx)?2:0);
uint16_t raw;
if (lpcfg_async_smb_echo_handler(req->smb_conn->lp_ctx)) {
raw = 0;
} else {
raw = (lpcfg_read_raw(req->smb_conn->lp_ctx)?1:0) |
(lpcfg_write_raw(req->smb_conn->lp_ctx)?2:0);
}
int secword=0;
time_t t = req->request_time.tv_sec;
@ -174,9 +186,15 @@ static void reply_lanman1(struct smbsrv_request *req, uint16_t choice)
****************************************************************************/
static void reply_lanman2(struct smbsrv_request *req, uint16_t choice)
{
int raw = (lpcfg_readraw(req->smb_conn->lp_ctx)?1:0) | (lpcfg_writeraw(req->smb_conn->lp_ctx)?2:0);
int secword=0;
time_t t = req->request_time.tv_sec;
uint16_t raw;
if (lpcfg_async_smb_echo_handler(req->smb_conn->lp_ctx)) {
raw = 0;
} else {
raw = (lpcfg_read_raw(req->smb_conn->lp_ctx)?1:0) |
(lpcfg_write_raw(req->smb_conn->lp_ctx)?2:0);
}
req->smb_conn->negotiate.encrypted_passwords = lpcfg_encrypt_passwords(req->smb_conn->lp_ctx);
@ -272,8 +290,9 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice)
capabilities |= CAP_LARGE_FILES;
}
if (lpcfg_readraw(req->smb_conn->lp_ctx) &&
lpcfg_writeraw(req->smb_conn->lp_ctx)) {
if (!lpcfg_async_smb_echo_handler(req->smb_conn->lp_ctx) &&
lpcfg_read_raw(req->smb_conn->lp_ctx) &&
lpcfg_write_raw(req->smb_conn->lp_ctx)) {
capabilities |= CAP_RAW_MODE;
}