1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-23 20:59:10 +03:00

lib: Remove init_names()

is_myname() looks at lp_* directly, nmbd maintains its own list: We don't
need the baroque loadparm handler anymore.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke
2021-03-13 22:07:53 +01:00
committed by Jeremy Allison
parent 57d548b502
commit bb5bf50819
18 changed files with 0 additions and 185 deletions

View File

@ -1,7 +1,6 @@
<samba:parameter name="netbios aliases"
context="G"
type="cmdlist"
handler="handle_netbios_aliases"
xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
<description>
<para>This is a list of NetBIOS names that nmbd will

View File

@ -1290,19 +1290,6 @@ bool handle_ldap_debug_level(struct loadparm_context *lp_ctx, struct loadparm_se
return true;
}
bool handle_netbios_aliases(struct loadparm_context *lp_ctx, struct loadparm_service *service,
const char *pszParmValue, char **ptr)
{
TALLOC_FREE(lp_ctx->globals->netbios_aliases);
lp_ctx->globals->netbios_aliases = str_list_make_v3_const(lp_ctx->globals->ctx,
pszParmValue, NULL);
if (lp_ctx->s3_fns) {
return lp_ctx->s3_fns->set_netbios_aliases(lp_ctx->globals->netbios_aliases);
}
return true;
}
/*
* idmap related parameters
*/

View File

@ -14,7 +14,6 @@ struct loadparm_s3_helpers
bool (*lp_include)(struct loadparm_context*, struct loadparm_service *,
const char *, char **);
void (*init_ldap_debugging)(void);
bool (*set_netbios_aliases)(const char **);
bool (*do_section)(const char *pszSectionName, void *userdata);
struct loadparm_global *globals;
unsigned int *flags;

View File

@ -6622,11 +6622,6 @@ int main(int argc,char *argv[])
}
}
if (!init_names()) {
fprintf(stderr, "init_names() failed\n");
exit(1);
}
if(new_name_resolve_order)
lp_set_cmdline("name resolve order", new_name_resolve_order);

View File

@ -310,10 +310,7 @@ bool is_allowed_domain(const char *domain_name);
enum protocol_types get_Protocol(void);
void set_Protocol(enum protocol_types p);
void gfree_names(void);
void gfree_all( void );
bool set_netbios_aliases(const char **str_array);
bool init_names(void);
bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf,
bool fake_dir_create_times);
bool socket_exist(const char *fname);

View File

@ -81,7 +81,6 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
return W_ERROR_V(WERR_GEN_FAILURE);
}
init_names();
load_interfaces();
reopen_logs();
@ -178,7 +177,6 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx)
}
}
gfree_names();
gfree_loadparm();
gfree_charcnv();
gfree_interfaces();

View File

