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 */
}
-/***************************************************************************
- 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.
return 0;
}
-/***************************************************************************
- Initialise the global parameter structure.
-***************************************************************************/
+/**
+ * Initialise the global parameter structure.
+ */
struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
{
int i;
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;
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)
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) {
}
-/*******************************************************************
- A useful volume label function.
-********************************************************************/
+/**
+ * A useful volume label function.
+ */
const char *volume_label(struct loadparm_service *service)
{
const char *ret = lp_volume(service);
}
-/***********************************************************
- 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);
}
-/*******************************************************************
- 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;
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);
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);
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;
}
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;