From bd2f5d072aeef03993cc92afdcb00bce16320768 Mon Sep 17 00:00:00 2001 From: Guillaume Xavier Taillon Date: Tue, 22 Mar 2016 10:45:49 -0400 Subject: [PATCH] param:Added "max default services" to restore behavior of "default service" Updated patch for master of original raw patch for 3.6 from Jeremy Allison. BUG: https://bugzilla.samba.org/show_bug.cgi?id=8935 Signed-off-by: Guillaume Xavier Taillon --- docs-xml/smbdotconf/misc/defaultservice.xml | 7 ++++--- docs-xml/smbdotconf/misc/maxdefaultservices.xml | 13 +++++++++++++ lib/param/loadparm.h | 1 + source3/include/proto.h | 2 +- source3/param/loadparm.c | 25 ++++++++++++++++++++----- source3/param/service.c | 8 +++++--- 6 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 docs-xml/smbdotconf/misc/maxdefaultservices.xml diff --git a/docs-xml/smbdotconf/misc/defaultservice.xml b/docs-xml/smbdotconf/misc/defaultservice.xml index 788506f..f80febb 100644 --- a/docs-xml/smbdotconf/misc/defaultservice.xml +++ b/docs-xml/smbdotconf/misc/defaultservice.xml @@ -10,9 +10,10 @@ be found. Note that the square brackets are NOT given in the parameter value (see example below). - There is no default value for this parameter. If this - parameter is not given, attempting to connect to a nonexistent - service results in an error. + There is no default value for this parameter. If this + parameter is not given, or if is not more than 0, attempting to + connect to a nonexistent service results in an error. Typically the default service would be a , + + This parameter specifies how many shares a client can connect + to by using . If set + to zero (the default) no connections are allowed using the default + service. + +0 +15 + diff --git a/lib/param/loadparm.h b/lib/param/loadparm.h index b453aca..b8ee867 100644 --- a/lib/param/loadparm.h +++ b/lib/param/loadparm.h @@ -243,6 +243,7 @@ enum case_handling {CASE_LOWER,CASE_UPPER}; #define DEFAULT_SMB2_MAX_CREDITS 8192 #define LOADPARM_EXTRA_LOCALS \ + bool from_default_service \ int usershare; \ struct timespec usershare_last_mod; \ char *szService; \ diff --git a/source3/include/proto.h b/source3/include/proto.h index dc8fee9..d906a6e 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -925,7 +925,7 @@ int lp_parm_enum(int snum, const char *type, const char *option, char *canonicalize_servicename(TALLOC_CTX *ctx, const char *src); bool lp_add_home(const char *pszHomename, int iDefaultService, const char *user, const char *pszHomedir); -int lp_add_service(const char *pszService, int iDefaultService); +int lp_add_default_service(const char *pszService, int iDefaultService); bool lp_add_printer(const char *pszPrintername, int iDefaultService); bool lp_parameter_is_valid(const char *pszParmName); bool lp_parameter_is_global(const char *pszParmName); diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 1f8e578..5bee46e 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -113,6 +113,7 @@ static struct loadparm_service sDefault = { .valid = true, .autoloaded = false, + .from_default_service = false, .usershare = 0, .usershare_last_mod = {0, 0}, .szService = NULL, @@ -1326,6 +1327,10 @@ static void free_service(struct loadparm_service *pservice) DEBUG(5, ("free_service: Freeing service %s\n", pservice->szService)); + if (pservice->from_default_service) { + Globals.max_default_services += 1; + } + free_parameters(pservice); lpcfg_string_free(&pservice->szService); @@ -1529,16 +1534,26 @@ bool lp_add_home(const char *pszHomename, int iDefaultService, } /*************************************************************************** - Add a new service, based on an old one. + Add a new service, based on the default service. ***************************************************************************/ -int lp_add_service(const char *pszService, int iDefaultService) +int lp_add_default_service(const char *pszService, int iDefaultService) { - if (iDefaultService < 0) { - return add_a_service(&sDefault, pszService); + int ret; + + if (Globals.max_default_services == 0) { + return -1; } - return (add_a_service(ServicePtrs[iDefaultService], pszService)); + ret = add_a_service(ServicePtrs[iDefaultService], pszService); + if (ret < 0) { + return -1; + } + + ServicePtrs[iDefaultService]->from_default_service = true; + Globals.max_default_services -= 1; + + return ret; } /*************************************************************************** diff --git a/source3/param/service.c b/source3/param/service.c index b21be60..a88dfa7 100644 --- a/source3/param/service.c +++ b/source3/param/service.c @@ -207,6 +207,7 @@ int find_service(TALLOC_CTX *ctx, const char *service_in, char **p_service_out) * below. Fix from Josef Hinteregger . */ char *defservice = talloc_strdup(ctx, pdefservice); + char *def_service_out = NULL; if (!defservice) { goto fail; @@ -220,17 +221,18 @@ int find_service(TALLOC_CTX *ctx, const char *service_in, char **p_service_out) goto fail; } - iService = find_service(ctx, defservice, p_service_out); - if (!*p_service_out) { + iService = find_service(ctx, defservice, &def_service_out); + if (!def_service_out) { TALLOC_FREE(defservice); iService = -1; goto fail; } if (iService >= 0) { all_string_sub(*p_service_out, "_","/",0); - iService = lp_add_service(*p_service_out, iService); + iService = lp_add_default_service(*p_service_out, iService); } TALLOC_FREE(defservice); + TALLOC_FREE(def_service_out); } } -- 1.8.3.1