@ -99,7 +99,6 @@ static enum remote_arch_types ra_type = RA_UNKNOWN;
void gfree_all( void )
{
gfree_names();
gfree_loadparm();
gfree_charcnv();
gfree_interfaces();

View File

@ -24,133 +24,6 @@
#include "includes.h"
/***********************************************************************
Definitions for all names.
***********************************************************************/
static int smb_num_netbios_names;
static char **smb_my_netbios_names;
static void free_netbios_names_array(void)
{
int i;
for (i = 0; i < smb_num_netbios_names; i++)
SAFE_FREE(smb_my_netbios_names[i]);
SAFE_FREE(smb_my_netbios_names);
smb_num_netbios_names = 0;
}
static bool allocate_my_netbios_names_array(size_t number)
{
free_netbios_names_array();
smb_num_netbios_names = number + 1;
smb_my_netbios_names = SMB_MALLOC_ARRAY( char *, smb_num_netbios_names );
if (!smb_my_netbios_names)
return False;
memset(smb_my_netbios_names, '\0', sizeof(char *) * smb_num_netbios_names);
return True;
}
static bool set_my_netbios_names(const char *name, int i)
{
SAFE_FREE(smb_my_netbios_names[i]);
/*
* Don't include space for terminating '\0' in strndup,
* it is automatically added. This screws up if the name
* is greater than MAX_NETBIOSNAME_LEN-1 in the unix
* charset, but less than or equal to MAX_NETBIOSNAME_LEN-1
* in the DOS charset, but this is so old we have to live
* with that.
*/
smb_my_netbios_names[i] = SMB_STRNDUP(name, MAX_NETBIOSNAME_LEN-1);
if (!smb_my_netbios_names[i])
return False;
return strupper_m(smb_my_netbios_names[i]);
}
/***********************************************************************
Free memory allocated to global objects
***********************************************************************/
void gfree_names(void)
{
free_netbios_names_array();
}
bool set_netbios_aliases(const char **str_array)
{
size_t namecount;
/* Work out the max number of netbios aliases that we have */
for( namecount=0; str_array && (str_array[namecount] != NULL); namecount++ )
;
if ( lp_netbios_name() && *lp_netbios_name())
namecount++;
/* Allocate space for the netbios aliases */
if (!allocate_my_netbios_names_array(namecount))
return False;
/* Use the global_myname string first */
namecount=0;
if ( lp_netbios_name() && *lp_netbios_name()) {
set_my_netbios_names( lp_netbios_name(), namecount );
namecount++;
}
if (str_array) {
size_t i;
for ( i = 0; str_array[i] != NULL; i++) {
size_t n;
bool duplicate = False;
/* Look for duplicates */
for( n=0; n<namecount; n++ ) {
if( strequal( str_array[i],
smb_my_netbios_names[n] ) ) {
duplicate = True;
break;
}
}
if (!duplicate) {
if (!set_my_netbios_names(str_array[i], namecount))
return False;
namecount++;
}
}
}
return True;
}
/****************************************************************************
Common name initialization code.
****************************************************************************/
bool init_names(void)
{
int n;
if (!set_netbios_aliases(lp_netbios_aliases())) {
DEBUG( 0, ( "init_names: malloc fail.\n" ) );
return False;
}
DEBUG( 5, ("Netbios name list:-\n") );
for( n=0; smb_my_netbios_names[n]; n++ ) {
DEBUGADD( 5, ("my_netbios_names[%d]=\"%s\"\n",
n, smb_my_netbios_names[n] ) );
}
return( True );
}
/******************************************************************
get the default domain/netbios name to be used when dealing
with our passdb list of accounts

View File

@ -68,7 +68,6 @@ static struct loadparm_s3_helpers s3_fns =
.dump = lp_dump,
.lp_include = lp_include,
.init_ldap_debugging = init_ldap_debugging,
.set_netbios_aliases = set_netbios_aliases,
.do_section = lp_do_section,
};

View File

@ -1088,11 +1088,6 @@ out_free:
rpcclient_msg_ctx = cmdline_messaging_context(get_dyn_CONFIGFILE());
if (!init_names()) {
result = 1;
goto done;
}
/*
* Get password
* from stdin if necessary

View File

@ -1387,9 +1387,6 @@ static bool init_structs(void )
* set from the config file.
*/
if (!init_names())
return False;
if (!secrets_init())
return False;

View File

@ -586,7 +586,6 @@ int main(int argc, const char **argv)
/* Load configuration */
lp_load_global(get_dyn_CONFIGFILE());
setup_logging("pdbtest", DEBUG_STDOUT);
init_names();
if (backend == NULL) {
backend = lp_passdb_backend();

View File

@ -1397,9 +1397,6 @@ static void get_credentials_file(struct net_context *c,
c->opt_target_workgroup = talloc_strdup(c, lp_workgroup());
}
if (!init_names())
exit(1);
load_interfaces();
/* this makes sure that when we do things like call scripts,

View File

@ -1135,9 +1135,6 @@ int main(int argc, const char **argv)
exit(1);
}
if (!init_names())
exit(1);
setparms = (backend ? BIT_BACKEND : 0) +
(verbose ? BIT_VERBOSE : 0) +
(spstyle ? BIT_SPSTYLE : 0) +

View File

@ -634,14 +634,6 @@ int main(int argc, char **argv)
setup_logging("smbpasswd", DEBUG_STDERR);
/*
* Set the machine NETBIOS name if not already
* set from the config file.
*/
if (!init_names())
return 1;
/* Check the effective uid - make sure we are not setuid */
if (is_setuid_root()) {
fprintf(stderr, "smbpasswd must *NOT* be setuid root.\n");

View File

@ -1842,11 +1842,6 @@ int main(int argc, const char **argv)
exit(1);
}
/* Setup names. */
if (!init_names())
exit(1);
load_interfaces();
if (!secrets_init()) {

View File

@ -3460,8 +3460,6 @@ static int do_message_op(const char *netbios_name, const char *desthost,
poptGetArg(pc), CRED_SPECIFIED);
}
/*init_names(); */
if (!query_host && !service && !message) {
poptPrintUsage(pc, stderr, 0);
exit(1);

View File

@ -39,7 +39,6 @@ bool torture_libnetapi_init_context(struct torture_context *tctx,
return W_ERROR_V(WERR_GEN_FAILURE);
}
init_names();
load_interfaces();
status = libnetapi_net_init(&ctx);