svn commit: samba r26350 - in branches/SAMBA_4_0: . source/lib/cmdline source/param source/param/tests source/smb_server/smb

jelmer at samba.org jelmer at samba.org
Sat Dec 8 23:32:30 GMT 2007


Author: jelmer
Date: 2007-12-08 23:32:27 +0000 (Sat, 08 Dec 2007)
New Revision: 26350

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=26350

Log:
More tests.
Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/lib/cmdline/popt_common.c
   branches/SAMBA_4_0/source/param/loadparm.c
   branches/SAMBA_4_0/source/param/tests/loadparm.c
   branches/SAMBA_4_0/source/smb_server/smb/signing.c


Changeset:

Property changes on: branches/SAMBA_4_0
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/SAMBA_4_0/source/lib/cmdline/popt_common.c
===================================================================
--- branches/SAMBA_4_0/source/lib/cmdline/popt_common.c	2007-12-08 23:32:23 UTC (rev 26349)
+++ branches/SAMBA_4_0/source/lib/cmdline/popt_common.c	2007-12-08 23:32:27 UTC (rev 26350)
@@ -62,11 +62,11 @@
 	struct loadparm_context *lp_ctx = global_loadparm; /* FIXME: allow overriding */
 
 	if (reason == POPT_CALLBACK_REASON_POST) {
-		if (!lp_loaded()) {
+		if (lp_ctx == NULL) {
 			if (getenv("SMB_CONF_PATH"))
-				lp_load(talloc_autofree_context(), getenv("SMB_CONF_PATH"), NULL);
+				lp_load(talloc_autofree_context(), getenv("SMB_CONF_PATH"), &lp_ctx);
 			else
-				lp_load(talloc_autofree_context(), dyn_CONFIGFILE, NULL);
+				lp_load(talloc_autofree_context(), dyn_CONFIGFILE, &lp_ctx);
 		}
 		/* Hook any 'every Samba program must do this, after
 		 * the smb.conf is setup' functions here */

Modified: branches/SAMBA_4_0/source/param/loadparm.c
===================================================================
--- branches/SAMBA_4_0/source/param/loadparm.c	2007-12-08 23:32:23 UTC (rev 26349)
+++ branches/SAMBA_4_0/source/param/loadparm.c	2007-12-08 23:32:27 UTC (rev 26350)
@@ -2198,25 +2198,16 @@
 }
 
 
-/***************************************************************************
- Auto-load some home services.
-***************************************************************************/
-
+/**
+ * Auto-load some home services.
+ */
 static void lp_add_auto_services(struct loadparm_context *lp_ctx, 
 				 const char *str)
 {
 	return;
 }
 
-/***************************************************************************
- Have we loaded a services file yet?
-***************************************************************************/
 
-bool lp_loaded(void)
-{
-	return (global_loadparm != NULL);
-}
-
 /***************************************************************************
  Unload unused services.
 ***************************************************************************/
@@ -2255,9 +2246,9 @@
 	return 0;
 }
 
-/***************************************************************************
- Initialise the global parameter structure.
-***************************************************************************/
+/**
+ * Initialise the global parameter structure.
+ */
 struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
 {
 	int i;
@@ -2423,10 +2414,11 @@
 	return lp_ctx;
 }
 
-/***************************************************************************
- Load the services array from the services file. Return True on success, 
- False on failure.
-***************************************************************************/
+/**
+ * Load the services array from the services file. 
+ *
+ * Return True on success, False on failure.
+ */
 bool lp_load(TALLOC_CTX *mem_ctx, const char *filename, struct loadparm_context **ret_lp)
 {
 	char *n2;
@@ -2481,18 +2473,18 @@
 	return bRetval;
 }
 
-/***************************************************************************
- Return the max number of services.
-***************************************************************************/
+/**
+ * Return the max number of services.
+ */
 
 int lp_numservices(struct loadparm_context *lp_ctx)
 {
 	return lp_ctx->iNumServices;
 }
 
-/***************************************************************************
-Display the contents of the services array in human-readable form.
-***************************************************************************/
+/**
+ * Display the contents of the services array in human-readable form.
+ */
 
 void lp_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults, 
 	     int maxtoprint)
@@ -2510,10 +2502,9 @@
 		lp_dump_one(f, show_defaults, lp_ctx->services[iService]);
 }
 
