s3:loadparm: prevent infinite include nesting.
[jra/samba/.git] / source3 / param / loadparm.c
index 66fb8bf1bc603f0c98da1983caf2472b36bb3afc..7e2affed082a3a4d70124d1bffc840646d3b41e6 100644 (file)
 #include "includes.h"
 #include "printing.h"
 
+#ifdef HAVE_HTTPCONNECTENCRYPT
+#include <cups/http.h>
+#endif
+
 bool bLoaded = False;
 
 extern enum protocol_types Protocol;
@@ -257,6 +261,7 @@ struct global {
        int ldap_debug_threshold;
        int iAclCompat;
        char *szCupsServer;
+       int CupsEncrypt;
        char *szIPrintServer;
        char *ctdbdSocket;
        char **szClusterAddresses;
@@ -774,6 +779,8 @@ static const struct enum_list enum_case[] = {
        {-1, NULL}
 };
 
+
+
 static const struct enum_list enum_bool_auto[] = {
        {False, "No"},
        {False, "False"},
@@ -878,7 +885,7 @@ static const struct enum_list enum_kerberos_method[] = {
 
 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
  *
- * The FLAG_HIDE is explicit. Paramters set this way do NOT appear in any edit
+ * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
  * screen in SWAT. This is used to exclude parameters as well as to squash all
  * parameters that have been duplicated by pseudonyms.
  *
@@ -887,7 +894,7 @@ static const struct enum_list enum_kerberos_method[] = {
  *      Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in
  *        respective views.
  *
- * NOTE2: Handling of duplicated (synonym) paramters:
+ * NOTE2: Handling of duplicated (synonym) parameters:
  *     Only the first occurance of a parameter should be enabled by FLAG_BASIC
  *     and/or FLAG_ADVANCED. All duplicates following the first mention should be
  *     set to FLAG_HIDE. ie: Make you must place the parameter that has the preferred
@@ -2628,6 +2635,16 @@ static struct parm_struct parm_table[] = {
                .flags          = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
        },
        {
+               .label          = "cups encrypt",
+               .type           = P_ENUM,
+               .p_class        = P_GLOBAL,
+               .ptr            = &Globals.CupsEncrypt,
+               .special        = NULL,
+               .enum_list      = enum_bool_auto,
+               .flags          = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
+       },
+       {
+
                .label          = "cups connection timeout",
                .type           = P_INTEGER,
                .p_class        = P_GLOBAL,
@@ -4639,7 +4656,7 @@ static void init_printer_values(struct service *pService)
                string_set(&pService->szLpqcommand, "vlp lpq %p");
                string_set(&pService->szLprmcommand, "vlp lprm %p %j");
                string_set(&pService->szLppausecommand, "vlp lppause %p %j");
-               string_set(&pService->szLpresumecommand, "vlp lpresum %p %j");
+               string_set(&pService->szLpresumecommand, "vlp lpresume %p %j");
                string_set(&pService->szQueuepausecommand, "vlp queuepause %p");
                string_set(&pService->szQueueresumecommand, "vlp queueresume %p");
                break;
@@ -5471,6 +5488,23 @@ FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
 FN_GLOBAL_LIST(lp_svcctl_list, &Globals.szServicesList)
 FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
 FN_GLOBAL_STRING(lp_cups_server, &Globals.szCupsServer)
+int lp_cups_encrypt(void)
+{
+#ifdef HAVE_HTTPCONNECTENCRYPT
+       switch (Globals.CupsEncrypt) {
+               case Auto:
+                       Globals.CupsEncrypt = HTTP_ENCRYPT_REQUIRED;
+                       break;
+               case True:
+                       Globals.CupsEncrypt = HTTP_ENCRYPT_ALWAYS;
+                       break;
+               case False:
+                       Globals.CupsEncrypt = HTTP_ENCRYPT_NEVER;
+                       break;
+       }
+#endif
+       return Globals.CupsEncrypt;
+}
 FN_GLOBAL_STRING(lp_iprint_server, &Globals.szIPrintServer)
 FN_GLOBAL_INTEGER(lp_cups_connection_timeout, &Globals.cups_connection_timeout)
 FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, &Globals.ctdbdSocket)
@@ -6784,6 +6818,9 @@ static bool process_smbconf_service(struct smbconf_service *service)
                        return false;
                }
        }
+       if (iServiceIndex >= 0) {
+               ret = service_ok(iServiceIndex);
+       }
        return true;
 }
 
@@ -6871,6 +6908,10 @@ done:
        return ret;
 }
 
+#define MAX_INCLUDE_DEPTH 100
+
+static uint8_t include_depth;
+
 static struct file_lists {
        struct file_lists *next;
        char *name;
@@ -7058,12 +7099,22 @@ static bool handle_include(int snum, const char *pszParmValue, char **ptr)
 {
        char *fname;
 
+       if (include_depth >= MAX_INCLUDE_DEPTH) {
+               DEBUG(0, ("Error: Maximum include depth (%u) exceeded!\n",
+                         include_depth));
+               return false;
+       }
+
        if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
                if (!bAllowIncludeRegistry) {
                        return true;
                }
                if (bInGlobalSection) {
-                       return process_registry_globals();
+                       bool ret;
+                       include_depth++;
+                       ret = process_registry_globals();
+                       include_depth--;
+                       return ret;
                } else {
                        DEBUG(1, ("\"include = registry\" only effective "
                                  "in %s section\n", GLOBAL_NAME));
@@ -7080,7 +7131,10 @@ static bool handle_include(int snum, const char *pszParmValue, char **ptr)
        string_set(ptr, fname);
 
        if (file_exist(fname)) {
-               bool ret = pm_process(fname, do_section, do_parameter, NULL);
+               bool ret;
+               include_depth++;
+               ret = pm_process(fname, do_section, do_parameter, NULL);
+               include_depth--;
                SAFE_FREE(fname);
                return ret;
        }