s3-param Remove special case for global_scope()
authorAndrew Bartlett <abartlet@samba.org>
Wed, 8 Jun 2011 06:27:06 +0000 (16:27 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 9 Jun 2011 10:40:09 +0000 (12:40 +0200)
There is no reason this can't be a normal constant string in the
loadparm system.  (Past reasons were that we didn't have lp_set_cmdline())

Andrew Bartlett

source3/include/proto.h
source3/lib/popt_common.c
source3/lib/util_names.c
source3/libsmb/nmblib.c
source3/nmbd/nmbd_packets.c
source3/nmbd/nmbd_winsserver.c
source3/param/loadparm.c
source3/param/loadparm_ctx.c
source3/utils/smbcontrol.c

index 2edd72e026d914f3ba52a5924186d4167927998b..edcb025101b8a9fa41927a7baf7b186ce4a33498 100644 (file)
@@ -504,8 +504,6 @@ const char *get_global_sam_name(void);
 enum protocol_types get_Protocol(void);
 void set_Protocol(enum protocol_types  p);
 bool all_zero(const uint8_t *ptr, size_t size);
-bool set_global_scope(const char *scope);
-const char *global_scope(void);
 void gfree_names(void);
 void gfree_all( void );
 const char *my_netbios_names(int i);
@@ -1198,6 +1196,7 @@ char *lp_passwd_program(void);
 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_workgroup(void);
 const char *lp_realm(void);
 const char *lp_dnsdomain(void);
index 628ed65820629ebdf97f0117e11f3027d371578a..58f0478a76f79c214712b4142406097d61c70832 100644 (file)
@@ -143,7 +143,7 @@ static void popt_common_callback(poptContext con,
 
        case 'i':
                if (arg) {
-                         set_global_scope(arg);
+                       lp_set_cmdline("netbios scope", arg);
                }
                break;
 
index d8ebf213cffb98972ce00bea1bca32dfd38eaefb..78d79883677e8f708e8c51e74790ff073b07d2fe 100644 (file)
 
 static char *smb_myname;
 static char *smb_myworkgroup;
-static char *smb_scope;
 static int smb_num_netbios_names;
 static char **smb_my_netbios_names;
 
-/***********************************************************************
- Allocate and set scope. Ensure upper case.
-***********************************************************************/
-
-bool set_global_scope(const char *scope)
-{
-       SAFE_FREE(smb_scope);
-       smb_scope = SMB_STRDUP(scope);
-       if (!smb_scope)
-               return False;
-       strupper_m(smb_scope);
-       return True;
-}
-
-/*********************************************************************
- Ensure scope is never null string.
-*********************************************************************/
-
-const char *global_scope(void)
-{
-       if (!smb_scope)
-               set_global_scope("");
-       return smb_scope;
-}
-
 static void free_netbios_names_array(void)
 {
        int i;
@@ -102,7 +76,6 @@ static bool set_my_netbios_names(const char *name, int i)
 void gfree_names(void)
 {
        gfree_netbios_names();
-       SAFE_FREE( smb_scope );
        free_netbios_names_array();
        free_local_machine_name();
 }
index f4d5ec7bbb92cb79491dbdc438ba7ecbeb6b125f..767ff81476e882140172a014b7699448d51ec975 100644 (file)
@@ -936,7 +936,7 @@ void make_nmb_name( struct nmb_name *n, const char *name, int type)
        strupper_m(unix_name);
        push_ascii(n->name, unix_name, sizeof(n->name), STR_TERMINATE);
        n->name_type = (unsigned int)type & 0xFF;
-       push_ascii(n->scope,  global_scope(), 64, STR_TERMINATE);
+       push_ascii(n->scope,  lp_netbios_scope(), 64, STR_TERMINATE);
 }
 
 /*******************************************************************
@@ -1261,7 +1261,7 @@ char *name_mangle(TALLOC_CTX *mem_ctx, const char *In, char name_type)
        char *result;
        char *p;
 
-       result = talloc_array(mem_ctx, char, 33 + strlen(global_scope()) + 2);
+       result = talloc_array(mem_ctx, char, 33 + strlen(lp_netbios_scope()) + 2);
        if (result == NULL) {
                return NULL;
        }
@@ -1296,8 +1296,8 @@ char *name_mangle(TALLOC_CTX *mem_ctx, const char *In, char name_type)
        p[0] = '\0';
 
        /* Add the scope string. */
-       for( i = 0, len = 0; *(global_scope()) != '\0'; i++, len++ ) {
-               switch( (global_scope())[i] ) {
+       for( i = 0, len = 0; *(lp_netbios_scope()) != '\0'; i++, len++ ) {
+               switch( (lp_netbios_scope())[i] ) {
                        case '\0':
                                p[0] = len;
                                if( len > 0 )
@@ -1309,7 +1309,7 @@ char *name_mangle(TALLOC_CTX *mem_ctx, const char *In, char name_type)
                                len  = -1;
                                break;
                        default:
-                               p[len+1] = (global_scope())[i];
+                               p[len+1] = (lp_netbios_scope())[i];
                                break;
                }
        }
index 3d51849287cb10394a544965aa7b4100ca783670..a89f49c8fc97257c0cc134364953381cba655c0c 100644 (file)
@@ -1073,9 +1073,9 @@ static void process_browse_packet(struct packet_struct *p, const char *buf,int l
 
        /* Drop the packet if it's a different NetBIOS scope, or the source is from one of our names. */
        pull_ascii(scope, dgram->dest_name.scope, 64, 64, STR_TERMINATE);
-       if (!strequal(scope, global_scope())) {
+       if (!strequal(scope, lp_netbios_scope())) {
                DEBUG(7,("process_browse_packet: Discarding datagram from IP %s. Scope (%s) \
-mismatch with our scope (%s).\n", inet_ntoa(p->ip), scope, global_scope()));
+mismatch with our scope (%s).\n", inet_ntoa(p->ip), scope, lp_netbios_scope()));
                return;
        }
 
@@ -1161,9 +1161,9 @@ static void process_lanman_packet(struct packet_struct *p, const char *buf,int l
        /* Drop the packet if it's a different NetBIOS scope, or the source is from one of our names. */
 
        pull_ascii(scope, dgram->dest_name.scope, 64, 64, STR_TERMINATE);
-       if (!strequal(scope, global_scope())) {
+       if (!strequal(scope, lp_netbios_scope())) {
                DEBUG(7,("process_lanman_packet: Discarding datagram from IP %s. Scope (%s) \
-mismatch with our scope (%s).\n", inet_ntoa(p->ip), scope, global_scope()));
+mismatch with our scope (%s).\n", inet_ntoa(p->ip), scope, lp_netbios_scope()));
                return;
        }
 
index d5691547198ae778f5d98f89006f08a0e0ef801b..1370535b7cdc00504c184cb5bbc77a81e205529e 100644 (file)
@@ -75,7 +75,7 @@ static void wins_delete_all_1b_in_memory_records(void)
 }
 
 /****************************************************************************
- Convert a wins.tdb record to a struct name_record. Add in our global_scope().
+ Convert a wins.tdb record to a struct name_record. Add in our lp_netbios_scope().
 *****************************************************************************/
 
 static struct name_record *wins_record_to_name_record(TDB_DATA key, TDB_DATA data)
@@ -128,7 +128,7 @@ static struct name_record *wins_record_to_name_record(TDB_DATA key, TDB_DATA dat
        push_ascii_nstring(namerec->name.name, (const char *)key.dptr);
        namerec->name.name_type = key.dptr[sizeof(unstring)];
        /* Add the scope. */
-       push_ascii(namerec->name.scope, global_scope(), 64, STR_TERMINATE);
+       push_ascii(namerec->name.scope, lp_netbios_scope(), 64, STR_TERMINATE);
 
         /* We're using a byte-by-byte compare, so we must be sure that
          * unused space doesn't have garbage in it.
index 56f039f46e52d4b9a8348c09a18a0f57e8463957..619faf69eb9ceebca3329a3994097a528a656604 100644 (file)
@@ -708,7 +708,6 @@ static bool handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
 static bool handle_debug_list( int snum, const char *pszParmValue, char **ptr );
 static bool handle_realm( int snum, const char *pszParmValue, char **ptr );
 static bool handle_netbios_aliases( int snum, const char *pszParmValue, char **ptr );
-static bool handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
 static bool handle_charset( int snum, const char *pszParmValue, char **ptr );
 static bool handle_dos_charset( int snum, const char *pszParmValue, char **ptr );
 static bool handle_printing( int snum, const char *pszParmValue, char **ptr);
@@ -1048,7 +1047,7 @@ static struct parm_struct parm_table[] = {
                .type           = P_USTRING,
                .p_class        = P_GLOBAL,
                .ptr            = &Globals.szNetbiosScope,
-               .special        = handle_netbios_scope,
+               .special        = NULL,
                .enum_list      = NULL,
                .flags          = FLAG_ADVANCED,
        },
@@ -5618,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_scope, &Globals.szNetbiosScope)
 FN_GLOBAL_CONST_STRING(lp_realm, &Globals.szRealmUpper)
 FN_GLOBAL_CONST_STRING(lp_dnsdomain, &Globals.szDnsDomain)
 FN_GLOBAL_CONST_STRING(lp_afs_username_map, &Globals.szAfsUsernameMap)
@@ -7599,16 +7599,6 @@ static bool handle_realm(int snum, const char *pszParmValue, char **ptr)
        return ret;
 }
 
-static bool handle_netbios_scope(int snum, const char *pszParmValue, char **ptr)
-{
-       bool ret;
-
-       ret = set_global_scope(pszParmValue);
-       string_set(&Globals.szNetbiosScope,global_scope());
-
-       return ret;
-}
-
 static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr)
 {
        TALLOC_FREE(Globals.szNetbiosAliases);
index cc2468651ae82c56491b9b0c1ea02ec26c60ea25..d07ef45d361751ab4fdedacbbf9b82bdb78dc232 100644 (file)
@@ -49,7 +49,7 @@ static const struct loadparm_s3_context s3_fns =
        .workgroup = lp_workgroup,
 
        .netbios_name = global_myname,
-       .netbios_scope = global_scope,
+       .netbios_scope = lp_netbios_scope,
 
        .lanman_auth = lp_lanman_auth,
        .ntlm_auth = lp_ntlm_auth,
index 0a3a94a1df0489dcddb7a3f2a226e136e0e66742..5520dcf608a3017539e2e723240b161749f3bd01 100644 (file)
@@ -1202,7 +1202,7 @@ static void my_make_nmb_name( struct nmb_name *n, const char *name, int type)
        strupper_m(unix_name);
        push_ascii(n->name, unix_name, sizeof(n->name), STR_TERMINATE);
        n->name_type = (unsigned int)type & 0xFF;
-       push_ascii(n->scope,  global_scope(), 64, STR_TERMINATE);
+       push_ascii(n->scope,  lp_netbios_scope(), 64, STR_TERMINATE);
 }
 
 static bool do_nodestatus(struct messaging_context *msg_ctx,