s3-param use Auto define for lm_announce default
[kai/samba-autobuild/.git] / source3 / param / loadparm.c
index 32aaed4fdb582f5d4c7bc5905d6e12a5c1bab184..345f7483842738038dc5f2e9feebb0466d21d4b0 100644 (file)
@@ -65,7 +65,7 @@
 #include "../librpc/gen_ndr/svcctl.h"
 #include "intl.h"
 #include "smb_signing.h"
-#include "dbwrap.h"
+#include "dbwrap/dbwrap.h"
 #include "smbldap.h"
 #include "../lib/util/bitmap.h"
 
@@ -310,9 +310,11 @@ static void set_allowed_client_auth(void);
 
 static void add_to_file_list(const char *fname, const char *subfname);
 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values);
+static void free_param_opts(struct parmlist_entry **popts);
 
 static const struct enum_list enum_protocol[] = {
-       {PROTOCOL_SMB2_02, "SMB2"},
+       {PROTOCOL_SMB2_02, "SMB2"}, /* for now keep PROTOCOL_SMB2_02 */
+       {PROTOCOL_SMB2_10, "SMB2_10"},
        {PROTOCOL_SMB2_02, "SMB2_02"},
        {PROTOCOL_NT1, "NT1"},
        {PROTOCOL_LANMAN2, "LANMAN2"},
@@ -3897,6 +3899,15 @@ static struct parm_struct parm_table[] = {
                .enum_list      = NULL,
                .flags          = FLAG_ADVANCED | FLAG_SHARE,
        },
+       {
+               .label          = "allow insecure wide links",
+               .type           = P_BOOL,
+               .p_class        = P_GLOBAL,
+               .offset         = GLOBAL_VAR(bAllowInsecureWidelinks),
+               .special        = NULL,
+               .enum_list      = NULL,
+               .flags          = FLAG_ADVANCED,
+       },
        {
                .label          = "wide links",
                .type           = P_BOOL,
@@ -4604,6 +4615,7 @@ static void free_parameters_by_snum(int snum)
  */
 static void free_global_parameters(void)
 {
+       free_param_opts(&Globals.param_opt);
        free_parameters_by_snum(GLOBAL_SECTION_SNUM);
 }
 
@@ -4700,7 +4712,7 @@ static void init_globals(bool reinit_globals)
         * wipe out smb.conf options set with lp_set_cmdline().  The
         * apply_lp_set_cmdline() call puts these values back in the
         * table once the defaults are set */
-       memset((void *)&Globals, '\0', sizeof(Globals));
+       ZERO_STRUCT(Globals);
 
        for (i = 0; parm_table[i].label; i++) {
                if ((parm_table[i].type == P_STRING ||
@@ -4822,7 +4834,7 @@ static void init_globals(bool reinit_globals)
        Globals.max_wins_ttl = 60 * 60 * 24 * 6;        /* 6 days default. */
        Globals.min_wins_ttl = 60 * 60 * 6;     /* 6 hours default. */
        Globals.machine_password_timeout = 60 * 60 * 24 * 7;    /* 7 days default. */
-       Globals.lm_announce = 2;        /* = Auto: send only if LM clients found */
+       Globals.lm_announce = Auto;     /* = Auto: send only if LM clients found */
        Globals.lm_interval = 60;
 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
        Globals.bNISHomeMap = false;
@@ -5387,6 +5399,7 @@ FN_GLOBAL_INTEGER(lp_ctdb_timeout, ctdb_timeout)
 FN_GLOBAL_INTEGER(lp_ctdb_locktime_warn_threshold, ctdb_locktime_warn_threshold)
 FN_GLOBAL_BOOL(lp_async_smb_echo_handler, bAsyncSMBEchoHandler)
 FN_GLOBAL_BOOL(lp_multicast_dns_register, bMulticastDnsRegister)
+FN_GLOBAL_BOOL(lp_allow_insecure_widelinks, bAllowInsecureWidelinks)
 FN_GLOBAL_INTEGER(lp_winbind_cache_time, winbind_cache_time)
 FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, winbind_reconnect_delay)
 FN_GLOBAL_INTEGER(lp_winbind_max_clients, winbind_max_clients)
@@ -5419,7 +5432,6 @@ static bool do_section(const char *pszSectionName, void *userdata);
 static void init_copymap(struct loadparm_service *pservice);
 static bool hash_a_service(const char *name, int number);
 static void free_service_byindex(int iService);
-static void free_param_opts(struct parmlist_entry **popts);
 static void show_parameter(int parmIndex);
 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
 
@@ -8940,7 +8952,7 @@ void gfree_loadparm(void)
 /***************************************************************************
  Allow client apps to specify that they are a client
 ***************************************************************************/
-void lp_set_in_client(bool b)
+static void lp_set_in_client(bool b)
 {
     in_client = b;
 }
@@ -8949,7 +8961,7 @@ void lp_set_in_client(bool b)
 /***************************************************************************
  Determine if we're running in a client app
 ***************************************************************************/
-bool lp_is_in_client(void)
+static bool lp_is_in_client(void)
 {
     return in_client;
 }
@@ -8987,7 +8999,10 @@ static bool lp_load_ex(const char *pszFname,
                lp_save_defaults();
        }
 
-       free_param_opts(&Globals.param_opt);
+       if (!initialize_globals) {
+               free_param_opts(&Globals.param_opt);
+               apply_lp_set_cmdline();
+       }
 
        lp_do_parameter(-1, "idmap config * : backend", Globals.szIdmapBackend);
 
@@ -9118,6 +9133,56 @@ bool lp_load_initial_only(const char *pszFname)
                          false); /* load_all_shares*/
 }
 
+/**
+ * most common lp_load wrapper, loading only the globals
+ */
+bool lp_load_global(const char *file_name)
+{
+       return lp_load_ex(file_name,
+                         true,   /* global_only */
+                         false,  /* save_defaults */
+                         false,  /* add_ipc */
+                         true,   /* initialize_globals */
+                         true,   /* allow_include_registry */
+                         false); /* load_all_shares*/
+}
+
+/**
+ * lp_load wrapper, especially for clients
+ */
+bool lp_load_client(const char *file_name)
+{
+       lp_set_in_client(true);
+
+       return lp_load_global(file_name);
+}
+
+/**
+ * lp_load wrapper, loading only globals, but intended
+ * for subsequent calls, not reinitializing the globals
+ * to default values
+ */
+bool lp_load_global_no_reinit(const char *file_name)
+{
+       return lp_load_ex(file_name,
+                         true,   /* global_only */
+                         false,  /* save_defaults */
+                         false,  /* add_ipc */
+                         false,  /* initialize_globals */
+                         true,   /* allow_include_registry */
+                         false); /* load_all_shares*/
+}
+
+/**
+ * lp_load wrapper, especially for clients, no reinitialization
+ */
+bool lp_load_client_no_reinit(const char *file_name)
+{
+       lp_set_in_client(true);
+
+       return lp_load_global_no_reinit(file_name);
+}
+
 bool lp_load_with_registry_shares(const char *pszFname,
                                  bool global_only,
                                  bool save_defaults,
@@ -9582,6 +9647,10 @@ static bool lp_widelinks_internal(int snum)
 
 void widelinks_warning(int snum)
 {
+       if (lp_allow_insecure_widelinks()) {
+               return;
+       }
+
        if (lp_unix_extensions() && lp_widelinks_internal(snum)) {
                DEBUG(0,("Share '%s' has wide links and unix extensions enabled. "
                        "These parameters are incompatible. "
@@ -9594,7 +9663,13 @@ bool lp_widelinks(int snum)
 {
        /* wide links is always incompatible with unix extensions */
        if (lp_unix_extensions()) {
-               return false;
+               /*
+                * Unless we have "allow insecure widelinks"
+                * turned on.
+                */
+               if (!lp_allow_insecure_widelinks()) {
+                       return false;
+               }
        }
 
        return lp_widelinks_internal(snum);