s3-param Remove special case for global_myname(), rename to lp_netbios_name()
[kai/samba.git] / source3 / param / loadparm.c
index c4cb37b088fc8dd315746e95e6e7fcbbf20a94af..3ba5312454afbfa37651c1d152585626929e26d0 100644 (file)
@@ -159,6 +159,8 @@ struct global {
        char *szPasswordServer;
        char *szSocketOptions;
        char *szRealm;
+       char *szRealmUpper;
+       char *szDnsDomain;
        char *szAfsUsernameMap;
        int iAfsTokenLifetime;
        char *szLogNtTokenCommand;
@@ -699,14 +701,12 @@ static int default_server_announce;
 /* prototypes for the special type handlers */
 static bool handle_include( int snum, const char *pszParmValue, char **ptr);
 static bool handle_copy( int snum, const char *pszParmValue, char **ptr);
-static bool handle_netbios_name( int snum, const char *pszParmValue, char **ptr);
 static bool handle_idmap_backend(int snum, const char *pszParmValue, char **ptr);
 static bool handle_idmap_uid( int snum, const char *pszParmValue, char **ptr);
 static bool handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
 static bool handle_debug_list( int snum, const char *pszParmValue, char **ptr );
-static bool handle_workgroup( int snum, const char *pszParmValue, char **ptr );
+static bool handle_realm( int snum, const char *pszParmValue, char **ptr );
 static bool handle_netbios_aliases( int snum, const char *pszParmValue, char **ptr );
-static bool handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
 static bool handle_charset( int snum, const char *pszParmValue, char **ptr );
 static bool handle_dos_charset( int snum, const char *pszParmValue, char **ptr );
 static bool handle_printing( int snum, const char *pszParmValue, char **ptr);
@@ -1010,27 +1010,25 @@ static struct parm_struct parm_table[] = {
                .type           = P_USTRING,
                .p_class        = P_GLOBAL,
                .ptr            = &Globals.szWorkgroup,
-               .special        = handle_workgroup,
+               .special        = NULL,
                .enum_list      = NULL,
                .flags          = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
        },
-#ifdef WITH_ADS
        {
                .label          = "realm",
                .type           = P_USTRING,
                .p_class        = P_GLOBAL,
                .ptr            = &Globals.szRealm,
-               .special        = NULL,
+               .special        = handle_realm,
                .enum_list      = NULL,
                .flags          = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
        },
-#endif
        {
                .label          = "netbios name",
                .type           = P_USTRING,
                .p_class        = P_GLOBAL,
                .ptr            = &Globals.szNetbiosName,
-               .special        = handle_netbios_name,
+               .special        = NULL,
                .enum_list      = NULL,
                .flags          = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
        },
@@ -1048,7 +1046,7 @@ static struct parm_struct parm_table[] = {
                .type           = P_USTRING,
                .p_class        = P_GLOBAL,
                .ptr            = &Globals.szNetbiosScope,
-               .special        = handle_netbios_scope,
+               .special        = NULL,
                .enum_list      = NULL,
                .flags          = FLAG_ADVANCED,
        },
@@ -5173,6 +5171,7 @@ static void init_globals(bool reinit_globals)
                }
        }
 
+
        string_set(&sDefault.fstype, FSTYPE_STRING);
        string_set(&sDefault.szPrintjobUsername, "%U");
 
@@ -5181,6 +5180,9 @@ static void init_globals(bool reinit_globals)
 
        DEBUG(3, ("Initialising global parameters\n"));
 
+       /* Must manually force to upper case here, as this does not go via the handler */
+       string_set(&Globals.szNetbiosName, myhostname_upper());
+
        string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
        string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
 
@@ -5209,11 +5211,7 @@ static void init_globals(bool reinit_globals)
         */
        string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
 
-       set_global_myname(myhostname());
-       string_set(&Globals.szNetbiosName,global_myname());
-
-       set_global_myworkgroup(WORKGROUP);
-       string_set(&Globals.szWorkgroup, lp_workgroup());
+       string_set(&Globals.szWorkgroup, WORKGROUP);
 
        string_set(&Globals.szPasswdProgram, "");
        string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
@@ -5618,7 +5616,11 @@ FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram)
 FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
 FN_GLOBAL_CONST_STRING(lp_passwordserver, &Globals.szPasswordServer)
 FN_GLOBAL_CONST_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder)
-FN_GLOBAL_CONST_STRING(lp_realm, &Globals.szRealm)
+FN_GLOBAL_CONST_STRING(lp_workgroup, &Globals.szWorkgroup)
+FN_GLOBAL_CONST_STRING(lp_netbios_name, &Globals.szNetbiosName)
+FN_GLOBAL_CONST_STRING(lp_netbios_scope, &Globals.szNetbiosScope)
+FN_GLOBAL_CONST_STRING(lp_realm, &Globals.szRealmUpper)
+FN_GLOBAL_CONST_STRING(lp_dnsdomain, &Globals.szDnsDomain)
 FN_GLOBAL_CONST_STRING(lp_afs_username_map, &Globals.szAfsUsernameMap)
 FN_GLOBAL_INTEGER(lp_afs_token_lifetime, &Globals.iAfsTokenLifetime)
 FN_GLOBAL_STRING(lp_log_nt_token_command, &Globals.szLogNtTokenCommand)
@@ -7500,29 +7502,6 @@ bool lp_file_list_changed(void)
 }
 
 
-/***************************************************************************
- Run standard_sub_basic on netbios name... needed because global_myname
- is not accessed through any lp_ macro.
- Note: We must *NOT* use string_set() here as ptr points to global_myname.
-***************************************************************************/
-
-static bool handle_netbios_name(int snum, const char *pszParmValue, char **ptr)
-{
-       bool ret;
-       char *netbios_name = talloc_sub_basic(
-               talloc_tos(), get_current_username(), current_user_info.domain,
-               pszParmValue);
-
-       ret = set_global_myname(netbios_name);
-       TALLOC_FREE(netbios_name);
-       string_set(&Globals.szNetbiosName,global_myname());
-
-       DEBUG(4, ("handle_netbios_name: set global_myname to: %s\n",
-              global_myname()));
-
-       return ret;
-}
-
 /**
  * Initialize iconv conversion descriptors.
  *
@@ -7583,24 +7562,17 @@ static bool handle_dos_charset(int snum, const char *pszParmValue, char **ptr)
        return true;
 }
 
-
-
-static bool handle_workgroup(int snum, const char *pszParmValue, char **ptr)
-{
-       bool ret;
-
-       ret = set_global_myworkgroup(pszParmValue);
-       string_set(&Globals.szWorkgroup,lp_workgroup());
-
-       return ret;
-}
-
-static bool handle_netbios_scope(int snum, const char *pszParmValue, char **ptr)
+static bool handle_realm(int snum, const char *pszParmValue, char **ptr)
 {
-       bool ret;
+       bool ret = true;
+       char *realm = strupper_talloc(talloc_tos(), pszParmValue);
+       char *dnsdomain = strlower_talloc(talloc_tos(), pszParmValue);
 
-       ret = set_global_scope(pszParmValue);
-       string_set(&Globals.szNetbiosScope,global_scope());
+       ret &= string_set(&Globals.szRealm, pszParmValue);
+       ret &= string_set(&Globals.szRealmUpper, realm);
+       ret &= string_set(&Globals.szDnsDomain, dnsdomain);
+       TALLOC_FREE(realm);
+       TALLOC_FREE(dnsdomain);
 
        return ret;
 }