diff options
Diffstat (limited to 'source3')
91 files changed, 264 insertions, 341 deletions
diff --git a/source3/auth/auth_domain.c b/source3/auth/auth_domain.c index 2afff6fc7b..c18a81ab57 100644 --- a/source3/auth/auth_domain.c +++ b/source3/auth/auth_domain.c @@ -69,7 +69,7 @@ void attempt_machine_password_change(void) DEBUG(0,("attempt_machine_password_change: unable to lock " "the machine account password for machine %s in " "domain %s.\n", - global_myname(), lp_workgroup() )); + lp_netbios_name(), lp_workgroup() )); return; } @@ -77,7 +77,7 @@ void attempt_machine_password_change(void) trust_passwd_hash, &lct, NULL)) { DEBUG(0,("attempt_machine_password_change: unable to read the " "machine account password for %s in domain %s.\n", - global_myname(), lp_workgroup())); + lp_netbios_name(), lp_workgroup())); TALLOC_FREE(lock); return; } @@ -146,7 +146,7 @@ static NTSTATUS connect_to_domain_password_server(struct cli_state **cli, } /* Attempt connection */ - result = cli_full_connection(cli, global_myname(), dc_name, dc_ss, 0, + result = cli_full_connection(cli, lp_netbios_name(), dc_name, dc_ss, 0, "IPC$", "IPC", "", "", "", 0, Undefined); if (!NT_STATUS_IS_OK(result)) { @@ -219,7 +219,7 @@ machine %s. Error was : %s.\n", dc_name, nt_errstr(result))); result = rpccli_netlogon_setup_creds(netlogon_pipe, dc_name, /* server name */ domain, /* domain */ - global_myname(), /* client name */ + lp_netbios_name(), /* client name */ account_name, /* machine account name */ machine_pwd, sec_chan_type, diff --git a/source3/auth/auth_netlogond.c b/source3/auth/auth_netlogond.c index e9a74b6d12..7fb037457e 100644 --- a/source3/auth/auth_netlogond.c +++ b/source3/auth/auth_netlogond.c @@ -133,7 +133,7 @@ static NTSTATUS netlogond_validate(TALLOC_CTX *mem_ctx, p, p, user_info->logon_parameters, /* flags such as 'allow * workstation logon' */ - global_myname(), /* server name */ + lp_netbios_name(), /* server name */ user_info->client.account_name, /* user name logging on. */ user_info->client.domain_name, /* domain name */ user_info->workstation_name, /* workstation name */ @@ -234,7 +234,7 @@ static NTSTATUS mymachinepw(uint8_t pwd[16]) DEBUG(10, ("default_nc = %s\n", default_nc)); myname = talloc_asprintf_strupper_m(talloc_tos(), "%s$", - global_myname()); + lp_netbios_name()); if (myname == NULL) { DEBUG(10, ("talloc failed\n")); status = NT_STATUS_NO_MEMORY; @@ -375,8 +375,8 @@ static NTSTATUS check_netlogond_security(const struct auth_context *auth_context dump_data(10, machine_password, 16); status = rpccli_netlogon_setup_creds( - p, global_myname(), lp_workgroup(), global_myname(), - global_myname(), machine_password, SEC_CHAN_BDC, &neg_flags); + p, lp_netbios_name(), lp_workgroup(), lp_netbios_name(), + lp_netbios_name(), machine_password, SEC_CHAN_BDC, &neg_flags); if (!NT_STATUS_IS_OK(status)) { DEBUG(10, ("rpccli_netlogon_setup_creds failed: %s\n", diff --git a/source3/auth/auth_ntlmssp.c b/source3/auth/auth_ntlmssp.c index 4151ebaf9d..1fecc0988e 100644 --- a/source3/auth/auth_ntlmssp.c +++ b/source3/auth/auth_ntlmssp.c @@ -190,7 +190,7 @@ NTSTATUS auth_ntlmssp_start(struct auth_ntlmssp_state **auth_ntlmssp_state) is_standalone = false; } - netbios_name = global_myname(); + netbios_name = lp_netbios_name(); netbios_domain = lp_workgroup(); /* This should be a 'netbios domain -> DNS domain' mapping */ dns_domain = get_mydnsdomname(talloc_tos()); diff --git a/source3/auth/auth_server.c b/source3/auth/auth_server.c index 33c658dd8f..da380db01a 100644 --- a/source3/auth/auth_server.c +++ b/source3/auth/auth_server.c @@ -85,7 +85,7 @@ static struct cli_state *server_cryptkey(TALLOC_CTX *mem_ctx) } status = cli_connect_nb(desthost, &dest_ss, 0, 0x20, - global_myname(), Undefined, &cli); + lp_netbios_name(), Undefined, &cli); if (NT_STATUS_IS_OK(status)) { DEBUG(3,("connected to password server %s\n",desthost)); connected_ok = True; @@ -332,7 +332,7 @@ static NTSTATUS check_smbserver_security(const struct auth_context *auth_context baduser = talloc_asprintf(mem_ctx, "%s%s", INVALID_USER_PREFIX, - global_myname()); + lp_netbios_name()); if (!baduser) { return NT_STATUS_NO_MEMORY; } diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c index b401409f6c..1b986a0640 100644 --- a/source3/auth/auth_util.c +++ b/source3/auth/auth_util.c @@ -668,7 +668,7 @@ NTSTATUS make_server_info_pw(struct auth_serversupplied_info **server_info, return NT_STATUS_NO_MEMORY; } - status = samu_to_SamInfo3(result, sampass, global_myname(), + status = samu_to_SamInfo3(result, sampass, lp_netbios_name(), &result->info3, &result->extra); TALLOC_FREE(sampass); if (!NT_STATUS_IS_OK(status)) { @@ -758,7 +758,7 @@ static NTSTATUS make_new_server_info_guest(struct auth_serversupplied_info **ses struct auth_serversupplied_info *server_info; static const char zeros[16] = {0}; const char *guest_account = lp_guestaccount(); - const char *domain = global_myname(); + const char *domain = lp_netbios_name(); struct netr_SamInfo3 info3; TALLOC_CTX *tmp_ctx; NTSTATUS status; diff --git a/source3/auth/server_info_sam.c b/source3/auth/server_info_sam.c index 31fd9f9926..261e3de8f2 100644 --- a/source3/auth/server_info_sam.c +++ b/source3/auth/server_info_sam.c @@ -49,7 +49,7 @@ static bool is_our_machine_account(const char *username) return false; } truncname[ulen-1] = '\0'; - ret = strequal(truncname, global_myname()); + ret = strequal(truncname, lp_netbios_name()); SAFE_FREE(truncname); return ret; } @@ -77,7 +77,7 @@ NTSTATUS make_server_info_sam(struct auth_serversupplied_info **server_info, return NT_STATUS_NO_SUCH_USER; } - status = samu_to_SamInfo3(result, sampass, global_myname(), + status = samu_to_SamInfo3(result, sampass, lp_netbios_name(), &result->info3, &result->extra); if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(result); diff --git a/source3/client/client.c b/source3/client/client.c index 209c2cb1c9..b485df7741 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -49,7 +49,6 @@ extern char tar_type; static int port = 0; static char *service; static char *desthost; -static char *calling_name; static bool grepable = false; static char *cmdstr = NULL; const char *cmd_ptr = NULL; @@ -5042,7 +5041,7 @@ static int do_message_op(struct user_auth_info *a_info) status = cli_connect_nb(desthost, have_ip ? &dest_ss : NULL, port ? port : 139, name_type, - calling_name, Undefined, &cli); + lp_netbios_name(), Undefined, &cli); if (!NT_STATUS_IS_OK(status)) { d_printf("Connection to %s failed. Error %s\n", desthost, nt_errstr(status)); return 1; @@ -5097,11 +5096,6 @@ static int do_message_op(struct user_auth_info *a_info) exit(ENOMEM); } - /* initialize the netbios name so we can determine whether or - not it was set by a command line option */ - - set_global_myname( "" ); - /* set default debug level to 1 regardless of what smb.conf sets */ setup_logging( "smbclient", DEBUG_DEFAULT_STDERR ); load_case_tables(); @@ -5247,11 +5241,6 @@ static int do_message_op(struct user_auth_info *a_info) poptGetArg(pc)); } - calling_name = talloc_strdup(frame, global_myname() ); - if (!calling_name) { - exit(ENOMEM); - } - if ( override_logfile ) setup_logging( lp_logfile(), DEBUG_FILE ); @@ -5285,13 +5274,6 @@ static int do_message_op(struct user_auth_info *a_info) } } - if ( strlen(calling_name) != 0 ) { - set_global_myname( calling_name ); - } else { - TALLOC_FREE(calling_name); - calling_name = talloc_strdup(frame, global_myname() ); - } - smb_encrypt = get_cmdline_auth_info_smb_encrypt(auth_info); if (!init_names()) { fprintf(stderr, "init_names() failed\n"); diff --git a/source3/include/proto.h b/source3/include/proto.h index 585d53f643..6820db99f2 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -493,10 +493,6 @@ char *get_user_home_dir(TALLOC_CTX *mem_ctx, const char *user); struct passwd *Get_Pwnam_alloc(TALLOC_CTX *mem_ctx, const char *user); /* The following definitions come from lib/util_names.c */ -void gfree_netbios_names(void); -bool set_global_myname(const char *myname); -const char *global_myname(void); -bool set_global_myworkgroup(const char *myworkgroup); const char *get_global_sam_name(void); /* The following definitions come from lib/util.c */ @@ -1198,6 +1194,7 @@ char *lp_passwd_chat(void); const char *lp_passwordserver(void); const char *lp_name_resolve_order(void); const char *lp_netbios_scope(void); +const char *lp_netbios_name(void); const char *lp_workgroup(void); const char *lp_realm(void); const char *lp_dnsdomain(void); diff --git a/source3/lib/netapi/serverinfo.c b/source3/lib/netapi/serverinfo.c index 8f76b4a63e..34db569cd7 100644 --- a/source3/lib/netapi/serverinfo.c +++ b/source3/lib/netapi/serverinfo.c @@ -36,7 +36,7 @@ static WERROR NetServerGetInfo_l_101(struct libnetapi_ctx *ctx, struct SERVER_INFO_101 i; i.sv101_platform_id = PLATFORM_ID_NT; - i.sv101_name = global_myname(); + i.sv101_name = lp_netbios_name(); i.sv101_version_major = lp_major_announce_version(); i.sv101_version_minor = lp_minor_announce_version(); i.sv101_type = lp_default_server_announce(); diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c index 58f0478a76..0c8f691c25 100644 --- a/source3/lib/popt_common.c +++ b/source3/lib/popt_common.c @@ -129,7 +129,7 @@ static void popt_common_callback(poptContext con, case 'n': if (arg) { - set_global_myname(arg); + lp_set_cmdline("netbios name", arg); } break; diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c index d98a18ae2e..38fdc40dd4 100644 --- a/source3/lib/substitute.c +++ b/source3/lib/substitute.c @@ -80,7 +80,7 @@ bool set_local_machine_name(const char *local_name, bool perm) const char *get_local_machine_name(void) { if (!local_machine || !*local_machine) { - return global_myname(); + return lp_netbios_name(); } return local_machine; @@ -489,7 +489,7 @@ static const char *automount_server(const char *user_name) if (local_machine_name && *local_machine_name) { server_name = talloc_strdup(ctx, local_machine_name); } else { - server_name = talloc_strdup(ctx, global_myname()); + server_name = talloc_strdup(ctx, lp_netbios_name()); } if (!server_name) { @@ -638,7 +638,7 @@ static char *alloc_sub_basic(const char *smb_name, const char *domain_name, if (local_machine_name && *local_machine_name) { a_string = realloc_string_sub(a_string, "%L", local_machine_name); } else { - a_string = realloc_string_sub(a_string, "%L", global_myname()); + a_string = realloc_string_sub(a_string, "%L", lp_netbios_name()); } break; case 'N': diff --git a/source3/lib/util_cmdline.c b/source3/lib/util_cmdline.c index 6c2802c208..39f136821c 100644 --- a/source3/lib/util_cmdline.c +++ b/source3/lib/util_cmdline.c @@ -228,7 +228,7 @@ bool set_cmdline_auth_info_machine_account_creds(struct user_auth_info *auth_inf return false; } - if (asprintf(&account, "%s$@%s", global_myname(), lp_realm()) < 0) { + if (asprintf(&account, "%s$@%s", lp_netbios_name(), lp_realm()) < 0) { return false; } diff --git a/source3/lib/util_names.c b/source3/lib/util_names.c index 78d7988367..0e128eab1c 100644 --- a/source3/lib/util_names.c +++ b/source3/lib/util_names.c @@ -28,8 +28,6 @@ Definitions for all names. ***********************************************************************/ -static char *smb_myname; -static char *smb_myworkgroup; static int smb_num_netbios_names; static char **smb_my_netbios_names; @@ -75,7 +73,6 @@ static bool set_my_netbios_names(const char *name, int i) void gfree_names(void) { - gfree_netbios_names(); free_netbios_names_array(); free_local_machine_name(); } @@ -93,7 +90,7 @@ bool set_netbios_aliases(const char **str_array) for( namecount=0; str_array && (str_array[namecount] != NULL); namecount++ ) ; - if ( global_myname() && *global_myname()) + if ( lp_netbios_name() && *lp_netbios_name()) namecount++; /* Allocate space for the netbios aliases */ @@ -102,8 +99,8 @@ bool set_netbios_aliases(const char **str_array) /* Use the global_myname string first */ namecount=0; - if ( global_myname() && *global_myname()) { - set_my_netbios_names( global_myname(), namecount ); + if ( lp_netbios_name() && *lp_netbios_name()) { + set_my_netbios_names( lp_netbios_name(), namecount ); namecount++; } @@ -138,19 +135,12 @@ bool init_names(void) { int n; - if (global_myname() == NULL || *global_myname() == '\0') { - if (!set_global_myname(myhostname())) { - DEBUG( 0, ( "init_names: malloc fail.\n" ) ); - return False; - } - } - if (!set_netbios_aliases(lp_netbios_aliases())) { DEBUG( 0, ( "init_names: malloc fail.\n" ) ); return False; } - set_local_machine_name(global_myname(),false); + set_local_machine_name(lp_netbios_name(),false); DEBUG( 5, ("Netbios name list:-\n") ); for( n=0; my_netbios_names(n); n++ ) { @@ -161,25 +151,6 @@ bool init_names(void) return( True ); } -/*********************************************************************** - Allocate and set myname. Ensure upper case. -***********************************************************************/ - -bool set_global_myname(const char *myname) -{ - SAFE_FREE(smb_myname); - smb_myname = SMB_STRDUP(myname); - if (!smb_myname) - return False; - strupper_m(smb_myname); - return True; -} - -const char *global_myname(void) -{ - return smb_myname; -} - /****************************************************************** get the default domain/netbios name to be used when dealing with our passdb list of accounts @@ -190,11 +161,6 @@ const char *get_global_sam_name(void) if (IS_DC) { return lp_workgroup(); } - return global_myname(); + return lp_netbios_name(); } -void gfree_netbios_names(void) -{ - SAFE_FREE( smb_myname ); - SAFE_FREE( smb_myworkgroup ); -} diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index fd91fd58dc..9b8632b181 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -1370,7 +1370,7 @@ bool is_myname_or_ipaddr(const char *s) } /* Optimize for the common case */ - if (strequal(servername, global_myname())) { + if (strequal(servername, lp_netbios_name())) { return true; } diff --git a/source3/libads/authdata.c b/source3/libads/authdata.c index 6f49b857da..44279a24d7 100644 --- a/source3/libads/authdata.c +++ b/source3/libads/authdata.c @@ -78,7 +78,7 @@ NTSTATUS kerberos_return_pac(TALLOC_CTX *mem_ctx, NT_STATUS_HAVE_NO_MEMORY(auth_princ); local_service = talloc_asprintf(mem_ctx, "%s$@%s", - global_myname(), lp_realm()); + lp_netbios_name(), lp_realm()); NT_STATUS_HAVE_NO_MEMORY(local_service); ret = kerberos_kinit_password_ext(auth_princ, diff --git a/source3/libads/kerberos.c b/source3/libads/kerberos.c index a41686a495..913d690049 100644 --- a/source3/libads/kerberos.c +++ b/source3/libads/kerberos.c @@ -352,7 +352,7 @@ char* kerberos_standard_des_salt( void ) { fstring salt; - fstr_sprintf( salt, "host/%s.%s@", global_myname(), lp_realm() ); + fstr_sprintf( salt, "host/%s.%s@", lp_netbios_name(), lp_realm() ); strlower_m( salt ); fstrcat( salt, lp_realm() ); diff --git a/source3/libads/kerberos_keytab.c b/source3/libads/kerberos_keytab.c index 6e1b7c08fe..7654c666f4 100644 --- a/source3/libads/kerberos_keytab.c +++ b/source3/libads/kerberos_keytab.c @@ -316,7 +316,7 @@ int ads_keytab_add_entry(ADS_STRUCT *ads, const char *srvPrinc) goto out; } - my_fqdn = ads_get_dnshostname(ads, tmpctx, global_myname()); + my_fqdn = ads_get_dnshostname(ads, tmpctx, lp_netbios_name()); if (!my_fqdn) { DEBUG(0, (__location__ ": unable to determine machine " "account's dns name in AD!\n")); @@ -324,7 +324,7 @@ int ads_keytab_add_entry(ADS_STRUCT *ads, const char *srvPrinc) goto out; } - machine_name = ads_get_samaccountname(ads, tmpctx, global_myname()); + machine_name = ads_get_samaccountname(ads, tmpctx, lp_netbios_name()); if (!machine_name) { DEBUG(0, (__location__ ": unable to determine machine " "account's short name in AD!\n")); @@ -380,7 +380,7 @@ int ads_keytab_add_entry(ADS_STRUCT *ads, const char *srvPrinc) "'%s'\n", princ_s)); aderr = ads_add_service_principal_name(ads, - global_myname(), my_fqdn, srvPrinc); + lp_netbios_name(), my_fqdn, srvPrinc); if (!ADS_ERR_OK(aderr)) { DEBUG(1, (__location__ ": failed to " "ads_add_service_principal_name.\n")); @@ -389,7 +389,7 @@ int ads_keytab_add_entry(ADS_STRUCT *ads, const char *srvPrinc) } } - kvno = (krb5_kvno)ads_get_machine_kvno(ads, global_myname()); + kvno = (krb5_kvno)ads_get_machine_kvno(ads, lp_netbios_name()); if (kvno == -1) { /* -1 indicates failure, everything else is OK */ DEBUG(1, (__location__ ": ads_get_machine_kvno failed to " @@ -458,7 +458,7 @@ int ads_keytab_flush(ADS_STRUCT *ads) goto out; } - kvno = (krb5_kvno)ads_get_machine_kvno(ads, global_myname()); + kvno = (krb5_kvno)ads_get_machine_kvno(ads, lp_netbios_name()); if (kvno == -1) { /* -1 indicates a failure */ DEBUG(1, (__location__ ": Error determining the kvno.\n")); @@ -472,7 +472,7 @@ int ads_keytab_flush(ADS_STRUCT *ads) goto out; } - aderr = ads_clear_service_principal_names(ads, global_myname()); + aderr = ads_clear_service_principal_names(ads, lp_netbios_name()); if (!ADS_ERR_OK(aderr)) { DEBUG(1, (__location__ ": Error while clearing service " "principal listings in LDAP.\n")); @@ -547,7 +547,7 @@ int ads_keytab_create_default(ADS_STRUCT *ads) goto done; } - machine_name = talloc_strdup(tmpctx, global_myname()); + machine_name = talloc_strdup(tmpctx, lp_netbios_name()); if (!machine_name) { ret = -1; goto done; diff --git a/source3/libads/kerberos_util.c b/source3/libads/kerberos_util.c index 4762e1b914..4935da8e79 100644 --- a/source3/libads/kerberos_util.c +++ b/source3/libads/kerberos_util.c @@ -72,13 +72,13 @@ int ads_kinit_password(ADS_STRUCT *ads) account_name = lp_workgroup(); } else { /* always use the sAMAccountName for security = domain */ - /* global_myname()$@REA.LM */ + /* lp_netbios_name()$@REA.LM */ if ( lp_security() == SEC_DOMAIN ) { - fstr_sprintf( acct_name, "%s$", global_myname() ); + fstr_sprintf( acct_name, "%s$", lp_netbios_name() ); account_name = acct_name; } else - /* This looks like host/global_myname()@REA.LM */ + /* This looks like host/lp_netbios_name()@REA.LM */ account_name = ads->auth.user_name; } diff --git a/source3/libads/kerberos_verify.c b/source3/libads/kerberos_verify.c index fab38dc4de..f11ea88477 100644 --- a/source3/libads/kerberos_verify.c +++ b/source3/libads/kerberos_verify.c @@ -151,10 +151,10 @@ static bool ads_keytab_verify_ticket(krb5_context context, * clients might want to use for authenticating to the file * service. We allow name$,{host,cifs}/{name,fqdn,name.REALM}. */ - fstrcpy(my_name, global_myname()); + fstrcpy(my_name, lp_netbios_name()); my_fqdn[0] = '\0'; - name_to_fqdn(my_fqdn, global_myname()); + name_to_fqdn(my_fqdn, lp_netbios_name()); err = asprintf(&valid_princ_formats[0], "%s$@%s", my_name, lp_realm()); @@ -534,7 +534,7 @@ NTSTATUS ads_verify_ticket(TALLOC_CTX *mem_ctx, krb5_auth_con_setflags( context, auth_context, flags ); } - if (asprintf(&host_princ_s, "%s$", global_myname()) == -1) { + if (asprintf(&host_princ_s, "%s$", lp_netbios_name()) == -1) { goto out; } diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index ed17ed8473..128c133760 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -657,7 +657,7 @@ got_connection: /* Must use the userPrincipalName value here or sAMAccountName and not servicePrincipalName; found by Guenther Deschner */ - if (asprintf(&ads->auth.user_name, "%s$", global_myname() ) == -1) { + if (asprintf(&ads->auth.user_name, "%s$", lp_netbios_name() ) == -1) { DEBUG(0,("ads_connect: asprintf fail.\n")); ads->auth.user_name = NULL; } @@ -3325,10 +3325,10 @@ char* ads_get_dnshostname( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine int count = 0; char *name = NULL; - status = ads_find_machine_acct(ads, &res, global_myname()); + status = ads_find_machine_acct(ads, &res, lp_netbios_name()); if (!ADS_ERR_OK(status)) { DEBUG(0,("ads_get_dnshostname: Failed to find account for %s\n", - global_myname())); + lp_netbios_name())); goto out; } @@ -3360,7 +3360,7 @@ char* ads_get_upn( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine_name ) status = ads_find_machine_acct(ads, &res, machine_name); if (!ADS_ERR_OK(status)) { DEBUG(0,("ads_get_upn: Failed to find account for %s\n", - global_myname())); + lp_netbios_name())); goto out; } @@ -3389,10 +3389,10 @@ char* ads_get_samaccountname( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *mach int count = 0; char *name = NULL; - status = ads_find_machine_acct(ads, &res, global_myname()); + status = ads_find_machine_acct(ads, &res, lp_netbios_name()); if (!ADS_ERR_OK(status)) { DEBUG(0,("ads_get_dnshostname: Failed to find account for %s\n", - global_myname())); + lp_netbios_name())); goto out; } diff --git a/source3/libads/sasl.c b/source3/libads/sasl.c index 8b2dbad434..45cf569c79 100644 --- a/source3/libads/sasl.c +++ b/source3/libads/sasl.c @@ -141,7 +141,7 @@ static ADS_STATUS ads_sasl_spnego_ntlmssp_bind(ADS_STRUCT *ads) struct ntlmssp_state *ntlmssp_state; nt_status = ntlmssp_client_start(NULL, - global_myname(), + lp_netbios_name(), lp_workgroup(), lp_client_ntlmv2_auth(), &ntlmssp_state); diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 4f67e51fc2..16c068c66e 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -1813,7 +1813,7 @@ WERROR libnet_init_JoinCtx(TALLOC_CTX *mem_ctx, talloc_set_destructor(ctx, libnet_destroy_JoinCtx); - ctx->in.machine_name = talloc_strdup(mem_ctx, global_myname()); + ctx->in.machine_name = talloc_strdup(mem_ctx, lp_netbios_name()); W_ERROR_HAVE_NO_MEMORY(ctx->in.machine_name); krb5_cc_env = getenv(KRB5_ENV_CCNAME); @@ -1846,7 +1846,7 @@ WERROR libnet_init_UnjoinCtx(TALLOC_CTX *mem_ctx, talloc_set_destructor(ctx, libnet_destroy_UnjoinCtx); - ctx->in.machine_name = talloc_strdup(mem_ctx, global_myname()); + ctx->in.machine_name = talloc_strdup(mem_ctx, lp_netbios_name()); W_ERROR_HAVE_NO_MEMORY(ctx->in.machine_name); krb5_cc_env = getenv(KRB5_ENV_CCNAME); diff --git a/source3/libnet/libnet_samsync.c b/source3/libnet/libnet_samsync.c index 9803c89538..75fc329e0a 100644 --- a/source3/libnet/libnet_samsync.c +++ b/source3/libnet/libnet_samsync.c @@ -203,7 +203,7 @@ static NTSTATUS libnet_samsync_delta(TALLOC_CTX *mem_ctx, NTSTATUS result, status; NTSTATUS callback_status; const char *logon_server = ctx->cli->desthost; - const char *computername = global_myname(); + const char *computername = lp_netbios_name(); struct netr_Authenticator credential; struct netr_Authenticator return_authenticator; uint16_t restart_state = 0; diff --git a/source3/librpc/crypto/cli_spnego.c b/source3/librpc/crypto/cli_spnego.c index bf58e25d9a..e4fdf315aa 100644 --- a/source3/librpc/crypto/cli_spnego.c +++ b/source3/librpc/crypto/cli_spnego.c @@ -99,7 +99,7 @@ NTSTATUS spnego_ntlmssp_init_client(TALLOC_CTX *mem_ctx, sp_ctx->mech = SPNEGO_NTLMSSP; status = auth_ntlmssp_client_start(sp_ctx, - global_myname(), + lp_netbios_name(), lp_workgroup(), lp_client_ntlmv2_auth(), &sp_ctx->mech_ctx.ntlmssp_state); diff --git a/source3/librpc/crypto/gse_krb5.c b/source3/librpc/crypto/gse_krb5.c index 830d517bc7..81a9a07596 100644 --- a/source3/librpc/crypto/gse_krb5.c +++ b/source3/librpc/crypto/gse_krb5.c @@ -90,7 +90,7 @@ static krb5_error_code get_host_principal(krb5_context krbctx, char *host_princ_s = NULL; int err; - err = asprintf(&host_princ_s, "%s$@%s", global_myname(), lp_realm()); + err = asprintf(&host_princ_s, "%s$@%s", lp_netbios_name(), lp_realm()); if (err == -1) { return -1; } diff --git a/source3/librpc/rpc/dcerpc_ep.c b/source3/librpc/rpc/dcerpc_ep.c index 5088e7efcf..3d1acbbee2 100644 --- a/source3/librpc/rpc/dcerpc_ep.c +++ b/source3/librpc/rpc/dcerpc_ep.c @@ -78,7 +78,7 @@ NTSTATUS dcerpc_binding_vector_create(TALLOC_CTX *mem_ctx, switch (b->transport) { case NCACN_NP: - b->host = talloc_asprintf(b, "\\\\%s", global_myname()); + b->host = talloc_asprintf(b, "\\\\%s", lp_netbios_name()); if (b->host == NULL) { status = NT_STATUS_NO_MEMORY; goto done; diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 2b269378dc..a9a1847f1c 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -1590,7 +1590,7 @@ static struct tevent_req *cli_session_setup_ntlmssp_send( cli_temp_set_signing(cli); status = ntlmssp_client_start(state, - global_myname(), + lp_netbios_name(), lp_workgroup(), lp_client_ntlmv2_auth(), &state->ntlmssp_state); diff --git a/source3/libsmb/clidgram.c b/source3/libsmb/clidgram.c index c0eb724fbf..90f06fd535 100644 --- a/source3/libsmb/clidgram.c +++ b/source3/libsmb/clidgram.c @@ -140,7 +140,7 @@ static bool prep_getdc_request(const struct sockaddr_storage *dc_ss, my_sid = *sid; } - my_acct_name = talloc_asprintf(talloc_tos(), "%s$", global_myname()); + my_acct_name = talloc_asprintf(talloc_tos(), "%s$", lp_netbios_name()); if (my_acct_name == NULL) { goto fail; } @@ -149,7 +149,7 @@ static bool prep_getdc_request(const struct sockaddr_storage *dc_ss, s = &packet.req.logon; s->request_count = 0; - s->computer_name = global_myname(); + s->computer_name = lp_netbios_name(); s->user_name = my_acct_name; s->mailslot_name = my_mailslot; s->acct_control = ACB_WSTRUST; @@ -170,7 +170,7 @@ static bool prep_getdc_request(const struct sockaddr_storage *dc_ss, ret = cli_prep_mailslot(false, NBT_MAILSLOT_NTLOGON, 0, (char *)blob.data, blob.length, - global_myname(), 0, domain_name, 0x1c, + lp_netbios_name(), 0, domain_name, 0x1c, dc_ss, dgm_id, p); fail: TALLOC_FREE(frame); diff --git a/source3/libsmb/clifsinfo.c b/source3/libsmb/clifsinfo.c index db4199d327..78024c8f98 100644 --- a/source3/libsmb/clifsinfo.c +++ b/source3/libsmb/clifsinfo.c @@ -592,7 +592,7 @@ NTSTATUS cli_raw_ntlm_smb_encryption_start(struct cli_state *cli, return NT_STATUS_NO_MEMORY; } status = ntlmssp_client_start(NULL, - global_myname(), + lp_netbios_name(), lp_workgroup(), lp_client_ntlmv2_auth(), &es->s.ntlmssp_state); diff --git a/source3/libsmb/clikrb5.c b/source3/libsmb/clikrb5.c index 73a37b3115..b11aed8c7b 100644 --- a/source3/libsmb/clikrb5.c +++ b/source3/libsmb/clikrb5.c @@ -1273,7 +1273,7 @@ done: return ENOMEM; } - put_name(buf, global_myname(), ' ', 0x20); + put_name(buf, lp_netbios_name(), ' ', 0x20); #if defined(HAVE_MAGIC_IN_KRB5_ADDRESS) && defined(HAVE_ADDRTYPE_IN_KRB5_ADDRESS) /* MIT */ { diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c index 9d473d19b2..dbf70e02c8 100644 --- a/source3/libsmb/libsmb_context.c +++ b/source3/libsmb/libsmb_context.c @@ -599,8 +599,8 @@ smbc_init_context(SMBCCTX *context) * our hostname etc */ char *netbios_name; - if (global_myname()) { - netbios_name = SMB_STRDUP(global_myname()); + if (lp_netbios_name()) { + netbios_name = SMB_STRDUP(lp_netbios_name()); } else { /* * Hmmm, I want to get hostname as well, but I am too diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c index 80faaed1af..4dbc2652d2 100644 --- a/source3/libsmb/libsmb_server.c +++ b/source3/libsmb/libsmb_server.c @@ -713,7 +713,7 @@ SMBC_attr_server(TALLOC_CTX *ctx, zero_sockaddr(&ss); nt_status = cli_full_connection(&ipc_cli, - global_myname(), server, + lp_netbios_name(), server, &ss, 0, "IPC$", "?????", *pp_username, *pp_workgroup, diff --git a/source3/libsmb/smbsock_connect.c b/source3/libsmb/smbsock_connect.c index 8cf403c5ac..3a228b1b9e 100644 --- a/source3/libsmb/smbsock_connect.c +++ b/source3/libsmb/smbsock_connect.c @@ -216,7 +216,7 @@ struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx, state->called_type = (called_type != -1) ? called_type : 0x20; state->calling_name = - (calling_name != NULL) ? calling_name : global_myname(); + (calling_name != NULL) ? calling_name : lp_netbios_name(); state->calling_type = (calling_type != -1) ? calling_type : 0x00; diff --git a/source3/libsmb/trusts_util.c b/source3/libsmb/trusts_util.c index eb79b2ba93..dc2cf03a04 100644 --- a/source3/libsmb/trusts_util.c +++ b/source3/libsmb/trusts_util.c @@ -169,7 +169,7 @@ bool enumerate_domain_trusts( TALLOC_CTX *mem_ctx, const char *domain, /* setup the anonymous connection */ - status = cli_full_connection( &cli, global_myname(), dc_name, &dc_ss, 0, "IPC$", "IPC", + status = cli_full_connection( &cli, lp_netbios_name(), dc_name, &dc_ss, 0, "IPC$", "IPC", "", "", "", 0, Undefined); if ( !NT_STATUS_IS_OK(status) ) goto done; @@ -264,7 +264,7 @@ NTSTATUS change_trust_account_password( const char *domain, const char *remote_m /* if this next call fails, then give up. We can't do password changes on BDC's --jerry */ - if (!NT_STATUS_IS_OK(cli_full_connection(&cli, global_myname(), dc_name, + if (!NT_STATUS_IS_OK(cli_full_connection(&cli, lp_netbios_name(), dc_name, NULL, 0, "IPC$", "IPC", "", "", diff --git a/source3/nmbd/nmbd_become_dmb.c b/source3/nmbd/nmbd_become_dmb.c index 160bcb3c33..276c381f6c 100644 --- a/source3/nmbd/nmbd_become_dmb.c +++ b/source3/nmbd/nmbd_become_dmb.c @@ -51,10 +51,10 @@ workgroup %s on subnet %s\n", failname, subrec->subnet_name)); /* Set the state back to DOMAIN_NONE. */ work->dom_state = DOMAIN_NONE; - if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) { + if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) { DEBUG(0,("become_domain_master_fail: Error - cannot find server %s \ in workgroup %s on subnet %s\n", - global_myname(), work->work_group, subrec->subnet_name)); + lp_netbios_name(), work->work_group, subrec->subnet_name)); return; } @@ -92,10 +92,10 @@ workgroup %s on subnet %s\n", regname, subrec->subnet_name)); return; } - if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) { + if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) { DEBUG(0,("become_domain_master_stage2: Error - cannot find server %s \ in workgroup %s on subnet %s\n", - global_myname(), regname, subrec->subnet_name)); + lp_netbios_name(), regname, subrec->subnet_name)); work->dom_state = DOMAIN_NONE; return; } @@ -110,7 +110,7 @@ in workgroup %s on subnet %s\n", subrec->work_changed = True; if( DEBUGLVL( 0 ) ) { - dbgtext( "*****\n\nSamba server %s ", global_myname() ); + dbgtext( "*****\n\nSamba server %s ", lp_netbios_name() ); dbgtext( "is now a domain master browser for " ); dbgtext( "workgroup %s ", work->work_group ); dbgtext( "on subnet %s\n\n*****\n", subrec->subnet_name ); @@ -126,7 +126,7 @@ in workgroup %s on subnet %s\n", will stop us syncing with ourself if we are also a local master browser. */ - make_nmb_name(&nmbname, global_myname(), 0x20); + make_nmb_name(&nmbname, lp_netbios_name(), 0x20); work->dmb_name = nmbname; diff --git a/source3/nmbd/nmbd_become_lmb.c b/source3/nmbd/nmbd_become_lmb.c index 58dd3eec9e..f94efd0371 100644 --- a/source3/nmbd/nmbd_become_lmb.c +++ b/source3/nmbd/nmbd_become_lmb.c @@ -85,10 +85,10 @@ subnet %s.\n", workgroup_name, subrec->subnet_name )); return; } - if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) { + if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) { DEBUG(0,("reset_workgroup_state: Error - cannot find server %s \ in workgroup %s on subnet %s\n", - global_myname(), work->work_group, subrec->subnet_name)); + lp_netbios_name(), work->work_group, subrec->subnet_name)); work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE; return; } @@ -149,7 +149,7 @@ static void unbecome_local_master_success(struct subnet_record *subrec, if( DEBUGLVL( 0 ) ) { dbgtext( "*****\n\n" ); - dbgtext( "Samba name server %s ", global_myname() ); + dbgtext( "Samba name server %s ", lp_netbios_name() ); dbgtext( "has stopped being a local master browser " ); dbgtext( "for workgroup %s ", relname ); dbgtext( "on subnet %s\n\n*****\n", subrec->subnet_name ); @@ -185,7 +185,7 @@ Removing from namelist anyway.\n", nmb_namestr(fail_name))); if( DEBUGLVL( 0 ) ) { dbgtext( "*****\n\n" ); - dbgtext( "Samba name server %s ", global_myname() ); + dbgtext( "Samba name server %s ", lp_netbios_name() ); dbgtext( "has stopped being a local master browser " ); dbgtext( "for workgroup %s ", failname ); dbgtext( "on subnet %s\n\n*****\n", subrec->subnet_name ); @@ -280,10 +280,10 @@ void unbecome_local_master_browser(struct subnet_record *subrec, struct work_rec DEBUG(2,("unbecome_local_master_browser: unbecoming local master for workgroup %s \ on subnet %s\n",work->work_group, subrec->subnet_name)); - if(find_server_in_workgroup( work, global_myname()) == NULL) { + if(find_server_in_workgroup( work, lp_netbios_name()) == NULL) { DEBUG(0,("unbecome_local_master_browser: Error - cannot find server %s \ in workgroup %s on subnet %s\n", - global_myname(), work->work_group, subrec->subnet_name)); + lp_netbios_name(), work->work_group, subrec->subnet_name)); work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE; return; } @@ -342,10 +342,10 @@ workgroup %s on subnet %s\n", regname, subrec->subnet_name)); return; } - if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) { + if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) { DEBUG(0,("become_local_master_stage2: Error - cannot find server %s \ in workgroup %s on subnet %s\n", - global_myname(), regname, subrec->subnet_name)); + lp_netbios_name(), regname, subrec->subnet_name)); work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE; return; } @@ -363,7 +363,7 @@ on subnet %s\n", work->work_group, subrec->subnet_name)); subrec->work_changed = True; /* Add this name to the workgroup as local master browser. */ - set_workgroup_local_master_browser_name( work, global_myname()); + set_workgroup_local_master_browser_name( work, lp_netbios_name()); /* Count the number of servers we have on our list. If it's less than 10 (just a heuristic) request the servers @@ -396,7 +396,7 @@ on subnet %s\n", work->work_group, subrec->subnet_name)); if( DEBUGLVL( 0 ) ) { dbgtext( "*****\n\n" ); - dbgtext( "Samba name server %s ", global_myname() ); + dbgtext( "Samba name server %s ", lp_netbios_name() ); dbgtext( "is now a local master browser " ); dbgtext( "for workgroup %s ", work->work_group ); dbgtext( "on subnet %s\n\n*****\n", subrec->subnet_name ); @@ -487,10 +487,10 @@ workgroup %s on subnet %s\n", work_name, subrec->subnet_name)); return; } - if(find_server_in_workgroup(work, global_myname()) == NULL) { + if(find_server_in_workgroup(work, lp_netbios_name()) == NULL) { DEBUG(0,("become_local_master_fail1: Error - cannot find server %s \ in workgroup %s on subnet %s\n", - global_myname(), work->work_group, subrec->subnet_name)); + lp_netbios_name(), work->work_group, subrec->subnet_name)); return; } @@ -527,10 +527,10 @@ void become_local_master_browser(struct subnet_record *subrec, struct work_recor return; } - if(find_server_in_workgroup( work, global_myname()) == NULL) { + if(find_server_in_workgroup( work, lp_netbios_name()) == NULL) { DEBUG(0,("become_local_master_browser: Error - cannot find server %s \ in workgroup %s on subnet %s\n", - global_myname(), work->work_group, subrec->subnet_name)); + lp_netbios_name(), work->work_group, subrec->subnet_name)); return; } diff --git a/source3/nmbd/nmbd_browsesync.c b/source3/nmbd/nmbd_browsesync.c index 1a262e4728..c6ded584e5 100644 --- a/source3/nmbd/nmbd_browsesync.c +++ b/source3/nmbd/nmbd_browsesync.c @@ -119,7 +119,7 @@ static void announce_local_master_browser_to_domain_master_browser( struct work_ SCVAL(p,0,ANN_MasterAnnouncement); p++; - unstrcpy(myname, global_myname()); + unstrcpy(myname, lp_netbios_name()); strupper_m(myname); myname[15]='\0'; /* The call below does CH_UNIX -> CH_DOS conversion. JRA */ @@ -137,7 +137,7 @@ static void announce_local_master_browser_to_domain_master_browser( struct work_ /* Target name for send_mailslot must be in UNIX charset. */ pull_ascii_nstring(dmb_name, sizeof(dmb_name), work->dmb_name.name); send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf), - global_myname(), 0x0, dmb_name, 0x0, + lp_netbios_name(), 0x0, dmb_name, 0x0, work->dmb_addr, FIRST_SUBNET->myip, DGRAM_PORT); } diff --git a/source3/nmbd/nmbd_elections.c b/source3/nmbd/nmbd_elections.c index 4340f66096..ac0d873512 100644 --- a/source3/nmbd/nmbd_elections.c +++ b/source3/nmbd/nmbd_elections.c @@ -57,7 +57,7 @@ static void send_election_dgram(struct subnet_record *subrec, const char *workgr p = skip_string(outbuf,sizeof(outbuf),p); send_mailslot(False, BROWSE_MAILSLOT, outbuf, PTR_DIFF(p,outbuf), - global_myname(), 0, + lp_netbios_name(), 0, workgroup_name, 0x1e, subrec->bcast_ip, subrec->myip, DGRAM_PORT); } @@ -194,7 +194,7 @@ yet registered on subnet %s\n", nmb_namestr(&nmbname), subrec->subnet_name )); } send_election_dgram(subrec, work->work_group, work->ElectionCriterion, - t - StartupTime, global_myname()); + t - StartupTime, lp_netbios_name()); if (work->ElectionCount++ >= 4) { /* Won election (4 packets were sent out uncontested. */ @@ -231,7 +231,7 @@ static bool win_election(struct work_record *work, int version, version, ELECTION_VERSION, criterion, mycriterion, timeup, mytimeup, - server_name, global_myname())); + server_name, lp_netbios_name())); if (version > ELECTION_VERSION) return(False); @@ -248,7 +248,7 @@ static bool win_election(struct work_record *work, int version, if (timeup < mytimeup) return(True); - if (strcasecmp_m(global_myname(), server_name) > 0) + if (strcasecmp_m(lp_netbios_name(), server_name) > 0) return(False); return(True); diff --git a/source3/nmbd/nmbd_incomingdgrams.c b/source3/nmbd/nmbd_incomingdgrams.c index 11f3d43e0c..582848c1fc 100644 --- a/source3/nmbd/nmbd_incomingdgrams.c +++ b/source3/nmbd/nmbd_incomingdgrams.c @@ -144,7 +144,7 @@ void process_host_announce(struct subnet_record *subrec, struct packet_struct *p * to be our primary workgroup name. */ - if(strequal(work_name, global_myname())) + if(strequal(work_name, lp_netbios_name())) unstrcpy(work_name,lp_workgroup()); /* @@ -484,7 +484,7 @@ originate from OS/2 Warp client. Ignoring packet.\n")); * not needed in the LanMan announce code, but it won't hurt. */ - if(strequal(work_name, global_myname())) + if(strequal(work_name, lp_netbios_name())) unstrcpy(work_name,lp_workgroup()); /* @@ -571,7 +571,7 @@ static void send_backup_list_response(struct subnet_record *subrec, /* We always return at least one name - our own. */ count = 1; - unstrcpy(myname, global_myname()); + unstrcpy(myname, lp_netbios_name()); strupper_m(myname); myname[15]='\0'; push_ascii(p, myname, sizeof(outbuf)-PTR_DIFF(p,outbuf)-1, STR_TERMINATE); @@ -599,7 +599,7 @@ static void send_backup_list_response(struct subnet_record *subrec, if(count >= (unsigned int)max_number_requested) break; - if(strnequal(servrec->serv.name, global_myname(),15)) + if(strnequal(servrec->serv.name, lp_netbios_name(),15)) continue; if(!(servrec->serv.type & SV_TYPE_BACKUP_BROWSER)) @@ -625,7 +625,7 @@ static void send_backup_list_response(struct subnet_record *subrec, send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf), - global_myname(), 0, + lp_netbios_name(), 0, send_to_namestr,0, sendto_ip, subrec->myip, port); } diff --git a/source3/nmbd/nmbd_incomingrequests.c b/source3/nmbd/nmbd_incomingrequests.c index d0138ddd4a..b2545f102f 100644 --- a/source3/nmbd/nmbd_incomingrequests.c +++ b/source3/nmbd/nmbd_incomingrequests.c @@ -290,14 +290,14 @@ static int status_compare(char *n1,char *n2) ; for (l2=0;l2<15 && n2[l2] && n2[l2] != ' ';l2++) ; - l3 = strlen(global_myname()); + l3 = strlen(lp_netbios_name()); - if ((l1==l3) && strncmp(n1,global_myname(),l3) == 0 && - (l2!=l3 || strncmp(n2,global_myname(),l3) != 0)) + if ((l1==l3) && strncmp(n1,lp_netbios_name(),l3) == 0 && + (l2!=l3 || strncmp(n2,lp_netbios_name(),l3) != 0)) return -1; - if ((l2==l3) && strncmp(n2,global_myname(),l3) == 0 && - (l1!=l3 || strncmp(n1,global_myname(),l3) != 0)) + if ((l2==l3) && strncmp(n2,lp_netbios_name(),l3) == 0 && + (l1!=l3 || strncmp(n1,lp_netbios_name(),l3) != 0)) return 1; return memcmp(n1,n2,sizeof(name1)); diff --git a/source3/nmbd/nmbd_logonnames.c b/source3/nmbd/nmbd_logonnames.c index f99092055b..9a05095bfd 100644 --- a/source3/nmbd/nmbd_logonnames.c +++ b/source3/nmbd/nmbd_logonnames.c @@ -46,10 +46,10 @@ workgroup %s on subnet %s\n", failname, subrec->subnet_name)); return; } - if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) { + if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) { DEBUG(0,("become_logon_server_fail: Error - cannot find server %s \ in workgroup %s on subnet %s\n", - global_myname(), failname, subrec->subnet_name)); + lp_netbios_name(), failname, subrec->subnet_name)); work->log_state = LOGON_NONE; return; } @@ -87,10 +87,10 @@ workgroup %s on subnet %s\n", reg_name, subrec->subnet_name)); return; } - if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) { + if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) { DEBUG(0,("become_logon_server_success: Error - cannot find server %s \ in workgroup %s on subnet %s\n", - global_myname(), reg_name, subrec->subnet_name)); + lp_netbios_name(), reg_name, subrec->subnet_name)); work->log_state = LOGON_NONE; return; } diff --git a/source3/nmbd/nmbd_processlogon.c b/source3/nmbd/nmbd_processlogon.c index 89adf5a48d..2adc81d76e 100644 --- a/source3/nmbd/nmbd_processlogon.c +++ b/source3/nmbd/nmbd_processlogon.c @@ -291,7 +291,7 @@ static void nmbd_proxy_logon_done(struct tevent_req *subreq) send_mailslot(true, state->remote_mailslot, (char *)response.data, response.length, - global_myname(), 0x0, + lp_netbios_name(), 0x0, state->remote_name, state->remote_name_type, state->p->ip, @@ -338,7 +338,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) )); pull_ascii_nstring(source_name, sizeof(source_name), dgram->source_name.name); - pdc_name = talloc_asprintf(talloc_tos(), "\\\\%s", global_myname()); + pdc_name = talloc_asprintf(talloc_tos(), "\\\\%s", lp_netbios_name()); if (!pdc_name) { return; } @@ -391,7 +391,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) )); send_mailslot(True, request.req.logon0.mailslot_name, (char *)blob_out.data, blob_out.length, - global_myname(), 0x0, + lp_netbios_name(), 0x0, source_name, dgram->source_name.name_type, p->ip, ip, p->port); @@ -411,7 +411,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) )); "reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n", request.req.pdc.computer_name, inet_ntoa(p->ip), - global_myname(), + lp_netbios_name(), lp_workgroup(), NETLOGON_RESPONSE_FROM_PDC, request.req.pdc.nt_version, @@ -419,9 +419,9 @@ logons are not enabled.\n", inet_ntoa(p->ip) )); request.req.pdc.lm20_token)); get_pdc.command = NETLOGON_RESPONSE_FROM_PDC; - get_pdc.pdc_name = global_myname(); + get_pdc.pdc_name = lp_netbios_name(); get_pdc._pad = data_blob_null; - get_pdc.unicode_pdc_name = global_myname(); + get_pdc.unicode_pdc_name = lp_netbios_name(); get_pdc.domain_name = lp_workgroup(); get_pdc.nt_version = NETLOGON_NT_VERSION_1; get_pdc.lmnt_token = 0xffff; @@ -443,7 +443,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) )); send_mailslot(True, request.req.pdc.mailslot_name, (char *)blob_out.data, blob_out.length, - global_myname(), 0x0, + lp_netbios_name(), 0x0, source_name, dgram->source_name.name_type, p->ip, ip, p->port); @@ -553,7 +553,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) )); nt5_ex.dns_domain = domain; nt5_ex.pdc_dns_name = hostname; nt5_ex.domain_name = lp_workgroup(); - nt5_ex.pdc_name = global_myname(); + nt5_ex.pdc_name = lp_netbios_name(); nt5_ex.user_name = request.req.logon.user_name; nt5_ex.server_site = "Default-First-Site-Name"; nt5_ex.client_site = "Default-First-Site-Name"; @@ -621,7 +621,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) )); send_mailslot(true, request.req.logon.mailslot_name, (char *)blob_out.data, blob_out.length, - global_myname(), 0x0, + lp_netbios_name(), 0x0, source_name, dgram->source_name.name_type, p->ip, ip, p->port); diff --git a/source3/nmbd/nmbd_sendannounce.c b/source3/nmbd/nmbd_sendannounce.c index b389c02278..847390b615 100644 --- a/source3/nmbd/nmbd_sendannounce.c +++ b/source3/nmbd/nmbd_sendannounce.c @@ -50,7 +50,7 @@ void send_browser_reset(int reset_type, const char *to_name, int to_type, struct p++; send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf), - global_myname(), 0x0, to_name, to_type, to_ip, + lp_netbios_name(), 0x0, to_name, to_type, to_ip, FIRST_SUBNET->myip, DGRAM_PORT); } @@ -76,10 +76,10 @@ to subnet %s\n", work->work_group, subrec->subnet_name)); SCVAL(p,0,work->token); /* (local) Unique workgroup token id. */ p++; - p += push_string_check(p+1, global_myname(), 15, STR_ASCII|STR_UPPER|STR_TERMINATE); + p += push_string_check(p+1, lp_netbios_name(), 15, STR_ASCII|STR_UPPER|STR_TERMINATE); send_mailslot(False, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf), - global_myname(), 0x0, work->work_group,0x1e, subrec->bcast_ip, + lp_netbios_name(), 0x0, work->work_group,0x1e, subrec->bcast_ip, subrec->myip, DGRAM_PORT); } @@ -164,14 +164,14 @@ static void send_local_master_announcement(struct subnet_record *subrec, struct uint32 type = servrec->serv.type & ~SV_TYPE_LOCAL_LIST_ONLY; DEBUG(3,("send_local_master_announcement: type %x for name %s on subnet %s for workgroup %s\n", - type, global_myname(), subrec->subnet_name, work->work_group)); + type, lp_netbios_name(), subrec->subnet_name, work->work_group)); send_announcement(subrec, ANN_LocalMasterAnnouncement, - global_myname(), /* From nbt name. */ + lp_netbios_name(), /* From nbt name. */ work->work_group, 0x1e, /* To nbt name. */ subrec->bcast_ip, /* To ip. */ work->announce_interval, /* Time until next announce. */ - global_myname(), /* Name to announce. */ + lp_netbios_name(), /* Name to announce. */ type, /* Type field. */ servrec->serv.comment); } @@ -186,13 +186,13 @@ static void send_workgroup_announcement(struct subnet_record *subrec, struct wor subrec->subnet_name, work->work_group)); send_announcement(subrec, ANN_DomainAnnouncement, - global_myname(), /* From nbt name. */ + lp_netbios_name(), /* From nbt name. */ MSBROWSE, 0x1, /* To nbt name. */ subrec->bcast_ip, /* To ip. */ work->announce_interval, /* Time until next announce. */ work->work_group, /* Name to announce. */ SV_TYPE_DOMAIN_ENUM|SV_TYPE_NT, /* workgroup announce flags. */ - global_myname()); /* From name as comment. */ + lp_netbios_name()); /* From name as comment. */ } /**************************************************************************** @@ -251,7 +251,7 @@ static void announce_server(struct subnet_record *subrec, struct work_record *wo /* Only do domain announcements if we are a master and it's our primary name we're being asked to announce. */ - if (AM_LOCAL_MASTER_BROWSER(work) && strequal(global_myname(),servrec->serv.name)) { + if (AM_LOCAL_MASTER_BROWSER(work) && strequal(lp_netbios_name(),servrec->serv.name)) { send_local_master_announcement(subrec, work, servrec); send_workgroup_announcement(subrec, work); } else { @@ -566,7 +566,7 @@ for workgroup %s on subnet %s.\n", lp_workgroup(), FIRST_SUBNET->subnet_name )); SCVAL(p,0,ANN_MasterAnnouncement); p++; - unstrcpy(myname, global_myname()); + unstrcpy(myname, lp_netbios_name()); strupper_m(myname); myname[15]='\0'; push_ascii(p, myname, sizeof(outbuf)-PTR_DIFF(p,outbuf)-1, STR_TERMINATE); @@ -579,10 +579,10 @@ for workgroup %s on subnet %s.\n", lp_workgroup(), FIRST_SUBNET->subnet_name )); addr = interpret_addr2(s2); DEBUG(5,("announce_remote: Doing remote browse sync announce for server %s to IP %s.\n", - global_myname(), inet_ntoa(addr) )); + lp_netbios_name(), inet_ntoa(addr) )); send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf), - global_myname(), 0x0, "*", 0x0, addr, FIRST_SUBNET->myip, DGRAM_PORT); + lp_netbios_name(), 0x0, "*", 0x0, addr, FIRST_SUBNET->myip, DGRAM_PORT); } TALLOC_FREE(frame); } diff --git a/source3/nmbd/nmbd_workgroupdb.c b/source3/nmbd/nmbd_workgroupdb.c index 819d5048ad..43a28aa669 100644 --- a/source3/nmbd/nmbd_workgroupdb.c +++ b/source3/nmbd/nmbd_workgroupdb.c @@ -250,7 +250,7 @@ workgroup %s on subnet %s\n", work->work_group, subrec->subnet_name)); const char *name = my_netbios_names(i); int stype = lp_default_server_announce() | (lp_local_master() ? SV_TYPE_POTENTIAL_BROWSER : 0 ); - if(!strequal(global_myname(), name)) + if(!strequal(lp_netbios_name(), name)) stype &= ~(SV_TYPE_MASTER_BROWSER|SV_TYPE_POTENTIAL_BROWSER|SV_TYPE_DOMAIN_MASTER|SV_TYPE_DOMAIN_MEMBER); create_server_on_workgroup(work,name,stype|SV_TYPE_LOCAL_LIST_ONLY, PERMANENT_TTL, diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 619faf69eb..3ba5312454 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -701,7 +701,6 @@ 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); @@ -1029,7 +1028,7 @@ static struct parm_struct parm_table[] = { .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, }, @@ -5172,6 +5171,7 @@ static void init_globals(bool reinit_globals) } } + string_set(&sDefault.fstype, FSTYPE_STRING); string_set(&sDefault.szPrintjobUsername, "%U"); @@ -5180,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()); @@ -5208,9 +5211,6 @@ static void init_globals(bool reinit_globals) */ string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT); - set_global_myname(myhostname()); - string_set(&Globals.szNetbiosName,global_myname()); - string_set(&Globals.szWorkgroup, WORKGROUP); string_set(&Globals.szPasswdProgram, ""); @@ -5617,6 +5617,7 @@ 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_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) @@ -7501,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. * diff --git a/source3/param/loadparm_ctx.c b/source3/param/loadparm_ctx.c index d07ef45d36..33e854d6e9 100644 --- a/source3/param/loadparm_ctx.c +++ b/source3/param/loadparm_ctx.c @@ -48,7 +48,7 @@ static const struct loadparm_s3_context s3_fns = .socket_options = lp_socket_options, .workgroup = lp_workgroup, - .netbios_name = global_myname, + .netbios_name = lp_netbios_name, .netbios_scope = lp_netbios_scope, .lanman_auth = lp_lanman_auth, diff --git a/source3/passdb/machine_sid.c b/source3/passdb/machine_sid.c index 8fd5103164..6d4cf237c7 100644 --- a/source3/passdb/machine_sid.c +++ b/source3/passdb/machine_sid.c @@ -97,7 +97,7 @@ static struct dom_sid *pdb_generate_sam_sid(void) } } - if (secrets_fetch_domain_sid(global_myname(), sam_sid)) { + if (secrets_fetch_domain_sid(lp_netbios_name(), sam_sid)) { /* We got our sid. If not a pdc/bdc, we're done. */ if ( !IS_DC ) @@ -120,7 +120,7 @@ static struct dom_sid *pdb_generate_sam_sid(void) /* Domain name sid doesn't match global sam sid. Re-store domain sid as 'local' sid. */ DEBUG(0,("pdb_generate_sam_sid: Mismatched SIDs as a pdc/bdc.\n")); - if (!secrets_store_domain_sid(global_myname(), &domain_sid)) { + if (!secrets_store_domain_sid(lp_netbios_name(), &domain_sid)) { DEBUG(0,("pdb_generate_sam_sid: Can't re-store domain SID for local sid as PDC/BDC.\n")); SAFE_FREE(sam_sid); return NULL; @@ -139,7 +139,7 @@ static struct dom_sid *pdb_generate_sam_sid(void) if (read_sid_from_file(fname, sam_sid)) { /* remember it for future reference and unlink the old MACHINE.SID */ - if (!secrets_store_domain_sid(global_myname(), sam_sid)) { + if (!secrets_store_domain_sid(lp_netbios_name(), sam_sid)) { DEBUG(0,("pdb_generate_sam_sid: Failed to store SID from file.\n")); SAFE_FREE(fname); SAFE_FREE(sam_sid); @@ -166,7 +166,7 @@ static struct dom_sid *pdb_generate_sam_sid(void) generate one and save it */ generate_random_sid(sam_sid); - if (!secrets_store_domain_sid(global_myname(), sam_sid)) { + if (!secrets_store_domain_sid(lp_netbios_name(), sam_sid)) { DEBUG(0,("pdb_generate_sam_sid: Failed to store generated machine SID.\n")); SAFE_FREE(sam_sid); return NULL; diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c index fcdaf272c8..5116396cd1 100644 --- a/source3/passdb/passdb.c +++ b/source3/passdb/passdb.c @@ -46,7 +46,7 @@ const char *my_sam_name(void) { /* Standalone servers can only use the local netbios name */ if ( lp_server_role() == ROLE_STANDALONE ) - return global_myname(); + return lp_netbios_name(); /* Default to the DOMAIN name when not specified */ return lp_workgroup(); @@ -149,7 +149,7 @@ static int count_commas(const char *str) static NTSTATUS samu_set_unix_internal(struct samu *user, const struct passwd *pwd, bool create) { const char *guest_account = lp_guestaccount(); - const char *domain = global_myname(); + const char *domain = lp_netbios_name(); char *fullname; uint32_t urid; @@ -2355,7 +2355,7 @@ bool get_trust_pw_clear(const char *domain, char **ret_pwd, if (pwd != NULL) { *ret_pwd = pwd; if (account_name != NULL) { - *account_name = global_myname(); + *account_name = lp_netbios_name(); } return true; @@ -2393,7 +2393,7 @@ bool get_trust_pw_hash(const char *domain, uint8_t ret_pwd[16], channel)) { if (account_name != NULL) { - *account_name = global_myname(); + *account_name = lp_netbios_name(); } return true; diff --git a/source3/printing/nt_printing_ads.c b/source3/printing/nt_printing_ads.c index 1ab1b0e652..6290417260 100644 --- a/source3/printing/nt_printing_ads.c +++ b/source3/printing/nt_printing_ads.c @@ -111,7 +111,7 @@ static WERROR nt_printer_publish_ads(struct messaging_context *msg_ctx, DEBUG(5, ("publishing printer %s\n", printer)); /* figure out where to publish */ - ads_find_machine_acct(ads, &res, global_myname()); + ads_find_machine_acct(ads, &res, lp_netbios_name()); /* We use ldap_get_dn here as we need the answer * in utf8 to call ldap_explode_dn(). JRA. */ @@ -214,7 +214,7 @@ static WERROR nt_printer_unpublish_ads(ADS_STRUCT *ads, /* remove the printer from the directory */ ads_rc = ads_find_printer_on_server(ads, &res, - printer, global_myname()); + printer, lp_netbios_name()); if (ADS_ERR_OK(ads_rc) && res && ads_count_replies(ads, res)) { prt_dn = ads_get_dn(ads, talloc_tos(), res); diff --git a/source3/printing/nt_printing_migrate.c b/source3/printing/nt_printing_migrate.c index 3879198977..03992432bf 100644 --- a/source3/printing/nt_printing_migrate.c +++ b/source3/printing/nt_printing_migrate.c @@ -73,7 +73,7 @@ static NTSTATUS migrate_form(TALLOC_CTX *mem_ctx, DEBUG(2, ("Migrating Form: %s\n", key_name)); - srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", global_myname()); + srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name()); if (srv_name_slash == NULL) { return NT_STATUS_NO_MEMORY; } @@ -164,7 +164,7 @@ static NTSTATUS migrate_driver(TALLOC_CTX *mem_ctx, DEBUG(2, ("Migrating Printer Driver: %s\n", key_name)); - srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", global_myname()); + srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name()); if (srv_name_slash == NULL) { return NT_STATUS_NO_MEMORY; } diff --git a/source3/registry/reg_perfcount.c b/source3/registry/reg_perfcount.c index cac0e5b4c3..3435e315b4 100644 --- a/source3/registry/reg_perfcount.c +++ b/source3/registry/reg_perfcount.c @@ -943,7 +943,7 @@ static bool _reg_perfcount_init_data_block(struct PERF_DATA_BLOCK *block, make_systemtime(&(block->SystemTime), gmtime(&tm)); _reg_perfcount_init_data_block_perf(block, names); memset(temp, 0, sizeof(temp)); - rpcstr_push((void *)temp, global_myname(), sizeof(temp), STR_TERMINATE); + rpcstr_push((void *)temp, lp_netbios_name(), sizeof(temp), STR_TERMINATE); block->SystemNameLength = (strlen_w(temp) * 2) + 2; block->data = talloc_zero_array(mem_ctx, uint8, block->SystemNameLength + (8 - (block->SystemNameLength % 8))); if (block->data == NULL) { diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index b519358558..3c685fd9a7 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -185,7 +185,7 @@ NTSTATUS rpccli_netlogon_sam_logon(struct rpc_pipe_client *cli, if (workstation) { fstr_sprintf( clnt_name_slash, "\\\\%s", workstation ); } else { - fstr_sprintf( clnt_name_slash, "\\\\%s", global_myname() ); + fstr_sprintf( clnt_name_slash, "\\\\%s", lp_netbios_name() ); } /* Initialise input parameters */ @@ -279,7 +279,7 @@ NTSTATUS rpccli_netlogon_sam_logon(struct rpc_pipe_client *cli, status = dcerpc_netr_LogonSamLogon(b, mem_ctx, cli->srv_name_slash, - global_myname(), + lp_netbios_name(), &clnt_creds, &ret_creds, logon_type, @@ -441,7 +441,7 @@ NTSTATUS rpccli_netlogon_sam_network_logon(struct rpc_pipe_client *cli, status = dcerpc_netr_LogonSamLogon(b, mem_ctx, server_name_slash, - global_myname(), + lp_netbios_name(), &clnt_creds, &ret_creds, NetlogonNetworkInformation, @@ -556,7 +556,7 @@ NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli, status = dcerpc_netr_LogonSamLogonEx(b, mem_ctx, server_name_slash, - global_myname(), + lp_netbios_name(), NetlogonNetworkInformation, logon, validation_level, @@ -608,7 +608,7 @@ NTSTATUS rpccli_netlogon_set_trust_password(struct rpc_pipe_client *cli, result = rpccli_netlogon_setup_creds(cli, cli->desthost, /* server name */ lp_workgroup(), /* domain */ - global_myname(), /* client name */ + lp_netbios_name(), /* client name */ account_name, /* machine account name */ orig_trust_passwd_hash, sec_channel_type, diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index 682f35ece0..0b9470620d 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -1087,7 +1087,7 @@ static NTSTATUS create_schannel_auth_rpc_bind_req(struct rpc_pipe_client *cli, r.Flags = NL_FLAG_OEM_NETBIOS_DOMAIN_NAME | NL_FLAG_OEM_NETBIOS_COMPUTER_NAME; r.oem_netbios_domain.a = cli->auth->domain; - r.oem_netbios_computer.a = global_myname(); + r.oem_netbios_computer.a = lp_netbios_name(); status = dcerpc_push_schannel_bind(cli, &r, auth_token); if (!NT_STATUS_IS_OK(status)) { @@ -2330,7 +2330,7 @@ static NTSTATUS rpccli_ntlmssp_bind_data(TALLOC_CTX *mem_ctx, } status = auth_ntlmssp_client_start(NULL, - global_myname(), + lp_netbios_name(), lp_workgroup(), lp_client_ntlmv2_auth(), &ntlmssp_ctx); diff --git a/source3/rpc_client/cli_pipe_schannel.c b/source3/rpc_client/cli_pipe_schannel.c index b7ef39f8e6..f48c4c7318 100644 --- a/source3/rpc_client/cli_pipe_schannel.c +++ b/source3/rpc_client/cli_pipe_schannel.c @@ -58,7 +58,7 @@ static NTSTATUS get_schannel_session_key_common(struct rpc_pipe_client *netlogon status = rpccli_netlogon_setup_creds(netlogon_pipe, cli->desthost, /* server name */ domain, /* domain */ - global_myname(), /* client name */ + lp_netbios_name(), /* client name */ machine_account, /* machine account name */ machine_pwd, sec_chan_type, diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index 3c15e2ffb0..5c8448b29b 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -47,7 +47,7 @@ WERROR rpccli_spoolss_openprinter_ex(struct rpc_pipe_client *cli, ZERO_STRUCT(devmode_ctr); level1.size = 28; - level1.client = talloc_asprintf(mem_ctx, "\\\\%s", global_myname()); + level1.client = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name()); W_ERROR_HAVE_NO_MEMORY(level1.client); level1.user = cli->auth->user_name; level1.build = 1381; @@ -230,7 +230,7 @@ WERROR rpccli_spoolss_addprinterex(struct rpc_pipe_client *cli, level1.major = 2; level1.minor = 0; level1.processor = 0; - level1.client = talloc_asprintf(mem_ctx, "\\\\%s", global_myname()); + level1.client = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name()); W_ERROR_HAVE_NO_MEMORY(level1.client); level1.user = cli->auth->user_name; diff --git a/source3/rpc_server/dfs/srv_dfs_nt.c b/source3/rpc_server/dfs/srv_dfs_nt.c index 486e14e268..5b4e423393 100644 --- a/source3/rpc_server/dfs/srv_dfs_nt.c +++ b/source3/rpc_server/dfs/srv_dfs_nt.c @@ -193,7 +193,7 @@ WERROR _dfs_Remove(struct pipes_struct *p, struct dfs_Remove *r) static bool init_reply_dfs_info_1(TALLOC_CTX *mem_ctx, struct junction_map* j,struct dfs_Info1* dfs1) { dfs1->path = talloc_asprintf(mem_ctx, - "\\\\%s\\%s\\%s", global_myname(), + "\\\\%s\\%s\\%s", lp_netbios_name(), j->service_name, j->volume_name); if (dfs1->path == NULL) return False; @@ -205,7 +205,7 @@ static bool init_reply_dfs_info_1(TALLOC_CTX *mem_ctx, struct junction_map* j,st static bool init_reply_dfs_info_2(TALLOC_CTX *mem_ctx, struct junction_map* j, struct dfs_Info2* dfs2) { dfs2->path = talloc_asprintf(mem_ctx, - "\\\\%s\\%s\\%s", global_myname(), j->service_name, j->volume_name); + "\\\\%s\\%s\\%s", lp_netbios_name(), j->service_name, j->volume_name); if (dfs2->path == NULL) return False; dfs2->comment = talloc_strdup(mem_ctx, j->comment); @@ -219,9 +219,9 @@ static bool init_reply_dfs_info_3(TALLOC_CTX *mem_ctx, struct junction_map* j, s int ii; if (j->volume_name[0] == '\0') dfs3->path = talloc_asprintf(mem_ctx, "\\\\%s\\%s", - global_myname(), j->service_name); + lp_netbios_name(), j->service_name); else - dfs3->path = talloc_asprintf(mem_ctx, "\\\\%s\\%s\\%s", global_myname(), + dfs3->path = talloc_asprintf(mem_ctx, "\\\\%s\\%s\\%s", lp_netbios_name(), j->service_name, j->volume_name); if (dfs3->path == NULL) diff --git a/source3/rpc_server/netlogon/srv_netlog_nt.c b/source3/rpc_server/netlogon/srv_netlog_nt.c index 46789f106a..03897d77a4 100644 --- a/source3/rpc_server/netlogon/srv_netlog_nt.c +++ b/source3/rpc_server/netlogon/srv_netlog_nt.c @@ -522,7 +522,7 @@ static NTSTATUS samr_find_machine_account(TALLOC_CTX *mem_ctx, uint32_t rid; status = dcerpc_samr_Connect2(b, mem_ctx, - global_myname(), + lp_netbios_name(), SAMR_ACCESS_CONNECT_TO_SERVER | SAMR_ACCESS_ENUM_DOMAINS | SAMR_ACCESS_LOOKUP_DOMAIN, diff --git a/source3/rpc_server/samr/srv_samr_nt.c b/source3/rpc_server/samr/srv_samr_nt.c index e5f59e604b..a253f307ac 100644 --- a/source3/rpc_server/samr/srv_samr_nt.c +++ b/source3/rpc_server/samr/srv_samr_nt.c @@ -3323,7 +3323,7 @@ static NTSTATUS query_dom_info_2(TALLOC_CTX *mem_ctx, r->oem_information.string = lp_serverstring(); r->domain_name.string = lp_workgroup(); - r->primary.string = global_myname(); + r->primary.string = lp_netbios_name(); r->sequence_num = seq_num; r->domain_server_state = DOMAIN_SERVER_ENABLED; r->role = (enum samr_Role) samr_get_server_role(); @@ -3390,7 +3390,7 @@ static NTSTATUS query_dom_info_6(TALLOC_CTX *mem_ctx, /* NT returns its own name when a PDC. win2k and later * only the name of the PDC if itself is a BDC (samba4 * idl) */ - r->primary.string = global_myname(); + r->primary.string = lp_netbios_name(); return NT_STATUS_OK; } @@ -6132,7 +6132,7 @@ NTSTATUS _samr_SetAliasInfo(struct pipes_struct *p, /* make sure the name doesn't already exist as a user or local group */ - fstr_sprintf( group_name, "%s\\%s", global_myname(), info.acct_name ); + fstr_sprintf( group_name, "%s\\%s", lp_netbios_name(), info.acct_name ); status = can_create( p->mem_ctx, group_name ); if ( !NT_STATUS_IS_OK( status ) ) return status; diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c index 1be5100d9e..cb311ef043 100644 --- a/source3/rpc_server/spoolss/srv_spoolss_nt.c +++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c @@ -2523,7 +2523,7 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe, } /* setup the connection */ - ret = cli_full_connection( &the_cli, global_myname(), remote_machine, + ret = cli_full_connection( &the_cli, lp_netbios_name(), remote_machine, &rm_addr, 0, "IPC$", "IPC", "", /* username */ "", /* domain */ @@ -6037,7 +6037,7 @@ static bool check_printer_ok(TALLOC_CTX *mem_ctx, info2->location)); /* we force some elements to "correct" values */ - info2->servername = talloc_asprintf(mem_ctx, "\\\\%s", global_myname()); + info2->servername = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name()); if (info2->servername == NULL) { return false; } @@ -6049,7 +6049,7 @@ static bool check_printer_ok(TALLOC_CTX *mem_ctx, /* check to see if we allow printername != sharename */ if (lp_force_printername(snum)) { info2->printername = talloc_asprintf(mem_ctx, "\\\\%s\\%s", - global_myname(), info2->sharename); + lp_netbios_name(), info2->sharename); } else { /* make sure printername is in \\server\printername format */ fstrcpy(printername, info2->printername); @@ -6060,7 +6060,7 @@ static bool check_printer_ok(TALLOC_CTX *mem_ctx, } info2->printername = talloc_asprintf(mem_ctx, "\\\\%s\\%s", - global_myname(), p); + lp_netbios_name(), p); } if (info2->printername == NULL) { return false; @@ -6446,7 +6446,7 @@ static WERROR update_dsspooler(TALLOC_CTX *mem_ctx, buffer.length); } - push_reg_sz(mem_ctx, &buffer, global_myname()); + push_reg_sz(mem_ctx, &buffer, lp_netbios_name()); winreg_set_printer_dataex(mem_ctx, session_info, msg_ctx, @@ -6461,7 +6461,7 @@ static WERROR update_dsspooler(TALLOC_CTX *mem_ctx, if (dnsdomname != NULL && dnsdomname[0] != '\0') { longname = talloc_strdup(mem_ctx, dnsdomname); } else { - longname = talloc_strdup(mem_ctx, global_myname()); + longname = talloc_strdup(mem_ctx, lp_netbios_name()); } if (longname == NULL) { result = WERR_NOMEM; @@ -6480,7 +6480,7 @@ static WERROR update_dsspooler(TALLOC_CTX *mem_ctx, buffer.length); uncname = talloc_asprintf(mem_ctx, "\\\\%s\\%s", - global_myname(), printer->sharename); + lp_netbios_name(), printer->sharename); push_reg_sz(mem_ctx, &buffer, uncname); winreg_set_printer_dataex(mem_ctx, session_info, diff --git a/source3/rpc_server/spoolss/srv_spoolss_util.c b/source3/rpc_server/spoolss/srv_spoolss_util.c index 8505c8ffb5..ecb3567060 100644 --- a/source3/rpc_server/spoolss/srv_spoolss_util.c +++ b/source3/rpc_server/spoolss/srv_spoolss_util.c @@ -1047,7 +1047,7 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx, winreg_handle, &key_hnd, SPOOL_REG_SHORTSERVERNAME, - global_myname(), + lp_netbios_name(), &result); if (!NT_STATUS_IS_OK(status)) { result = ntstatus_to_werror(status); @@ -1062,9 +1062,9 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx, */ dnssuffix = get_mydnsdomname(tmp_ctx); if (dnssuffix != NULL && dnssuffix[0] != '\0') { - longname = talloc_asprintf(tmp_ctx, "%s.%s", global_myname(), dnssuffix); + longname = talloc_asprintf(tmp_ctx, "%s.%s", lp_netbios_name(), dnssuffix); } else { - longname = talloc_strdup(tmp_ctx, global_myname()); + longname = talloc_strdup(tmp_ctx, lp_netbios_name()); } if (longname == NULL) { result = WERR_NOMEM; diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c index dd23a090f2..64a7264ece 100644 --- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c +++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c @@ -1145,7 +1145,7 @@ WERROR _srvsvc_NetSrvGetInfo(struct pipes_struct *p, } info102->platform_id = PLATFORM_ID_NT; - info102->server_name = global_myname(); + info102->server_name = lp_netbios_name(); info102->version_major = lp_major_announce_version(); info102->version_minor = lp_minor_announce_version(); info102->server_type = lp_default_server_announce(); @@ -1171,7 +1171,7 @@ WERROR _srvsvc_NetSrvGetInfo(struct pipes_struct *p, } info101->platform_id = PLATFORM_ID_NT; - info101->server_name = global_myname(); + info101->server_name = lp_netbios_name(); info101->version_major = lp_major_announce_version(); info101->version_minor = lp_minor_announce_version(); info101->server_type = lp_default_server_announce(); @@ -1190,7 +1190,7 @@ WERROR _srvsvc_NetSrvGetInfo(struct pipes_struct *p, } info100->platform_id = PLATFORM_ID_NT; - info100->server_name = global_myname(); + info100->server_name = lp_netbios_name(); r->out.info->info100 = info100; diff --git a/source3/rpc_server/wkssvc/srv_wkssvc_nt.c b/source3/rpc_server/wkssvc/srv_wkssvc_nt.c index cd257b4a26..633aa13360 100644 --- a/source3/rpc_server/wkssvc/srv_wkssvc_nt.c +++ b/source3/rpc_server/wkssvc/srv_wkssvc_nt.c @@ -196,7 +196,7 @@ static struct dom_usr *get_domain_userlist(TALLOC_CTX *mem_ctx) DEBUG(10, ("talloc_asprintf failed\n")); continue; } - if (strcmp(machine_name, global_myname()) == 0) { + if (strcmp(machine_name, lp_netbios_name()) == 0) { p = session_list[i].username; nm = strstr(p, sep); if (nm) { @@ -264,7 +264,7 @@ static struct wkssvc_NetWkstaInfo100 *create_wks_info_100(TALLOC_CTX *mem_ctx) info100->version_minor = lp_minor_announce_version(); info100->server_name = talloc_asprintf_strupper_m( - info100, "%s", global_myname()); + info100, "%s", lp_netbios_name()); info100->domain_name = talloc_asprintf_strupper_m( info100, "%s", lp_workgroup()); @@ -293,7 +293,7 @@ static struct wkssvc_NetWkstaInfo101 *create_wks_info_101(TALLOC_CTX *mem_ctx) info101->version_minor = lp_minor_announce_version(); info101->server_name = talloc_asprintf_strupper_m( - info101, "%s", global_myname()); + info101, "%s", lp_netbios_name()); info101->domain_name = talloc_asprintf_strupper_m( info101, "%s", lp_workgroup()); info101->lan_root = ""; @@ -324,7 +324,7 @@ static struct wkssvc_NetWkstaInfo102 *create_wks_info_102(TALLOC_CTX *mem_ctx) info102->version_minor = lp_minor_announce_version(); info102->server_name = talloc_asprintf_strupper_m( - info102, "%s", global_myname()); + info102, "%s", lp_netbios_name()); info102->domain_name = talloc_asprintf_strupper_m( info102, "%s", lp_workgroup()); info102->lan_root = ""; @@ -528,7 +528,7 @@ static struct wkssvc_NetWkstaEnumUsersCtr1 *create_enum_users1( /* For a local user the domain name and logon server are * both returned as the local machine's NetBIOS name */ ctr1->user1[i].logon_domain = ctr1->user1[i].logon_server = - talloc_asprintf_strupper_m(ctr1->user1, "%s", global_myname()); + talloc_asprintf_strupper_m(ctr1->user1, "%s", lp_netbios_name()); ctr1->user1[i].other_domains = NULL; /* Maybe in future? */ } diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 63057ac368..ad43452bf1 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -583,7 +583,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli, NTSTATUS result = NT_STATUS_UNSUCCESSFUL; NTSTATUS status; const char *logon_server = cli->desthost; - const char *computername = global_myname(); + const char *computername = lp_netbios_name(); struct netr_Authenticator credential; struct netr_Authenticator return_authenticator; enum netr_SamDatabaseID database_id = SAM_DATABASE_DOMAIN; @@ -654,7 +654,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli, NTSTATUS status; uint32_t tmp; const char *logon_server = cli->desthost; - const char *computername = global_myname(); + const char *computername = lp_netbios_name(); struct netr_Authenticator credential; struct netr_Authenticator return_authenticator; enum netr_SamDatabaseID database_id = SAM_DATABASE_DOMAIN; @@ -1121,8 +1121,8 @@ static NTSTATUS cmd_netlogon_database_redo(struct rpc_pipe_client *cli, status = rpccli_netlogon_setup_creds(cli, server_name, /* server name */ lp_workgroup(), /* domain */ - global_myname(), /* client name */ - global_myname(), /* machine account name */ + lp_netbios_name(), /* client name */ + lp_netbios_name(), /* machine account name */ trust_passwd_hash, sec_channel_type, &neg_flags); @@ -1141,7 +1141,7 @@ static NTSTATUS cmd_netlogon_database_redo(struct rpc_pipe_client *cli, status = dcerpc_netr_DatabaseRedo(b, mem_ctx, server_name, - global_myname(), + lp_netbios_name(), &clnt_creds, &srv_cred, e, @@ -1187,7 +1187,7 @@ static NTSTATUS cmd_netlogon_capabilities(struct rpc_pipe_client *cli, status = dcerpc_netr_LogonGetCapabilities(b, mem_ctx, cli->desthost, - global_myname(), + lp_netbios_name(), &credential, &return_authenticator, level, diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index da9826ae0e..0e12201f92 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -3263,7 +3263,7 @@ static WERROR cmd_spoolss_rffpcnex(struct rpc_pipe_client *cli, } option.types[1].fields[0].field = JOB_NOTIFY_FIELD_PRINTER_NAME; - clientname = talloc_asprintf(mem_ctx, "\\\\%s", global_myname()); + clientname = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name()); if (!clientname) { result = WERR_NOMEM; goto done; @@ -3429,7 +3429,7 @@ static WERROR cmd_spoolss_printercmp(struct rpc_pipe_client *cli, /* first get the connection to the remote server */ - nt_status = cli_full_connection(&cli_server2, global_myname(), argv[2], + nt_status = cli_full_connection(&cli_server2, lp_netbios_name(), argv[2], NULL, 0, "IPC$", "IPC", get_cmdline_auth_info_username(rpcclient_auth_info), diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index 5808f371f0..c5da092e9a 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -775,7 +775,7 @@ static NTSTATUS do_cmd(struct cli_state *cli, ntresult = rpccli_netlogon_setup_creds(cmd_entry->rpc_pipe, cli->desthost, /* server name */ get_cmdline_auth_info_domain(auth_info), /* domain */ - global_myname(), /* client name */ + lp_netbios_name(), /* client name */ machine_account, /* machine account name */ trust_password, sec_channel_type, @@ -1083,7 +1083,7 @@ out_free: } - nt_status = cli_full_connection(&cli, global_myname(), binding->host, + nt_status = cli_full_connection(&cli, lp_netbios_name(), binding->host, opt_ipaddr ? &server_ss : NULL, opt_port, "IPC$", "IPC", get_cmdline_auth_info_username(rpcclient_auth_info), diff --git a/source3/smbd/avahi_register.c b/source3/smbd/avahi_register.c index 05bd6038f4..368168d41d 100644 --- a/source3/smbd/avahi_register.c +++ b/source3/smbd/avahi_register.c @@ -88,7 +88,7 @@ static void avahi_client_callback(AvahiClient *c, AvahiClientState status, } if (avahi_entry_group_add_service( state->entry_group, AVAHI_IF_UNSPEC, - AVAHI_PROTO_UNSPEC, 0, global_myname(), + AVAHI_PROTO_UNSPEC, 0, lp_netbios_name(), "_smb._tcp", NULL, NULL, state->port, NULL) < 0) { error = avahi_client_errno(c); DEBUG(10, ("avahi_entry_group_add_service failed: " diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c index 5958bb9746..f8101d9571 100644 --- a/source3/smbd/lanman.c +++ b/source3/smbd/lanman.c @@ -2377,7 +2377,7 @@ static bool api_RNetGroupEnum(struct smbd_server_connection *sconn, b = samr_pipe->binding_handle; - status = dcerpc_samr_Connect2(b, talloc_tos(), global_myname(), + status = dcerpc_samr_Connect2(b, talloc_tos(), lp_netbios_name(), SAMR_ACCESS_LOOKUP_DOMAIN, &samr_handle, &result); if (!NT_STATUS_IS_OK(status)) { @@ -2583,7 +2583,7 @@ static bool api_NetUserGetGroups(struct smbd_server_connection *sconn, b = samr_pipe->binding_handle; - status = dcerpc_samr_Connect2(b, talloc_tos(), global_myname(), + status = dcerpc_samr_Connect2(b, talloc_tos(), lp_netbios_name(), SAMR_ACCESS_LOOKUP_DOMAIN, &samr_handle, &result); if (!NT_STATUS_IS_OK(status)) { @@ -2775,7 +2775,7 @@ static bool api_RNetUserEnum(struct smbd_server_connection *sconn, b = samr_pipe->binding_handle; - status = dcerpc_samr_Connect2(b, talloc_tos(), global_myname(), + status = dcerpc_samr_Connect2(b, talloc_tos(), lp_netbios_name(), SAMR_ACCESS_LOOKUP_DOMAIN, &samr_handle, &result); if (!NT_STATUS_IS_OK(status)) { @@ -3044,7 +3044,7 @@ static bool api_SetUserPassword(struct smbd_server_connection *sconn, b = cli->binding_handle; status = dcerpc_samr_Connect2(b, mem_ctx, - global_myname(), + lp_netbios_name(), SAMR_ACCESS_CONNECT_TO_SERVER | SAMR_ACCESS_ENUM_DOMAINS | SAMR_ACCESS_LOOKUP_DOMAIN, @@ -3294,7 +3294,7 @@ static bool api_SamOEMChangePassword(struct smbd_server_connection *sconn, b = cli->binding_handle; - init_lsa_AsciiString(&server, global_myname()); + init_lsa_AsciiString(&server, lp_netbios_name()); init_lsa_AsciiString(&account, user); status = dcerpc_samr_OemChangePasswordUser2(b, mem_ctx, @@ -4306,7 +4306,7 @@ static bool api_RNetUserGetInfo(struct smbd_server_connection *sconn, b = cli->binding_handle; status = dcerpc_samr_Connect2(b, mem_ctx, - global_myname(), + lp_netbios_name(), SAMR_ACCESS_CONNECT_TO_SERVER | SAMR_ACCESS_ENUM_DOMAINS | SAMR_ACCESS_LOOKUP_DOMAIN, diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index da66dad0d8..a6d7cc0ab3 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -224,7 +224,7 @@ DATA_BLOB negprot_spnego(TALLOC_CTX *ctx, struct smbd_server_connection *sconn) } else { fstring myname; char *host_princ_s = NULL; - name_to_fqdn(myname, global_myname()); + name_to_fqdn(myname, lp_netbios_name()); strlower_m(myname); if (asprintf(&host_princ_s, "cifs/%s@%s", myname, lp_realm()) == -1) { @@ -246,7 +246,7 @@ DATA_BLOB negprot_spnego(TALLOC_CTX *ctx, struct smbd_server_connection *sconn) memset(blob_out.data, '\0', 16); - checked_strlcpy(unix_name, global_myname(), sizeof(unix_name)); + checked_strlcpy(unix_name, lp_netbios_name(), sizeof(unix_name)); strlower_m(unix_name); push_ascii_nstring(dos_name, unix_name); strlcpy((char *)blob_out.data, dos_name, 17); diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 1980f757fd..a804884ef7 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -972,7 +972,7 @@ void reply_ioctl(struct smb_request *req) SSVAL(p, 0, 0); } srvstr_push((char *)req->outbuf, req->flags2, p+2, - global_myname(), 15, + lp_netbios_name(), 15, STR_TERMINATE|STR_ASCII); if (conn) { srvstr_push((char *)req->outbuf, req->flags2, diff --git a/source3/smbd/seal.c b/source3/smbd/seal.c index 28f70b6241..26185062a6 100644 --- a/source3/smbd/seal.c +++ b/source3/smbd/seal.c @@ -196,7 +196,7 @@ static NTSTATUS make_auth_gss(struct smb_srv_trans_enc_ctx *ec) gss_cred_id_t srv_cred; fstring fqdn; - name_to_fqdn(fqdn, global_myname()); + name_to_fqdn(fqdn, lp_netbios_name()); strlower_m(fqdn); status = get_srv_gss_creds("cifs", fqdn, GSS_C_ACCEPT, &srv_cred); diff --git a/source3/smbd/sesssetup.c b/source3/smbd/sesssetup.c index 98bed880df..dda4ef296e 100644 --- a/source3/smbd/sesssetup.c +++ b/source3/smbd/sesssetup.c @@ -194,7 +194,7 @@ static bool make_krb5_skew_error(DATA_BLOB *pblob_out) return False; } /* Create server principal. */ - asprintf(&host_princ_s, "%s$@%s", global_myname(), lp_realm()); + asprintf(&host_princ_s, "%s$@%s", lp_netbios_name(), lp_realm()); if (!host_princ_s) { goto out; } diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index ae6eb59451..b853722eae 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -8377,7 +8377,7 @@ static void call_trans2ioctl(connection_struct *conn, SSVAL(pdata, 0, 0); } srvstr_push(pdata, req->flags2, pdata + 2, - global_myname(), 15, + lp_netbios_name(), 15, STR_ASCII|STR_TERMINATE); /* Our NetBIOS name */ srvstr_push(pdata, req->flags2, pdata+18, lp_servicename(SNUM(conn)), 13, diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 0904f24356..8512a0e47b 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -6358,7 +6358,7 @@ static bool run_chain2(int dummy) NTSTATUS status; printf("starting chain2 test\n"); - status = cli_start_connection(&cli1, global_myname(), host, NULL, + status = cli_start_connection(&cli1, lp_netbios_name(), host, NULL, port_to_use, Undefined, 0); if (!NT_STATUS_IS_OK(status)) { return False; diff --git a/source3/utils/net.c b/source3/utils/net.c index c53b2859b0..0d79d6e6d2 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -243,7 +243,7 @@ static int net_getlocalsid(struct net_context *c, int argc, const char **argv) name = argv[0]; } else { - name = global_myname(); + name = lp_netbios_name(); } if(!initialize_password_db(false, NULL)) { @@ -286,7 +286,7 @@ static int net_setlocalsid(struct net_context *c, int argc, const char **argv) return 1; } - if (!secrets_store_domain_sid(global_myname(), &sid)) { + if (!secrets_store_domain_sid(lp_netbios_name(), &sid)) { DEBUG(0,("Can't store domain SID as a pdc/bdc.\n")); return 1; } @@ -346,13 +346,13 @@ static int net_getdomainsid(struct net_context *c, int argc, const char **argv) /* Generate one, if it doesn't exist */ get_global_sam_sid(); - if (!secrets_fetch_domain_sid(global_myname(), &domain_sid)) { + if (!secrets_fetch_domain_sid(lp_netbios_name(), &domain_sid)) { d_fprintf(stderr, _("Could not fetch local SID\n")); return 1; } sid_to_fstring(sid_str, &domain_sid); d_printf(_("SID for local machine %s is: %s\n"), - global_myname(), sid_str); + lp_netbios_name(), sid_str); if (!secrets_fetch_domain_sid(c->opt_workgroup, &domain_sid)) { d_fprintf(stderr, _("Could not fetch domain SID\n")); @@ -895,7 +895,7 @@ static struct functable net_func[] = { } if (c->opt_requester_name) { - set_global_myname(c->opt_requester_name); + lp_set_cmdline("netbios name", c->opt_requester_name); } if (!c->opt_user_name && getenv("LOGNAME")) { diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 69d5b102d4..bb78ecbf12 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -915,7 +915,7 @@ static int net_ads_status(struct net_context *c, int argc, const char **argv) return -1; } - rc = ads_find_machine_acct(ads, &res, global_myname()); + rc = ads_find_machine_acct(ads, &res, lp_netbios_name()); if (!ADS_ERR_OK(rc)) { d_fprintf(stderr, _("ads_find_machine_acct: %s\n"), ads_errstr(rc)); ads_destroy(&ads); @@ -923,7 +923,7 @@ static int net_ads_status(struct net_context *c, int argc, const char **argv) } if (ads_count_replies(ads, res) == 0) { - d_fprintf(stderr, _("No machine account for '%s' found\n"), global_myname()); + d_fprintf(stderr, _("No machine account for '%s' found\n"), lp_netbios_name()); ads_destroy(&ads); return -1; } @@ -1100,10 +1100,10 @@ static WERROR check_ads_config( void ) return WERR_INVALID_DOMAIN_ROLE; } - if (strlen(global_myname()) > 15) { + if (strlen(lp_netbios_name()) > 15) { d_printf(_("Our netbios name can be at most 15 chars long, " - "\"%s\" is %u chars long\n"), global_myname(), - (unsigned int)strlen(global_myname())); + "\"%s\" is %u chars long\n"), lp_netbios_name(), + (unsigned int)strlen(lp_netbios_name())); return WERR_INVALID_COMPUTERNAME; } @@ -1244,7 +1244,7 @@ static NTSTATUS net_update_dns_ext(TALLOC_CTX *mem_ctx, ADS_STRUCT *ads, if (hostname) { fstrcpy(machine_name, hostname); } else { - name_to_fqdn( machine_name, global_myname() ); + name_to_fqdn( machine_name, lp_netbios_name() ); } strlower_m( machine_name ); @@ -1468,7 +1468,7 @@ int net_ads_join(struct net_context *c, int argc, const char **argv) /* kinit with the machine password */ use_in_memory_ccache(); - if (asprintf( &ads_dns->auth.user_name, "%s$", global_myname()) == -1) { + if (asprintf( &ads_dns->auth.user_name, "%s$", lp_netbios_name()) == -1) { goto fail; } ads_dns->auth.password = secrets_fetch_machine_password( @@ -1756,7 +1756,7 @@ static int net_ads_printer_info(struct net_context *c, int argc, const char **ar if (argc > 1) { servername = argv[1]; } else { - servername = global_myname(); + servername = lp_netbios_name(); } rc = ads_find_printer_on_server(ads, &res, printername, servername); @@ -1819,14 +1819,14 @@ static int net_ads_printer_publish(struct net_context *c, int argc, const char * if (argc == 2) { servername = argv[1]; } else { - servername = global_myname(); + servername = lp_netbios_name(); } /* Get printer data from SPOOLSS */ resolve_name(servername, &server_ss, 0x20, false); - nt_status = cli_full_connection(&cli, global_myname(), servername, + nt_status = cli_full_connection(&cli, lp_netbios_name(), servername, &server_ss, 0, "IPC$", "IPC", c->opt_user_name, c->opt_workgroup, @@ -1942,7 +1942,7 @@ static int net_ads_printer_remove(struct net_context *c, int argc, const char ** if (argc > 1) { servername = argv[1]; } else { - servername = global_myname(); + servername = lp_netbios_name(); } rc = ads_find_printer_on_server(ads, &res, argv[0], servername); @@ -2135,7 +2135,7 @@ int net_ads_changetrustpw(struct net_context *c, int argc, const char **argv) return -1; } - fstrcpy(my_name, global_myname()); + fstrcpy(my_name, lp_netbios_name()); strlower_m(my_name); if (asprintf(&host_principal, "%s$@%s", my_name, ads->config.realm) == -1) { ads_destroy(&ads); diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index a8ce9b7d48..2ecf1aaa5a 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -366,7 +366,7 @@ static NTSTATUS rpc_oldjoin_internals(struct net_context *c, sec_channel_type = get_sec_channel_type(NULL); } - fstrcpy(trust_passwd, global_myname()); + fstrcpy(trust_passwd, lp_netbios_name()); strlower_m(trust_passwd); /* @@ -379,7 +379,7 @@ static NTSTATUS rpc_oldjoin_internals(struct net_context *c, E_md4hash(trust_passwd, orig_trust_passwd_hash); result = trust_pw_change_and_store_it(pipe_hnd, mem_ctx, c->opt_target_workgroup, - global_myname(), + lp_netbios_name(), orig_trust_passwd_hash, sec_channel_type); @@ -481,10 +481,10 @@ int net_rpc_join(struct net_context *c, int argc, const char **argv) return -1; } - if (strlen(global_myname()) > 15) { + if (strlen(lp_netbios_name()) > 15) { d_printf(_("Our netbios name can be at most 15 chars long, " "\"%s\" is %u chars long\n"), - global_myname(), (unsigned int)strlen(global_myname())); + lp_netbios_name(), (unsigned int)strlen(lp_netbios_name())); return -1; } @@ -6535,7 +6535,7 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc, domain_name = c->opt_workgroup; c->opt_target_workgroup = c->opt_workgroup; } else { - fstrcpy(pdc_name, global_myname()); + fstrcpy(pdc_name, lp_netbios_name()); domain_name = talloc_strdup(mem_ctx, lp_workgroup()); c->opt_target_workgroup = domain_name; }; @@ -6713,7 +6713,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv) domain_name = c->opt_workgroup; c->opt_target_workgroup = c->opt_workgroup; } else { - fstrcpy(pdc_name, global_myname()); + fstrcpy(pdc_name, lp_netbios_name()); domain_name = talloc_strdup(mem_ctx, lp_workgroup()); c->opt_target_workgroup = domain_name; }; @@ -7089,7 +7089,7 @@ bool net_rpc_check(struct net_context *c, unsigned flags) return false; status = cli_connect_nb(server_name, &server_ss, 0, 0x20, - global_myname(), Undefined, &cli); + lp_netbios_name(), Undefined, &cli); if (!NT_STATUS_IS_OK(status)) { return false; } diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c index 88bb6f83c1..d228f92804 100644 --- a/source3/utils/net_rpc_join.c +++ b/source3/utils/net_rpc_join.c @@ -307,7 +307,7 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv) "could not open domain"); /* Create domain user */ - if ((acct_name = talloc_asprintf(mem_ctx, "%s$", global_myname())) == NULL) { + if ((acct_name = talloc_asprintf(mem_ctx, "%s$", lp_netbios_name())) == NULL) { status = NT_STATUS_NO_MEMORY; goto done; } @@ -443,8 +443,8 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv) status = rpccli_netlogon_setup_creds(pipe_hnd, cli->desthost, /* server name */ domain, /* domain */ - global_myname(), /* client name */ - global_myname(), /* machine account name */ + lp_netbios_name(), /* client name */ + lp_netbios_name(), /* machine account name */ md4_trust_password, sec_channel_type, &neg_flags); @@ -458,7 +458,7 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv) d_fprintf(stderr, _("Please make sure that no computer " "account\nnamed like this machine " "(%s) exists in the domain\n"), - global_myname()); + lp_netbios_name()); } goto done; @@ -487,7 +487,7 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv) "computer account\nnamed " "like this machine (%s) " "exists in the domain\n"), - global_myname()); + lp_netbios_name()); } goto done; diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c index af420fca76..272e0c9dfa 100644 --- a/source3/utils/net_rpc_printer.c +++ b/source3/utils/net_rpc_printer.c @@ -2544,7 +2544,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, if (strequal(info[j].value_name, SPOOL_REG_SHORTSERVERNAME)) { - push_reg_sz(mem_ctx, &blob, global_myname()); + push_reg_sz(mem_ctx, &blob, lp_netbios_name()); } value = regval_compose(talloc_tos(), diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c index 46ce558d89..9b6293ed49 100644 --- a/source3/utils/net_time.c +++ b/source3/utils/net_time.c @@ -30,7 +30,7 @@ static time_t cli_servertime(const char *host, struct sockaddr_storage *pss, int struct cli_state *cli = NULL; NTSTATUS status; - status = cli_connect_nb(host, pss, 0, 0x20, global_myname(), + status = cli_connect_nb(host, pss, 0, 0x20, lp_netbios_name(), Undefined, &cli); if (!NT_STATUS_IS_OK(status)) { fprintf(stderr, _("Can't contact server %s. Error %s\n"), diff --git a/source3/utils/net_util.c b/source3/utils/net_util.c index 09c0b8fc76..0b8bd839d1 100644 --- a/source3/utils/net_util.c +++ b/source3/utils/net_util.c @@ -360,7 +360,7 @@ int net_use_krb_machine_account(struct net_context *c) c->opt_password = secrets_fetch_machine_password( c->opt_target_workgroup, NULL, NULL); - if (asprintf(&user_name, "%s$@%s", global_myname(), lp_realm()) == -1) { + if (asprintf(&user_name, "%s$@%s", lp_netbios_name(), lp_realm()) == -1) { return -1; } c->opt_user_name = user_name; @@ -382,7 +382,7 @@ int net_use_machine_account(struct net_context *c) c->opt_password = secrets_fetch_machine_password( c->opt_target_workgroup, NULL, NULL); - if (asprintf(&user_name, "%s$", global_myname()) == -1) { + if (asprintf(&user_name, "%s$", lp_netbios_name()) == -1) { return -1; } c->opt_user_name = user_name; diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c index c115e2d29d..5d81d43634 100644 --- a/source3/utils/netlookup.c +++ b/source3/utils/netlookup.c @@ -98,7 +98,7 @@ static struct con_struct *create_cs(struct net_context *c, } #endif - nt_status = cli_full_connection(&cs->cli, global_myname(), global_myname(), + nt_status = cli_full_connection(&cs->cli, lp_netbios_name(), lp_netbios_name(), &loopback_ss, 0, "IPC$", "IPC", #if 0 diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c index 3a5ba223da..ba11ec7368 100644 --- a/source3/utils/ntlm_auth.c +++ b/source3/utils/ntlm_auth.c @@ -217,7 +217,7 @@ const char *get_winbind_netbios_name(void) if (winbindd_request_response(WINBINDD_NETBIOS_NAME, NULL, &response) != NSS_STATUS_SUCCESS) { DEBUG(0, ("could not obtain winbind netbios name!\n")); - return global_myname(); + return lp_netbios_name(); } fstrcpy(winbind_netbios_name, response.data.netbios_name); @@ -657,7 +657,7 @@ static NTSTATUS ntlm_auth_start_ntlmssp_client(struct ntlmssp_state **client_ntl } status = ntlmssp_client_start(NULL, - global_myname(), + lp_netbios_name(), lp_workgroup(), lp_client_ntlmv2_auth(), client_ntlmssp_state); @@ -711,7 +711,7 @@ static NTSTATUS ntlm_auth_start_ntlmssp_server(struct ntlmssp_state **ntlmssp_st bool is_standalone = false; if (opt_password) { - netbios_name = global_myname(); + netbios_name = lp_netbios_name(); netbios_domain = lp_workgroup(); } else { netbios_name = get_winbind_netbios_name(); @@ -1182,7 +1182,7 @@ static void offer_gss_spnego_mechs(void) { ZERO_STRUCT(spnego); - myname_lower = talloc_strdup(ctx, global_myname()); + myname_lower = talloc_strdup(ctx, lp_netbios_name()); if (!myname_lower) { return; } @@ -2063,7 +2063,7 @@ static void manage_ntlm_server_1_request(struct ntlm_auth_state *state, if (!NT_STATUS_IS_OK( contact_winbind_auth_crap(username, domain, - global_myname(), + lp_netbios_name(), &challenge, &lm_response, &nt_response, diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index 1d5789ddd4..d226c84b9a 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -1150,7 +1150,7 @@ static struct cli_state *connect_one(struct user_auth_info *auth_info, set_cmdline_auth_info_getpass(auth_info); - nt_status = cli_full_connection(&c, global_myname(), server, + nt_status = cli_full_connection(&c, lp_netbios_name(), server, &ss, 0, share, "?????", get_cmdline_auth_info_username(auth_info), diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 955ec8c6fd..9858e0a3a8 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -523,7 +523,7 @@ static struct cli_state *connect_one(const char *share) set_cmdline_auth_info_getpass(smbcquotas_auth_info); - nt_status = cli_full_connection(&c, global_myname(), server, + nt_status = cli_full_connection(&c, lp_netbios_name(), server, &ss, 0, share, "?????", get_cmdline_auth_info_username(smbcquotas_auth_info), diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c index 870ba27602..721034dedf 100644 --- a/source3/utils/testparm.c +++ b/source3/utils/testparm.c @@ -77,7 +77,7 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n"); ret = 1; } - if (strequal(lp_workgroup(), global_myname())) { + if (strequal(lp_workgroup(), lp_netbios_name())) { fprintf(stderr, "WARNING: 'workgroup' and 'netbios name' " \ "must differ.\n"); ret = 1; diff --git a/source3/web/diagnose.c b/source3/web/diagnose.c index d73337ca84..abb4d79b9a 100644 --- a/source3/web/diagnose.c +++ b/source3/web/diagnose.c @@ -70,7 +70,7 @@ bool smbd_running(void) loopback_ip.s_addr = htonl(INADDR_LOOPBACK); in_addr_to_sockaddr_storage(&ss, loopback_ip); - status = cli_connect_nb("localhost", &ss, 0, 0x20, global_myname(), + status = cli_connect_nb("localhost", &ss, 0, 0x20, lp_netbios_name(), Undefined, &cli); if (!NT_STATUS_IS_OK(status)) { return false; diff --git a/source3/winbindd/winbindd_ccache_access.c b/source3/winbindd/winbindd_ccache_access.c index 6a265ccaf0..0b52ae2eb9 100644 --- a/source3/winbindd/winbindd_ccache_access.c +++ b/source3/winbindd/winbindd_ccache_access.c @@ -55,7 +55,7 @@ static NTSTATUS do_ntlm_auth_with_hashes(const char *username, DATA_BLOB dummy_msg, reply; status = ntlmssp_client_start(NULL, - global_myname(), + lp_netbios_name(), lp_workgroup(), lp_client_ntlmv2_auth(), &ntlmssp_state); diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index 726e99787f..86d6662e5a 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -885,7 +885,7 @@ static NTSTATUS cm_prepare_connection(const struct winbindd_domain *domain, (*cli)->use_kerberos = True; DEBUG(5, ("connecting to %s from %s with kerberos principal " - "[%s] and realm [%s]\n", controller, global_myname(), + "[%s] and realm [%s]\n", controller, lp_netbios_name(), machine_krb5_principal, domain->alt_name)); winbindd_set_locator_kdc_envs(domain); @@ -916,7 +916,7 @@ static NTSTATUS cm_prepare_connection(const struct winbindd_domain *domain, (*cli)->use_kerberos = False; DEBUG(5, ("connecting to %s from %s with username " - "[%s]\\[%s]\n", controller, global_myname(), + "[%s]\\[%s]\n", controller, lp_netbios_name(), lp_workgroup(), machine_account)); ads_status = cli_session_setup_spnego(*cli, @@ -952,7 +952,7 @@ static NTSTATUS cm_prepare_connection(const struct winbindd_domain *domain, /* Only try authenticated if we have a username */ DEBUG(5, ("connecting to %s from %s with username " - "[%s]\\[%s]\n", controller, global_myname(), + "[%s]\\[%s]\n", controller, lp_netbios_name(), ipc_domain, ipc_username)); if (NT_STATUS_IS_OK(cli_session_setup( @@ -2627,7 +2627,7 @@ NTSTATUS cm_connect_netlogon(struct winbindd_domain *domain, netlogon_pipe, domain->dcname, /* server name. */ domain->name, /* domain name */ - global_myname(), /* client name */ + lp_netbios_name(), /* client name */ account_name, /* machine account */ mach_pwd, /* machine password */ sec_chan_type, /* from get_trust_pw */ diff --git a/source3/winbindd/winbindd_misc.c b/source3/winbindd/winbindd_misc.c index 7d2516770b..3fb1436820 100644 --- a/source3/winbindd/winbindd_misc.c +++ b/source3/winbindd/winbindd_misc.c @@ -404,7 +404,7 @@ void winbindd_netbios_name(struct winbindd_cli_state *state) DEBUG(3, ("[%5lu]: request netbios name\n", (unsigned long)state->pid)); - fstrcpy(state->response->data.netbios_name, global_myname()); + fstrcpy(state->response->data.netbios_name, lp_netbios_name()); request_ok(state); } diff --git a/source3/winbindd/winbindd_pam.c b/source3/winbindd/winbindd_pam.c index e5ad2e00b0..910e42971a 100644 --- a/source3/winbindd/winbindd_pam.c +++ b/source3/winbindd/winbindd_pam.c @@ -1118,7 +1118,7 @@ static NTSTATUS winbindd_dual_auth_passdb(TALLOC_CTX *mem_ctx, NTSTATUS status; status = make_user_info(&user_info, user, user, domain, domain, - global_myname(), lm_resp, nt_resp, NULL, NULL, + lp_netbios_name(), lm_resp, nt_resp, NULL, NULL, NULL, AUTH_PASSWORD_RESPONSE); if (!NT_STATUS_IS_OK(status)) { DEBUG(10, ("make_user_info failed: %s\n", nt_errstr(status))); @@ -1348,7 +1348,7 @@ static NTSTATUS winbindd_dual_pam_auth_samlogon(TALLOC_CTX *mem_ctx, 'workstation' passed to the actual SamLogon call. */ names_blob = NTLMv2_generate_names_blob( - mem_ctx, global_myname(), lp_workgroup()); + mem_ctx, lp_netbios_name(), lp_workgroup()); if (!SMBNTLMv2encrypt(mem_ctx, name_user, name_domain, pass, @@ -1386,7 +1386,7 @@ static NTSTATUS winbindd_dual_pam_auth_samlogon(TALLOC_CTX *mem_ctx, domain->dcname, name_user, name_domain, - global_myname(), + lp_netbios_name(), chal, lm_resp, nt_resp, diff --git a/source3/winbindd/winbindd_pam_auth_crap.c b/source3/winbindd/winbindd_pam_auth_crap.c index 186e510aa3..2fb5111510 100644 --- a/source3/winbindd/winbindd_pam_auth_crap.c +++ b/source3/winbindd/winbindd_pam_auth_crap.c @@ -74,7 +74,7 @@ struct tevent_req *winbindd_pam_auth_crap_send( } if (request->data.auth_crap.workstation[0] == '\0') { - fstrcpy(request->data.auth_crap.workstation, global_myname()); + fstrcpy(request->data.auth_crap.workstation, lp_netbios_name()); } subreq = wb_domain_request_send(state, winbind_event_context(), domain, |