]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: Remove init_names()
authorVolker Lendecke <vl@samba.org>
Sat, 13 Mar 2021 21:07:53 +0000 (22:07 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 16 Mar 2021 17:09:32 +0000 (17:09 +0000)
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>
18 files changed:
docs-xml/smbdotconf/base/netbiosaliases.xml
lib/param/loadparm.c
lib/param/s3_param.h
source3/client/client.c
source3/include/proto.h
source3/lib/netapi/netapi.c
source3/lib/util.c
source3/lib/util_names.c
source3/param/loadparm_ctx.c
source3/rpcclient/rpcclient.c
source3/smbd/server.c
source3/torture/pdbtest.c
source3/utils/net.c
source3/utils/pdbedit.c
source3/utils/smbpasswd.c
source3/winbindd/winbindd.c
source4/client/client.c
source4/torture/libnetapi/libnetapi.c

index 0304ab02d92533b27acfd71ba12d39ef75fb7a58..b9b66b16ef12371de023df725733b8a9099b3de0 100644 (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 
index 0c4c3d0f555f02ddf41b18f477fb7f42f6bfcbbc..6f0eeb7edf6bc985e39fe350598f6b4fa31fe53b 100644 (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
  */
index 7bbadfd196a02a3658c3425363e04b10d0fb7e9c..f9ed7c3e2d7486e036c27c3c865fc68ef81d94f2 100644 (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;
index e2fdacd1251cd2c422215f3c4c30e91ee4e60a1b..7c0a3832a4146987651a060b0ce32c7025db28ab 100644 (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);
 
index 5bb5f2c36da95f7b1cbc510df3d1dc750162e2ea..1d5ebecb03c9d81c4ffafef5c15afdec6f4e9d98 100644 (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);
index f8f79c69baf89c91fb5261e6e950ce4fc2ba566f..fb8b4bc61136031b723a98943b42c6c27efce7a2 100644 (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();
index f4091e1759aa33815bc57702f4a6d4f26bf6fd5f..ee6cab17f0fb2f6628083e1420d1249d864e3c1b 100644 (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();
index ade9a0570c213ef6f8fafd97ad1e1f38e671b11d..f0e9f699f29f20ce701f3d0caca560629b003bce 100644 (file)
 
 #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
index 0a8f957b78790cfb554c1706f12ea5e7057d998e..43e431cec1cf0fb03766380d801b0c1f4ade8e13 100644 (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,
 };
 
index e2a9aa97c32d34badc34ae9eb97629b4a5bbf95e..6747aaec147094e0e48e749b5927fa216fbd1cb1 100644 (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
index f41ceb899d7e1e329718abdb8248f4c5f0dd02f9..8dd3068bf089954c13d4320a87c96724a91c6476 100644 (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;
 
index 5d74aa9ab78004a0eec45195350793af68e45711..06aee9c5db126b336ef31536ebfe76c6414b0492 100644 (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();
index 4fc19c4a121499b1054875a3c5c0405222b2af87..17d9a61ed87f1c5419a9e4ad7ebfed1c132f9960 100644 (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,
index ac71167ad073fb552afdd8c9ce54befb5e3764ea..4c21b53062311353d647d71aba18b509c7109cb3 100644 (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) +
index 4f727202863705765fc2cf061b6eac79ad22777c..4196e3f98f9a3345ac3e62b1fc4c726987517b97 100644 (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");
index bccd1726ce132158f03acf76a49cff27858c2256..cfc65b0b2d41c0973aa012f07979520140c2924a 100644 (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()) {
index 549e5343f8461223aee224d673952832c6f9078d..7d526ebd88a55b51932bb139b28860562ef6af63 100644 (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);
index dc48caf60318966b352c65e35db5b8997450e12b..96ab8b7f1518115bb7413098e887817c6cf40e2d 100644 (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);