1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-04 08:23:50 +03:00

s3-param Remove special case for global_scope()

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
This commit is contained in:
Andrew Bartlett
2011-06-08 16:27:06 +10:00
parent 3ccc760947
commit f348d148b4
9 changed files with 17 additions and 55 deletions

View 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);

View 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;

View File

@@ -30,35 +30,9 @@
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();
}

View 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;
}
}

View 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;
}

View 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.

View 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);

View 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,

View 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,