docs-xml: deprecate "client schannel" and change the default to "yes"
[samba.git] / source3 / param / loadparm.c
index 91ecba88ad836ae68ea3127de8eddaad8aa0ee54..9f79f132def3d087292f6294cd6779a86207cf24 100644 (file)
@@ -71,6 +71,7 @@
 #include "../lib/util/bitmap.h"
 #include "librpc/gen_ndr/nbt.h"
 #include "source4/lib/tls/tls.h"
+#include "libcli/auth/ntlm_check.h"
 
 #ifdef HAVE_SYS_SYSCTL_H
 #include <sys/sysctl.h>
@@ -110,7 +111,7 @@ static bool defaults_saved = false;
 static struct loadparm_global Globals;
 
 /* This is a default service used to prime a services structure */
-static struct loadparm_service sDefault =
+static const struct loadparm_service _sDefault =
 {
        .valid = true,
        .autoloaded = false,
@@ -167,7 +168,6 @@ static struct loadparm_service sDefault =
        .max_connections = 0,
        .default_case = CASE_LOWER,
        .printing = DEFAULT_PRINTING,
-       .oplock_contention_limit = 2,
        .csc_policy = 0,
        .block_size = 1024,
        .dfree_cache_time = 0,
@@ -229,7 +229,6 @@ static struct loadparm_service sDefault =
        .nt_acl_support = true,
        .force_unknown_acl_user = false,
        ._use_sendfile = false,
-       .profile_acls = false,
        .map_acl_inherit = false,
        .afs_share = false,
        .ea_support = false,
@@ -238,8 +237,8 @@ static struct loadparm_service sDefault =
        .acl_group_control = false,
        .acl_allow_execute_always = false,
        .allocation_roundup_size = SMB_ROUNDUP_ALLOCATION_SIZE,
-       .aio_read_size = 0,
-       .aio_write_size = 0,
+       .aio_read_size = 1,
+       .aio_write_size = 1,
        .map_readonly = MAP_READONLY_YES,
        .directory_name_cache_size = 100,
        .smb_encrypt = SMB_SIGNING_DEFAULT,
@@ -249,6 +248,12 @@ static struct loadparm_service sDefault =
        .dummy = ""
 };
 
+/*
+ * This is a copy of the default service structure. Service options in the
+ * global section would otherwise overwrite the initial default values.
+ */
+static struct loadparm_service sDefault;
+
 /* local variables */
 static struct loadparm_service **ServicePtrs = NULL;
 static int iNumServices = 0;
@@ -549,6 +554,8 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
                         get_dyn_SMB_PASSWD_FILE());
        lpcfg_string_set(Globals.ctx, &Globals.private_dir,
                         get_dyn_PRIVATE_DIR());
+       lpcfg_string_set(Globals.ctx, &Globals.binddns_dir,
+                        get_dyn_BINDDNS_DIR());
 
        /* use the new 'hash2' method by default, with a prefix of 1 */
        lpcfg_string_set(Globals.ctx, &Globals.mangling_method, "hash2");
@@ -644,7 +651,7 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
        Globals._client_ipc_min_protocol = PROTOCOL_DEFAULT;
        Globals._security = SEC_AUTO;
        Globals.encrypt_passwords = true;
-       Globals.client_schannel = Auto;
+       Globals.client_schannel = true;
        Globals.winbind_sealed_pipes = true;
        Globals.require_strong_key = true;
        Globals.server_schannel = Auto;
@@ -692,8 +699,8 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
        Globals.restrict_anonymous = 0;
        Globals.client_lanman_auth = false;     /* Do NOT use the LanMan hash if it is available */
        Globals.client_plaintext_auth = false;  /* Do NOT use a plaintext password even if is requested by the server */
-       Globals.lanman_auth = false;    /* Do NOT use the LanMan hash, even if it is supplied */
-       Globals.ntlm_auth = false;      /* Do NOT use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
+       Globals._lanman_auth = false;   /* Do NOT use the LanMan hash, even if it is supplied */
+       Globals.ntlm_auth = NTLM_AUTH_NTLMV2_ONLY;      /* Do NOT use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
        Globals.raw_ntlmv2_auth = false; /* Reject NTLMv2 without NTLMSSP */
        Globals.client_ntlmv2_auth = true; /* Client should always use use NTLMv2, as we can't tell that the server supports it, but most modern servers do */
        /* Note, that we will also use NTLM2 session security (which is different), if it is available */
@@ -810,7 +817,6 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
        Globals.winbind_enum_users = false;
        Globals.winbind_enum_groups = false;
        Globals.winbind_use_default_domain = false;
-       Globals.winbind_trusted_domains_only = false;
        Globals.winbind_nested_groups = true;
        Globals.winbind_expand_groups = 0;
        Globals.winbind_nss_info = str_list_make_v3_const(NULL, "template", NULL);
@@ -824,7 +830,6 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
 
        Globals.name_cache_timeout = 660; /* In seconds */
 
-       Globals.use_spnego = true;
        Globals.client_use_spnego = true;
 
        Globals.client_signing = SMB_SIGNING_DEFAULT;
