From bb5bf508197205f6a9d17b3418a9291b934bd9fa Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 13 Mar 2021 22:07:53 +0100 Subject: [PATCH] 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 Reviewed-by: Jeremy Allison --- docs-xml/smbdotconf/base/netbiosaliases.xml | 1 - lib/param/loadparm.c | 13 -- lib/param/s3_param.h | 1 - source3/client/client.c | 5 - source3/include/proto.h | 3 - source3/lib/netapi/netapi.c | 2 - source3/lib/util.c | 1 - source3/lib/util_names.c | 127 -------------------- source3/param/loadparm_ctx.c | 1 - source3/rpcclient/rpcclient.c | 5 - source3/smbd/server.c | 3 - source3/torture/pdbtest.c | 1 - source3/utils/net.c | 3 - source3/utils/pdbedit.c | 3 - source3/utils/smbpasswd.c | 8 -- source3/winbindd/winbindd.c | 5 - source4/client/client.c | 2 - source4/torture/libnetapi/libnetapi.c | 1 - 18 files changed, 185 deletions(-) diff --git a/docs-xml/smbdotconf/base/netbiosaliases.xml b/docs-xml/smbdotconf/base/netbiosaliases.xml index 0304ab02d92..b9b66b16ef1 100644 --- a/docs-xml/smbdotconf/base/netbiosaliases.xml +++ b/docs-xml/smbdotconf/base/netbiosaliases.xml @@ -1,7 +1,6 @@ This is a list of NetBIOS names that nmbd will diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c index 0c4c3d0f555..6f0eeb7edf6 100644 --- a/lib/param/loadparm.c +++ b/lib/param/loadparm.c @@ -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 */ diff --git a/lib/param/s3_param.h b/lib/param/s3_param.h index 7bbadfd196a..f9ed7c3e2d7 100644 --- a/lib/param/s3_param.h +++ b/lib/param/s3_param.h @@ -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; diff --git a/source3/client/client.c b/source3/client/client.c index e2fdacd1251..7c0a3832a41 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -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); diff --git a/source3/include/proto.h b/source3/include/proto.h index 5bb5f2c36da..1d5ebecb03c 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -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); diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index f8f79c69baf..fb8b4bc6113 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -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(); diff --git a/source3/lib/util.c b/source3/lib/util.c index f4091e1759a..ee6cab17f0f 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -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(); diff --git a/source3/lib/util_names.c b/source3/lib/util_names.c index ade9a0570c2..f0e9f699f29 100644 --- a/source3/lib/util_names.c +++ b/source3/lib/util_names.c @@ -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; nopt_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, diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index ac71167ad07..4c21b530623 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -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) + diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c index 4f727202863..4196e3f98f9 100644 --- a/source3/utils/smbpasswd.c +++ b/source3/utils/smbpasswd.c @@ -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"); diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index bccd1726ce1..cfc65b0b2d4 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -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()) { diff --git a/source4/client/client.c b/source4/client/client.c index 549e5343f84..7d526ebd88a 100644 --- a/source4/client/client.c +++ b/source4/client/client.c @@ -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); diff --git a/source4/torture/libnetapi/libnetapi.c b/source4/torture/libnetapi/libnetapi.c index dc48caf6031..96ab8b7f151 100644 --- a/source4/torture/libnetapi/libnetapi.c +++ b/source4/torture/libnetapi/libnetapi.c @@ -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); -- 2.47.3