summaryrefslogtreecommitdiff
path: root/source3/nameconf.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1996-10-02 14:09:22 +0000
committerAndrew Tridgell <tridge@samba.org>1996-10-02 14:09:22 +0000
commit5a2f52b79e28530c454cb488a44588147640f061 (patch)
tree1f412098bbcf050bce556d00f2c3fddd470746c9 /source3/nameconf.c
parent11d9539d755d5c5accb4481577781b8b7bfeda50 (diff)
downloadsamba-5a2f52b79e28530c454cb488a44588147640f061.tar.gz
samba-5a2f52b79e28530c454cb488a44588147640f061.tar.bz2
samba-5a2f52b79e28530c454cb488a44588147640f061.zip
- a huge pile of changes from Luke which implement the browse.conf
stuff and also fix a pile of nmbd bugs. Unfortunately I found it very hard to disentangle the new features from the bug fixes so I am putting in the new code. I hope this is the last big pile of changes to the 1.9.16 series! (This used to be commit 20b6203dac4bbb43e4e7bea0b214496d76d679d9)
Diffstat (limited to 'source3/nameconf.c')
-rw-r--r--source3/nameconf.c116
1 files changed, 73 insertions, 43 deletions
diff --git a/source3/nameconf.c b/source3/nameconf.c
index 79fa2abe43..2e1bdf5c79 100644
--- a/source3/nameconf.c
+++ b/source3/nameconf.c
@@ -58,10 +58,12 @@ struct smbbrowse
char work_name[16]; /* workgroup name */
char browsing_alias[16]; /* alias for our role in this workgroup */
struct server_identity *my_names; /* a list of server name we should appear here as */
- BOOL should_workgroup_member; /* should we try to become a member of this workgroup? */
- BOOL should_local_master; /* should we try to become a master browser? */
- BOOL should_domain_master; /* should we try to become the domain master browser? */
-} ;
+ BOOL should_workgroup_member; /* should we be a member of this workgroup? */
+ BOOL should_local_master; /* should we be a master browser? */
+ BOOL should_preferred_master; /* should we initiate attempts to become a master browser? */
+ BOOL should_domain_master; /* should we be the domain master browser? */
+ BOOL should_domain_logon; /* should we be the domain logon? */
+};
/* The whole list */
static struct smbbrowse *smbbrowse_workgroups = (struct smbbrowse*)NULL;
@@ -82,12 +84,12 @@ int get_num_workgroups(void)
** old one as a model.
*/
static struct smbbrowse *new_workgroup(struct smbbrowse *model,
- const char *workgroup_name,
- const char *default_name)
+ char *workgroup_name,
+ char *default_name)
{
struct smbbrowse *new;
- if( ! (array_size > nexttoken) )
+ if ( ! (array_size > nexttoken) )
{
array_size += 10;
smbbrowse_workgroups = (struct smbbrowse*)realloc(smbbrowse_workgroups,
@@ -96,7 +98,7 @@ static struct smbbrowse *new_workgroup(struct smbbrowse *model,
new = &smbbrowse_workgroups[nexttoken];
- if(model != (struct smbbrowse *)NULL )
+ if (model != (struct smbbrowse *)NULL )
memcpy(new, model, sizeof(struct smbbrowse));
else
memset(new, 0, sizeof(struct smbbrowse));
@@ -122,28 +124,27 @@ static struct smbbrowse *new_workgroup(struct smbbrowse *model,
** If the workgroup does not exist a new token is assigned unless
** new workgroups are not allowed.
*/
-int conf_workgroup_name_to_token(const char *workgroup_name,
- const char *default_name)
+int conf_workgroup_name_to_token(char *workgroup_name,char *default_name)
{
int idx;
/* Look for an existing instance. */
- for(idx=0; idx < nexttoken; idx++)
+ for (idx=0; idx < nexttoken; idx++)
{
- if(strequal(workgroup_name, smbbrowse_workgroups[idx].work_name))
+ if (strequal(workgroup_name, smbbrowse_workgroups[idx].work_name))
{
return idx;
}
}
/* See if creating new ones in admissable. */
- for(idx=0; idx < nexttoken; idx++)
+ for (idx=0; idx < nexttoken; idx++)
{
- if(strequal("*", smbbrowse_workgroups[idx].work_name))
+ if (strequal("*", smbbrowse_workgroups[idx].work_name))
{
struct smbbrowse *w = new_workgroup(&smbbrowse_workgroups[idx],
workgroup_name, default_name);
- w->should_workgroup_member = False;
+ w->should_workgroup_member = True;
return (nexttoken - 1);
}
@@ -159,7 +160,7 @@ int conf_workgroup_name_to_token(const char *workgroup_name,
*/
static int range_check(int token)
{
- if(token < 0 || token >= nexttoken)
+ if (token < 0 || token >= nexttoken)
{
DEBUG(0, ("range_check(): failed\n"));
return True;
@@ -173,7 +174,7 @@ static int range_check(int token)
*/
char *conf_workgroup_name(int token)
{
- if(range_check(token))
+ if (range_check(token))
return (char*)NULL;
return smbbrowse_workgroups[token].work_name;
@@ -183,10 +184,23 @@ char *conf_workgroup_name(int token)
** Given a token, return True if we should try
** to become a master browser.
*/
+int conf_should_preferred_master(int token)
+ {
+
+ if (range_check(token))
+ return False;
+
+ return smbbrowse_workgroups[token].should_preferred_master;
+ }
+
+/*
+** Given a token, return True if we should try
+** to become a master browser.
+*/
int conf_should_workgroup_member(int token)
{
- if(range_check(token))
+ if (range_check(token))
return False;
return smbbrowse_workgroups[token].should_workgroup_member;
@@ -197,12 +211,22 @@ int conf_should_workgroup_member(int token)
** to become a master browser.
*/
int conf_should_local_master(int token)
- {
- if(range_check(token))
- return False;
+{
+ if (range_check(token)) return False;
return smbbrowse_workgroups[token].should_local_master;
- }
+}
+
+/*
+** Given a token, return True if we should try
+** to become a domain master browser.
+*/
+int conf_should_domain_logon(int token)
+{
+ if (range_check(token)) return False;
+
+ return smbbrowse_workgroups[token].should_domain_logon;
+}
/*
** Given a token, return True if we should try
@@ -210,7 +234,7 @@ int conf_should_local_master(int token)
*/
int conf_should_domain_master(int token)
{
- if(range_check(token))
+ if (range_check(token))
return False;
return smbbrowse_workgroups[token].should_domain_master;
@@ -220,12 +244,12 @@ int conf_should_domain_master(int token)
** Given a token, return the name.
*/
char *conf_browsing_alias(int token)
- {
- if(range_check(token))
+{
+ if (range_check(token))
return (char*)NULL;
return smbbrowse_workgroups[token].browsing_alias;
- }
+}
/*
** Return the server comment which should be used with the
@@ -233,27 +257,27 @@ char *conf_browsing_alias(int token)
*/
char *conf_browsing_alias_comment(int token)
{
- if(range_check(token))
+ if (range_check(token))
return (char*) NULL;
- return "Browser";
- }
+ return lp_server_comment();
+}
/*
** Given an alias name for this server, return the name of the workgroup
** for which it is the browsing alias.
*/
-char *conf_alias_to_workgroup(const char *alias)
+char *conf_alias_to_workgroup(char *alias)
{
int x;
DEBUG(4,("alias_to_workgroup: %s", alias));
- for(x=0; x < nexttoken; x++)
+ for (x=0; x < nexttoken; x++)
{
DEBUG(4,("%s ", smbbrowse_workgroups[x].browsing_alias));
- if(strequal(alias, smbbrowse_workgroups[x].browsing_alias))
+ if (strequal(alias, smbbrowse_workgroups[x].browsing_alias))
{
DEBUG(4,("OK\n"));
return smbbrowse_workgroups[x].work_name;
@@ -267,13 +291,13 @@ char *conf_alias_to_workgroup(const char *alias)
** Given an alias name for this server, return the name of the workgroup
** for which it is the browsing alias.
*/
-int conf_alias_to_token(const char *alias)
+int conf_alias_to_token(char *alias)
{
int x;
- for(x=0; x < nexttoken; x++)
+ for (x=0; x < nexttoken; x++)
{
- if(strequal(alias, smbbrowse_workgroups[x].browsing_alias))
+ if (strequal(alias, smbbrowse_workgroups[x].browsing_alias))
{
return x;
}
@@ -285,21 +309,25 @@ int conf_alias_to_token(const char *alias)
** Since there is no smbbrowse.conf file, we will fill in
** the structures with information from the smb.conf file.
*/
-static void default_smbbrowse_conf(const char *default_name)
+static void default_smbbrowse_conf(char *default_name)
{
struct smbbrowse *w;
/* The workgroup specified in smb.conf */
w = new_workgroup((struct smbbrowse *)NULL, lp_workgroup(), default_name);
- w->should_local_master = lp_preferred_master();
- w->should_domain_master = lp_domain_master();
+ w->should_local_master = lp_local_master();
+ w->should_domain_master = lp_domain_master();
+ w->should_domain_logon = lp_domain_logons();
w->should_workgroup_member = True;
- /* default action: allow any new workgroup to be added */
+ /* default action: allow any new workgroup to be added. this is
+ _not_ the same as the old 1.9.14-1.9.15 definition of "*"
+ */
w = new_workgroup((struct smbbrowse *)NULL, "*", default_name);
- w->should_local_master = False;
- w->should_domain_master = False;
+ w->should_local_master = False;
+ w->should_domain_master = False;
w->should_workgroup_member = False;
+ w->should_domain_logon = False;
}
/*
@@ -332,8 +360,10 @@ void read_smbbrowse_conf(char *default_name)
if (count <= 0) continue;
w = new_workgroup((struct smbbrowse *)NULL, work_name, default_name);
- w->should_local_master = lp_local_master();
- w->should_domain_master = lp_domain_master();
+ w->should_local_master = lp_local_master();
+ w->should_domain_master = lp_domain_master();
+ w->should_preferred_master = lp_preferred_master();
+ w->should_domain_logon = lp_domain_logons();
w->should_workgroup_member = True;
}