-/***************************************************************************
-Display the contents of one service in human-readable form.
-***************************************************************************/
-
+/**
+ * Display the contents of one service in human-readable form.
+ */
 void lp_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service)
 {
 	if (service != NULL) {
@@ -2555,9 +2546,9 @@
 }
 
 
-/*******************************************************************
- A useful volume label function. 
-********************************************************************/
+/**
+ * A useful volume label function. 
+ */
 const char *volume_label(struct loadparm_service *service)
 {
 	const char *ret = lp_volume(service);
@@ -2567,15 +2558,9 @@
 }
 
 
-/***********************************************************
- If we are PDC then prefer us as DMB
-************************************************************/
-
-bool lp_domain_logons(struct loadparm_context *lp_ctx)
-{
-	return (lp_server_role(lp_ctx) == ROLE_DOMAIN_CONTROLLER);
-}
-
+/**
+ * If we are PDC then prefer us as DMB
+ */
 const char *lp_printername(struct loadparm_service *service)
 {
 	const char *ret = _lp_printername(service);
@@ -2586,10 +2571,9 @@
 }
 
 
-/*******************************************************************
- Return the max print jobs per queue.
-********************************************************************/
-
+/**
+ * Return the max print jobs per queue.
+ */
 int lp_maxprintjobs(struct loadparm_service *service)
 {
 	int maxjobs = (service != NULL) ? service->iMaxPrintJobs : sDefault.iMaxPrintJobs;

Modified: branches/SAMBA_4_0/source/param/tests/loadparm.c
===================================================================
--- branches/SAMBA_4_0/source/param/tests/loadparm.c	2007-12-08 23:32:23 UTC (rev 26349)
+++ branches/SAMBA_4_0/source/param/tests/loadparm.c	2007-12-08 23:32:27 UTC (rev 26350)
@@ -37,6 +37,35 @@
 	return true;
 }
 
+static bool test_set_cmdline(struct torture_context *tctx)
+{
+	struct loadparm_context *lp_ctx = loadparm_init(tctx);
+	torture_assert(tctx, lp_set_cmdline(lp_ctx, "workgroup", "werkgroep"), "lp_set_cmdline failed");
+	torture_assert(tctx, lp_do_global_parameter(lp_ctx, "workgroup", "barbla"), "lp_set_option failed");
+	torture_assert_str_equal(tctx, "WERKGROEP", lp_workgroup(lp_ctx), "workgroup");
+	return true;
+}
+
+static bool test_do_global_parameter(struct torture_context *tctx)
+{
+	struct loadparm_context *lp_ctx = loadparm_init(tctx);
+	torture_assert(tctx, lp_do_global_parameter(lp_ctx, "workgroup", "werkgroep42"), 
+		       "lp_set_cmdline failed");
+	torture_assert_str_equal(tctx, lp_workgroup(lp_ctx), "WERKGROEP42", "workgroup");
+	return true;
+}
+
+
+static bool test_do_global_parameter_var(struct torture_context *tctx)
+{
+	struct loadparm_context *lp_ctx = loadparm_init(tctx);
+	torture_assert(tctx, lp_do_global_parameter_var(lp_ctx, "workgroup", "werk%s%d", "groep", 42), 
+		       "lp_set_cmdline failed");
+	torture_assert_str_equal(tctx, lp_workgroup(lp_ctx), "WERKGROEP42", "workgroup");
+	return true;
+}
+
+
 static bool test_set_option_invalid(struct torture_context *tctx)
 {
 	struct loadparm_context *lp_ctx = loadparm_init(tctx);
@@ -108,12 +137,21 @@
 	return true;
 }
 
+static bool test_lp_service(struct torture_context *tctx)
+{
+	struct loadparm_context *lp_ctx = loadparm_init(tctx);
+	struct loadparm_service *service = lp_add_service(lp_ctx, &sDefault, "foo");
+	torture_assert(tctx, service == lp_service(lp_ctx, "foo"), "invalid service");
+	return true;
+}
+
 struct torture_suite *torture_local_loadparm(TALLOC_CTX *mem_ctx)
 {
 	struct torture_suite *suite = torture_suite_create(mem_ctx, "LOADPARM");
 
 	torture_suite_add_simple_test(suite, "create", test_create);
 	torture_suite_add_simple_test(suite, "set_option", test_set_option);
+	torture_suite_add_simple_test(suite, "set_cmdline", test_set_cmdline);
 	torture_suite_add_simple_test(suite, "set_option_invalid", test_set_option_invalid);
 	torture_suite_add_simple_test(suite, "set_option_parametric", test_set_option_parametric);
 	torture_suite_add_simple_test(suite, "set_lp_parm_double", test_lp_parm_double);
@@ -121,6 +159,9 @@
 	torture_suite_add_simple_test(suite, "set_lp_parm_int", test_lp_parm_int);
 	torture_suite_add_simple_test(suite, "set_lp_parm_bytes", test_lp_parm_bytes);
 	torture_suite_add_simple_test(suite, "service_parameter", test_lp_do_service_parameter);
+	torture_suite_add_simple_test(suite, "lp_service", test_lp_service);
+	torture_suite_add_simple_test(suite, "do_global_parameter_var", test_do_global_parameter_var);
+	torture_suite_add_simple_test(suite, "do_global_parameter", test_do_global_parameter);
 
 	return suite;
 }

Modified: branches/SAMBA_4_0/source/smb_server/smb/signing.c
===================================================================
--- branches/SAMBA_4_0/source/smb_server/smb/signing.c	2007-12-08 23:32:23 UTC (rev 26349)
+++ branches/SAMBA_4_0/source/smb_server/smb/signing.c	2007-12-08 23:32:27 UTC (rev 26350)
@@ -114,7 +114,7 @@
 		smb_conn->signing.mandatory_signing = true;
 		break;
 	case SMB_SIGNING_AUTO:
-		if (lp_domain_logons(smb_conn->lp_ctx)) {
+		if (lp_server_role(smb_conn->lp_ctx) == ROLE_DOMAIN_CONTROLLER) {
 			smb_conn->signing.allow_smb_signing = true;
 		} else {
 			smb_conn->signing.allow_smb_signing = false;



More information about the samba-cvs mailing list