diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-02-28 20:04:58 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-02-28 20:04:58 +0100 |
commit | 2ba62662f8e2578153be3125eb557b9349ccfd3b (patch) | |
tree | 829349576e6fa8431573abed7676b2cd61b98485 | |
parent | fc6bc92e116d3891671a77bc4564047eefd69f95 (diff) | |
download | samba-2ba62662f8e2578153be3125eb557b9349ccfd3b.tar.gz samba-2ba62662f8e2578153be3125eb557b9349ccfd3b.tar.xz samba-2ba62662f8e2578153be3125eb557b9349ccfd3b.zip |
Remove sDefault as static variable.
(This used to be commit 16f36ce499e93860dd535034a584ec2b93e7a172)
-rw-r--r-- | source4/param/generic.c | 7 | ||||
-rw-r--r-- | source4/param/loadparm.c | 128 | ||||
-rw-r--r-- | source4/param/loadparm.h | 3 | ||||
-rw-r--r-- | source4/param/param.h | 1 | ||||
-rw-r--r-- | source4/param/param.i | 7 | ||||
-rw-r--r-- | source4/param/param.py | 1 | ||||
-rw-r--r-- | source4/param/param_wrap.c | 111 | ||||
-rw-r--r-- | source4/param/share_classic.c | 48 | ||||
-rw-r--r-- | source4/param/tests/loadparm.c | 4 | ||||
-rwxr-xr-x | source4/script/mkproto.pl | 2 | ||||
-rw-r--r-- | source4/scripting/python/config.mk | 2 | ||||
-rw-r--r-- | source4/smbd/service_stream.c | 2 | ||||
-rw-r--r-- | source4/utils/testparm.c | 10 |
13 files changed, 188 insertions, 138 deletions
diff --git a/source4/param/generic.c b/source4/param/generic.c index 2327000fc91..b86e3ad2342 100644 --- a/source4/param/generic.c +++ b/source4/param/generic.c @@ -259,11 +259,8 @@ int param_use(struct loadparm_context *lp_ctx, struct param_context *ctx) struct loadparm_service *service = lp_service(lp_ctx, section->name); if (service == NULL) - service = lp_add_service(lp_ctx, &sDefault, section->name); - lp_do_service_parameter(lp_ctx, - service, - param->key, - param->value); + service = lp_add_service(lp_ctx, lp_default_service(lp_ctx), section->name); + lp_do_service_parameter(lp_ctx, service, param->key, param->value); } } } diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c index bad90fc74a9..d94ab92ac94 100644 --- a/source4/param/loadparm.c +++ b/source4/param/loadparm.c @@ -224,44 +224,11 @@ struct loadparm_service }; -/* This is a default service used to prime a services structure */ -struct loadparm_service sDefault = { - .szService = NULL, - .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, - .iCreate_force_mode = 0000, - .iDir_mask = 0755, - .iDir_force_mode = 0000, - .copymap = NULL, - .bMSDfsRoot = false, - .bStrictSync = false, - .bCIFileSystem = false, -}; - 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, const char *pszParmValue, char **ptr); @@ -521,11 +488,13 @@ static struct parm_struct parm_table[] = { {NULL, P_BOOL, P_NONE, 0, NULL, NULL} }; + /* local variables */ struct loadparm_context { const char *szConfigFile; struct loadparm_global *globals; struct loadparm_service **services; + struct loadparm_service *sDefault; int iNumServices; struct loadparm_service *currentService; bool bInGlobalSection; @@ -540,6 +509,10 @@ struct loadparm_context { }; +struct loadparm_service *lp_default_service(struct loadparm_context *lp_ctx) +{ + return lp_ctx->sDefault; +} /* return the parameter table @@ -619,15 +592,13 @@ static const char *lp_string(const char *s) int fn_name(struct loadparm_context *lp_ctx) {return lp_ctx->globals->var_name;} #define FN_LOCAL_STRING(fn_name,val) \ - const char *fn_name(struct loadparm_service *service) {return(lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault.val)));} -#define FN_LOCAL_CONST_STRING(fn_name,val) \ - const char *fn_name(struct loadparm_service *service) {return (const char *)(service != NULL && service->val != NULL) ? service->val : sDefault.val;} + const char *fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return(lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val)));} #define FN_LOCAL_LIST(fn_name,val) \ - const char **fn_name(struct loadparm_service *service) {return(const char **)(service != NULL && service->val != NULL? service->val : sDefault.val);} + const char **fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return(const char **)(service != NULL && service->val != NULL? service->val : sDefault->val);} #define FN_LOCAL_BOOL(fn_name,val) \ - bool fn_name(struct loadparm_service *service) {return((service != NULL)? service->val : sDefault.val);} + bool fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return((service != NULL)? service->val : sDefault->val);} #define FN_LOCAL_INTEGER(fn_name,val) \ - int fn_name(struct loadparm_service *service) {return((service != NULL)? service->val : sDefault.val);} + int fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return((service != NULL)? service->val : sDefault->val);} _PUBLIC_ FN_GLOBAL_INTEGER(lp_server_role, server_role) _PUBLIC_ FN_GLOBAL_LIST(lp_smb_ports, smb_ports) @@ -722,8 +693,11 @@ _PUBLIC_ FN_GLOBAL_INTEGER(lp_security, security) _PUBLIC_ FN_GLOBAL_BOOL(lp_paranoid_server_security, paranoid_server_security) _PUBLIC_ FN_GLOBAL_INTEGER(lp_announce_as, announce_as) _PUBLIC_ FN_GLOBAL_LIST(lp_js_include, jsInclude) -_PUBLIC_ FN_LOCAL_STRING(lp_servicename, szService) -_PUBLIC_ FN_LOCAL_CONST_STRING(lp_const_servicename, szService) +const char *lp_servicename(const struct loadparm_service *service) +{ + return lp_string((const char *)service->szService); +} + _PUBLIC_ FN_LOCAL_STRING(lp_pathname, szPath) static FN_LOCAL_STRING(_lp_printername, szPrintername) _PUBLIC_ FN_LOCAL_LIST(lp_hostsallow, szHostsallow) @@ -999,11 +973,11 @@ bool lp_parm_bool(struct loadparm_context *lp_ctx, * Initialise a service to the defaults. */ -static struct loadparm_service *init_service(TALLOC_CTX *mem_ctx) +static struct loadparm_service *init_service(TALLOC_CTX *mem_ctx, struct loadparm_service *sDefault) { struct loadparm_service *pservice = talloc_zero(mem_ctx, struct loadparm_service); - copy_service(pservice, &sDefault, NULL); + copy_service(pservice, sDefault, NULL); return pservice; } @@ -1085,7 +1059,7 @@ struct loadparm_service *lp_add_service(struct loadparm_context *lp_ctx, lp_ctx->iNumServices++; } - lp_ctx->services[i] = init_service(lp_ctx->services); + lp_ctx->services[i] = init_service(lp_ctx->services, lp_ctx->sDefault); if (lp_ctx->services[i] == NULL) { DEBUG(0,("lp_add_service: out of memory!\n")); return NULL; @@ -1114,10 +1088,10 @@ bool lp_add_home(struct loadparm_context *lp_ctx, return false; if (!(*(default_service->szPath)) - || strequal(default_service->szPath, sDefault.szPath)) { + || strequal(default_service->szPath, lp_ctx->sDefault->szPath)) { service->szPath = talloc_strdup(service, pszHomedir); } else { - service->szPath = string_sub_talloc(service, lp_pathname(default_service),"%H", pszHomedir); + service->szPath = string_sub_talloc(service, lp_pathname(default_service, lp_ctx->sDefault), "%H", pszHomedir); } if (!(*(service->comment))) { @@ -1139,7 +1113,7 @@ bool lp_add_home(struct loadparm_context *lp_ctx, 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); + struct loadparm_service *service = lp_add_service(lp_ctx, lp_ctx->sDefault, name); if (service == NULL) return false; @@ -1243,7 +1217,7 @@ void *lp_parm_ptr(struct loadparm_context *lp_ctx, { if (service == NULL) { if (parm->class == P_LOCAL) - return ((char *)&sDefault)+parm->offset; + return ((char *)lp_ctx->sDefault)+parm->offset; else if (parm->class == P_GLOBAL) return ((char *)lp_ctx->globals)+parm->offset; else return NULL; @@ -2019,7 +1993,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, lp_ctx->sDefault, pszSectionName)) == NULL) { DEBUG(0, ("Failed to add a new service\n")); @@ -2032,12 +2006,12 @@ static bool do_section(const char *pszSectionName, void *userdata) /** - * Determine if a partcular base parameter is currentl set to the default value. + * Determine if a particular base parameter is currently set to the default value. */ -static bool is_default(int i) +static bool is_default(struct loadparm_service *sDefault, int i) { - void *def_ptr = ((char *)&sDefault) + parm_table[i].offset; + void *def_ptr = ((char *)sDefault) + parm_table[i].offset; if (!defaults_saved) return false; switch (parm_table[i].type) { @@ -2096,12 +2070,12 @@ static void dump_globals(struct loadparm_context *lp_ctx, FILE *f, * Display the contents of a single services record. */ -static void dump_a_service(struct loadparm_service * pService, FILE * f) +static void dump_a_service(struct loadparm_service * pService, struct loadparm_service *sDefault, FILE * f) { int i; struct param_opt *data; - if (pService != &sDefault) + if (pService != sDefault) fprintf(f, "\n[%s]\n", pService->szService); for (i = 0; parm_table[i].label; i++) @@ -2109,14 +2083,14 @@ static void dump_a_service(struct loadparm_service * pService, FILE * f) parm_table[i].offset != -1 && (*parm_table[i].label != '-') && (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) { - if (pService == &sDefault) { - if (defaults_saved && is_default(i)) + if (pService == sDefault) { + if (defaults_saved && is_default(sDefault, i)) continue; } else { if (equal_parameter(parm_table[i].type, ((char *)pService) + parm_table[i].offset, - ((char *)&sDefault) + + ((char *)sDefault) + parm_table[i].offset)) continue; } @@ -2189,7 +2163,7 @@ struct parm_struct *lp_next_parameter(struct loadparm_context *lp_ctx, int snum, !equal_parameter(parm_table[*i].type, ((char *)pService) + parm_table[*i].offset, - ((char *)&sDefault) + + ((char *)lp_ctx->sDefault) + parm_table[*i].offset)) { return &parm_table[(*i)++]; @@ -2266,6 +2240,18 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx) talloc_set_destructor(lp_ctx, lp_destructor); lp_ctx->bInGlobalSection = true; lp_ctx->globals = talloc_zero(lp_ctx, struct loadparm_global); + lp_ctx->sDefault = talloc_zero(lp_ctx, struct loadparm_service); + + lp_ctx->sDefault->iMaxPrintJobs = 1000; + lp_ctx->sDefault->bAvailable = true; + lp_ctx->sDefault->bBrowseable = true; + lp_ctx->sDefault->bRead_only = true; + lp_ctx->sDefault->bMap_archive = true; + lp_ctx->sDefault->bStrictLocking = true; + lp_ctx->sDefault->iCreate_mask = 0744; + lp_ctx->sDefault->iCreate_force_mode = 0000; + lp_ctx->sDefault->iDir_mask = 0755; + lp_ctx->sDefault->iDir_force_mode = 0000; DEBUG(3, ("Initialising global parameters\n")); @@ -2276,7 +2262,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx) !(lp_ctx->flags[i] & FLAG_CMDLINE)) { char **r; if (parm_table[i].class == P_LOCAL) { - r = (char **)(((char *)&sDefault) + parm_table[i].offset); + r = (char **)(((char *)lp_ctx->sDefault) + parm_table[i].offset); } else { r = (char **)(((char *)lp_ctx->globals) + parm_table[i].offset); } @@ -2512,21 +2498,21 @@ void lp_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults, dump_globals(lp_ctx, f, show_defaults); - dump_a_service(&sDefault, f); + dump_a_service(lp_ctx->sDefault, lp_ctx->sDefault, f); for (iService = 0; iService < maxtoprint; iService++) - lp_dump_one(f, show_defaults, lp_ctx->services[iService]); + lp_dump_one(f, show_defaults, lp_ctx->services[iService], lp_ctx->sDefault); } /** * Display the contents of one service in human-readable form. */ -void lp_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service) +void lp_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service, struct loadparm_service *sDefault) { if (service != NULL) { if (service->szService[0] == '\0') return; - dump_a_service(service, f); + dump_a_service(service, sDefault, f); } } @@ -2565,9 +2551,9 @@ struct loadparm_service *lp_service(struct loadparm_context *lp_ctx, /** * A useful volume label function. */ -const char *volume_label(struct loadparm_service *service) +const char *volume_label(struct loadparm_service *service, struct loadparm_service *sDefault) { - const char *ret = lp_volume(service); + const char *ret = lp_volume(service, sDefault); if (!*ret) return lp_servicename(service); return ret; @@ -2577,11 +2563,11 @@ const char *volume_label(struct loadparm_service *service) /** * If we are PDC then prefer us as DMB */ -const char *lp_printername(struct loadparm_service *service) +const char *lp_printername(struct loadparm_service *service, struct loadparm_service *sDefault) { - const char *ret = _lp_printername(service); + const char *ret = _lp_printername(service, sDefault); if (ret == NULL || (ret != NULL && *ret == '\0')) - ret = lp_const_servicename(service); + ret = lp_servicename(service); return ret; } @@ -2590,9 +2576,9 @@ const char *lp_printername(struct loadparm_service *service) /** * Return the max print jobs per queue. */ -int lp_maxprintjobs(struct loadparm_service *service) +int lp_maxprintjobs(struct loadparm_service *service, struct loadparm_service *sDefault) { - int maxjobs = (service != NULL) ? service->iMaxPrintJobs : sDefault.iMaxPrintJobs; + int maxjobs = (service != NULL) ? service->iMaxPrintJobs : sDefault->iMaxPrintJobs; if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID) maxjobs = PRINT_MAX_JOBID - 1; diff --git a/source4/param/loadparm.h b/source4/param/loadparm.h index 842e1ce4376..cd3c0b9595d 100644 --- a/source4/param/loadparm.h +++ b/source4/param/loadparm.h @@ -59,6 +59,9 @@ struct parm_struct { } def; }; + + + #define FLAG_DEFAULT 0x0001 /* this option was a default */ #define FLAG_CMDLINE 0x0002 /* this option was set from the command line */ diff --git a/source4/param/param.h b/source4/param/param.h index 098a73deec5..84f864edaab 100644 --- a/source4/param/param.h +++ b/source4/param/param.h @@ -64,6 +64,5 @@ struct smbcli_options; #include "param/proto.h" extern struct loadparm_context *global_loadparm; -extern struct loadparm_service sDefault; #endif /* _PARAM_H */ diff --git a/source4/param/param.i b/source4/param/param.i index 7322302117e..77d781d6ffe 100644 --- a/source4/param/param.i +++ b/source4/param/param.i @@ -49,6 +49,7 @@ typedef struct param_opt param_opt; typedef struct loadparm_context { %extend { loadparm_context(TALLOC_CTX *mem_ctx) { return loadparm_init(mem_ctx); } + struct loadparm_service *default_service() { return lp_default_service($self); } bool load(const char *filename) { return lp_load($self, filename); } bool load_default() { return lp_load_default($self); } #ifdef SWIGPYTHON @@ -167,9 +168,9 @@ typedef struct loadparm_context { typedef struct loadparm_service { %extend { - const char *volume_label() { return volume_label($self); } - const char *printername() { return lp_printername($self); } - int maxprintjobs() { return lp_maxprintjobs($self); } + const char *volume_label(struct loadparm_service *sDefault) { return volume_label($self, sDefault); } + const char *printername(struct loadparm_service *sDefault) { return lp_printername($self, sDefault); } + int maxprintjobs(struct loadparm_service *sDefault) { return lp_maxprintjobs($self, sDefault); } } } loadparm_service; diff --git a/source4/param/param.py b/source4/param/param.py index 5adf7a4ecc3..025acc6be1e 100644 --- a/source4/param/param.py +++ b/source4/param/param.py @@ -63,6 +63,7 @@ class LoadParm(object): def __init__(self, *args, **kwargs): _param.LoadParm_swiginit(self,_param.new_LoadParm(*args, **kwargs)) __swig_destroy__ = _param.delete_LoadParm +LoadParm.default_service = new_instancemethod(_param.LoadParm_default_service,None,LoadParm) LoadParm.load = new_instancemethod(_param.LoadParm_load,None,LoadParm) LoadParm.load_default = new_instancemethod(_param.LoadParm_load_default,None,LoadParm) LoadParm.__len__ = new_instancemethod(_param.LoadParm___len__,None,LoadParm) diff --git a/source4/param/param_wrap.c b/source4/param/param_wrap.c index 275e2d67ecb..e74f9026453 100644 --- a/source4/param/param_wrap.c +++ b/source4/param/param_wrap.c @@ -2526,6 +2526,7 @@ typedef struct param_section param_section; typedef struct param_opt param_opt; SWIGINTERN loadparm_context *new_loadparm_context(TALLOC_CTX *mem_ctx){ return loadparm_init(mem_ctx); } +SWIGINTERN struct loadparm_service *loadparm_context_default_service(loadparm_context *self){ return lp_default_service(self); } SWIGINTERN swig_type_info* SWIG_pchar_descriptor(void) @@ -2742,9 +2743,9 @@ SWIGINTERN PyObject *loadparm_context_get(loadparm_context *self,char const *par return Py_None; } SWIGINTERN void delete_loadparm_context(loadparm_context *self){ talloc_free(self); } -SWIGINTERN char const *loadparm_service_volume_label(loadparm_service *self){ return volume_label(self); } -SWIGINTERN char const *loadparm_service_printername(loadparm_service *self){ return lp_printername(self); } -SWIGINTERN int loadparm_service_maxprintjobs(loadparm_service *self){ return lp_maxprintjobs(self); } +SWIGINTERN char const *loadparm_service_volume_label(loadparm_service *self,struct loadparm_service *sDefault){ return volume_label(self, sDefault); } +SWIGINTERN char const *loadparm_service_printername(loadparm_service *self,struct loadparm_service *sDefault){ return lp_printername(self, sDefault); } +SWIGINTERN int loadparm_service_maxprintjobs(loadparm_service *self,struct loadparm_service *sDefault){ return lp_maxprintjobs(self, sDefault); } SWIGINTERN param *new_param(TALLOC_CTX *mem_ctx){ return param_init(mem_ctx); } SWIGINTERN int param_set(param *self,char const *parameter,PyObject *ob,char const *section_name){ struct param_opt *opt = param_get_add(self, parameter, section_name); @@ -2799,6 +2800,34 @@ fail: } +SWIGINTERN PyObject *_wrap_LoadParm_default_service(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + loadparm_context *arg1 = (loadparm_context *) 0 ; + struct loadparm_service *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char * kwnames[] = { + (char *) "self", NULL + }; + + arg1 = loadparm_init(NULL); + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:LoadParm_default_service",kwnames,&obj0)) SWIG_fail; + if (obj0) { + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LoadParm_default_service" "', argument " "1"" of type '" "loadparm_context *""'"); + } + arg1 = (loadparm_context *)(argp1); + } + result = (struct loadparm_service *)loadparm_context_default_service(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_loadparm_service, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_LoadParm_load(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; loadparm_context *arg1 = (loadparm_context *) 0 ; @@ -3241,22 +3270,33 @@ SWIGINTERN PyObject *LoadParm_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject return SWIG_Python_InitShadowInstance(args); } -SWIGINTERN PyObject *_wrap_loadparm_service_volume_label(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_loadparm_service_volume_label(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; loadparm_service *arg1 = (loadparm_service *) 0 ; + struct loadparm_service *arg2 = (struct loadparm_service *) 0 ; char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject *swig_obj[1] ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char * kwnames[] = { + (char *) "self",(char *) "sDefault", NULL + }; - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_loadparm_service, 0 | 0 ); + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:loadparm_service_volume_label",kwnames,&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_service, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "loadparm_service_volume_label" "', argument " "1"" of type '" "loadparm_service *""'"); } arg1 = (loadparm_service *)(argp1); - result = (char *)loadparm_service_volume_label(arg1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_loadparm_service, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "loadparm_service_volume_label" "', argument " "2"" of type '" "struct loadparm_service *""'"); + } + arg2 = (struct loadparm_service *)(argp2); + result = (char *)loadparm_service_volume_label(arg1,arg2); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: @@ -3264,22 +3304,33 @@ fail: } -SWIGINTERN PyObject *_wrap_loadparm_service_printername(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_loadparm_service_printername(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; loadparm_service *arg1 = (loadparm_service *) 0 ; + struct loadparm_service *arg2 = (struct loadparm_service *) 0 ; char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject *swig_obj[1] ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char * kwnames[] = { + (char *) "self",(char *) "sDefault", NULL + }; - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_loadparm_service, 0 | 0 ); + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:loadparm_service_printername",kwnames,&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_service, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "loadparm_service_printername" "', argument " "1"" of type '" "loadparm_service *""'"); } arg1 = (loadparm_service *)(argp1); - result = (char *)loadparm_service_printername(arg1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_loadparm_service, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "loadparm_service_printername" "', argument " "2"" of type '" "struct loadparm_service *""'"); + } + arg2 = (struct loadparm_service *)(argp2); + result = (char *)loadparm_service_printername(arg1,arg2); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: @@ -3287,22 +3338,33 @@ fail: } -SWIGINTERN PyObject *_wrap_loadparm_service_maxprintjobs(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_loadparm_service_maxprintjobs(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; loadparm_service *arg1 = (loadparm_service *) 0 ; + struct loadparm_service *arg2 = (struct loadparm_service *) 0 ; int result; void *argp1 = 0 ; int res1 = 0 ; - PyObject *swig_obj[1] ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char * kwnames[] = { + (char *) "self",(char *) "sDefault", NULL + }; - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_loadparm_service, 0 | 0 ); + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:loadparm_service_maxprintjobs",kwnames,&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_service, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "loadparm_service_maxprintjobs" "', argument " "1"" of type '" "loadparm_service *""'"); } arg1 = (loadparm_service *)(argp1); - result = (int)loadparm_service_maxprintjobs(arg1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_loadparm_service, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "loadparm_service_maxprintjobs" "', argument " "2"" of type '" "struct loadparm_service *""'"); + } + arg2 = (struct loadparm_service *)(argp2); + result = (int)loadparm_service_maxprintjobs(arg1,arg2); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -4078,6 +4140,7 @@ SWIGINTERN PyObject *Swig_var_default_config_get(void) { static PyMethodDef SwigMethods[] = { { (char *)"new_LoadParm", (PyCFunction)_wrap_new_LoadParm, METH_NOARGS, NULL}, + { (char *)"LoadParm_default_service", (PyCFunction) _wrap_LoadParm_default_service, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"LoadParm_load", (PyCFunction) _wrap_LoadParm_load, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"LoadParm_load_default", (PyCFunction) _wrap_LoadParm_load_default, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"LoadParm___len__", (PyCFunction) _wrap_LoadParm___len__, METH_VARARGS | METH_KEYWORDS, NULL}, @@ -4091,9 +4154,9 @@ static PyMethodDef SwigMethods[] = { { (char *)"delete_LoadParm", (PyCFunction) _wrap_delete_LoadParm, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"LoadParm_swigregister", LoadParm_swigregister, METH_VARARGS, NULL}, { (char *)"LoadParm_swiginit", LoadParm_swiginit, METH_VARARGS, NULL}, - { (char *)"loadparm_service_volume_label", (PyCFunction)_wrap_loadparm_service_volume_label, METH_O, NULL}, - { (char *)"loadparm_service_printername", (PyCFunction)_wrap_loadparm_service_printername, METH_O, NULL}, - { (char *)"loadparm_service_maxprintjobs", (PyCFunction)_wrap_loadparm_service_maxprintjobs, METH_O, NULL}, + { (char *)"loadparm_service_volume_label", (PyCFunction) _wrap_loadparm_service_volume_label, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"loadparm_service_printername", (PyCFunction) _wrap_loadparm_service_printername, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"loadparm_service_maxprintjobs", (PyCFunction) _wrap_loadparm_service_maxprintjobs, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"loadparm_service_swigregister", loadparm_service_swigregister, METH_VARARGS, NULL}, { (char *)"new_ParamFile", (PyCFunction)_wrap_new_ParamFile, METH_NOARGS, NULL}, { (char *)"ParamFile_get_section", (PyCFunction) _wrap_ParamFile_get_section, METH_VARARGS | METH_KEYWORDS, NULL}, diff --git a/source4/param/share_classic.c b/source4/param/share_classic.c index eb5e486c449..f5a6fa67a48 100644 --- a/source4/param/share_classic.c +++ b/source4/param/share_classic.c @@ -73,25 +73,25 @@ static const char *sclassic_string_option(struct share_config *scfg, } if (strcmp(opt_name, SHARE_PATH) == 0) { - return lp_pathname(s); + return lp_pathname(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_COMMENT) == 0) { - return lp_comment(s); + return lp_comment(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_VOLUME) == 0) { - return volume_label(s); + return volume_label(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_TYPE) == 0) { - if (lp_print_ok(s)) { + if (lp_print_ok(s, lp_default_service(lp_ctx))) { return "PRINTER"; } - if (strcmp("NTFS", lp_fstype(s)) == 0) { + if (strcmp("NTFS", lp_fstype(s, lp_default_service(lp_ctx))) == 0) { return "DISK"; } - return lp_fstype(s); + return lp_fstype(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_PASSWORD) == 0) { @@ -131,27 +131,27 @@ static int sclassic_int_option(struct share_config *scfg, const char *opt_name, } if (strcmp(opt_name, SHARE_CSC_POLICY) == 0) { - return lp_csc_policy(s); + return lp_csc_policy(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_MAX_CONNECTIONS) == 0) { - return lp_max_connections(s); + return lp_max_connections(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_CREATE_MASK) == 0) { - return lp_create_mask(s); + return lp_create_mask(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_DIR_MASK) == 0) { - return lp_dir_mask(s); + return lp_dir_mask(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_FORCE_DIR_MODE) == 0) { - return lp_force_dir_mode(s); + return lp_force_dir_mode(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_FORCE_CREATE_MODE) == 0) { - return lp_force_create_mode(s); + return lp_force_create_mode(s, lp_default_service(lp_ctx)); } @@ -190,39 +190,39 @@ static bool sclassic_bool_option(struct share_config *scfg, const char *opt_name } if (strcmp(opt_name, SHARE_BROWSEABLE) == 0) { - return lp_browseable(s); + return lp_browseable(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_READONLY) == 0) { - return lp_readonly(s); + return lp_readonly(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_MAP_SYSTEM) == 0) { - return lp_map_system(s); + return lp_map_system(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_MAP_HIDDEN) == 0) { - return lp_map_hidden(s); + return lp_map_hidden(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_MAP_ARCHIVE) == 0) { - return lp_map_archive(s); + return lp_map_archive(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_STRICT_LOCKING) == 0) { - return lp_strict_locking(s); + return lp_strict_locking(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_STRICT_SYNC) == 0) { - return lp_strict_sync(s); + return lp_strict_sync(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_MSDFS_ROOT) == 0) { - return lp_msdfs_root(s); + return lp_msdfs_root(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_CI_FILESYSTEM) == 0) { - return lp_ci_filesystem(s); + return lp_ci_filesystem(s, lp_default_service(lp_ctx)); } DEBUG(0,("request for unknown share bool option '%s'\n", @@ -255,15 +255,15 @@ static const char **sclassic_string_list_option(TALLOC_CTX *mem_ctx, struct shar } if (strcmp(opt_name, SHARE_HOSTS_ALLOW) == 0) { - return lp_hostsallow(s); + return lp_hostsallow(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_HOSTS_DENY) == 0) { - return lp_hostsdeny(s); + return lp_hostsdeny(s, lp_default_service(lp_ctx)); } if (strcmp(opt_name, SHARE_NTVFS_HANDLER) == 0) { - return lp_ntvfs_handler(s); + return lp_ntvfs_handler(s, lp_default_service(lp_ctx)); } DEBUG(0,("request for unknown share list option '%s'\n", diff --git a/source4/param/tests/loadparm.c b/source4/param/tests/loadparm.c index 92871e043d8..49fcdf7249f 100644 --- a/source4/param/tests/loadparm.c +++ b/source4/param/tests/loadparm.c @@ -129,7 +129,7 @@ static bool test_lp_parm_bytes(struct torture_context *tctx) static bool test_lp_do_service_parameter(struct torture_context *tctx) { struct loadparm_context *lp_ctx = loadparm_init(tctx); - struct loadparm_service *service = lp_add_service(lp_ctx, &sDefault, "foo"); + struct loadparm_service *service = lp_add_service(lp_ctx, lp_default_service(lp_ctx), "foo"); torture_assert(tctx, lp_do_service_parameter(lp_ctx, service, "some:thing", "foo"), "lp_set_option failed"); torture_assert_str_equal(tctx, lp_parm_string(lp_ctx, service, "some", "thing"), "foo", @@ -140,7 +140,7 @@ static bool test_lp_do_service_parameter(struct torture_context *tctx) 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"); + struct loadparm_service *service = lp_add_service(lp_ctx, lp_default_service(lp_ctx), "foo"); torture_assert(tctx, service == lp_service(lp_ctx, "foo"), "invalid service"); return true; } diff --git a/source4/script/mkproto.pl b/source4/script/mkproto.pl index 3ed845e2bb5..5aeece71558 100755 --- a/source4/script/mkproto.pl +++ b/source4/script/mkproto.pl @@ -144,7 +144,7 @@ sub handle_loadparm($$) my %smap = ( "GLOBAL" => "struct loadparm_context *", - "LOCAL" => "struct loadparm_service *" + "LOCAL" => "struct loadparm_service *, struct loadparm_service *" ); $file->("$tmap{$type}$name($smap{$scope});\n"); diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk index b15e1fcda78..0d47c8c5427 100644 --- a/source4/scripting/python/config.mk +++ b/source4/scripting/python/config.mk @@ -25,7 +25,7 @@ swig:: pythonmods realdistclean:: @echo "Removing SWIG output files" - @-rm -f bin/python/* + @-rm -rf bin/python/* # FIXME: Remove _wrap.c files pythonmods:: $(PYTHON_DSOS) $(PYTHON_PYS) diff --git a/source4/smbd/service_stream.c b/source4/smbd/service_stream.c index 23cf830b291..9f744efa812 100644 --- a/source4/smbd/service_stream.c +++ b/source4/smbd/service_stream.c @@ -178,7 +178,7 @@ static void stream_new_connection(struct event_context *ev, srv_conn->event.fde = event_add_fd(ev, srv_conn, socket_get_fd(sock), 0, stream_io_handler_fde, srv_conn); - if (!socket_check_access(sock, "smbd", lp_hostsallow(NULL), lp_hostsdeny(NULL))) { + if (!socket_check_access(sock, "smbd", lp_hostsallow(NULL, lp_default_service(lp_ctx)), lp_hostsdeny(NULL, lp_default_service(lp_ctx)))) { stream_terminate_connection(srv_conn, "denied by access rules"); return; } diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index a4ff5221866..286a4a61fb1 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -93,8 +93,8 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c for (s=0;s<lp_numservices(lp_ctx);s++) { struct loadparm_service *service = lp_servicebynum(lp_ctx, s); if (service != NULL) { - const char **deny_list = lp_hostsdeny(service); - const char **allow_list = lp_hostsallow(service); + const char **deny_list = lp_hostsdeny(service, lp_default_service(lp_ctx)); + const char **allow_list = lp_hostsallow(service, lp_default_service(lp_ctx)); int i; if(deny_list) { for (i=0; deny_list[i]; i++) { @@ -139,7 +139,7 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c return(1); } if (!parameter_name) { - lp_dump_one(stdout, show_defaults, service); + lp_dump_one(stdout, show_defaults, service, lp_default_service(lp_ctx)); } else { ret = !lp_dump_a_parameter(lp_ctx, service, parameter_name, stdout); } @@ -154,8 +154,8 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c for (s=0;s<lp_numservices(lp_ctx);s++) { struct loadparm_service *service = lp_servicebynum(lp_ctx, s); if (service != NULL) { - if (allow_access(NULL, lp_hostsdeny(NULL), lp_hostsallow(NULL), cname, caddr) - && allow_access(NULL, lp_hostsdeny(service), lp_hostsallow(service), cname, caddr)) { + if (allow_access(NULL, lp_hostsdeny(NULL, lp_default_service(lp_ctx)), lp_hostsallow(NULL, lp_default_service(lp_ctx)), cname, caddr) + && allow_access(NULL, lp_hostsdeny(service, lp_default_service(lp_ctx)), lp_hostsallow(service, lp_default_service(lp_ctx)), cname, caddr)) { fprintf(stderr,"Allow connection from %s (%s) to %s\n", cname,caddr,lp_servicename(service)); } else { |