@@ -859,7 +864,6 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
 
        Globals.min_receivefile_size = 0;
 
-       Globals.map_untrusted_to_domain = false;
        Globals.multicast_dns_register = true;
 
        Globals.smb2_max_read = DEFAULT_SMB2_MAX_READ;
@@ -911,6 +915,13 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
        Globals.dns_update_command = str_list_make_v3_const(NULL, s, NULL);
        TALLOC_FREE(s);
 
+       s = talloc_asprintf(talloc_tos(), "%s/samba_gpoupdate", get_dyn_SCRIPTSBINDIR());
+       if (s == NULL) {
+               smb_panic("init_globals: ENOMEM");
+       }
+       Globals.gpo_update_command = str_list_make_v3_const(NULL, s, NULL);
+       TALLOC_FREE(s);
+
        s = talloc_asprintf(talloc_tos(), "%s/samba_spnupdate", get_dyn_SCRIPTSBINDIR());
        if (s == NULL) {
                smb_panic("init_globals: ENOMEM");
@@ -941,6 +952,7 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
                         "49152-65535");
        Globals.rpc_low_port = SERVER_TCP_LOW_PORT;
        Globals.rpc_high_port = SERVER_TCP_HIGH_PORT;
+       Globals.prefork_children = 1;
 
        /* Now put back the settings that were set with lp_set_cmdline() */
        apply_lp_set_cmdline();
@@ -958,7 +970,14 @@ static struct loadparm_context *setup_lp_context(TALLOC_CTX *mem_ctx)
                return NULL;
        }
 
-       lp_ctx->sDefault = &sDefault;
+       lp_ctx->sDefault = talloc_zero(lp_ctx, struct loadparm_service);
+       if (lp_ctx->sDefault == NULL) {
+               DBG_ERR("talloc_zero failed\n");
+               TALLOC_FREE(lp_ctx);
+               return NULL;
+       }
+
+       *lp_ctx->sDefault = _sDefault;
        lp_ctx->services = NULL; /* We do not want to access this directly */
        lp_ctx->bInGlobalSection = bInGlobalSection;
        lp_ctx->flags = flags_list;
@@ -1590,7 +1609,7 @@ static bool lp_add_ipc(const char *ipc_name, bool guest_ok)
        ServicePtrs[i]->guest_ok = guest_ok;
        ServicePtrs[i]->printable = false;
        ServicePtrs[i]->browseable = sDefault.browseable;
-       ServicePtrs[i]->autoloaded = true;
+       ServicePtrs[i]->autoloaded = false;
 
        DEBUG(3, ("adding IPC service\n"));
 
@@ -3513,6 +3532,19 @@ static bool usershare_exists(int iService, struct timespec *last_mod)
        return true;
 }
 
+static bool usershare_directory_is_root(uid_t uid)
+{
+       if (uid == 0) {
+               return true;
+       }
+
+       if (uid_wrapper_enabled()) {
+               return true;
+       }
+
+       return false;
+}
+
 /***************************************************************************
  Load a usershare service by name. Returns a valid servicenumber or -1.
 ***************************************************************************/
@@ -3546,9 +3578,11 @@ int load_usershare_service(const char *servicename)
         */
 
 #ifdef S_ISVTX
-       if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
+       if (!usershare_directory_is_root(sbuf.st_ex_uid) ||
+           !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
 #else
-       if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
+       if (!usershare_directory_is_root(sbuf.st_ex_uid) ||
+           (sbuf.st_ex_mode & S_IWOTH)) {
 #endif
                DEBUG(0,("load_usershare_service: directory %s is not owned by root "
                        "or does not have the sticky bit 't' set or is writable by anyone.\n",
@@ -3833,6 +3867,7 @@ static bool lp_load_ex(const char *pszFname,
        bInGlobalSection = true;
        bGlobalOnly = global_only;
        bAllowIncludeRegistry = allow_include_registry;
+       sDefault = _sDefault;
 
        lp_ctx = setup_lp_context(talloc_tos());
 
@@ -4528,7 +4563,7 @@ int lp_client_max_protocol(void)
 {
        int client_max_protocol = lp__client_max_protocol();
        if (client_max_protocol == PROTOCOL_DEFAULT) {
-               return PROTOCOL_NT1;
+               return PROTOCOL_LATEST;
        }
        return client_max_protocol;
 }
@@ -4576,6 +4611,22 @@ int lp_rpc_high_port(void)
        return Globals.rpc_high_port;
 }
 
+/*
+ * Do not allow LanMan auth if unless NTLMv1 is also allowed
+ *
+ * This also ensures it is disabled if NTLM is totally disabled
+ */
+bool lp_lanman_auth(void)
+{
+       enum ntlm_auth_level ntlm_auth_level = lp_ntlm_auth();
+
+       if (ntlm_auth_level == NTLM_AUTH_ON) {
+               return lp__lanman_auth();
+       } else {
+               return false;
+       }
+}
+
 struct loadparm_global * get_globals(void)
 {
        return &Globals;