summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/auth/gensec/cyrus_sasl.c5
-rw-r--r--source4/lib/talloc/web/index.html2
-rw-r--r--source4/lib/util/util_ldb.c17
-rw-r--r--source4/librpc/idl/dcerpc.idl3
-rw-r--r--source4/librpc/idl/drsuapi.idl9
-rw-r--r--source4/librpc/idl/epmapper.idl12
-rw-r--r--source4/librpc/idl/krb5pac.idl3
-rw-r--r--source4/librpc/idl/lsa.idl12
-rw-r--r--source4/librpc/ndr/ndr_sec_helper.c3
-rw-r--r--source4/param/loadparm.c326
-rw-r--r--source4/selftest/README21
-rwxr-xr-xsource4/selftest/samba4_tests.sh3
-rw-r--r--source4/selftest/target/Samba4.pm16
-rw-r--r--source4/torture/config.mk3
-rw-r--r--source4/torture/gentest.c173
-rw-r--r--source4/torture/locktest.c181
-rw-r--r--source4/torture/masktest.c157
17 files changed, 477 insertions, 469 deletions
diff --git a/source4/auth/gensec/cyrus_sasl.c b/source4/auth/gensec/cyrus_sasl.c
index 64a0b2f0c7..cb7bcb71d8 100644
--- a/source4/auth/gensec/cyrus_sasl.c
+++ b/source4/auth/gensec/cyrus_sasl.c
@@ -362,8 +362,11 @@ int gensec_sasl_log(void *context,
NTSTATUS gensec_sasl_init(void)
{
NTSTATUS ret;
- int sasl_ret, i;
+ int sasl_ret;
+#if 0
+ int i;
const char **sasl_mechs;
+#endif
static const sasl_callback_t callbacks[] = {
{
diff --git a/source4/lib/talloc/web/index.html b/source4/lib/talloc/web/index.html
index 106920e8a5..e53e8960a8 100644
--- a/source4/lib/talloc/web/index.html
+++ b/source4/lib/talloc/web/index.html
@@ -12,7 +12,7 @@ destructors. It is the core memory allocator used in Samba4, and has
made a huge difference in many aspects of Samba4 development.<p>
To get started with talloc, I would recommend you read the <a
-href="http://samba.org/ftp/unpacked/samba4/source/lib/talloc/talloc_guide.txt">talloc guide</a>.
+href="http://samba.org/ftp/unpacked/samba_4_0_test/source/lib/talloc/talloc_guide.txt">talloc guide</a>.
<h2>Discussion and bug reports</h2>
diff --git a/source4/lib/util/util_ldb.c b/source4/lib/util/util_ldb.c
index a8719af190..f1b42effd8 100644
--- a/source4/lib/util/util_ldb.c
+++ b/source4/lib/util/util_ldb.c
@@ -1,21 +1,21 @@
-/*
+/*
Unix SMB/CIFS implementation.
common share info functions
Copyright (C) Andrew Tridgell 2004
Copyright (C) Tim Potter 2004
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -56,7 +56,7 @@ int gendb_search_v(struct ldb_context *ldb,
if (ret == LDB_SUCCESS) {
talloc_steal(mem_ctx, res->msgs);
- DEBUG(6,("gendb_search_v: %s %s -> %d\n",
+ DEBUG(6,("gendb_search_v: %s %s -> %d\n",
basedn?ldb_dn_get_linearized(basedn):"NULL",
expr?expr:"NULL", res->count));
@@ -67,7 +67,8 @@ int gendb_search_v(struct ldb_context *ldb,
ret = 0;
*msgs = NULL;
} else {
- DEBUG(4,("gendb_search_v: search failed: %s", ldb_errstring(ldb)));
+ DEBUG(4,("gendb_search_v: search failed: %s\n",
+ ldb_errstring(ldb)));
ret = -1;
}
@@ -80,7 +81,7 @@ int gendb_search_v(struct ldb_context *ldb,
search the LDB for the specified attributes - varargs variant
*/
int gendb_search(struct ldb_context *ldb,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
struct ldb_dn *basedn,
struct ldb_message ***res,
const char * const *attrs,
@@ -101,7 +102,7 @@ int gendb_search(struct ldb_context *ldb,
*/
int gendb_search_dn(struct ldb_context *ldb,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
struct ldb_dn *dn,
struct ldb_message ***res,
const char * const *attrs)
diff --git a/source4/librpc/idl/dcerpc.idl b/source4/librpc/idl/dcerpc.idl
index fcb0be4639..b2c67542f5 100644
--- a/source4/librpc/idl/dcerpc.idl
+++ b/source4/librpc/idl/dcerpc.idl
@@ -64,7 +64,8 @@ interface dcerpc
uint16 max_xmit_frag;
uint16 max_recv_frag;
uint32 assoc_group_id;
- ascstr3 secondary_address;
+ [value(strlen(secondary_address)+1)] uint16 secondary_address_size;
+ [charset(DOS)] uint8 secondary_address[secondary_address_size];
[flag(NDR_ALIGN4)] DATA_BLOB _pad1;
uint8 num_results;
dcerpc_ack_ctx ctx_list[num_results];
diff --git a/source4/librpc/idl/drsuapi.idl b/source4/librpc/idl/drsuapi.idl
index f298b7e321..fb24122e26 100644
--- a/source4/librpc/idl/drsuapi.idl
+++ b/source4/librpc/idl/drsuapi.idl
@@ -130,7 +130,8 @@ interface drsuapi
[value(ndr_size_dom_sid28(&sid, ndr->flags))] uint32 __ndr_size_sid;
GUID guid;
dom_sid28 sid;
- [flag(STR_SIZE4|STR_CHARLEN|STR_CONFORMANT)] string dn;
+ [value(strlen_m(dn))] uint32 __ndr_size_dn;
+ [charset(UTF16),size_is(__ndr_size_dn+1)] uint16 dn[];
} drsuapi_DsReplicaObjectIdentifier;
typedef [public] bitmap {
@@ -451,7 +452,8 @@ interface drsuapi
[value(ndr_size_dom_sid28(&sid,ndr->flags))] uint32 __ndr_size_sid;
GUID guid;
dom_sid28 sid;
- [flag(STR_SIZE4|STR_CHARLEN)] string dn;
+ [value(strlen_m(dn))] uint32 __ndr_size_dn;
+ [charset(UTF16)] uint16 dn[__ndr_size_dn+1];
} drsuapi_DsReplicaObjectIdentifier3;
typedef [public,gensize] struct {
@@ -459,7 +461,8 @@ interface drsuapi
[value(ndr_size_dom_sid28(&sid,ndr->flags))] uint32 __ndr_size_sid;
GUID guid;
dom_sid28 sid;
- [flag(STR_SIZE4|STR_CHARLEN)] string dn;
+ [value(strlen_m(dn))] uint32 __ndr_size_dn;
+ [charset(UTF16)] uint16 dn[__ndr_size_dn+1];
[value(binary.length + 4)] uint32 __ndr_size_binary;
[flag(NDR_REMAINING)] DATA_BLOB binary;
} drsuapi_DsReplicaObjectIdentifier3Binary;
diff --git a/source4/librpc/idl/epmapper.idl b/source4/librpc/idl/epmapper.idl
index baf9f23877..60ff338ec4 100644
--- a/source4/librpc/idl/epmapper.idl
+++ b/source4/librpc/idl/epmapper.idl
@@ -3,6 +3,7 @@
/*
endpoint mapper interface
Related links:
+ http://www.opengroup.org/onlinepubs/9629399/apdxo.htm : The official IDL for this pipe
http://www.opengroup.org/onlinepubs/9629399/apdxl.htm : Details on towers
http://www.opengroup.org/onlinepubs/9629399/chap6.htm#tagcjh_11_02_03_01: binding strings
@@ -222,7 +223,16 @@ interface epmapper
typedef struct {
GUID object;
epm_twr_t *tower;
- ascstr2 annotation;
+ /*
+ * In theory this should be:
+ * [charset(DOS),string] uint8 annotation[64]
+ * But midl treats this as:
+ * [charset(DOS),string] uint8 annotation[]
+ * and pidl doesn't support this yet
+ */
+ [value(0)] uint32 __annotation_offset;
+ [value(strlen(annotation)+1)] uint32 __annotation_length;
+ [charset(DOS)] uint8 annotation[__annotation_length];
} epm_entry_t;
typedef struct {
diff --git a/source4/librpc/idl/krb5pac.idl b/source4/librpc/idl/krb5pac.idl
index fa6bf51e44..efd4aa860f 100644
--- a/source4/librpc/idl/krb5pac.idl
+++ b/source4/librpc/idl/krb5pac.idl
@@ -16,7 +16,8 @@ interface krb5pac
{
typedef struct {
NTTIME logon_time;
- [flag(STR_SIZE2|STR_NOTERM|STR_BYTESIZE)] string account_name;
+ [value(2*strlen_m(account_name))] uint16 size;
+ [charset(UTF16)] uint8 account_name[size];
} PAC_LOGON_NAME;
typedef [public,flag(NDR_PAHEX)] struct {
diff --git a/source4/librpc/idl/lsa.idl b/source4/librpc/idl/lsa.idl
index 8d26ec0aad..bc5ccaa78a 100644
--- a/source4/librpc/idl/lsa.idl
+++ b/source4/librpc/idl/lsa.idl
@@ -33,11 +33,17 @@ import "security.idl";
} lsa_Strings;
typedef [public] struct {
- [value(strlen_m(string))] uint16 length;
- [value(strlen_m(string))] uint16 size;
- ascstr_noterm *string;
+ [value(strlen(string))] uint16 length;
+ [value(strlen(string))] uint16 size;
+ [charset(DOS),size_is(size),length_is(length)] uint8 *string;
} lsa_AsciiString;
+ typedef [public] struct {
+ [value(strlen(string))] uint16 length;
+ [value(strlen(string)+1)] uint16 size;
+ [charset(DOS),size_is(size),length_is(length)] uint8 *string;
+ } lsa_AsciiStringLarge;
+
/******************/
/* Function: 0x00 */
NTSTATUS lsa_Close (
diff --git a/source4/librpc/ndr/ndr_sec_helper.c b/source4/librpc/ndr/ndr_sec_helper.c
index 30eaf9c6f4..5a0178bd25 100644
--- a/source4/librpc/ndr/ndr_sec_helper.c
+++ b/source4/librpc/ndr/ndr_sec_helper.c
@@ -187,6 +187,9 @@ enum ndr_err_code ndr_pull_dom_sid28(struct ndr_pull *ndr, int ndr_flags, struct
if (!NDR_ERR_CODE_IS_SUCCESS(status)) {
/* handle a w2k bug which send random data in the buffer */
ZERO_STRUCTP(sid);
+ } else if (sid->num_auths == 0 && sid->sub_auths) {
+ talloc_free(sid->sub_auths);
+ sid->sub_auths = NULL;
}
return NDR_ERR_SUCCESS;
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index 9ec5a59d15..e850d82193 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -11,17 +11,17 @@
Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
Copyright (C) James Myers 2003 <myersjj@samba.org>
Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -40,7 +40,7 @@
* 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
* 4) If it's a global then initialise it in init_globals. If a local
* (ie. service) parameter then initialise it in the sDefault structure
- *
+ *
*
* Notes:
* The configuration file is processed sequentially for speed. It is NOT
@@ -150,7 +150,7 @@ struct loadparm_global
char *socket_options;
int bWINSsupport;
int bWINSdnsProxy;
- char *szWINSHook;
+ char *szWINSHook;
int bLocalMaster;
int bPreferredMaster;
int bEncryptPasswords;
@@ -182,7 +182,7 @@ struct loadparm_global
/**
- * This structure describes a single service.
+ * This structure describes a single service.
*/
struct loadparm_service
{
@@ -228,28 +228,28 @@ struct loadparm_service sDefault = {
.szPath = NULL,
.szCopy = NULL,
.szInclude = NULL,
- .szPrintername = NULL,
- .szHostsallow = NULL,
- .szHostsdeny = NULL,
- .comment = NULL,
- .volume = NULL,
- .fstype = NULL,
- .ntvfs_handler = NULL,
- .iMaxPrintJobs = 1000,
- .iMaxConnections = 0,
- .iCSCPolicy = 0,
- .bAvailable = true,
- .bBrowseable = true,
- .bRead_only = true,
- .bPrint_ok = false,
- .bMap_system = false,
- .bMap_hidden = false,
- .bMap_archive = true,
- .bStrictLocking = true,
- .iCreate_mask = 0744,
+ .szPrintername = NULL,
+ .szHostsallow = NULL,
+ .szHostsdeny = NULL,
+ .comment = NULL,
+ .volume = NULL,
+ .fstype = NULL,
+ .ntvfs_handler = NULL,
+ .iMaxPrintJobs = 1000,
+ .iMaxConnections = 0,
+ .iCSCPolicy = 0,
+ .bAvailable = true,
+ .bBrowseable = true,
+ .bRead_only = true,
+ .bPrint_ok = false,
+ .bMap_system = false,
+ .bMap_hidden = false,
+ .bMap_archive = true,
+ .bStrictLocking = true,
+ .iCreate_mask = 0744,
.iCreate_force_mode = 0000,
- .iDir_mask = 0755,
- .iDir_force_mode = 0000,
+ .iDir_mask = 0755,
+ .iDir_force_mode = 0000,
.copymap = NULL,
.bMSDfsRoot = false,
.bStrictSync = false,
@@ -261,9 +261,9 @@ struct loadparm_context *global_loadparm = NULL;
#define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
/* prototypes for the special type handlers */
-static bool handle_include(struct loadparm_context *lp_ctx,
+static bool handle_include(struct loadparm_context *lp_ctx,
const char *pszParmValue, char **ptr);
-static bool handle_copy(struct loadparm_context *lp_ctx,
+static bool handle_copy(struct loadparm_context *lp_ctx,
const char *pszParmValue, char **ptr);
static bool handle_debuglevel(struct loadparm_context *lp_ctx,
const char *pszParmValue, char **ptr);
@@ -308,9 +308,9 @@ static const struct enum_list enum_bool_auto[] = {
};
/* Client-side offline caching policy types */
-enum csc_policy {
- CSC_POLICY_MANUAL=0,
- CSC_POLICY_DOCUMENTS=1,
+enum csc_policy {
+ CSC_POLICY_MANUAL=0,
+ CSC_POLICY_DOCUMENTS=1,
CSC_POLICY_PROGRAMS=2,
CSC_POLICY_DISABLE=3
};
@@ -397,12 +397,12 @@ static struct parm_struct parm_table[] = {
{"client lanman auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientLanManAuth), NULL, NULL},
{"client plaintext auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientPlaintextAuth), NULL, NULL},
{"client use spnego principal", P_BOOL, P_GLOBAL, GLOBAL_VAR(client_use_spnego_principal), NULL, NULL},
-
+
{"read only", P_BOOL, P_LOCAL, LOCAL_VAR(bRead_only), NULL, NULL},
- {"create mask", P_OCTAL, P_LOCAL, LOCAL_VAR(iCreate_mask), NULL, NULL},
+ {"create mask", P_OCTAL, P_LOCAL, LOCAL_VAR(iCreate_mask), NULL, NULL},
{"force create mode", P_OCTAL, P_LOCAL, LOCAL_VAR(iCreate_force_mode), NULL, NULL},
- {"directory mask", P_OCTAL, P_LOCAL, LOCAL_VAR(iDir_mask), NULL, NULL},
+ {"directory mask", P_OCTAL, P_LOCAL, LOCAL_VAR(iDir_mask), NULL, NULL},
{"force directory mode", P_OCTAL, P_LOCAL, LOCAL_VAR(iDir_force_mode), NULL, NULL},
{"hosts allow", P_LIST, P_LOCAL, LOCAL_VAR(szHostsallow), NULL, NULL},
@@ -411,7 +411,7 @@ static struct parm_struct parm_table[] = {
{"log level", P_INTEGER, P_GLOBAL, GLOBAL_VAR(debuglevel), handle_debuglevel, NULL},
{"debuglevel", P_INTEGER, P_GLOBAL, GLOBAL_VAR(debuglevel), handle_debuglevel, NULL},
{"log file", P_STRING, P_GLOBAL, GLOBAL_VAR(logfile), handle_logfile, NULL},
-
+
{"smb ports", P_LIST, P_GLOBAL, GLOBAL_VAR(smb_ports), NULL, NULL},
{"nbt port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(nbt_port), NULL, NULL},
{"dgram port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(dgram_port), NULL, NULL},
@@ -435,7 +435,7 @@ static struct parm_struct parm_table[] = {
{"read raw", P_BOOL, P_GLOBAL, GLOBAL_VAR(bReadRaw), NULL, NULL},
{"write raw", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWriteRaw), NULL, NULL},
{"disable netbios", P_BOOL, P_GLOBAL, GLOBAL_VAR(bDisableNetbios), NULL, NULL},
-
+
{"nt status support", P_BOOL, P_GLOBAL, GLOBAL_VAR(bNTStatusSupport), NULL, NULL},
{"announce version", P_STRING, P_GLOBAL, GLOBAL_VAR(szAnnounceVersion), NULL, NULL},
@@ -457,13 +457,13 @@ static struct parm_struct parm_table[] = {
{"paranoid server security", P_BOOL, P_GLOBAL, GLOBAL_VAR(paranoid_server_security), NULL, NULL},
{"socket options", P_STRING, P_GLOBAL, GLOBAL_VAR(socket_options), NULL, NULL},
- {"strict sync", P_BOOL, P_LOCAL, LOCAL_VAR(bStrictSync), NULL, NULL},
+ {"strict sync", P_BOOL, P_LOCAL, LOCAL_VAR(bStrictSync), NULL, NULL},
{"case insensitive filesystem", P_BOOL, P_LOCAL, LOCAL_VAR(bCIFileSystem), NULL, NULL},
{"max print jobs", P_INTEGER, P_LOCAL, LOCAL_VAR(iMaxPrintJobs), NULL, NULL},
{"printable", P_BOOL, P_LOCAL, LOCAL_VAR(bPrint_ok), NULL, NULL},
{"print ok", P_BOOL, P_LOCAL, LOCAL_VAR(bPrint_ok), NULL, NULL},
-
+
{"printer name", P_STRING, P_LOCAL, LOCAL_VAR(szPrintername), NULL, NULL},
{"printer", P_STRING, P_LOCAL, LOCAL_VAR(szPrintername), NULL, NULL},
@@ -483,7 +483,7 @@ static struct parm_struct parm_table[] = {
{"wins hook", P_STRING, P_GLOBAL, GLOBAL_VAR(szWINSHook), NULL, NULL},
{"csc policy", P_ENUM, P_LOCAL, LOCAL_VAR(iCSCPolicy), NULL, enum_csc_policy},
-
+
{"strict locking", P_BOOL, P_LOCAL, LOCAL_VAR(bStrictLocking), NULL, NULL},
{"share backend", P_STRING, P_GLOBAL, GLOBAL_VAR(szShareBackend), NULL, NULL},
@@ -495,11 +495,11 @@ static struct parm_struct parm_table[] = {
{"pid directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szPidDir), NULL, NULL},
{"js include", P_LIST, P_GLOBAL, GLOBAL_VAR(jsInclude), NULL, NULL},
{"setup directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szSetupDir), NULL, NULL},
-
+
{"socket address", P_STRING, P_GLOBAL, GLOBAL_VAR(szSocketAddress), NULL, NULL},
{"copy", P_STRING, P_LOCAL, LOCAL_VAR(szCopy), handle_copy, NULL},
{"include", P_STRING, P_LOCAL, LOCAL_VAR(szInclude), handle_include, NULL},
-
+
{"available", P_BOOL, P_LOCAL, LOCAL_VAR(bAvailable), NULL, NULL},
{"volume", P_STRING, P_LOCAL, LOCAL_VAR(volume), NULL, NULL },
{"fstype", P_STRING, P_LOCAL, LOCAL_VAR(fstype), NULL, NULL},
@@ -547,7 +547,7 @@ struct parm_struct *lp_parm_table(void)
/**
* Convenience routine to grab string parameters into temporary memory
- * and run standard_sub_basic on them.
+ * and run standard_sub_basic on them.
*
* The buffers can be written to by
* callers without affecting the source string.
@@ -595,8 +595,8 @@ static const char *lp_string(const char *s)
}
/*
- In this section all the functions that are used to access the
- parameters from the rest of the program are defined
+ In this section all the functions that are used to access the
+ parameters from the rest of the program are defined
*/
#define FN_GLOBAL_STRING(fn_name,var_name) \
@@ -750,7 +750,7 @@ static int map_parameter(const char *pszParmName);
static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
const char *pszServiceName);
static void copy_service(struct loadparm_service *pserviceDest,
- struct loadparm_service *pserviceSource,
+ struct loadparm_service *pserviceSource,
int *pcopymapDest);
static bool service_ok(struct loadparm_service *service);
static bool do_section(const char *pszSectionName, void *);
@@ -759,8 +759,8 @@ static void init_copymap(struct loadparm_service *pservice);
/* This is a helper function for parametrical options support. */
/* It returns a pointer to parametrical option value if it exists or NULL otherwise */
/* Actual parametrical functions are quite simple */
-const char *lp_get_parametric(struct loadparm_context *lp_ctx,
- struct loadparm_service *service,
+const char *lp_get_parametric(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
const char *type, const char *option)
{
char *vfskey;
@@ -768,9 +768,9 @@ const char *lp_get_parametric(struct loadparm_context *lp_ctx,
if (lp_ctx == NULL)
return NULL;
-
+
data = (service == NULL ? lp_ctx->globals->param_opt : service->param_opt);
-
+
asprintf(&vfskey, "%s:%s", type, option);
strlower(vfskey);
@@ -785,7 +785,7 @@ const char *lp_get_parametric(struct loadparm_context *lp_ctx,
if (service != NULL) {
/* Try to fetch the same option but from globals */
/* but only if we are not already working with globals */
- for (data = lp_ctx->globals->param_opt; data;
+ for (data = lp_ctx->globals->param_opt; data;
data = data->next) {
if (strcmp(data->key, vfskey) == 0) {
free(vfskey);
@@ -795,7 +795,7 @@ const char *lp_get_parametric(struct loadparm_context *lp_ctx,
}
free(vfskey);
-
+
return NULL;
}
@@ -811,7 +811,7 @@ static int lp_int(const char *s)
return -1;
}
- return strtol(s, NULL, 0);
+ return strtol(s, NULL, 0);
}
/**
@@ -853,7 +853,7 @@ static bool lp_bool(const char *s)
DEBUG(0,("lp_bool(%s): is called with NULL!\n",s));
return false;
}
-
+
if (!set_boolean(s, &ret)) {
DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
return false;
@@ -866,11 +866,11 @@ static bool lp_bool(const char *s)
/**
* Return parametric option from a given service. Type is a part of option before ':'
* Parametric option has following syntax: 'Type: option = value'
- * Returned value is allocated in 'lp_talloc' context
+ * Returned value is allocated in 'lp_talloc' context
*/
-const char *lp_parm_string(struct loadparm_context *lp_ctx,
- struct loadparm_service *service, const char *type,
+const char *lp_parm_string(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
const char *option)
{
const char *value = lp_get_parametric(lp_ctx, service, type, option);
@@ -888,13 +888,13 @@ const char *lp_parm_string(struct loadparm_context *lp_ctx,
*/
const char **lp_parm_string_list(TALLOC_CTX *mem_ctx,
- struct loadparm_context *lp_ctx,
- struct loadparm_service *service,
- const char *type,
+ struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
+ const char *type,
const char *option, const char *separator)
{
const char *value = lp_get_parametric(lp_ctx, service, type, option);
-
+
if (value != NULL)
return str_list_make(mem_ctx, value, separator);
@@ -906,12 +906,12 @@ const char **lp_parm_string_list(TALLOC_CTX *mem_ctx,
* Parametric option has following syntax: 'Type: option = value'
*/
-int lp_parm_int(struct loadparm_context *lp_ctx,
- struct loadparm_service *service, const char *type,
+int lp_parm_int(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
const char *option, int default_v)
{
const char *value = lp_get_parametric(lp_ctx, service, type, option);
-
+
if (value)
return lp_int(value);
@@ -924,8 +924,8 @@ int lp_parm_int(struct loadparm_context *lp_ctx,
* Parametric option has following syntax: 'Type: option = value'.
*/
-int lp_parm_bytes(struct loadparm_context *lp_ctx,
- struct loadparm_service *service, const char *type,
+int lp_parm_bytes(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
const char *option, int default_v)
{
uint64_t bval;
@@ -942,16 +942,16 @@ int lp_parm_bytes(struct loadparm_context *lp_ctx,
}
/**
- * Return parametric option from a given service.
+ * Return parametric option from a given service.
* Type is a part of option before ':'
* Parametric option has following syntax: 'Type: option = value'
*/
-unsigned long lp_parm_ulong(struct loadparm_context *lp_ctx,
- struct loadparm_service *service, const char *type,
+unsigned long lp_parm_ulong(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
const char *option, unsigned long default_v)
{
const char *value = lp_get_parametric(lp_ctx, service, type, option);
-
+
if (value)
return lp_ulong(value);
@@ -959,12 +959,12 @@ unsigned long lp_parm_ulong(struct loadparm_context *lp_ctx,
}
-double lp_parm_double(struct loadparm_context *lp_ctx,
- struct loadparm_service *service, const char *type,
+double lp_parm_double(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
const char *option, double default_v)
{
const char *value = lp_get_parametric(lp_ctx, service, type, option);
-
+
if (value != NULL)
return lp_double(value);
@@ -976,12 +976,12 @@ double lp_parm_double(struct loadparm_context *lp_ctx,
* Parametric option has following syntax: 'Type: option = value'
*/
-bool lp_parm_bool(struct loadparm_context *lp_ctx,
- struct loadparm_service *service, const char *type,
+bool lp_parm_bool(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
const char *option, bool default_v)
{
const char *value = lp_get_parametric(lp_ctx, service, type, option);
-
+
if (value != NULL)
return lp_bool(value);
@@ -995,7 +995,7 @@ bool lp_parm_bool(struct loadparm_context *lp_ctx,
static struct loadparm_service *init_service(TALLOC_CTX *mem_ctx)
{
- struct loadparm_service *pservice =
+ struct loadparm_service *pservice =
talloc_zero(mem_ctx, struct loadparm_service);
copy_service(pservice, &sDefault, NULL);
return pservice;
@@ -1009,7 +1009,7 @@ static bool string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
{
talloc_free(*dest);
- if (src == NULL)
+ if (src == NULL)
src = "";
*dest = talloc_strdup(mem_ctx, src);
@@ -1024,12 +1024,12 @@ static bool string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
/**
- * Add a new service to the services array initialising it with the given
- * service.
+ * Add a new service to the services array initialising it with the given
+ * service.
*/
-struct loadparm_service *lp_add_service(struct loadparm_context *lp_ctx,
- const struct loadparm_service *pservice,
+struct loadparm_service *lp_add_service(struct loadparm_context *lp_ctx,
+ const struct loadparm_service *pservice,
const char *name)
{
int i;
@@ -1041,7 +1041,7 @@ struct loadparm_service *lp_add_service(struct loadparm_context *lp_ctx,
/* it might already exist */
if (name) {
- struct loadparm_service *service = getservicebyname(lp_ctx,
+ struct loadparm_service *service = getservicebyname(lp_ctx,
name);
if (service != NULL) {
/* Clean all parametric options for service */
@@ -1065,9 +1065,9 @@ struct loadparm_service *lp_add_service(struct loadparm_context *lp_ctx,
/* if not, then create one */
if (i == lp_ctx->iNumServices) {
struct loadparm_service **tsp;
-
+
tsp = talloc_realloc(lp_ctx, lp_ctx->services, struct loadparm_service *, num_to_alloc);
-
+
if (!tsp) {
DEBUG(0,("lp_add_service: failed to enlarge services!\n"));
return NULL;
@@ -1077,7 +1077,7 @@ struct loadparm_service *lp_add_service(struct loadparm_context *lp_ctx,
}
lp_ctx->iNumServices++;
- }
+ }
lp_ctx->services[i] = init_service(lp_ctx->services);
if (lp_ctx->services[i] == NULL) {
@@ -1091,12 +1091,12 @@ struct loadparm_service *lp_add_service(struct loadparm_context *lp_ctx,
}
/**
- * Add a new home service, with the specified home directory, defaults coming
+ * Add a new home service, with the specified home directory, defaults coming
* from service ifrom.
*/
-bool lp_add_home(struct loadparm_context *lp_ctx,
- const char *pszHomename,
+bool lp_add_home(struct loadparm_context *lp_ctx,
+ const char *pszHomename,
struct loadparm_service *default_service,
const char *user, const char *pszHomedir)
{
@@ -1120,9 +1120,9 @@ bool lp_add_home(struct loadparm_context *lp_ctx,
service->bAvailable = default_service->bAvailable;
service->bBrowseable = default_service->bBrowseable;
- DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n",
+ DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n",
pszHomename, user, service->szPath));
-
+
return true;
}
@@ -1130,7 +1130,7 @@ bool lp_add_home(struct loadparm_context *lp_ctx,
* Add the IPC service.
*/
-static bool lp_add_hidden(struct loadparm_context *lp_ctx, const char *name,
+static bool lp_add_hidden(struct loadparm_context *lp_ctx, const char *name,
const char *fstype)
{
struct loadparm_service *service = lp_add_service(lp_ctx, &sDefault, name);
@@ -1140,7 +1140,7 @@ static bool lp_add_hidden(struct loadparm_context *lp_ctx, const char *name,
string_set(service, &service->szPath, tmpdir());
- service->comment = talloc_asprintf(service, "%s Service (%s)",
+ service->comment = talloc_asprintf(service, "%s Service (%s)",
fstype, lp_ctx->globals->szServerString);
string_set(service, &service->fstype, fstype);
service->iMaxConnections = -1;
@@ -1150,7 +1150,7 @@ static bool lp_add_hidden(struct loadparm_context *lp_ctx, const char *name,
service->bBrowseable = false;
if (strcasecmp(fstype, "IPC") == 0) {
- lp_do_service_parameter(lp_ctx, service, "ntvfs handler",
+ lp_do_service_parameter(lp_ctx, service, "ntvfs handler",
"default");
}
@@ -1164,7 +1164,7 @@ static bool lp_add_hidden(struct loadparm_context *lp_ctx, const char *name,
*/
bool lp_add_printer(struct loadparm_context *lp_ctx,
- const char *pszPrintername,
+ const char *pszPrintername,
struct loadparm_service *default_service)
{
const char *comment = "From Printcap";
@@ -1194,7 +1194,7 @@ bool lp_add_printer(struct loadparm_context *lp_ctx,
}
/**
- * Map a parameter's string representation to something we can use.
+ * Map a parameter's string representation to something we can use.
* Returns False if the parameter string is not recognised, else TRUE.
*/
@@ -1269,8 +1269,8 @@ static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx
* If pcopymapDest is NULL then copy all fields
*/
-static void copy_service(struct loadparm_service *pserviceDest,
- struct loadparm_service *pserviceSource,
+static void copy_service(struct loadparm_service *pserviceDest,
+ struct loadparm_service *pserviceSource,
int *pcopymapDest)
{
int i;
@@ -1298,13 +1298,13 @@ static void copy_service(struct loadparm_service *pserviceDest,
break;
case P_STRING:
- string_set(pserviceDest,
+ string_set(pserviceDest,
(char **)dest_ptr,
*(char **)src_ptr);
break;
case P_USTRING:
- string_set(pserviceDest,
+ string_set(pserviceDest,
(char **)dest_ptr,
*(char **)src_ptr);
strupper(*(char **)dest_ptr);
@@ -1325,7 +1325,7 @@ static void copy_service(struct loadparm_service *pserviceDest,
(void *)pserviceSource->copymap,
sizeof(int) * NUMPARAMETERS);
}
-
+
data = pserviceSource->param_opt;
while (data) {
not_added = true;
@@ -1335,7 +1335,7 @@ static void copy_service(struct loadparm_service *pserviceDest,
/* If we already have same option, override it */
if (strcmp(pdata->key, data->key) == 0) {
talloc_free(pdata->value);
- pdata->value = talloc_reference(pdata,
+ pdata->value = talloc_reference(pdata,
data->value);
not_added = false;
break;
@@ -1392,11 +1392,11 @@ static bool service_ok(struct loadparm_service *service)
/*******************************************************************
- Keep a linked list of all config files so we know when one has changed
+ Keep a linked list of all config files so we know when one has changed
it's date and needs to be reloaded.
********************************************************************/
-static void add_to_file_list(struct loadparm_context *lp_ctx,
+static void add_to_file_list(struct loadparm_context *lp_ctx,
const char *fname, const char *subfname)
{
struct file_lists *f = lp_ctx->file_lists;
@@ -1466,7 +1466,7 @@ bool lp_file_list_changed(struct loadparm_context *lp_ctx)
Handle the include operation.
***************************************************************************/
-static bool handle_include(struct loadparm_context *lp_ctx,
+static bool handle_include(struct loadparm_context *lp_ctx,
const char *pszParmValue, char **ptr)
{
char *fname = standard_sub_basic(lp_ctx, pszParmValue);
@@ -1487,7 +1487,7 @@ static bool handle_include(struct loadparm_context *lp_ctx,
Handle the interpretation of the copy parameter.
***************************************************************************/
-static bool handle_copy(struct loadparm_context *lp_ctx,
+static bool handle_copy(struct loadparm_context *lp_ctx,
const char *pszParmValue, char **ptr)
{
bool bRetval;
@@ -1509,7 +1509,7 @@ static bool handle_copy(struct loadparm_context *lp_ctx,
bRetval = true;
}
} else {
- DEBUG(0, ("Unable to copy service - source not found: %s\n",
+ DEBUG(0, ("Unable to copy service - source not found: %s\n",
pszParmValue));
bRetval = false;
}
@@ -1517,7 +1517,7 @@ static bool handle_copy(struct loadparm_context *lp_ctx,
return bRetval;
}
-static bool handle_debuglevel(struct loadparm_context *lp_ctx,
+static bool handle_debuglevel(struct loadparm_context *lp_ctx,
const char *pszParmValue, char **ptr)
{
DEBUGLEVEL = atoi(pszParmValue);
@@ -1525,7 +1525,7 @@ static bool handle_debuglevel(struct loadparm_context *lp_ctx,
return true;
}
-static bool handle_logfile(struct loadparm_context *lp_ctx,
+static bool handle_logfile(struct loadparm_context *lp_ctx,
const char *pszParmValue, char **ptr)
{
logfile = pszParmValue;
@@ -1554,9 +1554,9 @@ static void init_copymap(struct loadparm_service *pservice)
/**
* Process a parametric option
*/
-static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
- struct loadparm_service *service,
- const char *pszParmName,
+static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
+ const char *pszParmName,
const char *pszParmValue, int flags)
{
struct param_opt *paramo, *data;
@@ -1611,18 +1611,18 @@ static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
}
free(name);
-
+
return true;
}
-static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
+static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
const char *pszParmName, const char *pszParmValue,
struct loadparm_context *lp_ctx)
{
int i;
/* if it is a special case then go ahead */
if (parm_table[parmnum].special) {
- parm_table[parmnum].special(lp_ctx, pszParmValue,
+ parm_table[parmnum].special(lp_ctx, pszParmValue,
(char **)parm_ptr);
return true;
}
@@ -1664,7 +1664,7 @@ static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
}
case P_LIST:
- *(const char ***)parm_ptr = str_list_make(mem_ctx,
+ *(const char ***)parm_ptr = str_list_make(mem_ctx,
pszParmValue, NULL);
break;
@@ -1710,7 +1710,7 @@ static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
}
-bool lp_do_global_parameter(struct loadparm_context *lp_ctx,
+bool lp_do_global_parameter(struct loadparm_context *lp_ctx,
const char *pszParmName, const char *pszParmValue)
{
int parmnum = map_parameter(pszParmName);
@@ -1732,12 +1732,12 @@ bool lp_do_global_parameter(struct loadparm_context *lp_ctx,
parm_ptr = lp_parm_ptr(lp_ctx, NULL, &parm_table[parmnum]);
- return set_variable(lp_ctx, parmnum, parm_ptr,
+ return set_variable(lp_ctx, parmnum, parm_ptr,
pszParmName, pszParmValue, lp_ctx);
}
-bool lp_do_service_parameter(struct loadparm_context *lp_ctx,
- struct loadparm_service *service,
+bool lp_do_service_parameter(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
const char *pszParmName, const char *pszParmValue)
{
void *parm_ptr;
@@ -1769,14 +1769,14 @@ bool lp_do_service_parameter(struct loadparm_context *lp_ctx,
if (!service->copymap)
init_copymap(service);
- /* this handles the aliases - set the copymap for other
+ /* this handles the aliases - set the copymap for other
* entries with the same data pointer */
for (i = 0; parm_table[i].label; i++)
- if (parm_table[i].offset == parm_table[parmnum].offset &&
+ if (parm_table[i].offset == parm_table[parmnum].offset &&
parm_table[i].class == parm_table[parmnum].class)
service->copymap[i] = false;
- return set_variable(service, parmnum, parm_ptr, pszParmName,
+ return set_variable(service, parmnum, parm_ptr, pszParmName,
pszParmValue, lp_ctx);
}
@@ -1784,15 +1784,15 @@ bool lp_do_service_parameter(struct loadparm_context *lp_ctx,
* Process a parameter.
*/
-static bool do_parameter(const char *pszParmName, const char *pszParmValue,
+static bool do_parameter(const char *pszParmName, const char *pszParmValue,
void *userdata)
{
struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
- if (lp_ctx->bInGlobalSection)
- return lp_do_global_parameter(lp_ctx, pszParmName,
+ if (lp_ctx->bInGlobalSection)
+ return lp_do_global_parameter(lp_ctx, pszParmName,
pszParmValue);
- else
+ else
return lp_do_service_parameter(lp_ctx, lp_ctx->currentService,
pszParmName, pszParmValue);
}
@@ -1801,14 +1801,14 @@ static bool do_parameter(const char *pszParmName, const char *pszParmValue,
variable argument do parameter
*/
bool lp_do_global_parameter_var(struct loadparm_context *lp_ctx, const char *pszParmName, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
-bool lp_do_global_parameter_var(struct loadparm_context *lp_ctx,
- const char *pszParmName, const char *fmt, ...)
+bool lp_do_global_parameter_var(struct loadparm_context *lp_ctx,
+ const char *pszParmName, const char *fmt, ...)
{
char *s;
bool ret;
va_list ap;
- va_start(ap, fmt);
+ va_start(ap, fmt);
s = talloc_vasprintf(NULL, fmt, ap);
va_end(ap);
ret = lp_do_global_parameter(lp_ctx, pszParmName, s);
@@ -1822,7 +1822,7 @@ bool lp_do_global_parameter_var(struct loadparm_context *lp_ctx,
parsing code. It sets the parameter then marks the parameter as unable to be modified
by smb.conf processing
*/
-bool lp_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
+bool lp_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
const char *pszParmValue)
{
int parmnum = map_parameter(pszParmName);
@@ -1833,7 +1833,7 @@ bool lp_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
if (parmnum < 0 && strchr(pszParmName, ':')) {
/* set a parametric option */
- return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName,
+ return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName,
pszParmValue, FLAG_CMDLINE);
}
@@ -1926,7 +1926,7 @@ static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
case P_LIST:
if ((char ***)ptr && *(char ***)ptr) {
char **list = *(char ***)ptr;
-
+
for (; *list; list++)
fprintf(f, "%s%s", *list,
((*(list+1))?", ":""));
@@ -1959,7 +1959,7 @@ static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
return (*((int *)ptr1) == *((int *)ptr2));
case P_LIST:
- return str_list_equal((const char **)(*(char ***)ptr1),
+ return str_list_equal((const char **)(*(char ***)ptr1),
(const char **)(*(char ***)ptr2));
case P_STRING:
@@ -1977,11 +1977,11 @@ static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
}
/**
- * Process a new section (service).
+ * Process a new section (service).
*
* At this stage all sections are services.
* Later we'll have special sections that permit server parameters to be set.
- * Returns True on success, False on failure.
+ * Returns True on success, False on failure.
*/
static bool do_section(const char *pszSectionName, void *userdata)
@@ -2013,7 +2013,7 @@ static bool do_section(const char *pszSectionName, void *userdata)
/* issued by the post-processing of a previous section. */
DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
- if ((lp_ctx->currentService = lp_add_service(lp_ctx, &sDefault,
+ if ((lp_ctx->currentService = lp_add_service(lp_ctx, &sDefault,
pszSectionName))
== NULL) {
DEBUG(0, ("Failed to add a new service\n"));
@@ -2059,12 +2059,12 @@ static bool is_default(int i)
*Display the contents of the global structure.
*/
-static void dump_globals(struct loadparm_context *lp_ctx, FILE *f,
+static void dump_globals(struct loadparm_context *lp_ctx, FILE *f,
bool show_defaults)
{
int i;
struct param_opt *data;
-
+
fprintf(f, "# Global parameters\n[global]\n");
for (i = 0; parm_table[i].label; i++)
@@ -2078,7 +2078,7 @@ static void dump_globals(struct loadparm_context *lp_ctx, FILE *f,
fprintf(f, "\n");
}
if (lp_ctx->globals->param_opt != NULL) {
- for (data = lp_ctx->globals->param_opt; data;
+ for (data = lp_ctx->globals->param_opt; data;
data = data->next) {
fprintf(f, "\t%s = %s\n", data->key, data->value);
}
@@ -2094,7 +2094,7 @@ static void dump_a_service(struct loadparm_service * pService, FILE * f)
{
int i;
struct param_opt *data;
-
+
if (pService != &sDefault)
fprintf(f, "\n[%s]\n", pService->szService);
@@ -2127,20 +2127,20 @@ static void dump_a_service(struct loadparm_service * pService, FILE * f)
}
}
-bool lp_dump_a_parameter(struct loadparm_context *lp_ctx,
- struct loadparm_service *service,
+bool lp_dump_a_parameter(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
const char *parm_name, FILE * f)
{
struct parm_struct *parm;
void *ptr;
-
+
parm = lp_parm_struct(parm_name);
if (!parm) {
return false;
}
ptr = lp_parm_ptr(lp_ctx, service,parm);
-
+
print_parameter(parm, ptr, f);
fprintf(f, "\n");
return true;
@@ -2199,7 +2199,7 @@ struct parm_struct *lp_next_parameter(struct loadparm_context *lp_ctx, int snum,
/**
* Auto-load some home services.
*/
-static void lp_add_auto_services(struct loadparm_context *lp_ctx,
+static void lp_add_auto_services(struct loadparm_context *lp_ctx,
const char *str)
{
return;
@@ -2210,8 +2210,8 @@ static void lp_add_auto_services(struct loadparm_context *lp_ctx,
* Unload unused services.
*/
-void lp_killunused(struct loadparm_context *lp_ctx,
- struct smbsrv_connection *smb,
+void lp_killunused(struct loadparm_context *lp_ctx,
+ struct smbsrv_connection *smb,
bool (*snumused) (struct smbsrv_connection *, int))
{
int i;
@@ -2279,7 +2279,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
}
lp_do_global_parameter(lp_ctx, "share backend", "classic");
-
+
lp_do_global_parameter(lp_ctx, "server role", "standalone");
/* options that can be set on the command line must be initialised via
@@ -2315,7 +2315,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
data from the sam, but for the moment leave it in a tdb to
keep regedt32 from popping up an annoying dialog. */
lp_do_global_parameter(lp_ctx, "registry:HKEY_USERS", "hku.ldb");
-
+
/* using UTF8 by default allows us to support all chars */
lp_do_global_parameter(lp_ctx, "unix charset", "UTF8");
@@ -2333,10 +2333,10 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
lp_do_global_parameter(lp_ctx, "ncalrpc dir", dyn_NCALRPCDIR);
lp_do_global_parameter(lp_ctx, "socket address", "0.0.0.0");
- lp_do_global_parameter_var(lp_ctx, "server string",
+ lp_do_global_parameter_var(lp_ctx, "server string",
"Samba %s", SAMBA_VERSION_STRING);
- lp_do_global_parameter_var(lp_ctx, "announce version", "%d.%d",
+ lp_do_global_parameter_var(lp_ctx, "announce version", "%d.%d",
DEFAULT_MAJOR_VERSION,
DEFAULT_MINOR_VERSION);
@@ -2366,7 +2366,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
lp_do_global_parameter(lp_ctx, "LanmanAuth", "True");
lp_do_global_parameter(lp_ctx, "NTLMAuth", "True");
lp_do_global_parameter(lp_ctx, "client use spnego principal", "False");
-
+
lp_do_global_parameter(lp_ctx, "UnixExtensions", "False");
lp_do_global_parameter(lp_ctx, "PreferredMaster", "Auto");
@@ -2405,7 +2405,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
lp_do_global_parameter(lp_ctx, "tls certfile", "tls/cert.pem");
lp_do_global_parameter(lp_ctx, "tls cafile", "tls/ca.pem");
lp_do_global_parameter_var(lp_ctx, "js include", "%s", dyn_JSDIR);
- lp_do_global_parameter_var(lp_ctx, "setup directory", "%s",
+ lp_do_global_parameter_var(lp_ctx, "setup directory", "%s",
dyn_SETUPDIR);
lp_do_global_parameter(lp_ctx, "prefork children:smb", "4");
@@ -2430,7 +2430,7 @@ bool lp_load_default(struct loadparm_context *lp_ctx)
}
/**
- * Load the services array from the services file.
+ * Load the services array from the services file.
*
* Return True on success, False on failure.
*/
@@ -2442,11 +2442,11 @@ bool lp_load(struct loadparm_context *lp_ctx, const char *filename)
filename = talloc_strdup(lp_ctx, filename);
lp_ctx->szConfigFile = filename;
-
+
lp_ctx->bInGlobalSection = true;
n2 = standard_sub_basic(lp_ctx, lp_ctx->szConfigFile);
DEBUG(2, ("lp_load: refreshing parameters from %s\n", n2));
-
+
add_to_file_list(lp_ctx, lp_ctx->szConfigFile, n2);
/* We get sections first, so have to start 'behind' to make up */
@@ -2494,7 +2494,7 @@ int lp_numservices(struct loadparm_context *lp_ctx)
* Display the contents of the services array in human-readable form.
*/
-void lp_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
+void lp_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
int maxtoprint)
{
int iService;
@@ -2528,14 +2528,14 @@ struct loadparm_service *lp_servicebynum(struct loadparm_context *lp_ctx,
return lp_ctx->services[snum];
}
-struct loadparm_service *lp_service(struct loadparm_context *lp_ctx,
+struct loadparm_service *lp_service(struct loadparm_context *lp_ctx,
const char *service_name)
{
int iService;
char *serviceName;
for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--) {
- if (lp_ctx->services[iService] &&
+ if (lp_ctx->services[iService] &&
lp_ctx->services[iService]->szService) {
/*
* The substitution here is used to support %U is
@@ -2555,7 +2555,7 @@ struct loadparm_service *lp_service(struct loadparm_context *lp_ctx,
/**
- * A useful volume label function.
+ * A useful volume label function.
*/
const char *volume_label(struct loadparm_service *service)
{
@@ -2609,10 +2609,10 @@ _PUBLIC_ void reload_charcnv(struct loadparm_context *lp_ctx)
lp_ctx->iconv_convenience = smb_iconv_convenience_init_lp(lp_ctx, lp_ctx);
}
-void lp_smbcli_options(struct loadparm_context *lp_ctx,
+void lp_smbcli_options(struct loadparm_context *lp_ctx,
struct smbcli_options *options)
{
- options->max_xmit = lp_max_xmit(lp_ctx);
+ options->max_xmit = lp_max_xmit(lp_ctx);
options->max_mux = lp_maxmux(lp_ctx);
options->use_spnego = lp_nt_status_support(lp_ctx) && lp_use_spnego(lp_ctx);
options->signing = lp_client_signing(lp_ctx);
diff --git a/source4/selftest/README b/source4/selftest/README
index 3250f32ec7..e8e87c8b3f 100644
--- a/source4/selftest/README
+++ b/source4/selftest/README
@@ -39,3 +39,24 @@ The following environments are currently available:
* DOMAIN: Domain name
* REALM: Realm name
* SERVER: Name of the member server
+
+
+=============
+Running tests
+=============
+
+To run all the tests use:
+
+ make test
+
+To run a quick subset (aiming for about 1 minute of testing) run:
+
+ make quicktest
+
+To run a specific test, use this syntax
+
+ make test TESTS=testname
+
+for example
+
+ make test TESTS=samba4.BASE-DELETE
diff --git a/source4/selftest/samba4_tests.sh b/source4/selftest/samba4_tests.sh
index 2595d51177..79c5c3e994 100755
--- a/source4/selftest/samba4_tests.sh
+++ b/source4/selftest/samba4_tests.sh
@@ -253,6 +253,9 @@ plantest "blackbox.kinit" dc $bbdir/test_kinit.sh "\$SERVER" "\$USERNAME" "\$PAS
plantest "blackbox.cifsdd" dc $bbdir/test_cifsdd.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN"
plantest "blackbox.nmblookup" dc $samba4srcdir/utils/tests/test_nmblookup.sh "\$NETBIOSNAME" "\$NETBIOSALIAS" "\$SERVER" "\$SERVER_IP"
plantest "blackbox.nmblookup" member $samba4srcdir/utils/tests/test_nmblookup.sh "\$NETBIOSNAME" "\$NETBIOSALIAS" "\$SERVER" "\$SERVER_IP"
+plantest "blackbox.locktest" dc $bbdir/test_locktest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX"
+plantest "blackbox.masktest" dc $bbdir/test_masktest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX"
+plantest "blackbox.gentest" dc $bbdir/test_gentest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX"
# Tests using the "Simple" NTVFS backend
diff --git a/source4/selftest/target/Samba4.pm b/source4/selftest/target/Samba4.pm
index fba0f6a6f8..563aca876e 100644
--- a/source4/selftest/target/Samba4.pm
+++ b/source4/selftest/target/Samba4.pm
@@ -525,7 +525,7 @@ sub provision($$$$$$)
(system("rm -rf $prefix/*") == 0) or die("Unable to clean up");
mkdir($_, 0777) foreach ($privatedir, $etcdir, $piddir, $ncalrpcdir, $lockdir,
- $tmpdir);
+ $tmpdir, "$tmpdir/test1", "$tmpdir/test2");
my $localbasedn = $basedn;
@@ -569,6 +569,20 @@ sub provision($$$$$$)
posix:sharedelay = 100000
posix:eadb = $lockdir/eadb.tdb
+[test1]
+ path = $tmpdir/test1
+ read only = no
+ ntvfs handler = posix
+ posix:sharedelay = 100000
+ posix:eadb = $lockdir/eadb.tdb
+
+[test2]
+ path = $tmpdir/test2
+ read only = no
+ ntvfs handler = posix
+ posix:sharedelay = 100000
+ posix:eadb = $lockdir/eadb.tdb
+
[cifs]
read only = no
ntvfs handler = cifs
diff --git a/source4/torture/config.mk b/source4/torture/config.mk
index bcb3233ce4..5a3e3d0658 100644
--- a/source4/torture/config.mk
+++ b/source4/torture/config.mk
@@ -360,6 +360,9 @@ INSTALLDIR = BINDIR
OBJ_FILES = \
locktest.o
PRIVATE_DEPENDENCIES = \
+ LIBPOPT \
+ POPT_SAMBA \
+ POPT_CREDENTIALS \
LIBSAMBA-UTIL \
LIBCLI_SMB \
LIBSAMBA-CONFIG
diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c
index d50393baf0..d5fc855f17 100644
--- a/source4/torture/gentest.c
+++ b/source4/torture/gentest.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "lib/cmdline/popt_common.h"
#include "system/time.h"
#include "system/filesys.h"
#include "libcli/raw/request.h"
@@ -1755,6 +1756,7 @@ static void gen_setfileinfo(int instance, union smb_setfileinfo *info)
info->end_of_file_info.in.size = gen_offset();
break;
case RAW_SFILEINFO_RENAME_INFORMATION:
+ case RAW_SFILEINFO_RENAME_INFORMATION_SMB2:
info->rename_information.in.overwrite = gen_bool();
info->rename_information.in.root_fid = gen_root_fid(instance);
info->rename_information.in.new_name = gen_fname_open(instance);
@@ -2129,25 +2131,13 @@ static bool start_gentest(struct loadparm_context *lp_ctx)
}
-static void usage(void)
+static void usage(poptContext pc)
{
printf(
"Usage:\n\
- gentest2 //server1/share1 //server2/share2 [options..]\n\
- options:\n\
- -U user%%pass (can be specified twice)\n\
- -s seed\n\
- -o numops\n\
- -a (show all ops)\n\
- -A backtrack to find minimal ops\n\
- -i FILE add a list of wildcard exclusions\n\
- -O enable oplocks\n\
- -S FILE set preset seeds file\n\
- -L use preset seeds\n\
- -F fast reconnect (just close files)\n\
- -C continuous analysis mode\n\
- -X analyse even when test OK\n\
+ gentest //server1/share1 //server2/share2 [options..]\n\
");
+ poptPrintUsage(pc, stdout, 0);
}
/**
@@ -2180,105 +2170,106 @@ static bool split_unc_name(const char *unc, char **server, char **share)
int opt;
int i, username_count=0;
bool ret;
+ char *ignore_file=NULL;
struct loadparm_context *lp_ctx;
+ poptContext pc;
+ int argc_new;
+ char **argv_new;
+ enum {OPT_UNCLIST=1000};
+ struct poptOption long_options[] = {
+ POPT_AUTOHELP
+ {"seed", 0, POPT_ARG_INT, &options.seed, 0, "Seed to use for randomizer", NULL},
+ {"num-ops", 0, POPT_ARG_INT, &options.numops, 0, "num ops", NULL},
+ {"oplocks", 0, POPT_ARG_NONE, &options.use_oplocks,0, "use oplocks", NULL},
+ {"showall", 0, POPT_ARG_NONE, &options.showall, 0, "display all operations", NULL},
+ {"analyse", 0, POPT_ARG_NONE, &options.analyze, 0, "do backtrack analysis", NULL},
+ {"analysealways", 0, POPT_ARG_NONE, &options.analyze_always, 0, "analysis always", NULL},
+ {"analysecontinuous", 0, POPT_ARG_NONE, &options.analyze_continuous, 0, "analysis continuous", NULL},
+ {"ignore", 0, POPT_ARG_STRING, &ignore_file, 0, "ignore from file", NULL},
+ {"preset", 0, POPT_ARG_NONE, &options.use_preset_seeds, 0, "use preset seeds", NULL},
+ {"fast", 0, POPT_ARG_NONE, &options.fast_reconnect, 0, "use fast reconnect", NULL},
+ {"unclist", 0, POPT_ARG_STRING, NULL, OPT_UNCLIST, "unclist", NULL},
+ {"seedsfile", 0, POPT_ARG_STRING, &options.seeds_file, 0, "seed file", NULL},
+ { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "[DOMAIN/]USERNAME[%PASSWORD]" },
+ POPT_COMMON_SAMBA
+ POPT_COMMON_CONNECTION
+ POPT_COMMON_CREDENTIALS
+ POPT_COMMON_VERSION
+ { NULL }
+ };
setlinebuf(stdout);
+ options.seed = time(NULL);
+ options.numops = 1000;
+ options.max_open_handles = 20;
+ options.seeds_file = "gentest_seeds.dat";
- setup_logging("gentest", DEBUG_STDOUT);
-
- if (argc < 3 || argv[1][0] == '-') {
- usage();
- exit(1);
- }
-
- setup_logging(argv[0], DEBUG_STDOUT);
-
- for (i=0;i<NSERVERS;i++) {
- const char *share = argv[1+i];
- servers[i].credentials = cli_credentials_init(NULL);
- if (!split_unc_name(share, &servers[i].server_name, &servers[i].share_name)) {
- printf("Invalid share name '%s'\n", share);
- return -1;
- }
- }
-
- argc -= NSERVERS;
- argv += NSERVERS;
+ pc = poptGetContext("gentest", argc, (const char **) argv, long_options,
+ POPT_CONTEXT_KEEP_FIRST);
- lp_ctx = loadparm_init(talloc_autofree_context());
- lp_load(lp_ctx, dyn_CONFIGFILE);
+ poptSetOtherOptionHelp(pc, "<unc1> <unc2>");
+ lp_ctx = cmdline_lp_ctx;
servers[0].credentials = cli_credentials_init(talloc_autofree_context());
servers[1].credentials = cli_credentials_init(talloc_autofree_context());
cli_credentials_guess(servers[0].credentials, lp_ctx);
cli_credentials_guess(servers[1].credentials, lp_ctx);
- options.seed = time(NULL);
- options.numops = 1000;
- options.max_open_handles = 20;
- options.seeds_file = "gentest_seeds.dat";
-
- while ((opt = getopt(argc, argv, "U:s:o:ad:i:AOhS:LFXC")) != EOF) {
+ while((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
+ case OPT_UNCLIST:
+ lp_set_cmdline(cmdline_lp_ctx, "torture:unclist", poptGetOptArg(pc));
+ break;
case 'U':
if (username_count == 2) {
- usage();
+ usage(pc);
exit(1);
}
- cli_credentials_parse_string(servers[username_count].credentials,
- optarg, CRED_SPECIFIED);
+ cli_credentials_parse_string(servers[username_count].credentials, poptGetOptArg(pc), CRED_SPECIFIED);
username_count++;
break;
- case 'd':
- DEBUGLEVEL = atoi(optarg);
- setup_logging(NULL, DEBUG_STDOUT);
- break;
- case 's':
- options.seed = atoi(optarg);
- break;
- case 'S':
- options.seeds_file = optarg;
- break;
- case 'L':
- options.use_preset_seeds = true;
- break;
- case 'F':
- options.fast_reconnect = true;
- break;
- case 'o':
- options.numops = atoi(optarg);
- break;
- case 'O':
- options.use_oplocks = true;
- break;
- case 'a':
- options.showall = true;
- break;
- case 'A':
- options.analyze = true;
- break;
- case 'X':
- options.analyze_always = true;
- break;
- case 'C':
- options.analyze_continuous = true;
- break;
- case 'i':
- options.ignore_patterns = file_lines_load(optarg, NULL, NULL);
+ }
+ }
+
+ if (ignore_file) {
+ options.ignore_patterns = file_lines_load(ignore_file, NULL, NULL);
+ }
+
+ argv_new = discard_const_p(char *, poptGetArgs(pc));
+ argc_new = argc;
+ for (i=0; i<argc; i++) {
+ if (argv_new[i] == NULL) {
+ argc_new = i;
break;
- case 'h':
- usage();
- exit(1);
- default:
- printf("Unknown option %c (%d)\n", (char)opt, opt);
- exit(1);
}
}
- gensec_init(lp_ctx);
+ if (!(argc_new >= 3)) {
+ usage(pc);
+ exit(1);
+ }
+
+ setlinebuf(stdout);
+
+ setup_logging("gentest", DEBUG_STDOUT);
+
+ if (argc < 3 || argv[1][0] == '-') {
+ usage(pc);
+ exit(1);
+ }
+
+ setup_logging(argv[0], DEBUG_STDOUT);
+
+ for (i=0;i<NSERVERS;i++) {
+ const char *share = argv[1+i];
+ if (!split_unc_name(share, &servers[i].server_name, &servers[i].share_name)) {
+ printf("Invalid share name '%s'\n", share);
+ return -1;
+ }
+ }
if (username_count == 0) {
- usage();
+ usage(pc);
return -1;
}
if (username_count == 1) {
@@ -2287,6 +2278,8 @@ static bool split_unc_name(const char *unc, char **server, char **share)
printf("seed=%u\n", options.seed);
+ gensec_init(lp_ctx);
+
ret = start_gentest(lp_ctx);
if (ret) {
diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c
index 90e2eec2be..618568acf9 100644
--- a/source4/torture/locktest.c
+++ b/source4/torture/locktest.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "lib/cmdline/popt_common.h"
#include "system/filesys.h"
#include "system/time.h"
#include "pstring.h"
@@ -29,15 +30,15 @@
#include "libcli/resolve/resolve.h"
static int numops = 1000;
-static bool showall;
-static bool analyze;
-static bool hide_unlock_fails;
-static bool use_oplocks;
+static int showall;
+static int analyze;
+static int hide_unlock_fails;
+static int use_oplocks;
static uint_t lock_range = 100;
static uint_t lock_base = 0;
static uint_t min_length = 0;
-static bool exact_error_codes;
-static bool zero_zero;
+static int exact_error_codes;
+static int zero_zero;
#define FILENAME "\\locktest.dat"
@@ -395,7 +396,7 @@ static int retest(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
we then do random locking ops in tamdem on the 4 fnums from each
server and ensure that the results match
*/
-static void test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
+static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
{
struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
int fnum[NSERVERS][NCONNECTIONS][NFILES];
@@ -450,7 +451,12 @@ static void test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
open_files(cli, fnum);
n = retest(cli, fnum, numops);
- if (n == numops || !analyze) return;
+ if (n == numops || !analyze) {
+ if (n != numops) {
+ return 1;
+ }
+ return 0;
+ }
n++;
skip = n/2;
@@ -516,30 +522,16 @@ static void test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
(double)recorded[i].len,
recorded[i].needed);
}
+
+ return 1;
}
-static void usage(void)
+static void usage(poptContext pc)
{
- printf(
-"Usage:\n\
- locktest //server1/share1 //server2/share2 [options..]\n\
- options:\n\
- -U user%%pass (may be specified twice)\n\
- -s seed\n\
- -o numops\n\
- -u hide unlock fails\n\
- -a (show all ops)\n\
- -A analyse for minimal ops\n\
- -O use oplocks\n\
- -E enable exact error code checking\n\
- -Z enable the zero/zero lock\n\
- -R range set lock range\n\
- -B base set lock base\n\
- -M min set min lock length\n\
- -l filename unclist file\n\
-");
+ printf("Usage:\n\tlocktest //server1/share1 //server2/share2 [options..]\n");
+ poptPrintUsage(pc, stdout, 0);
}
/****************************************************************************
@@ -552,97 +544,87 @@ static void usage(void)
int seed, server;
int username_count=0;
struct loadparm_context *lp_ctx;
+ poptContext pc;
+ int argc_new, i;
+ char **argv_new;
+ enum {OPT_UNCLIST=1000};
+ struct poptOption long_options[] = {
+ POPT_AUTOHELP
+ {"seed", 0, POPT_ARG_INT, &seed, 0, "Seed to use for randomizer", NULL},
+ {"num-ops", 0, POPT_ARG_INT, &numops, 0, "num ops", NULL},
+ {"lockrange", 0, POPT_ARG_INT, &lock_range,0, "locking range", NULL},
+ {"lockbase", 0, POPT_ARG_INT, &lock_base, 0, "locking base", NULL},
+ {"minlength", 0, POPT_ARG_INT, &min_length,0, "min lock length", NULL},
+ {"hidefails", 0, POPT_ARG_NONE, &hide_unlock_fails,0,"hide unlock fails", NULL},
+ {"oplocks", 0, POPT_ARG_NONE, &use_oplocks,0, "use oplocks", NULL},
+ {"showall", 0, POPT_ARG_NONE, &showall, 0, "display all operations", NULL},
+ {"analyse", 0, POPT_ARG_NONE, &analyze, 0, "do backtrack analysis", NULL},
+ {"zerozero", 0, POPT_ARG_NONE, &zero_zero, 0, "do zero/zero lock", NULL},
+ {"exacterrors", 0, POPT_ARG_NONE, &exact_error_codes,0,"use exact error codes", NULL},
+ {"unclist", 0, POPT_ARG_STRING, NULL, OPT_UNCLIST, "unclist", NULL},
+ { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "[DOMAIN/]USERNAME[%PASSWORD]" },
+ POPT_COMMON_SAMBA
+ POPT_COMMON_CONNECTION
+ POPT_COMMON_CREDENTIALS
+ POPT_COMMON_VERSION
+ { NULL }
+ };
setlinebuf(stdout);
+ seed = time(NULL);
- setup_logging("locktest", DEBUG_STDOUT);
-
- if (argc < 3 || argv[1][0] == '-') {
- usage();
- exit(1);
- }
-
- setup_logging(argv[0], DEBUG_STDOUT);
-
- for (server=0;server<NSERVERS;server++) {
- share[server] = argv[1+server];
- all_string_sub(share[server],"/","\\",0);
- }
-
- argc -= NSERVERS;
- argv += NSERVERS;
+ pc = poptGetContext("locktest", argc, (const char **) argv, long_options,
+ POPT_CONTEXT_KEEP_FIRST);
- lp_ctx = loadparm_init(talloc_autofree_context());
- lp_load(lp_ctx, dyn_CONFIGFILE);
+ poptSetOtherOptionHelp(pc, "<unc1> <unc2>");
+ lp_ctx = cmdline_lp_ctx;
servers[0] = cli_credentials_init(talloc_autofree_context());
servers[1] = cli_credentials_init(talloc_autofree_context());
cli_credentials_guess(servers[0], lp_ctx);
cli_credentials_guess(servers[1], lp_ctx);
- seed = time(NULL);
-
- while ((opt = getopt(argc, argv, "U:s:ho:aAW:OR:B:M:EZW:l:")) != EOF) {
+ while((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
+ case OPT_UNCLIST:
+ lp_set_cmdline(cmdline_lp_ctx, "torture:unclist", poptGetOptArg(pc));
+ break;
case 'U':
if (username_count == 2) {
- usage();
+ usage(pc);
exit(1);
}
- cli_credentials_parse_string(servers[username_count],
- optarg, CRED_SPECIFIED);
+ cli_credentials_parse_string(servers[username_count], poptGetOptArg(pc), CRED_SPECIFIED);
username_count++;
break;
- case 'R':
- lock_range = strtol(optarg, NULL, 0);
- break;
- case 'B':
- lock_base = strtol(optarg, NULL, 0);
- break;
- case 'M':
- min_length = strtol(optarg, NULL, 0);
- break;
- case 's':
- seed = atoi(optarg);
- break;
- case 'u':
- hide_unlock_fails = true;
- break;
- case 'o':
- numops = atoi(optarg);
- break;
- case 'O':
- use_oplocks = true;
- break;
- case 'a':
- showall = true;
- break;
- case 'A':
- analyze = true;
- break;
- case 'Z':
- zero_zero = true;
- break;
- case 'E':
- exact_error_codes = true;
- break;
- case 'l':
- lp_set_cmdline(lp_ctx, "torture:unclist", optarg);
- break;
- case 'W':
- lp_set_cmdline(lp_ctx, "workgroup", optarg);
+ }
+ }
+
+ argv_new = discard_const_p(char *, poptGetArgs(pc));
+ argc_new = argc;
+ for (i=0; i<argc; i++) {
+ if (argv_new[i] == NULL) {
+ argc_new = i;
break;
- case 'h':
- usage();
- exit(1);
- default:
- printf("Unknown option %c (%d)\n", (char)opt, opt);
- exit(1);
}
}
+ if (!(argc_new >= 3)) {
+ usage(pc);
+ exit(1);
+ }
+
+ setup_logging("locktest", DEBUG_STDOUT);
+
+ for (server=0;server<NSERVERS;server++) {
+ share[server] = argv_new[1+server];
+ all_string_sub(share[server],"/","\\",0);
+ }
+
+ lp_ctx = cmdline_lp_ctx;
+
if (username_count == 0) {
- usage();
+ usage(pc);
return -1;
}
if (username_count == 1) {
@@ -651,15 +633,10 @@ static void usage(void)
gensec_init(lp_ctx);
- argc -= optind;
- argv += optind;
-
DEBUG(0,("seed=%u base=%d range=%d min_length=%d\n",
seed, lock_base, lock_range, min_length));
srandom(seed);
- test_locks(lp_ctx, share);
-
- return(0);
+ return test_locks(lp_ctx, share);
}
diff --git a/source4/torture/masktest.c b/source4/torture/masktest.c
index d1b853de72..ac7029aa50 100644
--- a/source4/torture/masktest.c
+++ b/source4/torture/masktest.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "lib/cmdline/popt_common.h"
#include "system/filesys.h"
#include "system/dir.h"
#include "libcli/libcli.h"
@@ -30,12 +31,10 @@
#include "dynconfig.h"
#include "libcli/resolve/resolve.h"
-static struct cli_credentials *credentials;
static bool showall = false;
static bool old_list = false;
static const char *maskchars = "<>\"?*abc.";
static const char *filechars = "abcdefghijklm.";
-static int verbose;
static int die_on_error;
static int NumLoops = 0;
static int max_length = 20;
@@ -87,13 +86,13 @@ static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx,
*share = 0;
share++;
- cli_credentials_set_workstation(credentials, "masktest", CRED_SPECIFIED);
+ cli_credentials_set_workstation(cmdline_credentials, "masktest", CRED_SPECIFIED);
status = smbcli_full_connection(NULL, &c,
server,
ports,
share, NULL,
- credentials, resolve_ctx, NULL,
+ cmdline_credentials, resolve_ctx, NULL,
options);
if (!NT_STATUS_IS_OK(status)) {
@@ -112,7 +111,7 @@ static bool f_info_hit;
static void listfn(struct clilist_file_info *f, const char *s, void *state)
{
- struct masktest_state *m = talloc_get_type(state,struct masktest_state);
+ struct masktest_state *m = (struct masktest_state *)state;
if (ISDOT(f->name)) {
resultp[0] = '+';
@@ -128,7 +127,7 @@ static void listfn(struct clilist_file_info *f, const char *s, void *state)
}
static void get_real_name(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
- char *long_name, fstring short_name)
+ char **long_name, fstring short_name)
{
const char *mask;
struct masktest_state state;
@@ -151,12 +150,12 @@ static void get_real_name(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
if (f_info_hit) {
fstrcpy(short_name, last_hit.short_name);
strlower(short_name);
- long_name = talloc_strdup(mem_ctx, last_hit.long_name);
- strlower(long_name);
+ *long_name = talloc_strdup(mem_ctx, last_hit.long_name);
+ strlower(*long_name);
}
if (*short_name == '\0') {
- fstrcpy(short_name, long_name);
+ fstrcpy(short_name, *long_name);
}
}
@@ -168,7 +167,7 @@ static void testpair(TALLOC_CTX *mem_ctx, struct smbcli_state *cli, char *mask,
char *res2;
static int count;
fstring short_name;
- char *long_name;
+ char *long_name = NULL;
struct masktest_state state;
count++;
@@ -186,7 +185,7 @@ static void testpair(TALLOC_CTX *mem_ctx, struct smbcli_state *cli, char *mask,
resultp = res1;
fstrcpy(short_name, "");
- get_real_name(mem_ctx, cli, long_name, short_name);
+ get_real_name(mem_ctx, cli, &long_name, short_name);
fstrcpy(res1, "---");
smbcli_list_new(cli->tree, mask,
FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,
@@ -241,6 +240,8 @@ static void test_mask(int argc, char *argv[],
l2 = 1 + random() % max_length;
mask = talloc_strdup(mem_ctx, "\\masktest\\");
file = talloc_strdup(mem_ctx, "\\masktest\\");
+ mask = talloc_realloc_size(mem_ctx, mask, strlen(mask)+l1+1);
+ file = talloc_realloc_size(mem_ctx, file, strlen(file)+l2+1);
l = strlen(mask);
for (i=0;i<l1;i++) {
mask[i+l] = maskchars[random() % mc_len];
@@ -269,30 +270,16 @@ static void test_mask(int argc, char *argv[],
}
-static void usage(void)
+static void usage(poptContext pc)
{
printf(
"Usage:\n\
masktest //server/share [options..]\n\
- options:\n\
- -d debuglevel\n\
- -n numloops\n\
- -W workgroup\n\
- -U user%%pass\n\
- -s seed\n\
- -l max test length\n\
- -M max protocol\n\
- -f filechars (default %s)\n\
- -m maskchars (default %s)\n\
- -v verbose mode\n\
- -E die on error\n\
- -a show all tests\n\
\n\
This program tests wildcard matching between two servers. It generates\n\
random pairs of filenames/masks and tests that they match in the same\n\
- way on the servers and internally\n\
-",
- filechars, maskchars);
+ way on the servers and internally\n");
+ poptPrintUsage(pc, stdout, 0);
}
/****************************************************************************
@@ -306,85 +293,67 @@ static void usage(void)
int seed;
struct loadparm_context *lp_ctx;
struct smbcli_options options;
+ poptContext pc;
+ int argc_new, i;
+ char **argv_new;
+ enum {OPT_UNCLIST=1000};
+ struct poptOption long_options[] = {
+ POPT_AUTOHELP
+ {"seed", 0, POPT_ARG_INT, &seed, 0, "Seed to use for randomizer", NULL},
+ {"num-ops", 0, POPT_ARG_INT, &NumLoops, 0, "num ops", NULL},
+ {"maxlength", 0, POPT_ARG_INT, &max_length,0, "maximum length", NULL},
+ {"dieonerror", 0, POPT_ARG_NONE, &die_on_error, 0, "die on errors", NULL},
+ {"showall", 0, POPT_ARG_NONE, &showall, 0, "display all operations", NULL},
+ {"oldlist", 0, POPT_ARG_NONE, &old_list, 0, "use old list call", NULL},
+ {"maskchars", 0, POPT_ARG_STRING, &maskchars, 0,"mask characters", NULL},
+ {"filechars", 0, POPT_ARG_STRING, &filechars, 0,"file characters", NULL},
+ POPT_COMMON_SAMBA
+ POPT_COMMON_CONNECTION
+ POPT_COMMON_CREDENTIALS
+ POPT_COMMON_VERSION
+ { NULL }
+ };
setlinebuf(stdout);
+ seed = time(NULL);
- setup_logging("masktest", DEBUG_STDOUT);
+ pc = poptGetContext("locktest", argc, (const char **) argv, long_options,
+ POPT_CONTEXT_KEEP_FIRST);
- if (argc < 2 || argv[1][0] == '-') {
- usage();
- exit(1);
- }
+ poptSetOtherOptionHelp(pc, "<unc>");
- share = argv[1];
-
- all_string_sub(share,"/","\\",0);
+ while((opt = poptGetNextOpt(pc)) != -1) {
+ switch (opt) {
+ case OPT_UNCLIST:
+ lp_set_cmdline(cmdline_lp_ctx, "torture:unclist", poptGetOptArg(pc));
+ break;
+ }
+ }
- setup_logging(argv[0], DEBUG_STDOUT);
+ argv_new = discard_const_p(char *, poptGetArgs(pc));
+ argc_new = argc;
+ for (i=0; i<argc; i++) {
+ if (argv_new[i] == NULL) {
+ argc_new = i;
+ break;
+ }
+ }
- argc -= 1;
- argv += 1;
+ if (!(argc_new >= 2)) {
+ usage(pc);
+ exit(1);
+ }
- lp_ctx = loadparm_init(talloc_autofree_context());
- lp_load(lp_ctx, dyn_CONFIGFILE);
+ setup_logging("masktest", DEBUG_STDOUT);
- credentials = cli_credentials_init(talloc_autofree_context());
- cli_credentials_guess(credentials, lp_ctx);
+ share = argv_new[1];
- seed = time(NULL);
+ all_string_sub(share,"/","\\",0);
- while ((opt = getopt(argc, argv, "n:d:U:s:hm:f:aoW:M:vEl:")) != EOF) {
- switch (opt) {
- case 'n':
- NumLoops = atoi(optarg);
- break;
- case 'd':
- DEBUGLEVEL = atoi(optarg);
- break;
- case 'E':
- die_on_error = 1;
- break;
- case 'v':
- verbose++;
- break;
- case 'M':
- lp_set_cmdline(lp_ctx, "max protocol", optarg);
- break;
- case 'U':
- cli_credentials_parse_string(credentials, optarg, CRED_SPECIFIED);
- break;
- case 's':
- seed = atoi(optarg);
- break;
- case 'h':
- usage();
- exit(1);
- case 'm':
- maskchars = optarg;
- break;
- case 'l':
- max_length = atoi(optarg);
- break;
- case 'f':
- filechars = optarg;
- break;
- case 'a':
- showall = 1;
- break;
- case 'o':
- old_list = true;
- break;
- default:
- printf("Unknown option %c (%d)\n", (char)opt, opt);
- exit(1);
- }
- }
+ lp_ctx = cmdline_lp_ctx;
gensec_init(lp_ctx);
- argc -= optind;
- argv += optind;
-
lp_smbcli_options(lp_ctx, &options);
cli = connect_one(lp_resolve_context(lp_ctx), share,
@@ -398,7 +367,7 @@ static void usage(void)
DEBUG(0,("seed=%d format --- --- (server, correct)\n", seed));
srandom(seed);
- test_mask(argc, argv, cli);
+ test_mask(argc_new-1, argv_new+1, cli);
return(0);
}