summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-07-07 20:33:55 +1000
committerAndrew Bartlett <abartlet@samba.org>2011-07-08 11:23:23 +0200
commit6b2749f8a9f527c1d52ba76566c661cab30b59c6 (patch)
treee2a07d6c5bd59d387c27ebd926841dad701f9a01 /source3
parent198ad4df31e5e4ab177d0abb851cb5c0c527f8d4 (diff)
downloadsamba-6b2749f8a9f527c1d52ba76566c661cab30b59c6.tar.gz
samba-6b2749f8a9f527c1d52ba76566c661cab30b59c6.tar.bz2
samba-6b2749f8a9f527c1d52ba76566c661cab30b59c6.zip
param: Add hooks to s3 parm_struct and the parameters void * pointer
This is to that the pyparam hooks can use the hooks to connect with the s3 loadparm system. This now also includes per-service parameters. Andrew Bartlett
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h5
-rw-r--r--source3/param/loadparm.c51
-rw-r--r--source3/param/loadparm_ctx.c10
3 files changed, 53 insertions, 13 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 6d901a07dc..d719bd9089 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1549,6 +1549,8 @@ int lp_server_signing(void);
int lp_client_ldap_sasl_wrapping(void);
char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def);
const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def);
+struct loadparm_service;
+const char *lp_parm_const_string_service(struct loadparm_service *service, const char *type, const char *option);
const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def);
int lp_parm_int(int snum, const char *type, const char *option, int def);
unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def);
@@ -1586,8 +1588,9 @@ const char *lp_ldap_machine_suffix(void);
const char *lp_ldap_user_suffix(void);
const char *lp_ldap_group_suffix(void);
const char *lp_ldap_idmap_suffix(void);
-struct loadparm_service;
struct parm_struct;
+/* Return a pointer to a service by name. */
+struct loadparm_service *lp_service(const char *pszServiceName);
void *lp_parm_ptr(struct loadparm_service *service, struct parm_struct *parm);
void *lp_local_ptr_by_snum(int snum, struct parm_struct *parm);
bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue);
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 045a47e107..e143726f66 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -5571,20 +5571,18 @@ static bool is_synonym_of(int parm1, int parm2, bool *inverse);
* pointer to parametrical option value if it exists or NULL otherwise. Actual
* parametrical functions are quite simple
*/
-static struct param_opt_struct *get_parametrics(int snum, const char *type,
- const char *option)
+static struct param_opt_struct *get_parametrics_by_service(struct loadparm_service *service, const char *type,
+ const char *option)
{
bool global_section = false;
char* param_key;
struct param_opt_struct *data;
- if (snum >= iNumServices) return NULL;
-
- if (snum < 0) {
+ if (service == NULL) {
data = Globals.param_opt;
global_section = true;
} else {
- data = ServicePtrs[snum]->param_opt;
+ data = service->param_opt;
}
if (asprintf(&param_key, "%s:%s", type, option) == -1) {
@@ -5618,6 +5616,25 @@ static struct param_opt_struct *get_parametrics(int snum, const char *type,
return NULL;
}
+/*
+ * 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
+ */
+static struct param_opt_struct *get_parametrics(int snum, const char *type,
+ const char *option)
+{
+ struct param_opt_struct *data;
+
+ if (snum >= iNumServices) return NULL;
+
+ if (snum < 0) {
+ return get_parametrics_by_service(NULL, type, option);
+ } else {
+ return get_parametrics_by_service(ServicePtrs[snum], type, option);
+ }
+}
+
#define MISSING_PARAMETER(name) \
DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
@@ -5723,6 +5740,17 @@ const char *lp_parm_const_string(int snum, const char *type, const char *option,
return data->value;
}
+const char *lp_parm_const_string_service(struct loadparm_service *service, const char *type, const char *option)
+{
+ struct param_opt_struct *data = get_parametrics_by_service(service, type, option);
+
+ if (data == NULL||data->value==NULL)
+ return NULL;
+
+ return data->value;
+}
+
+
/* Return parametric option from a given service. Type is a part of option before ':' */
/* Parametric option has following syntax: 'Type: option = value' */
@@ -6525,6 +6553,17 @@ static int getservicebyname(const char *pszServiceName, struct loadparm_service
return (iService);
}
+/* Return a pointer to a service by name. Unlike getservicebyname, it does not copy the service */
+struct loadparm_service *lp_service(const char *pszServiceName)
+{
+ int iService = getservicebyname(pszServiceName, NULL);
+ if (iService == -1 || !LP_SNUM_OK(iService)) {
+ return NULL;
+ }
+ return ServicePtrs[iService];
+}
+
+
/***************************************************************************
Copy a service structure to another.
If pcopymapDest is NULL then copy all fields
diff --git a/source3/param/loadparm_ctx.c b/source3/param/loadparm_ctx.c
index e80f6f1844..0136c8bef4 100644
--- a/source3/param/loadparm_ctx.c
+++ b/source3/param/loadparm_ctx.c
@@ -20,18 +20,16 @@
#include "includes.h"
#include "../source4/param/s3_param.h"
-static const char *get_parametric(const char *type, const char *option)
-{
- return lp_parm_const_string(-1, type, option, NULL);
-}
-
/* These are in the order that they appear in the s4 loadparm file.
* All of the s4 loadparm functions should be here eventually, once
* they are implemented in the s3 loadparm, have the same format (enum
* values in particular) and defaults. */
static const struct loadparm_s3_context s3_fns =
{
- .get_parametric = get_parametric,
+ .get_parametric = lp_parm_const_string_service,
+ .get_parm_struct = lp_get_parameter,
+ .get_parm_ptr = lp_parm_ptr,
+ .get_service = lp_service,
.server_role = lp_server_role,