summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/auth/auth.c2
-rw-r--r--source3/auth/auth_domain.c15
-rw-r--r--source3/auth/auth_sam.c4
-rw-r--r--source3/auth/auth_server.c10
-rw-r--r--source3/auth/auth_util.c1
-rw-r--r--source3/client/client.c19
-rw-r--r--source3/client/smbspool.c14
-rw-r--r--source3/groupdb/mapping.c2
-rw-r--r--source3/lib/access.c165
-rw-r--r--source3/lib/interface.c4
-rw-r--r--source3/lib/popt_common.c4
-rw-r--r--source3/lib/substitute.c7
-rw-r--r--source3/lib/username.c4
-rw-r--r--source3/lib/util.c1383
-rw-r--r--source3/lib/util_sid.c12
-rw-r--r--source3/lib/util_sock.c2
-rw-r--r--source3/lib/util_str.c15
-rw-r--r--source3/lib/wins_srv.c14
-rw-r--r--source3/libads/kerberos_verify.c3
-rw-r--r--source3/libads/ldap.c38
-rw-r--r--source3/libads/ldap_printer.c9
-rw-r--r--source3/libads/sasl.c3
-rw-r--r--source3/libsmb/cliconnect.c51
-rw-r--r--source3/libsmb/namequery.c17
-rw-r--r--source3/libsmb/nmblib.c31
-rw-r--r--source3/libsmb/passchange.c5
-rw-r--r--source3/libsmb/pwd_cache.c14
-rw-r--r--source3/libsmb/trust_passwd.c6
-rw-r--r--source3/nmbd/nmbd.c102
-rw-r--r--source3/nmbd/nmbd_become_dmb.c25
-rw-r--r--source3/nmbd/nmbd_become_lmb.c32
-rw-r--r--source3/nmbd/nmbd_browsesync.c17
-rw-r--r--source3/nmbd/nmbd_elections.c23
-rw-r--r--source3/nmbd/nmbd_incomingdgrams.c30
-rw-r--r--source3/nmbd/nmbd_incomingrequests.c15
-rw-r--r--source3/nmbd/nmbd_logonnames.c19
-rw-r--r--source3/nmbd/nmbd_mynames.c27
-rw-r--r--source3/nmbd/nmbd_namelistdb.c4
-rw-r--r--source3/nmbd/nmbd_nameregister.c6
-rw-r--r--source3/nmbd/nmbd_packets.c14
-rw-r--r--source3/nmbd/nmbd_processlogon.c22
-rw-r--r--source3/nmbd/nmbd_sendannounce.c66
-rw-r--r--source3/nmbd/nmbd_serverlistdb.c31
-rw-r--r--source3/nmbd/nmbd_subnetdb.c3
-rw-r--r--source3/nmbd/nmbd_synclists.c2
-rw-r--r--source3/nmbd/nmbd_workgroupdb.c15
-rw-r--r--source3/nsswitch/wbinfo.c25
-rw-r--r--source3/nsswitch/winbindd.c14
-rw-r--r--source3/nsswitch/winbindd_cm.c9
-rw-r--r--source3/nsswitch/winbindd_misc.c4
-rw-r--r--source3/nsswitch/winbindd_pam.c22
-rw-r--r--source3/nsswitch/winbindd_util.c9
-rw-r--r--source3/param/loadparm.c536
-rw-r--r--source3/passdb/machine_sid.c7
-rw-r--r--source3/passdb/passdb.c14
-rw-r--r--source3/passdb/pdb_interface.c4
-rw-r--r--source3/passdb/pdb_ldap.c8
-rw-r--r--source3/passdb/util_sam_sid.c11
-rw-r--r--source3/printing/lpq_parse.c40
-rw-r--r--source3/rpc_client/cli_netlogon.c23
-rw-r--r--source3/rpc_client/cli_pipe.c18
-rw-r--r--source3/rpc_parse/parse_misc.c31
-rw-r--r--source3/rpc_parse/parse_net.c31
-rw-r--r--source3/rpc_parse/parse_rpc.c4
-rw-r--r--source3/rpc_parse/parse_samr.c4
-rw-r--r--source3/rpc_parse/parse_srv.c12
-rw-r--r--source3/rpc_server/srv_dfs.c2
-rw-r--r--source3/rpc_server/srv_dfs_nt.c10
-rw-r--r--source3/rpc_server/srv_lsa_nt.c41
-rw-r--r--source3/rpc_server/srv_netlog_nt.c5
-rw-r--r--source3/rpc_server/srv_samr_nt.c16
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c4
-rw-r--r--source3/rpc_server/srv_srvsvc_nt.c8
-rw-r--r--source3/rpc_server/srv_wkssvc_nt.c4
-rw-r--r--source3/rpcclient/rpcclient.c12
-rw-r--r--source3/script/mkproto.awk4
-rw-r--r--source3/smbd/change_trust_pw.c10
-rw-r--r--source3/smbd/chgpasswd.c2
-rw-r--r--source3/smbd/lanman.c18
-rw-r--r--source3/smbd/negprot.c6
-rw-r--r--source3/smbd/password.c12
-rw-r--r--source3/smbd/process.c18
-rw-r--r--source3/smbd/reply.c3
-rw-r--r--source3/smbd/server.c23
-rw-r--r--source3/smbd/service.c4
-rw-r--r--source3/smbd/sesssetup.c5
-rw-r--r--source3/smbd/trans2.c3
-rw-r--r--source3/smbd/uid.c6
-rw-r--r--source3/utils/net.c31
-rw-r--r--source3/utils/net_ads.c45
-rw-r--r--source3/utils/net_ads_cldap.c3
-rw-r--r--source3/utils/net_rpc.c11
-rw-r--r--source3/utils/net_rpc_join.c8
-rw-r--r--source3/utils/net_time.c3
-rw-r--r--source3/utils/nmblookup.c8
-rw-r--r--source3/utils/pdbedit.c17
-rw-r--r--source3/utils/smbcacls.c18
-rw-r--r--source3/utils/smbcontrol.c2
-rw-r--r--source3/utils/smbgroupedit.c16
-rw-r--r--source3/utils/smbpasswd.c10
-rw-r--r--source3/utils/testparm.c6
-rw-r--r--source3/wrepld/server.c30
102 files changed, 1662 insertions, 1895 deletions
diff --git a/source3/auth/auth.c b/source3/auth/auth.c
index d43afc71e1..232d401a24 100644
--- a/source3/auth/auth.c
+++ b/source3/auth/auth.c
@@ -137,7 +137,7 @@ static BOOL check_domain_match(const char *user, const char *domain)
if (!lp_allow_trusted_domains() &&
!(strequal("", domain) ||
strequal(lp_workgroup(), domain) ||
- is_netbios_alias_or_name(domain))) {
+ is_myname(domain))) {
DEBUG(1, ("check_domain_match: Attempt to connect as user %s from domain %s denied.\n", user, domain));
return False;
} else {
diff --git a/source3/auth/auth_domain.c b/source3/auth/auth_domain.c
index 9d4824fbc7..2a6614e28e 100644
--- a/source3/auth/auth_domain.c
+++ b/source3/auth/auth_domain.c
@@ -26,7 +26,6 @@
BOOL global_machine_password_needs_changing = False;
-extern pstring global_myname;
extern userdom_struct current_user_info;
@@ -172,7 +171,7 @@ static NTSTATUS connect_to_domain_password_server(struct cli_state **cli,
return NT_STATUS_NO_LOGON_SERVERS;
/* Attempt connection */
- result = cli_full_connection(cli, global_myname, remote_machine,
+ result = cli_full_connection(cli, global_myname(), remote_machine,
&dest_ip, 0, "IPC$", "IPC", "", "", "",0, retry);
if (!NT_STATUS_IS_OK(result)) {
@@ -250,7 +249,7 @@ static NTSTATUS attempt_connect_to_dc(struct cli_state **cli,
if (is_zero_ip(*ip))
return NT_STATUS_NO_LOGON_SERVERS;
- if (!lookup_dc_name(global_myname, domain, ip, dc_name))
+ if (!lookup_dc_name(global_myname(), domain, ip, dc_name))
return NT_STATUS_NO_LOGON_SERVERS;
for (i = 0; (!NT_STATUS_IS_OK(ret)) && retry && (i < 3); i++)
@@ -372,7 +371,7 @@ static NTSTATUS domain_client_validate(TALLOC_CTX *mem_ctx,
const char *domain,
uchar chal[8],
auth_serversupplied_info **server_info,
- char *server, char *setup_creds_as,
+ const char *server, const char *setup_creds_as,
uint16 sec_chan,
unsigned char trust_passwd[16],
time_t last_change_time)
@@ -481,7 +480,7 @@ static NTSTATUS check_ntdomain_security(const struct auth_context *auth_context,
char *password_server;
unsigned char trust_passwd[16];
time_t last_change_time;
- char *domain = lp_workgroup();
+ const char *domain = lp_workgroup();
if (!user_info || !server_info || !auth_context) {
DEBUG(1,("check_ntdomain_security: Critical variables not present. Failing.\n"));
@@ -494,7 +493,7 @@ static NTSTATUS check_ntdomain_security(const struct auth_context *auth_context,
* password file.
*/
- if(is_netbios_alias_or_name(user_info->domain.str)) {
+ if(is_myname(user_info->domain.str)) {
DEBUG(3,("check_ntdomain_security: Requested domain was for this machine.\n"));
return NT_STATUS_LOGON_FAILURE;
}
@@ -528,7 +527,7 @@ static NTSTATUS check_ntdomain_security(const struct auth_context *auth_context,
nt_status = domain_client_validate(mem_ctx, user_info, domain,
(uchar *)auth_context->challenge.data,
server_info,
- password_server, global_myname, SEC_CHAN_WKSTA, trust_passwd, last_change_time);
+ password_server, global_myname(), SEC_CHAN_WKSTA, trust_passwd, last_change_time);
return nt_status;
}
@@ -572,7 +571,7 @@ static NTSTATUS check_trustdomain_security(const struct auth_context *auth_conte
* password file.
*/
- if(is_netbios_alias_or_name(user_info->domain.str)) {
+ if(is_myname(user_info->domain.str)) {
DEBUG(3,("check_trustdomain_security: Requested domain was for this machine.\n"));
return NT_STATUS_LOGON_FAILURE;
}
diff --git a/source3/auth/auth_sam.c b/source3/auth/auth_sam.c
index 7252193c9a..9fa33dccf6 100644
--- a/source3/auth/auth_sam.c
+++ b/source3/auth/auth_sam.c
@@ -316,7 +316,7 @@ static NTSTATUS sam_account_ok(TALLOC_CTX *mem_ctx,
if (*workstation_list) {
BOOL invalid_ws = True;
- char *s = workstation_list;
+ const char *s = workstation_list;
fstring tok;
@@ -454,7 +454,7 @@ static NTSTATUS check_samstrict_security(const struct auth_context *auth_context
attempt to check the password locally,
unless it is one of our aliases. */
- if (!is_netbios_alias_or_name(user_info->domain.str)) {
+ if (!is_myname(user_info->domain.str)) {
return NT_STATUS_NO_SUCH_USER;
}
diff --git a/source3/auth/auth_server.c b/source3/auth/auth_server.c
index 0ed905e79c..5144852d3b 100644
--- a/source3/auth/auth_server.c
+++ b/source3/auth/auth_server.c
@@ -24,7 +24,6 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_AUTH
-extern pstring global_myname;
extern userdom_struct current_user_info;
/****************************************************************************
@@ -36,7 +35,8 @@ static struct cli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
struct cli_state *cli = NULL;
fstring desthost;
struct in_addr dest_ip;
- char *p, *pserver;
+ const char *p;
+ char *pserver;
BOOL connected_ok = False;
if (!(cli = cli_initialise(cli)))
@@ -85,7 +85,7 @@ static struct cli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
return NULL;
}
- if (!attempt_netbios_session_request(cli, global_myname,
+ if (!attempt_netbios_session_request(cli, global_myname(),
desthost, &dest_ip)) {
release_server_mutex();
DEBUG(1,("password server fails session request\n"));
@@ -231,7 +231,7 @@ static NTSTATUS check_smbserver_security(const struct auth_context *auth_context
* password file.
*/
- if(is_netbios_alias_or_name(user_info->domain.str)) {
+ if(is_myname(user_info->domain.str)) {
DEBUG(3,("check_smbserver_security: Requested domain was for this machine.\n"));
return NT_STATUS_LOGON_FAILURE;
}
@@ -275,7 +275,7 @@ static NTSTATUS check_smbserver_security(const struct auth_context *auth_context
if(baduser[0] == 0) {
fstrcpy(baduser, INVALID_USER_PREFIX);
- fstrcat(baduser, global_myname);
+ fstrcat(baduser, global_myname());
}
/*
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
index b14344ef50..98b15f3fb6 100644
--- a/source3/auth/auth_util.c
+++ b/source3/auth/auth_util.c
@@ -26,7 +26,6 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_AUTH
-extern pstring global_myname;
extern DOM_SID global_sid_World;
extern DOM_SID global_sid_Network;
extern DOM_SID global_sid_Builtin_Guests;
diff --git a/source3/client/client.c b/source3/client/client.c
index 96b9837fef..c8529b84f2 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -37,7 +37,6 @@ pstring cur_dir = "\\";
static pstring cd_path = "";
static pstring service;
static pstring desthost;
-extern pstring global_myname;
static pstring password;
static pstring username;
static pstring workgroup;
@@ -2177,7 +2176,7 @@ process a -c command string
static int process_command_string(char *cmd)
{
pstring line;
- char *ptr;
+ const char *ptr;
int rc = 0;
/* establish the connection if not already */
@@ -2297,7 +2296,7 @@ process commands on stdin
****************************************************************************/
static void process_stdin(void)
{
- char *ptr;
+ const char *ptr;
while (1) {
fstring tok;
@@ -2362,7 +2361,7 @@ static struct cli_state *do_connect(const char *server, const char *share)
zero_ip(&ip);
- make_nmb_name(&calling, global_myname, 0x0);
+ make_nmb_name(&calling, global_myname(), 0x0);
make_nmb_name(&called , server, name_type);
again:
@@ -2635,7 +2634,7 @@ static int do_message_op(void)
fstring server_name;
char name_type_hex[10];
- make_nmb_name(&calling, global_myname, 0x0);
+ make_nmb_name(&calling, global_myname(), 0x0);
make_nmb_name(&called , desthost, name_type);
safe_strcpy(server_name, desthost, sizeof(server_name));
@@ -2845,17 +2844,13 @@ static void remember_query_host(const char *arg,
message = True;
break;
case 'i':
- {
- extern pstring global_scope;
- pstrcpy(global_scope,optarg);
- strupper(global_scope);
- }
+ set_global_scope(optarg);
break;
case 'N':
got_pass = True;
break;
case 'n':
- pstrcpy(global_myname,optarg);
+ set_global_myname(optarg);
break;
case 'd':
if (*optarg == 'A')
@@ -3000,7 +2995,7 @@ static void remember_query_host(const char *arg,
}
}
- get_myname((*global_myname)?NULL:global_myname);
+ init_names();
if(*new_name_resolve_order)
lp_set_name_resolve_order(new_name_resolve_order);
diff --git a/source3/client/smbspool.c b/source3/client/smbspool.c
index ff10963533..4c90db4114 100644
--- a/source3/client/smbspool.c
+++ b/source3/client/smbspool.c
@@ -36,7 +36,7 @@ extern BOOL in_client; /* Boolean for client library */
*/
static void list_devices(void);
-static struct cli_state *smb_connect(char *, char *, char *, char *, char *);
+static struct cli_state *smb_connect(const char *, const char *, const char *, const char *, const char *);
static int smb_print(struct cli_state *, char *, FILE *);
@@ -54,9 +54,9 @@ static int smb_print(struct cli_state *, char *, FILE *);
*sep, /* Pointer to separator */
*username, /* Username */
*password, /* Password */
- *workgroup, /* Workgroup */
*server, /* Server name */
*printer; /* Printer name */
+ const char *workgroup; /* Workgroup */
FILE *fp; /* File to print */
int status=0; /* Status of LPD job */
struct cli_state *cli; /* SMB interface */
@@ -265,11 +265,11 @@ list_devices(void)
*/
static struct cli_state * /* O - SMB connection */
-smb_connect(char *workgroup, /* I - Workgroup */
- char *server, /* I - Server */
- char *share, /* I - Printer */
- char *username, /* I - Username */
- char *password) /* I - Password */
+smb_connect(const char *workgroup, /* I - Workgroup */
+ const char *server, /* I - Server */
+ const char *share, /* I - Printer */
+ const char *username, /* I - Username */
+ const char *password) /* I - Password */
{
struct cli_state *c; /* New connection */
pstring myname; /* Client name */
diff --git a/source3/groupdb/mapping.c b/source3/groupdb/mapping.c
index f1f9fdafc1..0a2c1f3239 100644
--- a/source3/groupdb/mapping.c
+++ b/source3/groupdb/mapping.c
@@ -840,7 +840,7 @@ convert a privilege string to a privilege array
void convert_priv_from_text(PRIVILEGE_SET *se_priv, char *privilege)
{
pstring tok;
- char *p = privilege;
+ const char *p = privilege;
int i;
LUID_ATTR set;
diff --git a/source3/lib/access.c b/source3/lib/access.c
index a39bc6df76..50efdcc5f0 100644
--- a/source3/lib/access.c
+++ b/source3/lib/access.c
@@ -15,17 +15,20 @@
#define ALLONES ((uint32)0xFFFFFFFF)
/* masked_match - match address against netnumber/netmask */
-static int masked_match(char *tok, char *slash, char *s)
+static BOOL masked_match(const char *tok, const char *slash, const char *s)
{
uint32 net;
uint32 mask;
uint32 addr;
+ fstring tok_cpy;
if ((addr = interpret_addr(s)) == INADDR_NONE)
return (False);
- *slash = 0;
- net = interpret_addr(tok);
- *slash = '/';
+
+ fstrcpy(tok_cpy, tok);
+ tok_cpy[PTR_DIFF(slash,tok)] = '\0';
+ net = interpret_addr(tok_cpy);
+ tok_cpy[PTR_DIFF(slash,tok)] = '/';
if (strlen(slash + 1) > 2) {
mask = interpret_addr(slash + 1);
@@ -41,11 +44,11 @@ static int masked_match(char *tok, char *slash, char *s)
}
/* string_match - match string against token */
-static int string_match(char *tok,char *s, char *invalid_char)
+static BOOL string_match(const char *tok,const char *s, char *invalid_char)
{
size_t tok_len;
size_t str_len;
- char *cut;
+ const char *cut;
*invalid_char = '\0';
@@ -73,7 +76,8 @@ static int string_match(char *tok,char *s, char *invalid_char)
char *hostname = NULL;
BOOL netgroup_ok = False;
- if (!mydomain) yp_get_default_domain(&mydomain);
+ if (!mydomain)
+ yp_get_default_domain(&mydomain);
if (!mydomain) {
DEBUG(0,("Unable to get default yp domain.\n"));
@@ -94,7 +98,8 @@ static int string_match(char *tok,char *s, char *invalid_char)
SAFE_FREE(hostname);
- if (netgroup_ok) return(True);
+ if (netgroup_ok)
+ return(True);
#else
DEBUG(0,("access: netgroup support is not configured\n"));
return (False);
@@ -122,20 +127,19 @@ static int string_match(char *tok,char *s, char *invalid_char)
return (False);
}
-
/* client_match - match host name and address against token */
-static int client_match(char *tok,char *item)
+static BOOL client_match(const char *tok, const char *item)
{
- char **client = (char **)item;
- int match;
+ const char **client = (const char **)item;
+ BOOL match;
char invalid_char = '\0';
- /*
- * Try to match the address first. If that fails, try to match the host
- * name if available.
- */
+ /*
+ * Try to match the address first. If that fails, try to match the host
+ * name if available.
+ */
- if ((match = string_match(tok, client[1], &invalid_char)) == 0) {
+ if ((match = string_match(tok, client[1], &invalid_char)) == 0) {
if(invalid_char)
DEBUG(0,("client_match: address match failing due to invalid character '%c' found in \
token '%s' in an allow/deny hosts line.\n", invalid_char, tok ));
@@ -148,50 +152,51 @@ token '%s' in an allow/deny hosts line.\n", invalid_char, tok ));
token '%s' in an allow/deny hosts line.\n", invalid_char, tok ));
}
- return (match);
+ return (match);
}
/* list_match - match an item against a list of tokens with exceptions */
-static int list_match(char **list,char *item, int (*match_fn)(char *, char *))
+static BOOL list_match(const char **list,const char *item,
+ BOOL (*match_fn)(const char *, const char *))
{
- int match = False;
-
- if (!list) return False;
-
- /*
- * Process tokens one at a time. We have exhausted all possible matches
- * when we reach an "EXCEPT" token or the end of the list. If we do find
- * a match, look for an "EXCEPT" list and recurse to determine whether
- * the match is affected by any exceptions.
- */
-
- for (; *list ; list++) {
- if (strcasecmp(*list, "EXCEPT") == 0) /* EXCEPT: give up */
- break;
- if ((match = (*match_fn) (*list, item))) /* True or FAIL */
- break;
- }
- /* Process exceptions to True or FAIL matches. */
-
- if (match != False) {
- while (*list && strcasecmp(*list, "EXCEPT"))
- list++;
-
- for (; *list; list++) {
- if ((*match_fn) (*list, item)) /* Exception Found */
- return False;
+ BOOL match = False;
+
+ if (!list)
+ return False;
+
+ /*
+ * Process tokens one at a time. We have exhausted all possible matches
+ * when we reach an "EXCEPT" token or the end of the list. If we do find
+ * a match, look for an "EXCEPT" list and recurse to determine whether
+ * the match is affected by any exceptions.
+ */
+
+ for (; *list ; list++) {
+ if (strcasecmp(*list, "EXCEPT") == 0) /* EXCEPT: give up */
+ break;
+ if ((match = (*match_fn) (*list, item))) /* True or FAIL */
+ break;
}
- }
+ /* Process exceptions to True or FAIL matches. */
- return (match);
-}
+ if (match != False) {
+ while (*list && strcasecmp(*list, "EXCEPT"))
+ list++;
+ for (; *list; list++) {
+ if ((*match_fn) (*list, item)) /* Exception Found */
+ return False;
+ }
+ }
+
+ return (match);
+}
/* return true if access should be allowed */
-static BOOL allow_access_internal(char **deny_list,char **allow_list,
- char *cname,char *caddr)
+static BOOL allow_access_internal(const char **deny_list,const char **allow_list,
+ const char *cname, const char *caddr)
{
- char *client[2];
+ const char *client[2];
client[0] = cname;
client[1] = caddr;
@@ -203,9 +208,9 @@ static BOOL allow_access_internal(char **deny_list,char **allow_list,
* Patch from Steve Langasek vorlon@netexpress.net.
*/
if (deny_list &&
- list_match(deny_list,(char *)client,client_match) &&
+ list_match(deny_list,(const char *)client,client_match) &&
(!allow_list ||
- !list_match(allow_list,(char *)client, client_match))) {
+ !list_match(allow_list,(const char *)client, client_match))) {
return False;
}
return True;
@@ -220,32 +225,31 @@ static BOOL allow_access_internal(char **deny_list,char **allow_list,
/* if there is an allow list but no deny list then allow only hosts
on the allow list */
if (!deny_list || *deny_list == 0)
- return(list_match(allow_list,(char *)client,client_match));
+ return(list_match(allow_list,(const char *)client,client_match));
/* if theres a deny list but no allow list then allow
all hosts not on the deny list */
if (!allow_list || *allow_list == 0)
- return(!list_match(deny_list,(char *)client,client_match));
+ return(!list_match(deny_list,(const char *)client,client_match));
/* if there are both types of list then allow all hosts on the
allow list */
- if (list_match(allow_list,(char *)client,client_match))
+ if (list_match(allow_list,(const char *)client,client_match))
return (True);
/* if there are both types of list and it's not on the allow then
allow it if its not on the deny */
- if (list_match(deny_list,(char *)client,client_match))
+ if (list_match(deny_list,(const char *)client,client_match))
return (False);
return (True);
}
/* return true if access should be allowed */
-BOOL allow_access(char **deny_list,char **allow_list,
+BOOL allow_access(const char **deny_list, const char **allow_list,
const char *cname, const char *caddr)
{
BOOL ret;
-
char *nc_cname = smb_xstrdup(cname);
char *nc_caddr = smb_xstrdup(caddr);
@@ -258,31 +262,29 @@ BOOL allow_access(char **deny_list,char **allow_list,
/* return true if the char* contains ip addrs only. Used to avoid
gethostbyaddr() calls */
-static BOOL only_ipaddrs_in_list(char** list)
+
+static BOOL only_ipaddrs_in_list(const char** list)
{
- BOOL only_ip = True;
+ BOOL only_ip = True;
- if (!list) return True;
+ if (!list)
+ return True;
- for (; *list ; list++)
- {
+ for (; *list ; list++) {
/* factor out the special strings */
if (!strcasecmp(*list, "ALL") || !strcasecmp(*list, "FAIL") ||
- !strcasecmp(*list, "EXCEPT"))
- {
+ !strcasecmp(*list, "EXCEPT")) {
continue;
}
- if (!is_ipaddress(*list))
- {
+ if (!is_ipaddress(*list)) {
char *p;
/*
* if we failed, make sure that it was not because the token
* was a network/netmask pair. Only network/netmask pairs
* have a '/' in them
*/
- if ((p=strchr_m(*list, '/')) == NULL)
- {
+ if ((p=strchr_m(*list, '/')) == NULL) {
only_ip = False;
DEBUG(3,("only_ipaddrs_in_list: list has non-ip address (%s)\n", *list));
break;
@@ -294,40 +296,31 @@ static BOOL only_ipaddrs_in_list(char** list)
}
/* return true if access should be allowed to a service for a socket */
-BOOL check_access(int sock, char **allow_list, char **deny_list)
+BOOL check_access(int sock, const char **allow_list, const char **deny_list)
{
BOOL ret = False;
BOOL only_ip = False;
- if ((!deny_list || *deny_list==0) && (!allow_list || *allow_list==0))
- {
+ if ((!deny_list || *deny_list==0) && (!allow_list || *allow_list==0))
ret = True;
- }
- if (!ret)
- {
+ if (!ret) {
/* bypass gethostbyaddr() calls if the lists only contain IP addrs */
- if (only_ipaddrs_in_list(allow_list) && only_ipaddrs_in_list(deny_list))
- {
+ if (only_ipaddrs_in_list(allow_list) && only_ipaddrs_in_list(deny_list)) {
only_ip = True;
DEBUG (3, ("check_access: no hostnames in host allow/deny list.\n"));
ret = allow_access(deny_list,allow_list, "", get_socket_addr(sock));
- }
- else
- {
+ } else {
DEBUG (3, ("check_access: hostnames in host allow/deny list.\n"));
ret = allow_access(deny_list,allow_list, get_socket_name(sock,True),
get_socket_addr(sock));
}
- if (ret)
- {
+ if (ret) {
DEBUG(2,("Allowed connection from %s (%s)\n",
only_ip ? "" : get_socket_name(sock,True),
get_socket_addr(sock)));
- }
- else
- {
+ } else {
DEBUG(0,("Denied connection from %s (%s)\n",
only_ip ? "" : get_socket_name(sock,True),
get_socket_addr(sock)));
diff --git a/source3/lib/interface.c b/source3/lib/interface.c
index 0d751a9c7c..4d8010e31b 100644
--- a/source3/lib/interface.c
+++ b/source3/lib/interface.c
@@ -94,7 +94,7 @@ This handles the following different forms:
4) ip/mask
5) bcast/mask
****************************************************************************/
-static void interpret_interface(char *token)
+static void interpret_interface(const char *token)
{
struct in_addr ip, nmask;
char *p;
@@ -162,7 +162,7 @@ load the list of network interfaces
****************************************************************************/
void load_interfaces(void)
{
- char **ptr;
+ const char **ptr;
int i;
struct iface_struct ifaces[MAX_INTERFACES];
diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c
index aaec448762..77c44f127a 100644
--- a/source3/lib/popt_common.c
+++ b/source3/lib/popt_common.c
@@ -33,7 +33,6 @@
extern pstring user_socket_options;
extern BOOL AllowDebugChange;
-extern pstring global_myname;
static void popt_common_callback(poptContext con,
enum poptCallbackReason reason,
@@ -84,8 +83,7 @@ static void popt_common_callback(poptContext con,
case 'n':
if (arg) {
- pstrcpy(global_myname,arg);
- strupper(global_myname);
+ set_global_myname(arg);
}
break;
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c
index 2550d00d14..23cfce6c69 100644
--- a/source3/lib/substitute.c
+++ b/source3/lib/substitute.c
@@ -25,7 +25,6 @@ fstring local_machine="";
fstring remote_arch="UNKNOWN";
userdom_struct current_user_info;
fstring remote_proto="UNKNOWN";
-extern pstring global_myname;
static fstring remote_machine="";
@@ -230,7 +229,7 @@ static const char *automount_server(const char *user_name)
if (local_machine_name && *local_machine_name)
pstrcpy(server_name, local_machine_name);
else
- pstrcpy(server_name, global_myname);
+ pstrcpy(server_name, global_myname());
#if (defined(HAVE_NETGROUP) && defined (WITH_AUTOMOUNT))
@@ -300,7 +299,7 @@ void standard_sub_basic(const char *smb_name, char *str,size_t len)
else {
pstring temp_name;
- pstrcpy(temp_name, global_myname);
+ pstrcpy(temp_name, global_myname());
strlower(temp_name);
string_sub(p,"%L", temp_name,l);
}
@@ -458,7 +457,7 @@ char *alloc_sub_basic(const char *smb_name, const char *str)
if (local_machine_name && *local_machine_name)
t = realloc_string_sub(t, "%L", local_machine_name);
else
- t = realloc_string_sub(t, "%L", global_myname);
+ t = realloc_string_sub(t, "%L", global_myname());
break;
case 'M' :
t = realloc_string_sub(t, "%M", client_name());
diff --git a/source3/lib/username.c b/source3/lib/username.c
index ef11542ab1..b1c9ca0f08 100644
--- a/source3/lib/username.c
+++ b/source3/lib/username.c
@@ -169,7 +169,7 @@ BOOL map_username(char *user)
return False;
}
- if (strchr_m(dosname,'*') || user_in_list(user, dosuserlist)) {
+ if (strchr_m(dosname,'*') || user_in_list(user, (const char **)dosuserlist)) {
DEBUG(3,("Mapped user %s to %s\n",user,unixname));
mapped_user = True;
fstrcpy(last_from,user);
@@ -451,7 +451,7 @@ BOOL user_in_group_list(const char *user, const char *gname)
and netgroup lists.
****************************************************************************/
-BOOL user_in_list(const char *user,char **list)
+BOOL user_in_list(const char *user,const char **list)
{
if (!list || !*list)
return False;
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 51b92568b4..2dbd732cd8 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -2,7 +2,7 @@
Unix SMB/CIFS implementation.
Samba utility functions
Copyright (C) Andrew Tridgell 1992-1998
- Copyright (C) Jeremy Allison 2001
+ Copyright (C) Jeremy Allison 2001-2002
Copyright (C) Simo Sorce 2001
This program is free software; you can redistribute it and/or modify
@@ -78,22 +78,212 @@ BOOL case_mangle;
static enum remote_arch_types ra_type = RA_UNKNOWN;
pstring user_socket_options=DEFAULT_SOCKET_OPTIONS;
-pstring global_myname = "";
-fstring global_myworkgroup = "";
-char **my_netbios_names;
+/***********************************************************************
+ Definitions for all names.
+***********************************************************************/
+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 myname. Ensure upper case.
+***********************************************************************/
+
+BOOL set_global_myname(const char *myname)
+{
+ SAFE_FREE(smb_myname);
+ smb_myname = strdup(myname);
+ if (!smb_myname)
+ return False;
+ strupper(smb_myname);
+ return True;
+}
+
+const char *global_myname(void)
+{
+ return smb_myname;
+}
+
+/***********************************************************************
+ Allocate and set myworkgroup. Ensure upper case.
+***********************************************************************/
+
+BOOL set_global_myworkgroup(const char *myworkgroup)
+{
+ SAFE_FREE(smb_myworkgroup);
+ smb_myworkgroup = strdup(myworkgroup);
+ if (!smb_myworkgroup)
+ return False;
+ strupper(smb_myworkgroup);
+ return True;
+}
+
+const char *lp_workgroup(void)
+{
+ return smb_myworkgroup;
+}
+
+/***********************************************************************
+ Allocate and set scope. Ensure upper case.
+***********************************************************************/
+
+BOOL set_global_scope(const char *scope)
+{
+ SAFE_FREE(smb_scope);
+ smb_scope = strdup(scope);
+ if (!smb_scope)
+ return False;
+ strupper(smb_scope);
+ return True;
+}
+
+const char *global_scope(void)
+{
+ return smb_scope;
+}
+
+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 = (char **)malloc( sizeof(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]);
+
+ smb_my_netbios_names[i] = strdup(name);
+ if (!smb_my_netbios_names[i])
+ return False;
+ strupper(smb_my_netbios_names[i]);
+ return True;
+}
+
+const char *my_netbios_names(int i)
+{
+ return smb_my_netbios_names[i];
+}
+
+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 ( global_myname() && *global_myname())
+ 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 ( global_myname() && *global_myname()) {
+ set_my_netbios_names( global_myname(), 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], 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)
+{
+ extern fstring local_machine;
+ char *p;
+ int n;
+
+ if (global_myname() == NULL || *global_myname() == '\0') {
+ fstring name;
+
+ fstrcpy( name, myhostname() );
+ p = strchr( name, '.' );
+ if (p)
+ *p = 0;
+ if (!set_global_myname(name)) {
+ DEBUG( 0, ( "init_structs: malloc fail.\n" ) );
+ return False;
+ }
+ }
+
+ if (!set_netbios_aliases(lp_netbios_aliases())) {
+ DEBUG( 0, ( "init_structs: malloc fail.\n" ) );
+ return False;
+ }
+
+ fstrcpy( local_machine, global_myname() );
+ trim_string( local_machine, " ", " " );
+ p = strchr( local_machine, ' ' );
+ if (p)
+ *p = 0;
+ strlower( local_machine );
+
+ DEBUG( 5, ("Netbios name list:-\n") );
+ for( n=0; my_netbios_names(n); n++ )
+ DEBUGADD( 5, ( "my_netbios_names[%d]=\"%s\"\n", n, my_netbios_names(n) ) );
+
+ return( True );
+}
+
+/**************************************************************************n
Find a suitable temporary directory. The result should be copied immediately
as it may be overwritten by a subsequent call.
****************************************************************************/
-char *tmpdir(void)
+const char *tmpdir(void)
{
- char *p;
+ char *p;
if ((p = getenv("TMPDIR")))
- return p;
- return "/tmp";
+ return p;
+ return "/tmp";
}
/****************************************************************************
@@ -130,8 +320,7 @@ static char *Atoic(char *p, int *n, char *c)
while ((*p) && isdigit((int)*p))
p++;
- if (strchr_m(c, *p) == NULL)
- {
+ if (strchr_m(c, *p) == NULL) {
DEBUG(5, ("Atoic: no separator characters (%s) not found\n", c));
return NULL;
}
@@ -157,8 +346,7 @@ char *get_numlist(char *p, uint32 **num, int *count)
uint32 *tn;
tn = Realloc((*num), ((*count)+1) * sizeof(uint32));
- if (tn == NULL)
- {
+ if (tn == NULL) {
SAFE_FREE(*num);
return NULL;
} else
@@ -177,12 +365,12 @@ char *get_numlist(char *p, uint32 **num, int *count)
BOOL file_exist(const char *fname,SMB_STRUCT_STAT *sbuf)
{
- SMB_STRUCT_STAT st;
+ SMB_STRUCT_STAT st;
if (!sbuf)
sbuf = &st;
- if (sys_stat(fname,sbuf) != 0)
- return(False);
+ if (sys_stat(fname,sbuf) != 0)
+ return(False);
return((S_ISREG(sbuf->st_mode)) || (S_ISFIFO(sbuf->st_mode)));
}
@@ -193,12 +381,12 @@ BOOL file_exist(const char *fname,SMB_STRUCT_STAT *sbuf)
time_t file_modtime(const char *fname)
{
- SMB_STRUCT_STAT st;
+ SMB_STRUCT_STAT st;
- if (sys_stat(fname,&st) != 0)
- return(0);
+ if (sys_stat(fname,&st) != 0)
+ return(0);
- return(st.st_mtime);
+ return(st.st_mtime);
}
/*******************************************************************
@@ -207,60 +395,65 @@ time_t file_modtime(const char *fname)
BOOL directory_exist(char *dname,SMB_STRUCT_STAT *st)
{
- SMB_STRUCT_STAT st2;
- BOOL ret;
+ SMB_STRUCT_STAT st2;
+ BOOL ret;
- if (!st) st = &st2;
+ if (!st)
+ st = &st2;
- if (sys_stat(dname,st) != 0)
- return(False);
+ if (sys_stat(dname,st) != 0)
+ return(False);
- ret = S_ISDIR(st->st_mode);
- if(!ret)
- errno = ENOTDIR;
- return ret;
+ ret = S_ISDIR(st->st_mode);
+ if(!ret)
+ errno = ENOTDIR;
+ return ret;
}
/*******************************************************************
-returns the size in bytes of the named file
+ Returns the size in bytes of the named file.
********************************************************************/
+
SMB_OFF_T get_file_size(char *file_name)
{
- SMB_STRUCT_STAT buf;
- buf.st_size = 0;
- if(sys_stat(file_name,&buf) != 0)
- return (SMB_OFF_T)-1;
- return(buf.st_size);
+ SMB_STRUCT_STAT buf;
+ buf.st_size = 0;
+ if(sys_stat(file_name,&buf) != 0)
+ return (SMB_OFF_T)-1;
+ return(buf.st_size);
}
/*******************************************************************
-return a string representing an attribute for a file
+ Return a string representing an attribute for a file.
********************************************************************/
+
char *attrib_string(uint16 mode)
{
- static fstring attrstr;
+ static fstring attrstr;
- attrstr[0] = 0;
+ attrstr[0] = 0;
- if (mode & aVOLID) fstrcat(attrstr,"V");
- if (mode & aDIR) fstrcat(attrstr,"D");
- if (mode & aARCH) fstrcat(attrstr,"A");
- if (mode & aHIDDEN) fstrcat(attrstr,"H");
- if (mode & aSYSTEM) fstrcat(attrstr,"S");
- if (mode & aRONLY) fstrcat(attrstr,"R");
+ if (mode & aVOLID) fstrcat(attrstr,"V");
+ if (mode & aDIR) fstrcat(attrstr,"D");
+ if (mode & aARCH) fstrcat(attrstr,"A");
+ if (mode & aHIDDEN) fstrcat(attrstr,"H");
+ if (mode & aSYSTEM) fstrcat(attrstr,"S");
+ if (mode & aRONLY) fstrcat(attrstr,"R");
- return(attrstr);
+ return(attrstr);
}
/*******************************************************************
- show a smb message structure
+ Show a smb message structure.
********************************************************************/
+
void show_msg(char *buf)
{
int i;
int bcc=0;
- if (!DEBUGLVL(5)) return;
+ if (!DEBUGLVL(5))
+ return;
DEBUG(5,("size=%d\nsmb_com=0x%x\nsmb_rcls=%d\nsmb_reh=%d\nsmb_err=%d\nsmb_flg=%d\nsmb_flg2=%d\n",
smb_len(buf),
@@ -285,29 +478,33 @@ void show_msg(char *buf)
DEBUGADD(5,("smb_bcc=%d\n",bcc));
- if (DEBUGLEVEL < 10) return;
+ if (DEBUGLEVEL < 10)
+ return;
- if (DEBUGLEVEL < 50) bcc = MIN(bcc, 512);
+ if (DEBUGLEVEL < 50)
+ bcc = MIN(bcc, 512);
dump_data(10, smb_buf(buf), bcc);
}
/*******************************************************************
- set the length and marker of an smb packet
+ Set the length and marker of an smb packet.
********************************************************************/
+
void smb_setlen(char *buf,int len)
{
- _smb_setlen(buf,len);
+ _smb_setlen(buf,len);
- SCVAL(buf,4,0xFF);
- SCVAL(buf,5,'S');
- SCVAL(buf,6,'M');
- SCVAL(buf,7,'B');
+ SCVAL(buf,4,0xFF);
+ SCVAL(buf,5,'S');
+ SCVAL(buf,6,'M');
+ SCVAL(buf,7,'B');
}
/*******************************************************************
- setup the word count and byte count for a smb message
+ Setup the word count and byte count for a smb message.
********************************************************************/
+
int set_message(char *buf,int num_words,int num_bytes,BOOL zero)
{
if (zero)
@@ -319,8 +516,9 @@ int set_message(char *buf,int num_words,int num_bytes,BOOL zero)
}
/*******************************************************************
- setup only the byte count for a smb message
+ Setup only the byte count for a smb message.
********************************************************************/
+
int set_message_bcc(char *buf,int num_bytes)
{
int num_words = CVAL(buf,smb_wct);
@@ -330,111 +528,117 @@ int set_message_bcc(char *buf,int num_bytes)
}
/*******************************************************************
- setup only the byte count for a smb message, using the end of the
- message as a marker
+ Setup only the byte count for a smb message, using the end of the
+ message as a marker.
********************************************************************/
+
int set_message_end(void *outbuf,void *end_ptr)
{
return set_message_bcc((char *)outbuf,PTR_DIFF(end_ptr,smb_buf((char *)outbuf)));
}
/*******************************************************************
-reduce a file name, removing .. elements.
+ Reduce a file name, removing .. elements.
********************************************************************/
+
void dos_clean_name(char *s)
{
- char *p=NULL;
+ char *p=NULL;
- DEBUG(3,("dos_clean_name [%s]\n",s));
+ DEBUG(3,("dos_clean_name [%s]\n",s));
- /* remove any double slashes */
- all_string_sub(s, "\\\\", "\\", 0);
+ /* remove any double slashes */
+ all_string_sub(s, "\\\\", "\\", 0);
- while ((p = strstr(s,"\\..\\")) != NULL)
- {
- pstring s1;
+ while ((p = strstr(s,"\\..\\")) != NULL) {
+ pstring s1;
- *p = 0;
- pstrcpy(s1,p+3);
+ *p = 0;
+ pstrcpy(s1,p+3);
- if ((p=strrchr_m(s,'\\')) != NULL)
- *p = 0;
- else
- *s = 0;
- pstrcat(s,s1);
- }
+ if ((p=strrchr_m(s,'\\')) != NULL)
+ *p = 0;
+ else
+ *s = 0;
+ pstrcat(s,s1);
+ }
- trim_string(s,NULL,"\\..");
+ trim_string(s,NULL,"\\..");
- all_string_sub(s, "\\.\\", "\\", 0);
+ all_string_sub(s, "\\.\\", "\\", 0);
}
/*******************************************************************
-reduce a file name, removing .. elements.
+ Reduce a file name, removing .. elements.
********************************************************************/
+
void unix_clean_name(char *s)
{
- char *p=NULL;
+ char *p=NULL;
- DEBUG(3,("unix_clean_name [%s]\n",s));
+ DEBUG(3,("unix_clean_name [%s]\n",s));
- /* remove any double slashes */
- all_string_sub(s, "//","/", 0);
+ /* remove any double slashes */
+ all_string_sub(s, "//","/", 0);
- /* Remove leading ./ characters */
- if(strncmp(s, "./", 2) == 0) {
- trim_string(s, "./", NULL);
- if(*s == 0)
- pstrcpy(s,"./");
- }
+ /* Remove leading ./ characters */
+ if(strncmp(s, "./", 2) == 0) {
+ trim_string(s, "./", NULL);
+ if(*s == 0)
+ pstrcpy(s,"./");
+ }
- while ((p = strstr(s,"/../")) != NULL)
- {
- pstring s1;
+ while ((p = strstr(s,"/../")) != NULL) {
+ pstring s1;
- *p = 0;
- pstrcpy(s1,p+3);
+ *p = 0;
+ pstrcpy(s1,p+3);
- if ((p=strrchr_m(s,'/')) != NULL)
- *p = 0;
- else
- *s = 0;
- pstrcat(s,s1);
- }
+ if ((p=strrchr_m(s,'/')) != NULL)
+ *p = 0;
+ else
+ *s = 0;
+ pstrcat(s,s1);
+ }
- trim_string(s,NULL,"/..");
+ trim_string(s,NULL,"/..");
}
/*******************************************************************
-convert '\' to '/'
-reduce a file name, removing or reducing /../ , /./ , // elements.
-remove also any trailing . and /
-return a new allocated string.
+ Convert '\' to '/'.
+ Reduce a file name, removing or reducing /../ , /./ , // elements.
+ Remove also any trailing . and /
+ Return a new allocated string.
********************************************************************/
+
smb_ucs2_t *unix_clean_path(const smb_ucs2_t *s)
{
smb_ucs2_t *ns;
smb_ucs2_t *p, *r, *t;
DEBUG(3, ("unix_clean_path\n")); /* [%unicode]\n")); */
- if(!s) return NULL;
+ if(!s)
+ return NULL;
/* convert '\' to '/' */
ns = strdup_w(s);
- if (!ns) return NULL;
+ if (!ns)
+ return NULL;
unix_format_w(ns);
/* remove all double slashes */
p = ns;
ns = all_string_sub_wa(p, "//", "/");
SAFE_FREE(p);
- if (!ns) return NULL;
+ if (!ns)
+ return NULL;
/* remove any /./ */
p = ns;
ns = all_string_sub_wa(p, "/./", "/");
SAFE_FREE(p);
- if (!ns) return NULL;
+ if (!ns)
+ return NULL;
/* reduce any /../ */
t = ns;
@@ -443,9 +647,12 @@ smb_ucs2_t *unix_clean_path(const smb_ucs2_t *s)
if (*t == UCS2_CHAR('/') || *t == 0) {
*r = 0;
p = strrchr_w(ns, UCS2_CHAR('/'));
- if (!p) p = ns;
- if (*t == 0) *p = 0;
- else memmove(p, t, (strlen_w(t) + 1) * sizeof(smb_ucs2_t));
+ if (!p)
+ p = ns;
+ if (*t == 0)
+ *p = 0;
+ else
+ memmove(p, t, (strlen_w(t) + 1) * sizeof(smb_ucs2_t));
t = p;
}
}
@@ -460,82 +667,82 @@ smb_ucs2_t *unix_clean_path(const smb_ucs2_t *s)
}
/****************************************************************************
- make a dir struct
+ Make a dir struct.
****************************************************************************/
+
void make_dir_struct(char *buf,char *mask,char *fname,SMB_OFF_T size,int mode,time_t date)
{
- char *p;
- pstring mask2;
+ char *p;
+ pstring mask2;
- pstrcpy(mask2,mask);
+ pstrcpy(mask2,mask);
- if ((mode & aDIR) != 0)
- size = 0;
+ if ((mode & aDIR) != 0)
+ size = 0;
- memset(buf+1,' ',11);
- if ((p = strchr_m(mask2,'.')) != NULL)
- {
- *p = 0;
- push_ascii(buf+1,mask2,8, 0);
- push_ascii(buf+9,p+1,3, 0);
- *p = '.';
- }
- else
- push_ascii(buf+1,mask2,11, 0);
+ memset(buf+1,' ',11);
+ if ((p = strchr_m(mask2,'.')) != NULL) {
+ *p = 0;
+ push_ascii(buf+1,mask2,8, 0);
+ push_ascii(buf+9,p+1,3, 0);
+ *p = '.';
+ } else
+ push_ascii(buf+1,mask2,11, 0);
- memset(buf+21,'\0',DIR_STRUCT_SIZE-21);
- SCVAL(buf,21,mode);
- put_dos_date(buf,22,date);
- SSVAL(buf,26,size & 0xFFFF);
- SSVAL(buf,28,(size >> 16)&0xFFFF);
- push_ascii(buf+30,fname,12, 0);
- if (!case_sensitive)
- strupper(buf+30);
- DEBUG(8,("put name [%s] from [%s] into dir struct\n",buf+30, fname));
+ memset(buf+21,'\0',DIR_STRUCT_SIZE-21);
+ SCVAL(buf,21,mode);
+ put_dos_date(buf,22,date);
+ SSVAL(buf,26,size & 0xFFFF);
+ SSVAL(buf,28,(size >> 16)&0xFFFF);
+ push_ascii(buf+30,fname,12, case_sensitive ? 0 : STR_UPPER);
+ DEBUG(8,("put name [%s] from [%s] into dir struct\n",buf+30, fname));
}
-
/*******************************************************************
-close the low 3 fd's and open dev/null in their place
+ Close the low 3 fd's and open dev/null in their place.
********************************************************************/
+
void close_low_fds(BOOL stderr_too)
{
- int fd;
- int i;
- close(0); close(1);
-
- if (stderr_too) {
- close(2);
- }
-
- /* try and use up these file descriptors, so silly
- library routines writing to stdout etc won't cause havoc */
- for (i=0;i<3;i++) {
- if (i == 2 && !stderr_too)
- continue;
-
- fd = sys_open("/dev/null",O_RDWR,0);
- if (fd < 0) fd = sys_open("/dev/null",O_WRONLY,0);
- if (fd < 0) {
- DEBUG(0,("Can't open /dev/null\n"));
- return;
- }
- if (fd != i) {
- DEBUG(0,("Didn't get file descriptor %d\n",i));
- return;
- }
- }
+ int fd;
+ int i;
+
+ close(0);
+ close(1);
+
+ if (stderr_too)
+ close(2);
+
+ /* try and use up these file descriptors, so silly
+ library routines writing to stdout etc won't cause havoc */
+ for (i=0;i<3;i++) {
+ if (i == 2 && !stderr_too)
+ continue;
+
+ fd = sys_open("/dev/null",O_RDWR,0);
+ if (fd < 0)
+ fd = sys_open("/dev/null",O_WRONLY,0);
+ if (fd < 0) {
+ DEBUG(0,("Can't open /dev/null\n"));
+ return;
+ }
+ if (fd != i) {
+ DEBUG(0,("Didn't get file descriptor %d\n",i));
+ return;
+ }
+ }
}
/****************************************************************************
-Set a fd into blocking/nonblocking mode. Uses POSIX O_NONBLOCK if available,
-else
-if SYSV use O_NDELAY
-if BSD use FNDELAY
+ Set a fd into blocking/nonblocking mode. Uses POSIX O_NONBLOCK if available,
+ else
+ if SYSV use O_NDELAY
+ if BSD use FNDELAY
****************************************************************************/
+
int set_blocking(int fd, BOOL set)
{
- int val;
+ int val;
#ifdef O_NONBLOCK
#define FLAG_TO_SET O_NONBLOCK
#else
@@ -546,13 +753,13 @@ int set_blocking(int fd, BOOL set)
#endif
#endif
- if((val = sys_fcntl_long(fd, F_GETFL, 0)) == -1)
- return -1;
- if(set) /* Turn blocking on - ie. clear nonblock flag */
- val &= ~FLAG_TO_SET;
- else
- val |= FLAG_TO_SET;
- return sys_fcntl_long( fd, F_SETFL, val);
+ if((val = sys_fcntl_long(fd, F_GETFL, 0)) == -1)
+ return -1;
+ if(set) /* Turn blocking on - ie. clear nonblock flag */
+ val &= ~FLAG_TO_SET;
+ else
+ val |= FLAG_TO_SET;
+ return sys_fcntl_long( fd, F_SETFL, val);
#undef FLAG_TO_SET
}
@@ -660,9 +867,8 @@ void msleep(unsigned int t)
void become_daemon(void)
{
- if (sys_fork()) {
+ if (sys_fork())
_exit(0);
- }
/* detach from the terminal */
#ifdef HAVE_SETSID
@@ -682,22 +888,22 @@ void become_daemon(void)
attach it to the logfile */
}
-
/****************************************************************************
- Put up a yes/no prompt
+ Put up a yes/no prompt.
****************************************************************************/
+
BOOL yesno(char *p)
{
- pstring ans;
- printf("%s",p);
+ pstring ans;
+ printf("%s",p);
- if (!fgets(ans,sizeof(ans)-1,stdin))
- return(False);
+ if (!fgets(ans,sizeof(ans)-1,stdin))
+ return(False);
- if (*ans == 'y' || *ans == 'Y')
- return(True);
+ if (*ans == 'y' || *ans == 'Y')
+ return(True);
- return(False);
+ return(False);
}
/****************************************************************************
@@ -706,29 +912,29 @@ BOOL yesno(char *p)
void *Realloc(void *p,size_t size)
{
- void *ret=NULL;
+ void *ret=NULL;
- if (size == 0) {
- SAFE_FREE(p);
- DEBUG(5,("Realloc asked for 0 bytes\n"));
- return NULL;
- }
+ if (size == 0) {
+ SAFE_FREE(p);
+ DEBUG(5,("Realloc asked for 0 bytes\n"));
+ return NULL;
+ }
- if (!p)
- ret = (void *)malloc(size);
- else
- ret = (void *)realloc(p,size);
+ if (!p)
+ ret = (void *)malloc(size);
+ else
+ ret = (void *)realloc(p,size);
- if (!ret)
- DEBUG(0,("Memory allocation error: failed to expand to %d bytes\n",(int)size));
+ if (!ret)
+ DEBUG(0,("Memory allocation error: failed to expand to %d bytes\n",(int)size));
- return(ret);
+ return(ret);
}
/****************************************************************************
Free memory, checks for NULL.
-use directly SAFE_FREE()
-exist only because we need to pass a function pointer somewhere --SSS
+ Use directly SAFE_FREE()
+ Exists only because we need to pass a function pointer somewhere --SSS
****************************************************************************/
void safe_free(void *p)
@@ -774,22 +980,22 @@ BOOL get_myname(char *my_name)
int interpret_protocol(char *str,int def)
{
- if (strequal(str,"NT1"))
- return(PROTOCOL_NT1);
- if (strequal(str,"LANMAN2"))
- return(PROTOCOL_LANMAN2);
- if (strequal(str,"LANMAN1"))
- return(PROTOCOL_LANMAN1);
- if (strequal(str,"CORE"))
- return(PROTOCOL_CORE);
- if (strequal(str,"COREPLUS"))
- return(PROTOCOL_COREPLUS);
- if (strequal(str,"CORE+"))
- return(PROTOCOL_COREPLUS);
+ if (strequal(str,"NT1"))
+ return(PROTOCOL_NT1);
+ if (strequal(str,"LANMAN2"))
+ return(PROTOCOL_LANMAN2);
+ if (strequal(str,"LANMAN1"))
+ return(PROTOCOL_LANMAN1);
+ if (strequal(str,"CORE"))
+ return(PROTOCOL_CORE);
+ if (strequal(str,"COREPLUS"))
+ return(PROTOCOL_COREPLUS);
+ if (strequal(str,"CORE+"))
+ return(PROTOCOL_COREPLUS);
- DEBUG(0,("Unrecognised protocol level %s\n",str));
+ DEBUG(0,("Unrecognised protocol level %s\n",str));
- return(def);
+ return(def);
}
/****************************************************************************
@@ -798,77 +1004,83 @@ int interpret_protocol(char *str,int def)
BOOL is_ipaddress(const char *str)
{
- BOOL pure_address = True;
- int i;
+ BOOL pure_address = True;
+ int i;
- for (i=0; pure_address && str[i]; i++)
- if (!(isdigit((int)str[i]) || str[i] == '.'))
- pure_address = False;
+ for (i=0; pure_address && str[i]; i++)
+ if (!(isdigit((int)str[i]) || str[i] == '.'))
+ pure_address = False;
- /* Check that a pure number is not misinterpreted as an IP */
- pure_address = pure_address && (strchr_m(str, '.') != NULL);
+ /* Check that a pure number is not misinterpreted as an IP */
+ pure_address = pure_address && (strchr_m(str, '.') != NULL);
- return pure_address;
+ return pure_address;
}
/****************************************************************************
-interpret an internet address or name into an IP address in 4 byte form
+ Interpret an internet address or name into an IP address in 4 byte form.
****************************************************************************/
uint32 interpret_addr(const char *str)
{
- struct hostent *hp;
- uint32 res;
+ struct hostent *hp;
+ uint32 res;
- if (strcmp(str,"0.0.0.0") == 0) return(0);
- if (strcmp(str,"255.255.255.255") == 0) return(0xFFFFFFFF);
+ if (strcmp(str,"0.0.0.0") == 0)
+ return(0);
+ if (strcmp(str,"255.255.255.255") == 0)
+ return(0xFFFFFFFF);
/* if it's in the form of an IP address then get the lib to interpret it */
- if (is_ipaddress(str)) {
- res = inet_addr(str);
- } else {
- /* otherwise assume it's a network name of some sort and use
- sys_gethostbyname */
- if ((hp = sys_gethostbyname(str)) == 0) {
- DEBUG(3,("sys_gethostbyname: Unknown host. %s\n",str));
- return 0;
- }
- if(hp->h_addr == NULL) {
- DEBUG(3,("sys_gethostbyname: host address is invalid for host %s\n",str));
- return 0;
- }
- putip((char *)&res,(char *)hp->h_addr);
- }
+ if (is_ipaddress(str)) {
+ res = inet_addr(str);
+ } else {
+ /* otherwise assume it's a network name of some sort and use
+ sys_gethostbyname */
+ if ((hp = sys_gethostbyname(str)) == 0) {
+ DEBUG(3,("sys_gethostbyname: Unknown host. %s\n",str));
+ return 0;
+ }
+
+ if(hp->h_addr == NULL) {
+ DEBUG(3,("sys_gethostbyname: host address is invalid for host %s\n",str));
+ return 0;
+ }
+ putip((char *)&res,(char *)hp->h_addr);
+ }
- if (res == (uint32)-1) return(0);
+ if (res == (uint32)-1)
+ return(0);
- return(res);
+ return(res);
}
/*******************************************************************
- a convenient addition to interpret_addr()
- ******************************************************************/
+ A convenient addition to interpret_addr().
+******************************************************************/
+
struct in_addr *interpret_addr2(const char *str)
{
- static struct in_addr ret;
- uint32 a = interpret_addr(str);
- ret.s_addr = a;
- return(&ret);
+ static struct in_addr ret;
+ uint32 a = interpret_addr(str);
+ ret.s_addr = a;
+ return(&ret);
}
/*******************************************************************
- Check if an IP is the 0.0.0.0
- ******************************************************************/
+ Check if an IP is the 0.0.0.0.
+******************************************************************/
+
BOOL is_zero_ip(struct in_addr ip)
{
- uint32 a;
- putip((char *)&a,(char *)&ip);
- return(a == 0);
+ uint32 a;
+ putip((char *)&a,(char *)&ip);
+ return(a == 0);
}
/*******************************************************************
- Set an IP to 0.0.0.0
- ******************************************************************/
+ Set an IP to 0.0.0.0.
+******************************************************************/
void zero_ip(struct in_addr *ip)
{
@@ -891,20 +1103,19 @@ void zero_ip(struct in_addr *ip)
static void strip_mount_options( pstring *str)
{
- if (**str == '-')
- {
- char *p = *str;
- while(*p && !isspace(*p))
- p++;
- while(*p && isspace(*p))
- p++;
- if(*p) {
- pstring tmp_str;
-
- pstrcpy(tmp_str, p);
- pstrcpy(*str, tmp_str);
- }
- }
+ if (**str == '-') {
+ char *p = *str;
+ while(*p && !isspace(*p))
+ p++;
+ while(*p && isspace(*p))
+ p++;
+ if(*p) {
+ pstring tmp_str;
+
+ pstrcpy(tmp_str, p);
+ pstrcpy(*str, tmp_str);
+ }
+ }
}
/*******************************************************************
@@ -917,127 +1128,118 @@ static void strip_mount_options( pstring *str)
#ifdef WITH_NISPLUS_HOME
char *automount_lookup(const char *user_name)
{
- static fstring last_key = "";
- static pstring last_value = "";
+ static fstring last_key = "";
+ static pstring last_value = "";
- char *nis_map = (char *)lp_nis_home_map_name();
+ char *nis_map = (char *)lp_nis_home_map_name();
- char buffer[NIS_MAXATTRVAL + 1];
- nis_result *result;
- nis_object *object;
- entry_obj *entry;
+ char buffer[NIS_MAXATTRVAL + 1];
+ nis_result *result;
+ nis_object *object;
+ entry_obj *entry;
- if (strcmp(user_name, last_key))
- {
- slprintf(buffer, sizeof(buffer)-1, "[key=%s],%s", user_name, nis_map);
- DEBUG(5, ("NIS+ querystring: %s\n", buffer));
+ if (strcmp(user_name, last_key)) {
+ slprintf(buffer, sizeof(buffer)-1, "[key=%s],%s", user_name, nis_map);
+ DEBUG(5, ("NIS+ querystring: %s\n", buffer));
- if (result = nis_list(buffer, FOLLOW_PATH|EXPAND_NAME|HARD_LOOKUP, NULL, NULL))
- {
- if (result->status != NIS_SUCCESS)
- {
- DEBUG(3, ("NIS+ query failed: %s\n", nis_sperrno(result->status)));
- fstrcpy(last_key, ""); pstrcpy(last_value, "");
- }
- else
- {
- object = result->objects.objects_val;
- if (object->zo_data.zo_type == ENTRY_OBJ)
- {
- entry = &object->zo_data.objdata_u.en_data;
- DEBUG(5, ("NIS+ entry type: %s\n", entry->en_type));
- DEBUG(3, ("NIS+ result: %s\n", entry->en_cols.en_cols_val[1].ec_value.ec_value_val));
+ if (result = nis_list(buffer, FOLLOW_PATH|EXPAND_NAME|HARD_LOOKUP, NULL, NULL)) {
+ if (result->status != NIS_SUCCESS) {
+ DEBUG(3, ("NIS+ query failed: %s\n", nis_sperrno(result->status)));
+ fstrcpy(last_key, ""); pstrcpy(last_value, "");
+ } else {
+ object = result->objects.objects_val;
+ if (object->zo_data.zo_type == ENTRY_OBJ) {
+ entry = &object->zo_data.objdata_u.en_data;
+ DEBUG(5, ("NIS+ entry type: %s\n", entry->en_type));
+ DEBUG(3, ("NIS+ result: %s\n", entry->en_cols.en_cols_val[1].ec_value.ec_value_val));
- pstrcpy(last_value, entry->en_cols.en_cols_val[1].ec_value.ec_value_val);
- pstring_sub(last_value, "&", user_name);
- fstrcpy(last_key, user_name);
- }
- }
- }
- nis_freeresult(result);
- }
+ pstrcpy(last_value, entry->en_cols.en_cols_val[1].ec_value.ec_value_val);
+ pstring_sub(last_value, "&", user_name);
+ fstrcpy(last_key, user_name);
+ }
+ }
+ }
+ nis_freeresult(result);
+ }
- strip_mount_options(&last_value);
+ strip_mount_options(&last_value);
- DEBUG(4, ("NIS+ Lookup: %s resulted in %s\n", user_name, last_value));
- return last_value;
+ DEBUG(4, ("NIS+ Lookup: %s resulted in %s\n", user_name, last_value));
+ return last_value;
}
#else /* WITH_NISPLUS_HOME */
+
char *automount_lookup(const char *user_name)
{
- static fstring last_key = "";
- static pstring last_value = "";
-
- int nis_error; /* returned by yp all functions */
- char *nis_result; /* yp_match inits this */
- int nis_result_len; /* and set this */
- char *nis_domain; /* yp_get_default_domain inits this */
- char *nis_map = (char *)lp_nis_home_map_name();
-
- if ((nis_error = yp_get_default_domain(&nis_domain)) != 0) {
- DEBUG(3, ("YP Error: %s\n", yperr_string(nis_error)));
- return last_value;
- }
-
- DEBUG(5, ("NIS Domain: %s\n", nis_domain));
-
- if (!strcmp(user_name, last_key)) {
- nis_result = last_value;
- nis_result_len = strlen(last_value);
- nis_error = 0;
-
- } else {
-
- if ((nis_error = yp_match(nis_domain, nis_map,
- user_name, strlen(user_name),
- &nis_result, &nis_result_len)) == 0) {
- if (!nis_error && nis_result_len >= sizeof(pstring)) {
- nis_result_len = sizeof(pstring)-1;
- }
- fstrcpy(last_key, user_name);
- strncpy(last_value, nis_result, nis_result_len);
- last_value[nis_result_len] = '\0';
- strip_mount_options(&last_value);
-
- } else if(nis_error == YPERR_KEY) {
-
- /* If Key lookup fails user home server is not in nis_map
- use default information for server, and home directory */
- last_value[0] = 0;
- DEBUG(3, ("YP Key not found: while looking up \"%s\" in map \"%s\"\n",
- user_name, nis_map));
- DEBUG(3, ("using defaults for server and home directory\n"));
- } else {
- DEBUG(3, ("YP Error: \"%s\" while looking up \"%s\" in map \"%s\"\n",
- yperr_string(nis_error), user_name, nis_map));
- }
- }
+ static fstring last_key = "";
+ static pstring last_value = "";
+ int nis_error; /* returned by yp all functions */
+ char *nis_result; /* yp_match inits this */
+ int nis_result_len; /* and set this */
+ char *nis_domain; /* yp_get_default_domain inits this */
+ char *nis_map = (char *)lp_nis_home_map_name();
+
+ if ((nis_error = yp_get_default_domain(&nis_domain)) != 0) {
+ DEBUG(3, ("YP Error: %s\n", yperr_string(nis_error)));
+ return last_value;
+ }
+
+ DEBUG(5, ("NIS Domain: %s\n", nis_domain));
+
+ if (!strcmp(user_name, last_key)) {
+ nis_result = last_value;
+ nis_result_len = strlen(last_value);
+ nis_error = 0;
+ } else {
+ if ((nis_error = yp_match(nis_domain, nis_map, user_name, strlen(user_name),
+ &nis_result, &nis_result_len)) == 0) {
+ if (!nis_error && nis_result_len >= sizeof(pstring)) {
+ nis_result_len = sizeof(pstring)-1;
+ }
+ fstrcpy(last_key, user_name);
+ strncpy(last_value, nis_result, nis_result_len);
+ last_value[nis_result_len] = '\0';
+ strip_mount_options(&last_value);
+
+ } else if(nis_error == YPERR_KEY) {
+
+ /* If Key lookup fails user home server is not in nis_map
+ use default information for server, and home directory */
+ last_value[0] = 0;
+ DEBUG(3, ("YP Key not found: while looking up \"%s\" in map \"%s\"\n",
+ user_name, nis_map));
+ DEBUG(3, ("using defaults for server and home directory\n"));
+ } else {
+ DEBUG(3, ("YP Error: \"%s\" while looking up \"%s\" in map \"%s\"\n",
+ yperr_string(nis_error), user_name, nis_map));
+ }
+ }
- DEBUG(4, ("YP Lookup: %s resulted in %s\n", user_name, last_value));
- return last_value;
+ DEBUG(4, ("YP Lookup: %s resulted in %s\n", user_name, last_value));
+ return last_value;
}
#endif /* WITH_NISPLUS_HOME */
#endif
-
/*******************************************************************
-are two IPs on the same subnet?
+ Are two IPs on the same subnet?
********************************************************************/
+
BOOL same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask)
{
- uint32 net1,net2,nmask;
+ uint32 net1,net2,nmask;
- nmask = ntohl(mask.s_addr);
- net1 = ntohl(ip1.s_addr);
- net2 = ntohl(ip2.s_addr);
+ nmask = ntohl(mask.s_addr);
+ net1 = ntohl(ip1.s_addr);
+ net2 = ntohl(ip2.s_addr);
- return((net1 & nmask) == (net2 & nmask));
+ return((net1 & nmask) == (net2 & nmask));
}
/****************************************************************************
-check if a process exists. Does this work on all unixes?
+ Check if a process exists. Does this work on all unixes?
****************************************************************************/
BOOL process_exists(pid_t pid)
@@ -1048,7 +1250,6 @@ BOOL process_exists(pid_t pid)
return(kill(pid,0) == 0 || errno != ESRCH);
}
-
/*******************************************************************
Convert a uid into a user name.
********************************************************************/
@@ -1130,8 +1331,9 @@ gid_t nametogid(const char *name)
}
/*******************************************************************
-something really nasty happened - panic!
+ Something really nasty happened - panic !
********************************************************************/
+
void smb_panic(char *why)
{
char *cmd = lp_panic_action();
@@ -1153,24 +1355,27 @@ void smb_panic(char *why)
abort();
}
-
/*******************************************************************
-a readdir wrapper which just returns the file name
+ A readdir wrapper which just returns the file name.
********************************************************************/
+
char *readdirname(DIR *p)
{
SMB_STRUCT_DIRENT *ptr;
char *dname;
- if (!p) return(NULL);
+ if (!p)
+ return(NULL);
ptr = (SMB_STRUCT_DIRENT *)sys_readdir(p);
- if (!ptr) return(NULL);
+ if (!ptr)
+ return(NULL);
dname = ptr->d_name;
#ifdef NEXT2
- if (telldir(p) < 0) return(NULL);
+ if (telldir(p) < 0)
+ return(NULL);
#endif
#ifdef HAVE_BROKEN_READDIR
@@ -1196,46 +1401,39 @@ char *readdirname(DIR *p)
BOOL is_in_path(char *name, name_compare_entry *namelist)
{
- pstring last_component;
- char *p;
-
- DEBUG(8, ("is_in_path: %s\n", name));
-
- /* if we have no list it's obviously not in the path */
- if((namelist == NULL ) || ((namelist != NULL) && (namelist[0].name == NULL)))
- {
- DEBUG(8,("is_in_path: no name list.\n"));
- return False;
- }
-
- /* Get the last component of the unix name. */
- p = strrchr_m(name, '/');
- strncpy(last_component, p ? ++p : name, sizeof(last_component)-1);
- last_component[sizeof(last_component)-1] = '\0';
-
- for(; namelist->name != NULL; namelist++)
- {
- if(namelist->is_wild)
- {
- if (mask_match(last_component, namelist->name, case_sensitive))
- {
- DEBUG(8,("is_in_path: mask match succeeded\n"));
- return True;
- }
- }
- else
- {
- if((case_sensitive && (strcmp(last_component, namelist->name) == 0))||
- (!case_sensitive && (StrCaseCmp(last_component, namelist->name) == 0)))
- {
- DEBUG(8,("is_in_path: match succeeded\n"));
- return True;
- }
- }
- }
- DEBUG(8,("is_in_path: match not found\n"));
+ pstring last_component;
+ char *p;
+
+ DEBUG(8, ("is_in_path: %s\n", name));
+
+ /* if we have no list it's obviously not in the path */
+ if((namelist == NULL ) || ((namelist != NULL) && (namelist[0].name == NULL))) {
+ DEBUG(8,("is_in_path: no name list.\n"));
+ return False;
+ }
+
+ /* Get the last component of the unix name. */
+ p = strrchr_m(name, '/');
+ strncpy(last_component, p ? ++p : name, sizeof(last_component)-1);
+ last_component[sizeof(last_component)-1] = '\0';
+
+ for(; namelist->name != NULL; namelist++) {
+ if(namelist->is_wild) {
+ if (mask_match(last_component, namelist->name, case_sensitive)) {
+ DEBUG(8,("is_in_path: mask match succeeded\n"));
+ return True;
+ }
+ } else {
+ if((case_sensitive && (strcmp(last_component, namelist->name) == 0))||
+ (!case_sensitive && (StrCaseCmp(last_component, namelist->name) == 0))) {
+ DEBUG(8,("is_in_path: match succeeded\n"));
+ return True;
+ }
+ }
+ }
+ DEBUG(8,("is_in_path: match not found\n"));
- return False;
+ return False;
}
/*******************************************************************
@@ -1253,99 +1451,92 @@ BOOL is_in_path(char *name, name_compare_entry *namelist)
void set_namearray(name_compare_entry **ppname_array, char *namelist)
{
- char *name_end;
- char *nameptr = namelist;
- int num_entries = 0;
- int i;
-
- (*ppname_array) = NULL;
-
- if((nameptr == NULL ) || ((nameptr != NULL) && (*nameptr == '\0')))
- return;
-
- /* We need to make two passes over the string. The
- first to count the number of elements, the second
- to split it.
- */
- while(*nameptr)
- {
- if ( *nameptr == '/' )
- {
- /* cope with multiple (useless) /s) */
- nameptr++;
- continue;
- }
- /* find the next / */
- name_end = strchr_m(nameptr, '/');
+ char *name_end;
+ char *nameptr = namelist;
+ int num_entries = 0;
+ int i;
- /* oops - the last check for a / didn't find one. */
- if (name_end == NULL)
- break;
+ (*ppname_array) = NULL;
- /* next segment please */
- nameptr = name_end + 1;
- num_entries++;
- }
+ if((nameptr == NULL ) || ((nameptr != NULL) && (*nameptr == '\0')))
+ return;
- if(num_entries == 0)
- return;
+ /* We need to make two passes over the string. The
+ first to count the number of elements, the second
+ to split it.
+ */
- if(( (*ppname_array) = (name_compare_entry *)malloc(
- (num_entries + 1) * sizeof(name_compare_entry))) == NULL)
- {
- DEBUG(0,("set_namearray: malloc fail\n"));
- return;
- }
+ while(*nameptr) {
+ if ( *nameptr == '/' ) {
+ /* cope with multiple (useless) /s) */
+ nameptr++;
+ continue;
+ }
+ /* find the next / */
+ name_end = strchr_m(nameptr, '/');
- /* Now copy out the names */
- nameptr = namelist;
- i = 0;
- while(*nameptr)
- {
- if ( *nameptr == '/' )
- {
- /* cope with multiple (useless) /s) */
- nameptr++;
- continue;
- }
- /* find the next / */
- if ((name_end = strchr_m(nameptr, '/')) != NULL)
- {
- *name_end = 0;
- }
-
- /* oops - the last check for a / didn't find one. */
- if(name_end == NULL)
- break;
-
- (*ppname_array)[i].is_wild = ms_has_wild(nameptr);
- if(((*ppname_array)[i].name = strdup(nameptr)) == NULL)
- {
- DEBUG(0,("set_namearray: malloc fail (1)\n"));
- return;
- }
-
- /* next segment please */
- nameptr = name_end + 1;
- i++;
- }
+ /* oops - the last check for a / didn't find one. */
+ if (name_end == NULL)
+ break;
+
+ /* next segment please */
+ nameptr = name_end + 1;
+ num_entries++;
+ }
+
+ if(num_entries == 0)
+ return;
+
+ if(( (*ppname_array) = (name_compare_entry *)malloc(
+ (num_entries + 1) * sizeof(name_compare_entry))) == NULL) {
+ DEBUG(0,("set_namearray: malloc fail\n"));
+ return;
+ }
+
+ /* Now copy out the names */
+ nameptr = namelist;
+ i = 0;
+ while(*nameptr) {
+ if ( *nameptr == '/' ) {
+ /* cope with multiple (useless) /s) */
+ nameptr++;
+ continue;
+ }
+ /* find the next / */
+ if ((name_end = strchr_m(nameptr, '/')) != NULL)
+ *name_end = 0;
+
+ /* oops - the last check for a / didn't find one. */
+ if(name_end == NULL)
+ break;
+
+ (*ppname_array)[i].is_wild = ms_has_wild(nameptr);
+ if(((*ppname_array)[i].name = strdup(nameptr)) == NULL) {
+ DEBUG(0,("set_namearray: malloc fail (1)\n"));
+ return;
+ }
+
+ /* next segment please */
+ nameptr = name_end + 1;
+ i++;
+ }
- (*ppname_array)[i].name = NULL;
+ (*ppname_array)[i].name = NULL;
- return;
+ return;
}
/****************************************************************************
-routine to free a namearray.
+ Routine to free a namearray.
****************************************************************************/
void free_namearray(name_compare_entry *name_array)
{
- if(name_array == NULL)
- return;
+ if(name_array == NULL)
+ return;
- SAFE_FREE(name_array->name);
- SAFE_FREE(name_array);
+ SAFE_FREE(name_array->name);
+ SAFE_FREE(name_array);
}
/****************************************************************************
@@ -1355,50 +1546,47 @@ void free_namearray(name_compare_entry *name_array)
BOOL fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
{
- SMB_STRUCT_FLOCK lock;
- int ret;
+ SMB_STRUCT_FLOCK lock;
+ int ret;
- DEBUG(8,("fcntl_lock %d %d %.0f %.0f %d\n",fd,op,(double)offset,(double)count,type));
+ DEBUG(8,("fcntl_lock %d %d %.0f %.0f %d\n",fd,op,(double)offset,(double)count,type));
- lock.l_type = type;
- lock.l_whence = SEEK_SET;
- lock.l_start = offset;
- lock.l_len = count;
- lock.l_pid = 0;
+ lock.l_type = type;
+ lock.l_whence = SEEK_SET;
+ lock.l_start = offset;
+ lock.l_len = count;
+ lock.l_pid = 0;
- ret = sys_fcntl_ptr(fd,op,&lock);
+ ret = sys_fcntl_ptr(fd,op,&lock);
- if (ret == -1 && errno != 0)
- DEBUG(3,("fcntl_lock: fcntl lock gave errno %d (%s)\n",errno,strerror(errno)));
+ if (ret == -1 && errno != 0)
+ DEBUG(3,("fcntl_lock: fcntl lock gave errno %d (%s)\n",errno,strerror(errno)));
- /* a lock query */
- if (op == SMB_F_GETLK)
- {
- if ((ret != -1) &&
- (lock.l_type != F_UNLCK) &&
- (lock.l_pid != 0) &&
- (lock.l_pid != sys_getpid()))
- {
- DEBUG(3,("fcntl_lock: fd %d is locked by pid %d\n",fd,(int)lock.l_pid));
- return(True);
- }
+ /* a lock query */
+ if (op == SMB_F_GETLK) {
+ if ((ret != -1) &&
+ (lock.l_type != F_UNLCK) &&
+ (lock.l_pid != 0) &&
+ (lock.l_pid != sys_getpid())) {
+ DEBUG(3,("fcntl_lock: fd %d is locked by pid %d\n",fd,(int)lock.l_pid));
+ return(True);
+ }
- /* it must be not locked or locked by me */
- return(False);
- }
+ /* it must be not locked or locked by me */
+ return(False);
+ }
- /* a lock set or unset */
- if (ret == -1)
- {
- DEBUG(3,("fcntl_lock: lock failed at offset %.0f count %.0f op %d type %d (%s)\n",
- (double)offset,(double)count,op,type,strerror(errno)));
- return(False);
- }
+ /* a lock set or unset */
+ if (ret == -1) {
+ DEBUG(3,("fcntl_lock: lock failed at offset %.0f count %.0f op %d type %d (%s)\n",
+ (double)offset,(double)count,op,type,strerror(errno)));
+ return(False);
+ }
- /* everything went OK */
- DEBUG(8,("fcntl_lock: Lock call successful\n"));
+ /* everything went OK */
+ DEBUG(8,("fcntl_lock: Lock call successful\n"));
- return(True);
+ return(True);
}
/*******************************************************************
@@ -1406,14 +1594,16 @@ BOOL fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
Returns true if it is equal, false otherwise.
********************************************************************/
-BOOL is_myname(char *s)
+BOOL is_myname(const char *s)
{
int n;
BOOL ret = False;
- for (n=0; my_netbios_names[n]; n++) {
- if (strequal(my_netbios_names[n], s))
+ for (n=0; my_netbios_names(n); n++) {
+ if (strequal(my_netbios_names(n), s)) {
ret=True;
+ break;
+ }
}
DEBUG(8, ("is_myname(\"%s\") returns %d\n", s, ret));
return(ret);
@@ -1437,12 +1627,10 @@ const char* get_my_primary_ip (void)
return ip_string;
}
-BOOL is_myname_or_ipaddr(char *s)
+BOOL is_myname_or_ipaddr(const char *s)
{
- char **ptr;
-
/* optimize for the common case */
- if (strequal(s, global_myname))
+ if (strequal(s, global_myname()))
return True;
/* maybe its an IP address? */
@@ -1463,11 +1651,8 @@ BOOL is_myname_or_ipaddr(char *s)
}
/* check for an alias */
- ptr = lp_netbios_aliases();
- for ( ; *ptr; ptr++ ) {
- if (StrCaseCmp(s, *ptr) == 0)
- return True;
- }
+ if (is_myname(s))
+ return True;
/* no match */
return False;
@@ -1609,15 +1794,14 @@ char *tab_depth(int depth)
}
/*****************************************************************************
- * Provide a checksum on a string
- *
- * Input: s - the null-terminated character string for which the checksum
- * will be calculated.
- *
- * Output: The checksum value calculated for s.
- *
- * ****************************************************************************
- */
+ Provide a checksum on a string
+
+ Input: s - the null-terminated character string for which the checksum
+ will be calculated.
+
+ Output: The checksum value calculated for s.
+*****************************************************************************/
+
int str_checksum(const char *s)
{
int res = 0;
@@ -1631,23 +1815,22 @@ int str_checksum(const char *s)
i++;
}
return(res);
-} /* str_checksum */
-
-
+}
/*****************************************************************
-zero a memory area then free it. Used to catch bugs faster
+ Zero a memory area then free it. Used to catch bugs faster.
*****************************************************************/
+
void zero_free(void *p, size_t size)
{
memset(p, 0, size);
SAFE_FREE(p);
}
-
/*****************************************************************
-set our open file limit to a requested max and return the limit
+ Set our open file limit to a requested max and return the limit.
*****************************************************************/
+
int set_maxfiles(int requested_max)
{
#if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
@@ -1662,7 +1845,7 @@ int set_maxfiles(int requested_max)
}
/*
- * Set the fd limit to be real_max_open_files + MAX_OPEN_FUDGEFACTOR to
+ * Set the fd limit to be real_max_open_files + MAX_OPEN_FUDGEFACTOR to
* account for the extra fd we need
* as well as the log files and standard
* handles etc. Save the limit we want to set in case
@@ -1715,7 +1898,7 @@ int set_maxfiles(int requested_max)
return saved_current_limit;
#endif
- if((int)rlp.rlim_cur > saved_current_limit)
+ if((int)rlp.rlim_cur > saved_current_limit)
return saved_current_limit;
return rlp.rlim_cur;
@@ -1728,53 +1911,43 @@ int set_maxfiles(int requested_max)
}
/*****************************************************************
- splits out the start of the key (HKLM or HKU) and the rest of the key
- *****************************************************************/
-BOOL reg_split_key(char *full_keyname, uint32 *reg_type, char *key_name)
+ Splits out the start of the key (HKLM or HKU) and the rest of the key.
+*****************************************************************/
+
+BOOL reg_split_key(const char *full_keyname, uint32 *reg_type, char *key_name)
{
pstring tmp;
if (!next_token(&full_keyname, tmp, "\\", sizeof(tmp)))
- {
return False;
- }
(*reg_type) = 0;
DEBUG(10, ("reg_split_key: hive %s\n", tmp));
if (strequal(tmp, "HKLM") || strequal(tmp, "HKEY_LOCAL_MACHINE"))
- {
(*reg_type) = HKEY_LOCAL_MACHINE;
- }
else if (strequal(tmp, "HKU") || strequal(tmp, "HKEY_USERS"))
- {
(*reg_type) = HKEY_USERS;
- }
- else
- {
+ else {
DEBUG(10,("reg_split_key: unrecognised hive key %s\n", tmp));
return False;
}
if (next_token(&full_keyname, tmp, "\n\r", sizeof(tmp)))
- {
fstrcpy(key_name, tmp);
- }
else
- {
key_name[0] = 0;
- }
DEBUG(10, ("reg_split_key: name %s\n", key_name));
return True;
}
-
/*****************************************************************
-possibly replace mkstemp if it is broken
+ Possibly replace mkstemp if it is broken.
*****************************************************************/
+
int smb_mkstemp(char *template)
{
#if HAVE_SECURE_MKSTEMP
@@ -1783,7 +1956,8 @@ int smb_mkstemp(char *template)
/* have a reasonable go at emulating it. Hope that
the system mktemp() isn't completly hopeless */
char *p = mktemp(template);
- if (!p) return -1;
+ if (!p)
+ return -1;
return open(p, O_CREAT|O_EXCL|O_RDWR, 0600);
#endif
}
@@ -1805,6 +1979,7 @@ void *smb_xmalloc(size_t size)
/**
Memdup with smb_panic on fail.
**/
+
void *smb_xmemdup(const void *p, size_t size)
{
void *p2;
@@ -1816,6 +1991,7 @@ void *smb_xmemdup(const void *p, size_t size)
/**
strdup that aborts on malloc fail.
**/
+
char *smb_xstrdup(const char *s)
{
char *s1 = strdup(s);
@@ -1827,6 +2003,7 @@ char *smb_xstrdup(const char *s)
/**
strndup that aborts on malloc fail.
**/
+
char *smb_xstrndup(const char *s, size_t n)
{
char *s1 = strndup(s, n);
@@ -1838,6 +2015,7 @@ char *smb_xstrndup(const char *s, size_t n)
/*
vasprintf that aborts on malloc fail
*/
+
int smb_xvasprintf(char **ptr, const char *format, va_list ap)
{
int n;
@@ -1846,41 +2024,43 @@ int smb_xvasprintf(char **ptr, const char *format, va_list ap)
VA_COPY(ap2, ap);
n = vasprintf(ptr, format, ap2);
- if (n == -1 || ! *ptr) {
+ if (n == -1 || ! *ptr)
smb_panic("smb_xvasprintf: out of memory");
- }
return n;
}
/*****************************************************************
-like strdup but for memory
- *****************************************************************/
+ Like strdup but for memory.
+*****************************************************************/
+
void *memdup(const void *p, size_t size)
{
void *p2;
- if (size == 0) return NULL;
+ if (size == 0)
+ return NULL;
p2 = malloc(size);
- if (!p2) return NULL;
+ if (!p2)
+ return NULL;
memcpy(p2, p, size);
return p2;
}
/*****************************************************************
-get local hostname and cache result
- *****************************************************************/
+ Get local hostname and cache result.
+*****************************************************************/
+
char *myhostname(void)
{
static pstring ret;
- if (ret[0] == 0) {
+ if (ret[0] == 0)
get_myname(ret);
- }
return ret;
}
-
/*****************************************************************
-a useful function for returning a path in the Samba lock directory
- *****************************************************************/
+ A useful function for returning a path in the Samba lock directory.
+*****************************************************************/
+
char *lock_path(const char *name)
{
static pstring fname;
@@ -1888,9 +2068,8 @@ char *lock_path(const char *name)
pstrcpy(fname,lp_lockdir());
trim_string(fname,"","/");
- if (!directory_exist(fname,NULL)) {
+ if (!directory_exist(fname,NULL))
mkdir(fname,0755);
- }
pstrcat(fname,"/");
pstrcat(fname,name);
@@ -1899,8 +2078,9 @@ char *lock_path(const char *name)
}
/*****************************************************************
-a useful function for returning a path in the Samba pid directory
- *****************************************************************/
+ A useful function for returning a path in the Samba pid directory.
+*****************************************************************/
+
char *pid_path(const char *name)
{
static pstring fname;
@@ -1908,9 +2088,8 @@ char *pid_path(const char *name)
pstrcpy(fname,lp_piddir());
trim_string(fname,"","/");
- if (!directory_exist(fname,NULL)) {
+ if (!directory_exist(fname,NULL))
mkdir(fname,0755);
- }
pstrcat(fname,"/");
pstrcat(fname,name);
@@ -1918,7 +2097,6 @@ char *pid_path(const char *name)
return fname;
}
-
/**
* @brief Returns an absolute path to a file in the Samba lib directory.
*
@@ -1926,6 +2104,7 @@ char *pid_path(const char *name)
*
* @retval Pointer to a static #pstring containing the full path.
**/
+
char *lib_path(const char *name)
{
static pstring fname;
@@ -1963,8 +2142,9 @@ char *parent_dirname(const char *path)
/*******************************************************************
-determine if a pattern contains any Microsoft wildcard characters
- *******************************************************************/
+ Determine if a pattern contains any Microsoft wildcard characters.
+*******************************************************************/
+
BOOL ms_has_wild(char *s)
{
char c;
@@ -1999,19 +2179,21 @@ BOOL ms_has_wild_w(const smb_ucs2_t *s)
}
/*******************************************************************
- a wrapper that handles case sensitivity and the special handling
- of the ".." name
- *******************************************************************/
+ A wrapper that handles case sensitivity and the special handling
+ of the ".." name.
+*******************************************************************/
+
BOOL mask_match(char *string, char *pattern, BOOL is_case_sensitive)
{
fstring p2, s2;
- if (strcmp(string,"..") == 0) string = ".";
- if (strcmp(pattern,".") == 0) return False;
+ if (strcmp(string,"..") == 0)
+ string = ".";
+ if (strcmp(pattern,".") == 0)
+ return False;
- if (is_case_sensitive) {
+ if (is_case_sensitive)
return ms_fnmatch(pattern, string, Protocol) == 0;
- }
fstrcpy(p2, pattern);
fstrcpy(s2, string);
@@ -2153,6 +2335,7 @@ This routine is a trick to immediately catch errors when debugging
with insure. A xterm with a gdb is popped up when insure catches
a error. It is Linux specific.
********************************************************************/
+
int _Insure_trap_error(int a1, int a2, int a3, int a4, int a5, int a6)
{
static int (*fn)();
diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c
index f0daf9787e..edd59ae109 100644
--- a/source3/lib/util_sid.c
+++ b/source3/lib/util_sid.c
@@ -24,9 +24,6 @@
#include "includes.h"
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-
/*
* Some useful sids
*/
@@ -178,7 +175,7 @@ NT_USER_TOKEN *get_system_token(void)
/**************************************************************************
Splits a name of format \DOMAIN\name or name into its two components.
- Sets the DOMAIN name to global_myname if it has not been specified.
+ Sets the DOMAIN name to global_myname() if it has not been specified.
***************************************************************************/
void split_domain_name(const char *fullname, char *domain, char *name)
@@ -202,7 +199,7 @@ void split_domain_name(const char *fullname, char *domain, char *name)
fstrcpy(domain, full_name);
fstrcpy(name, p+1);
} else {
- fstrcpy(domain, global_myname);
+ fstrcpy(domain, global_myname());
fstrcpy(name, full_name);
}
@@ -280,7 +277,8 @@ const char *sid_string_static(const DOM_SID *sid)
BOOL string_to_sid(DOM_SID *sidout, const char *sidstr)
{
pstring tok;
- char *p, *q;
+ char *q;
+ const char *p;
/* BIG NOTE: this function only does SIDS where the identauth is not >= 2^32 */
uint32 ia;
@@ -291,7 +289,7 @@ BOOL string_to_sid(DOM_SID *sidout, const char *sidstr)
memset((char *)sidout, '\0', sizeof(DOM_SID));
- q = p = strdup(sidstr + 2);
+ p = q = strdup(sidstr + 2);
if (p == NULL) {
DEBUG(0, ("string_to_sid: out of memory!\n"));
return False;
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 04c20f6596..2acb20861b 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -108,7 +108,7 @@ static void print_socket_options(int s)
Set user socket options.
****************************************************************************/
-void set_socket_options(int fd, char *options)
+void set_socket_options(int fd, const char *options)
{
fstring tok;
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index 6d1f8fe023..32efee1536 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -28,9 +28,9 @@
Extensively modified by Andrew.Tridgell@anu.edu.au
****************************************************************************/
-BOOL next_token(char **ptr,char *buff, const char *sep, size_t bufsize)
+BOOL next_token(const char **ptr,char *buff, const char *sep, size_t bufsize)
{
- char *s;
+ const char *s;
BOOL quoted;
size_t len=1;
@@ -75,11 +75,11 @@ but beware the fact that it is not re-entrant!
static char *last_ptr=NULL;
-BOOL next_token_nr(char **ptr,char *buff, const char *sep, size_t bufsize)
+BOOL next_token_nr(const char **ptr,char *buff, const char *sep, size_t bufsize)
{
BOOL ret;
if (!ptr)
- ptr = &last_ptr;
+ ptr = (const char **)&last_ptr;
ret = next_token(ptr, buff, sep, bufsize);
last_ptr = *ptr;
@@ -613,7 +613,7 @@ size_t strhex_to_str(char *p, size_t len, const char *strhex)
BOOL in_list(char *s,char *list,BOOL casesensitive)
{
pstring tok;
- char *p=list;
+ const char *p=list;
if (!list)
return(False);
@@ -1185,7 +1185,8 @@ int fstr_sprintf(fstring s, const char *fmt, ...)
char **str_list_make(const char *string, const char *sep)
{
char **list, **rlist;
- char *str, *s;
+ const char *str;
+ char *s;
int num, lsize;
pstring tok;
@@ -1231,7 +1232,7 @@ char **str_list_make(const char *string, const char *sep)
return list;
}
-BOOL str_list_copy(char ***dest, char **src)
+BOOL str_list_copy(char ***dest, const char **src)
{
char **list, **rlist;
int num, lsize;
diff --git a/source3/lib/wins_srv.c b/source3/lib/wins_srv.c
index 61e77aca58..01dfd6dd62 100644
--- a/source3/lib/wins_srv.c
+++ b/source3/lib/wins_srv.c
@@ -154,7 +154,7 @@ void wins_srv_died(struct in_addr wins_ip, struct in_addr src_ip)
*/
unsigned wins_srv_count(void)
{
- char **list;
+ const char **list;
int count = 0;
if (lp_wins_support()) {
@@ -163,7 +163,8 @@ unsigned wins_srv_count(void)
}
list = lp_wins_server_list();
- for (count=0; list && list[count]; count++) /* nop */ ;
+ for (count=0; list && list[count]; count++)
+ /* nop */ ;
return count;
}
@@ -202,7 +203,7 @@ char **wins_srv_tags(void)
{
char **ret = NULL;
int count=0, i, j;
- char **list;
+ const char **list;
if (lp_wins_support()) {
/* give the caller something to chew on. This makes
@@ -215,7 +216,8 @@ char **wins_srv_tags(void)
}
list = lp_wins_server_list();
- if (!list) return NULL;
+ if (!list)
+ return NULL;
/* yes, this is O(n^2) but n is very small */
for (i=0;list[i];i++) {
@@ -268,7 +270,7 @@ void wins_srv_tags_free(char **list)
*/
struct in_addr wins_srv_ip_tag(const char *tag, struct in_addr src_ip)
{
- char **list;
+ const char **list;
int i;
struct tagged_ip t_ip;
@@ -324,7 +326,7 @@ struct in_addr wins_srv_ip_tag(const char *tag, struct in_addr src_ip)
*/
unsigned wins_srv_count_tag(const char *tag)
{
- char **list;
+ const char **list;
int i, count=0;
/* if we are a wins server then we always just talk to ourselves */
diff --git a/source3/libads/kerberos_verify.c b/source3/libads/kerberos_verify.c
index 22b58f47dd..f761467d6f 100644
--- a/source3/libads/kerberos_verify.c
+++ b/source3/libads/kerberos_verify.c
@@ -42,7 +42,6 @@ NTSTATUS ads_verify_ticket(ADS_STRUCT *ads, const DATA_BLOB *ticket,
krb5_keyblock * key;
krb5_principal host_princ;
char *host_princ_s;
- extern pstring global_myname;
fstring myname;
char *password_s;
krb5_data password;
@@ -83,7 +82,7 @@ NTSTATUS ads_verify_ticket(ADS_STRUCT *ads, const DATA_BLOB *ticket,
return NT_STATUS_LOGON_FAILURE;
}
- fstrcpy(myname, global_myname);
+ fstrcpy(myname, global_myname());
strlower(myname);
asprintf(&host_princ_s, "HOST/%s@%s", myname, lp_realm());
ret = krb5_parse_name(context, host_princ_s, &host_princ);
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index a59b78bf13..d5cd56001b 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -105,26 +105,28 @@ static int ldap_ip_compare(struct ldap_ip *ip1, struct ldap_ip *ip2)
/* try connecting to a ldap server via DNS */
static BOOL ads_try_dns(ADS_STRUCT *ads)
{
- char *realm, *ptr;
+ const char *c_realm;
+ const char *ptr;
+ char *realm;
char *list = NULL;
pstring tok;
struct ldap_ip *ip_list;
int count, i=0;
- realm = ads->server.realm;
- if (!realm || !*realm) {
- realm = lp_realm();
+ c_realm = ads->server.realm;
+ if (!c_realm || !*c_realm) {
+ c_realm = lp_realm();
}
- if (!realm || !*realm) {
- realm = ads->server.workgroup;
+ if (!c_realm || !*c_realm) {
+ c_realm = ads->server.workgroup;
}
- if (!realm || !*realm) {
- realm = lp_workgroup();
+ if (!c_realm || !*c_realm) {
+ c_realm = lp_workgroup();
}
- if (!realm) {
+ if (!c_realm) {
return False;
}
- realm = smb_xstrdup(realm);
+ realm = smb_xstrdup(c_realm);
DEBUG(6,("ads_try_dns: looking for realm '%s'\n", realm));
if (ldap_domain2hostlist(realm, &list) != LDAP_SUCCESS) {
@@ -183,7 +185,7 @@ static BOOL ads_try_netbios(ADS_STRUCT *ads)
struct in_addr *ip_list, pdc_ip;
int count;
int i;
- char *workgroup = ads->server.workgroup;
+ const char *workgroup = ads->server.workgroup;
if (!workgroup) {
workgroup = lp_workgroup();
@@ -273,9 +275,8 @@ got_connection:
if (!ads->auth.user_name) {
/* by default use the machine account */
- extern pstring global_myname;
fstring myname;
- fstrcpy(myname, global_myname);
+ fstrcpy(myname, global_myname());
strlower(myname);
asprintf(&ads->auth.user_name, "HOST/%s", myname);
}
@@ -435,8 +436,7 @@ ADS_STATUS ads_do_paged_search(ADS_STRUCT *ads, const char *bind_path,
else {
/* This would be the utf8-encoded version...*/
/* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */
- if (!(str_list_copy(&search_attrs, attrs)))
- {
+ if (!(str_list_copy(&search_attrs, attrs))) {
rc = LDAP_NO_MEMORY;
goto done;
}
@@ -1026,7 +1026,8 @@ static ADS_STATUS ads_add_machine_acct(ADS_STRUCT *ads, const char *hostname,
ADS_MODLIST mods;
const char *objectClass[] = {"top", "person", "organizationalPerson",
"user", "computer", NULL};
- char *servicePrincipalName[3] = {NULL, NULL, NULL};
+ const char *servicePrincipalName[3] = {NULL, NULL, NULL};
+ char *psp;
unsigned acct_control;
if (!(ctx = talloc_init_named("machine_account")))
@@ -1046,10 +1047,11 @@ static ADS_STATUS ads_add_machine_acct(ADS_STRUCT *ads, const char *hostname,
new_dn = talloc_asprintf(ctx, "cn=%s,%s,%s", hostname, ou_str,
ads->config.bind_path);
servicePrincipalName[0] = talloc_asprintf(ctx, "HOST/%s", hostname);
- servicePrincipalName[1] = talloc_asprintf(ctx, "HOST/%s.%s",
+ psp = talloc_asprintf(ctx, "HOST/%s.%s",
hostname,
ads->config.realm);
- strlower(&servicePrincipalName[1][5]);
+ strlower(&psp[5]);
+ servicePrincipalName[1] = psp;
free(ou_str);
if (!new_dn)
diff --git a/source3/libads/ldap_printer.c b/source3/libads/ldap_printer.c
index 66984477b8..0185bf7811 100644
--- a/source3/libads/ldap_printer.c
+++ b/source3/libads/ldap_printer.c
@@ -28,7 +28,7 @@
results can be used. It should be freed using ads_msgfree.
*/
ADS_STATUS ads_find_printer_on_server(ADS_STRUCT *ads, void **res,
- const char *printer, char *servername)
+ const char *printer, const char *servername)
{
ADS_STATUS status;
char *srv_dn, **srv_cn, *exp;
@@ -77,7 +77,7 @@ ADS_STATUS ads_mod_printer_entry(ADS_STRUCT *ads, char *prt_dn,
ads_mod_str(ctx, &mods, "versionNumber", prt->versionNumber);
/* now the optional ones */
- ads_mod_strlist(ctx, &mods, "description", prt->description);
+ ads_mod_strlist(ctx, &mods, "description", (const char **)prt->description);
ads_mod_str(ctx, &mods, "assetNumber",prt->assetNumber);
ads_mod_str(ctx, &mods, "bytesPerMinute",prt->bytesPerMinute);
ads_mod_str(ctx, &mods, "defaultPriority",prt->defaultPriority);
@@ -93,10 +93,10 @@ ADS_STATUS ads_mod_printer_entry(ADS_STRUCT *ads, char *prt_dn,
prt->operatingSystemVersion);
ads_mod_str(ctx, &mods, "physicalLocationObject",
prt->physicalLocationObject);
- ads_mod_strlist(ctx, &mods, "portName", prt->portName);
+ ads_mod_strlist(ctx, &mods, "portName", (const char **)prt->portName);
ads_mod_str(ctx, &mods, "printStartTime", prt->printStartTime);
ads_mod_str(ctx, &mods, "printEndTime", prt->printEndTime);
- ads_mod_strlist(ctx, &mods, "printBinNames", prt->printBinNames);
+ ads_mod_strlist(ctx, &mods, "printBinNames", (const char **)prt->printBinNames);
/*... and many others */
/* do the ldap modify */
@@ -107,7 +107,6 @@ ADS_STATUS ads_mod_printer_entry(ADS_STRUCT *ads, char *prt_dn,
return status;
}
-
/*
add a printer to the directory
diff --git a/source3/libads/sasl.c b/source3/libads/sasl.c
index 16ad397d0e..7aa77bf2a2 100644
--- a/source3/libads/sasl.c
+++ b/source3/libads/sasl.c
@@ -36,7 +36,6 @@ static ADS_STATUS ads_sasl_spnego_ntlmssp_bind(ADS_STRUCT *ads)
uint32 neg_flags;
struct berval cred, *scred;
ADS_STATUS status;
- extern pstring global_myname;
int rc;
if (!ads->auth.password) {
@@ -97,7 +96,7 @@ static ADS_STATUS ads_sasl_spnego_ntlmssp_bind(ADS_STRUCT *ads)
nthash, 24,
lp_workgroup(),
ads->auth.user_name,
- global_myname,
+ global_myname(),
sess_key, 16,
neg_flags);
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index ee311932a7..584ad15174 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -44,8 +44,8 @@ static const struct {
Do an old lanman2 style session setup.
****************************************************************************/
-static BOOL cli_session_setup_lanman2(struct cli_state *cli, char *user,
- char *pass, int passlen, const char *workgroup)
+static BOOL cli_session_setup_lanman2(struct cli_state *cli, const char *user,
+ const char *pass, int passlen, const char *workgroup)
{
fstring pword;
char *p;
@@ -183,8 +183,8 @@ static BOOL cli_session_setup_guest(struct cli_state *cli)
Do a NT1 plaintext session setup.
****************************************************************************/
-static BOOL cli_session_setup_plaintext(struct cli_state *cli, char *user,
- char *pass, char *workgroup)
+static BOOL cli_session_setup_plaintext(struct cli_state *cli, const char *user,
+ const char *pass, const char *workgroup)
{
uint32 capabilities = cli_session_setup_capabilities(cli);
char *p;
@@ -228,7 +228,7 @@ static BOOL cli_session_setup_plaintext(struct cli_state *cli, char *user,
return True;
}
-static void set_signing_on_cli (struct cli_state *cli, char* pass, uint8 response[24])
+static void set_signing_on_cli (struct cli_state *cli, const char* pass, uint8 response[24])
{
uint8 zero_sig[8];
ZERO_STRUCT(zero_sig);
@@ -264,10 +264,10 @@ static void set_temp_signing_on_cli(struct cli_state *cli)
@param workgroup The user's domain.
****************************************************************************/
-static BOOL cli_session_setup_nt1(struct cli_state *cli, char *user,
- char *pass, int passlen,
- char *ntpass, int ntpasslen,
- char *workgroup)
+static BOOL cli_session_setup_nt1(struct cli_state *cli, const char *user,
+ const char *pass, int passlen,
+ const char *ntpass, int ntpasslen,
+ const char *workgroup)
{
uint32 capabilities = cli_session_setup_capabilities(cli);
uchar pword[24];
@@ -423,7 +423,7 @@ static DATA_BLOB cli_session_setup_blob(struct cli_state *cli, DATA_BLOB blob)
Do a spnego/kerberos encrypted session setup.
****************************************************************************/
-static BOOL cli_session_setup_kerberos(struct cli_state *cli, char *principal, char *workgroup)
+static BOOL cli_session_setup_kerberos(struct cli_state *cli, const char *principal, const char *workgroup)
{
DATA_BLOB blob2, negTokenTarg;
@@ -453,8 +453,8 @@ static BOOL cli_session_setup_kerberos(struct cli_state *cli, char *principal, c
Do a spnego/NTLMSSP encrypted session setup.
****************************************************************************/
-static BOOL cli_session_setup_ntlmssp(struct cli_state *cli, char *user,
- char *pass, char *workgroup)
+static BOOL cli_session_setup_ntlmssp(struct cli_state *cli, const char *user,
+ const char *pass, const char *workgroup)
{
DATA_BLOB msg1, struct_blob;
DATA_BLOB blob, chal1, chal2, auth, challenge_blob;
@@ -581,8 +581,8 @@ static BOOL cli_session_setup_ntlmssp(struct cli_state *cli, char *user,
Do a spnego encrypted session setup.
****************************************************************************/
-static BOOL cli_session_setup_spnego(struct cli_state *cli, char *user,
- char *pass, char *workgroup)
+static BOOL cli_session_setup_spnego(struct cli_state *cli, const char *user,
+ const char *pass, const char *workgroup)
{
char *principal;
char *OIDs[ASN1_MAX_OIDS];
@@ -646,10 +646,10 @@ ntlmssp:
****************************************************************************/
BOOL cli_session_setup(struct cli_state *cli,
- char *user,
- char *pass, int passlen,
- char *ntpass, int ntpasslen,
- char *workgroup)
+ const char *user,
+ const char *pass, int passlen,
+ const char *ntpass, int ntpasslen,
+ const char *workgroup)
{
char *p;
fstring user2;
@@ -1130,8 +1130,8 @@ BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip)
Initialise client credentials for authenticated pipe access.
****************************************************************************/
-static void init_creds(struct ntuser_creds *creds, char* username,
- char* domain, char* password)
+static void init_creds(struct ntuser_creds *creds, const char* username,
+ const char* domain, const char* password)
{
ZERO_STRUCTP(creds);
@@ -1163,9 +1163,9 @@ NTSTATUS cli_full_connection(struct cli_state **output_cli,
const char *my_name,
const char *dest_host,
struct in_addr *dest_ip, int port,
- char *service, char *service_type,
- char *user, char *domain,
- char *password, int flags,
+ const char *service, const char *service_type,
+ const char *user, const char *domain,
+ const char *password, int flags,
BOOL *retry)
{
struct ntuser_creds creds;
@@ -1174,13 +1174,12 @@ NTSTATUS cli_full_connection(struct cli_state **output_cli,
struct nmb_name called;
struct cli_state *cli;
struct in_addr ip;
- extern pstring global_myname;
if (retry)
*retry = False;
if (!my_name)
- my_name = global_myname;
+ my_name = global_myname();
if (!(cli = cli_initialise(NULL)))
return NT_STATUS_NO_MEMORY;
@@ -1258,7 +1257,7 @@ again:
if (service) {
if (!cli_send_tconX(cli, service, service_type,
- (char*)password, strlen(password)+1)) {
+ password, strlen(password)+1)) {
DEBUG(1,("failed tcon_X with %s\n", nt_errstr(nt_status)));
nt_status = cli_nt_error(cli);
cli_shutdown(cli);
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 8fdf145625..5c3d942b90 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -471,7 +471,8 @@ BOOL getlmhostsent( XFILE *fp, pstring name, int *name_type, struct in_addr *ipa
while(!x_feof(fp) && !x_ferror(fp)) {
pstring ip,flags,extra;
- char *ptr;
+ const char *ptr;
+ char *ptr1;
int count = 0;
*name_type = -1;
@@ -524,20 +525,20 @@ BOOL getlmhostsent( XFILE *fp, pstring name, int *name_type, struct in_addr *ipa
/* Extra feature. If the name ends in '#XX', where XX is a hex number,
then only add that name type. */
- if((ptr = strchr_m(name, '#')) != NULL)
+ if((ptr1 = strchr_m(name, '#')) != NULL)
{
char *endptr;
- ptr++;
- *name_type = (int)strtol(ptr, &endptr, 16);
+ ptr1++;
+ *name_type = (int)strtol(ptr1, &endptr, 16);
- if(!*ptr || (endptr == ptr))
+ if(!*ptr1 || (endptr == ptr1))
{
DEBUG(0,("getlmhostsent: invalid name %s containing '#'.\n", name));
continue;
}
- *(--ptr) = '\0'; /* Truncate at the '#' */
+ *(--ptr1) = '\0'; /* Truncate at the '#' */
}
return True;
@@ -787,7 +788,7 @@ static BOOL internal_resolve_name(const char *name, int name_type,
{
pstring name_resolve_list;
fstring tok;
- char *ptr;
+ const char *ptr;
BOOL allones = (strcmp(name,"255.255.255.255") == 0);
BOOL allzeros = (strcmp(name,"0.0.0.0") == 0);
BOOL is_address = is_ipaddress(name);
@@ -1242,7 +1243,7 @@ BOOL get_dc_list(const char *domain, struct in_addr **ip_list, int *count)
*/
if (strequal(domain, lp_workgroup())) {
- char *p;
+ const char *p;
char *pserver = lp_passwordserver();
fstring name;
int num_adresses = 0;
diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c
index ba0d8cee5d..43e32aebbd 100644
--- a/source3/libsmb/nmblib.c
+++ b/source3/libsmb/nmblib.c
@@ -28,14 +28,14 @@ static const struct opcode_names {
char *nmb_opcode_name;
int opcode;
} nmb_header_opcode_names[] = {
- {"Query", 0 },
- {"Registration", 5 },
- {"Release", 6 },
- {"WACK", 7 },
- {"Refresh", 8 },
- {"Refresh(altcode)", 9 },
- {"Multi-homed Registration", 15 },
- {0, -1 }
+ {"Query", 0 },
+ {"Registration", 5 },
+ {"Release", 6 },
+ {"WACK", 7 },
+ {"Refresh", 8 },
+ {"Refresh(altcode)", 9 },
+ {"Multi-homed Registration", 15 },
+ {0, -1 }
};
/****************************************************************************
@@ -814,15 +814,15 @@ static int build_dgram(char *buf,struct packet_struct *p)
}
/*******************************************************************
- build a nmb name
- *******************************************************************/
+ Build a nmb name
+*******************************************************************/
+
void make_nmb_name( struct nmb_name *n, const char *name, int type)
{
- extern pstring global_scope;
memset( (char *)n, '\0', sizeof(struct nmb_name) );
push_ascii(n->name, name, 16, STR_TERMINATE|STR_UPPER);
n->name_type = (unsigned int)type & 0xFF;
- StrnCpy( n->scope, global_scope, 63 );
+ StrnCpy( n->scope, global_scope(), 63 );
strupper( n->scope );
}
@@ -1180,7 +1180,6 @@ int name_mangle( char *In, char *Out, char name_type )
int len;
char buf[20];
char *p = Out;
- extern pstring global_scope;
/* Safely copy the input string, In, into buf[]. */
(void)memset( buf, 0, 20 );
@@ -1204,9 +1203,9 @@ int name_mangle( char *In, char *Out, char name_type )
p[0] = '\0';
/* Add the scope string. */
- for( i = 0, len = 0; NULL != global_scope; i++, len++ )
+ for( i = 0, len = 0; NULL != global_scope(); i++, len++ )
{
- switch( global_scope[i] )
+ switch( (global_scope())[i] )
{
case '\0':
p[0] = len;
@@ -1219,7 +1218,7 @@ int name_mangle( char *In, char *Out, char name_type )
len = -1;
break;
default:
- p[len+1] = global_scope[i];
+ p[len+1] = (global_scope())[i];
break;
}
}
diff --git a/source3/libsmb/passchange.c b/source3/libsmb/passchange.c
index b96bdc95a1..41b6095520 100644
--- a/source3/libsmb/passchange.c
+++ b/source3/libsmb/passchange.c
@@ -20,9 +20,6 @@
#include "includes.h"
-
-extern pstring global_myname;
-
/*************************************************************
change a password on a remote machine using IPC calls
*************************************************************/
@@ -50,7 +47,7 @@ BOOL remote_password_change(const char *remote_machine, const char *user_name,
return False;
}
- make_nmb_name(&calling, global_myname , 0x0);
+ make_nmb_name(&calling, global_myname() , 0x0);
make_nmb_name(&called , remote_machine, 0x20);
if (!cli_session_request(&cli, &calling, &called)) {
diff --git a/source3/libsmb/pwd_cache.c b/source3/libsmb/pwd_cache.c
index fc0602507a..7ddcf853c4 100644
--- a/source3/libsmb/pwd_cache.c
+++ b/source3/libsmb/pwd_cache.c
@@ -41,7 +41,7 @@ static void pwd_init(struct pwd_info *pwd)
Makes lm and nt hashed passwords.
****************************************************************************/
-static void pwd_make_lm_nt_16(struct pwd_info *pwd, char *clr)
+static void pwd_make_lm_nt_16(struct pwd_info *pwd, const char *clr)
{
pstring dos_passwd;
@@ -59,7 +59,7 @@ static void pwd_make_lm_nt_16(struct pwd_info *pwd, char *clr)
Stores a cleartext password.
****************************************************************************/
-void pwd_set_cleartext(struct pwd_info *pwd, char *clr)
+void pwd_set_cleartext(struct pwd_info *pwd, const char *clr)
{
pwd_init(pwd);
push_ascii_fstring(pwd->password, clr);
@@ -138,13 +138,3 @@ void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], uchar nt_owf[24])
if (nt_owf != NULL)
memcpy(nt_owf, pwd->smb_nt_owf, 24);
}
-
-
-
-
-
-
-
-
-
-
diff --git a/source3/libsmb/trust_passwd.c b/source3/libsmb/trust_passwd.c
index 4d7acd1988..cf9fd58b13 100644
--- a/source3/libsmb/trust_passwd.c
+++ b/source3/libsmb/trust_passwd.c
@@ -20,8 +20,6 @@
#include "includes.h"
-extern pstring global_myname;
-
/*********************************************************
Change the domain password on the PDC.
@@ -45,7 +43,7 @@ static NTSTATUS just_change_the_password(struct cli_state *cli, TALLOC_CTX *mem_
return result;
}
- result = cli_net_srv_pwset(cli, mem_ctx, global_myname, new_trust_passwd_hash);
+ result = cli_net_srv_pwset(cli, mem_ctx, global_myname(), new_trust_passwd_hash);
if (!NT_STATUS_IS_OK(result)) {
DEBUG(0,("just_change_the_password: unable to change password (%s)!\n",
@@ -99,7 +97,7 @@ NTSTATUS trust_pw_change_and_store_it(struct cli_state *cli, TALLOC_CTX *mem_ctx
**********************************************************/
NTSTATUS trust_pw_find_change_and_store_it(struct cli_state *cli, TALLOC_CTX *mem_ctx,
- char *domain)
+ const char *domain)
{
unsigned char old_trust_passwd_hash[16];
char *up_domain;
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 50730d40f3..5987d70a45 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -27,10 +27,6 @@ int ClientNMB = -1;
int ClientDGRAM = -1;
int global_nmb_port = -1;
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-extern char **my_netbios_names;
-
extern BOOL global_in_nmbd;
/* are we running as a daemon ? */
@@ -565,98 +561,6 @@ static BOOL open_sockets(BOOL isdaemon, int port)
}
/**************************************************************************** **
- Initialise connect, service and file structs.
- **************************************************************************** */
-
-static BOOL init_structs(void)
-{
- extern fstring local_machine;
- char *p, **ptr;
- int namecount;
- int n;
- int nodup;
- char *nbname;
-
- if (! *global_myname)
- {
- fstrcpy( global_myname, myhostname() );
- p = strchr_m( global_myname, '.' );
- if (p)
- *p = 0;
- }
- strupper( global_myname );
-
- /* Add any NETBIOS name aliases. Ensure that the first entry
- is equal to global_myname.
- */
- /* Work out the max number of netbios aliases that we have */
- ptr = lp_netbios_aliases();
- namecount = 0;
- if (ptr)
- for( ; *ptr; namecount++,ptr++ )
- ;
- if ( *global_myname )
- namecount++;
-
- /* Allocate space for the netbios aliases */
- my_netbios_names = (char **)malloc( sizeof(char *) * (namecount+1) );
- if( NULL == my_netbios_names )
- {
- DEBUG( 0, ( "init_structs: malloc fail.\n" ) );
- return( False );
- }
-
- /* Use the global_myname string first */
- namecount=0;
- if ( *global_myname )
- my_netbios_names[namecount++] = global_myname;
-
- ptr = lp_netbios_aliases();
- if (ptr)
- {
- while ( *ptr )
- {
- nbname = strdup(*ptr);
- if (nbname == NULL)
- {
- DEBUG(0,("init_structs: malloc fail when allocating names.\n"));
- return False;
- }
- strupper( nbname );
- /* Look for duplicates */
- nodup=1;
- for( n=0; n<namecount; n++ )
- {
- if( 0 == strcmp( nbname, my_netbios_names[n] ) )
- nodup=0;
- }
- if (nodup)
- my_netbios_names[namecount++] = nbname;
- else
- SAFE_FREE(nbname);
-
- ptr++;
- }
- }
-
- /* Terminate name list */
- my_netbios_names[namecount++] = NULL;
-
- fstrcpy( local_machine, global_myname );
- trim_string( local_machine, " ", " " );
- p = strchr_m( local_machine, ' ' );
- if (p)
- *p = 0;
- strlower( local_machine );
-
- DEBUG( 5, ("Netbios name list:-\n") );
- for( n=0; my_netbios_names[n]; n++ )
- DEBUGADD( 5, ( "my_netbios_names[%d]=\"%s\"\n", n, my_netbios_names[n] ) );
-
- return( True );
-}
-
-/**************************************************************************** **
main program
**************************************************************************** */
int main(int argc, const char *argv[])
@@ -727,14 +631,12 @@ static BOOL init_structs(void)
if ( !reload_nmbd_services(False) )
return(-1);
- if(!init_structs())
+ if(!init_names())
return -1;
reload_nmbd_services( True );
- fstrcpy( global_myworkgroup, lp_workgroup() );
-
- if (strequal(global_myworkgroup,"*"))
+ if (strequal(lp_workgroup(),"*"))
{
DEBUG(0,("ERROR: a workgroup name of * is no longer supported\n"));
exit(1);
diff --git a/source3/nmbd/nmbd_become_dmb.c b/source3/nmbd/nmbd_become_dmb.c
index ccc1f7e8ad..6b92f4c3c0 100644
--- a/source3/nmbd/nmbd_become_dmb.c
+++ b/source3/nmbd/nmbd_become_dmb.c
@@ -23,14 +23,11 @@
#include "includes.h"
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-extern char **my_netbios_names;
extern struct in_addr allones_ip;
extern uint16 samba_nb_type; /* Samba's NetBIOS type. */
-static void become_domain_master_browser_bcast(char *);
+static void become_domain_master_browser_bcast(const char *);
/****************************************************************************
Fail to become a Domain Master Browser on a subnet.
@@ -53,11 +50,11 @@ workgroup %s on subnet %s\n", fail_name->name, subrec->subnet_name));
/* Set the state back to DOMAIN_NONE. */
work->dom_state = DOMAIN_NONE;
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, global_myname())) == NULL)
{
DEBUG(0,("become_domain_master_fail: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, work->work_group, subrec->subnet_name));
+ global_myname(), work->work_group, subrec->subnet_name));
return;
}
@@ -92,11 +89,11 @@ workgroup %s on subnet %s\n", registered_name->name, subrec->subnet_name));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, global_myname())) == NULL)
{
DEBUG(0,("become_domain_master_stage2: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, registered_name->name, subrec->subnet_name));
+ global_myname(), registered_name->name, subrec->subnet_name));
work->dom_state = DOMAIN_NONE;
return;
}
@@ -112,7 +109,7 @@ in workgroup %s on subnet %s\n",
if( DEBUGLVL( 0 ) )
{
- dbgtext( "*****\n\nSamba server %s ", global_myname );
+ dbgtext( "*****\n\nSamba server %s ", global_myname() );
dbgtext( "is now a domain master browser for " );
dbgtext( "workgroup %s ", work->work_group );
dbgtext( "on subnet %s\n\n*****\n", subrec->subnet_name );
@@ -128,7 +125,7 @@ in workgroup %s on subnet %s\n",
will stop us syncing with ourself if we are also
a local master browser. */
- make_nmb_name(&nmbname, global_myname, 0x20);
+ make_nmb_name(&nmbname, global_myname(), 0x20);
work->dmb_name = nmbname;
/* Pick the first interface ip address as the domain master browser ip. */
@@ -266,7 +263,7 @@ querying WINS server for name %s.\n",
Attempt to become a domain master browser on all broadcast subnets.
****************************************************************************/
-static void become_domain_master_browser_bcast(char *workgroup_name)
+static void become_domain_master_browser_bcast(const char *workgroup_name)
{
struct subnet_record *subrec;
@@ -315,7 +312,7 @@ for domain master browser on workgroup %s\n", subrec->subnet_name, workgroup_nam
Attempt to become a domain master browser by registering with WINS.
****************************************************************************/
-static void become_domain_master_browser_wins(char *workgroup_name)
+static void become_domain_master_browser_wins(const char *workgroup_name)
{
struct work_record *work;
@@ -391,9 +388,9 @@ void add_domain_names(time_t t)
1.9.16p2 to 1.9.16p11 - due to a bug in namelogon.c,
cannot provide domain master / domain logon services.
*/
- become_domain_master_browser_wins(global_myworkgroup);
+ become_domain_master_browser_wins(lp_workgroup());
}
else
- become_domain_master_browser_bcast(global_myworkgroup);
+ become_domain_master_browser_bcast(lp_workgroup());
}
}
diff --git a/source3/nmbd/nmbd_become_lmb.c b/source3/nmbd/nmbd_become_lmb.c
index 3e0884567e..7b8ba14bb5 100644
--- a/source3/nmbd/nmbd_become_lmb.c
+++ b/source3/nmbd/nmbd_become_lmb.c
@@ -23,8 +23,6 @@
#include "includes.h"
-extern pstring global_myname;
-
extern uint16 samba_nb_type; /* Samba's NetBIOS name type. */
/*******************************************************************
@@ -89,11 +87,11 @@ subnet %s.\n", workgroup_name, subrec->subnet_name ));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, global_myname())) == NULL)
{
DEBUG(0,("reset_workgroup_state: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, work->work_group, subrec->subnet_name));
+ global_myname(), work->work_group, subrec->subnet_name));
work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE;
return;
}
@@ -153,7 +151,7 @@ static void unbecome_local_master_success(struct subnet_record *subrec,
if( DEBUGLVL( 0 ) )
{
dbgtext( "*****\n\n" );
- dbgtext( "Samba name server %s ", global_myname );
+ dbgtext( "Samba name server %s ", global_myname() );
dbgtext( "has stopped being a local master browser " );
dbgtext( "for workgroup %s ", released_name->name );
dbgtext( "on subnet %s\n\n*****\n", subrec->subnet_name );
@@ -188,7 +186,7 @@ Removing from namelist anyway.\n", nmb_namestr(fail_name)));
if( DEBUGLVL( 0 ) )
{
dbgtext( "*****\n\n" );
- dbgtext( "Samba name server %s ", global_myname );
+ dbgtext( "Samba name server %s ", global_myname() );
dbgtext( "has stopped being a local master browser " );
dbgtext( "for workgroup %s ", fail_name->name );
dbgtext( "on subnet %s\n\n*****\n", subrec->subnet_name );
@@ -285,11 +283,11 @@ void unbecome_local_master_browser(struct subnet_record *subrec, struct work_rec
DEBUG(2,("unbecome_local_master_browser: unbecoming local master for workgroup %s \
on subnet %s\n",work->work_group, subrec->subnet_name));
- if(find_server_in_workgroup( work, global_myname) == NULL)
+ if(find_server_in_workgroup( work, global_myname()) == NULL)
{
DEBUG(0,("unbecome_local_master_browser: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, work->work_group, subrec->subnet_name));
+ global_myname(), work->work_group, subrec->subnet_name));
work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE;
return;
}
@@ -346,11 +344,11 @@ workgroup %s on subnet %s\n", registered_name->name, subrec->subnet_name));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, global_myname())) == NULL)
{
DEBUG(0,("become_local_master_stage2: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, registered_name->name, subrec->subnet_name));
+ global_myname(), registered_name->name, subrec->subnet_name));
work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE;
return;
}
@@ -368,7 +366,7 @@ on subnet %s\n", work->work_group, subrec->subnet_name));
subrec->work_changed = True;
/* Add this name to the workgroup as local master browser. */
- set_workgroup_local_master_browser_name( work, global_myname);
+ set_workgroup_local_master_browser_name( work, global_myname());
/* Count the number of servers we have on our list. If it's
less than 10 (just a heuristic) request the servers
@@ -403,7 +401,7 @@ on subnet %s\n", work->work_group, subrec->subnet_name));
if( DEBUGLVL( 0 ) )
{
dbgtext( "*****\n\n" );
- dbgtext( "Samba name server %s ", global_myname );
+ dbgtext( "Samba name server %s ", global_myname() );
dbgtext( "is now a local master browser " );
dbgtext( "for workgroup %s ", work->work_group );
dbgtext( "on subnet %s\n\n*****\n", subrec->subnet_name );
@@ -493,11 +491,11 @@ workgroup %s on subnet %s\n", work_name, subrec->subnet_name));
return;
}
- if(find_server_in_workgroup(work, global_myname) == NULL)
+ if(find_server_in_workgroup(work, global_myname()) == NULL)
{
DEBUG(0,("become_local_master_fail1: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, work->work_group, subrec->subnet_name));
+ global_myname(), work->work_group, subrec->subnet_name));
return;
}
@@ -536,11 +534,11 @@ void become_local_master_browser(struct subnet_record *subrec, struct work_recor
return;
}
- if(find_server_in_workgroup( work, global_myname) == NULL)
+ if(find_server_in_workgroup( work, global_myname()) == NULL)
{
DEBUG(0,("become_local_master_browser: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, work->work_group, subrec->subnet_name));
+ global_myname(), work->work_group, subrec->subnet_name));
return;
}
@@ -583,7 +581,7 @@ in workgroup %s on subnet %s\n",
as the workgroup name.
****************************************************************/
-void set_workgroup_local_master_browser_name( struct work_record *work, char *newname)
+void set_workgroup_local_master_browser_name( struct work_record *work, const char *newname)
{
DEBUG(5,("set_workgroup_local_master_browser_name: setting local master name to '%s' \
for workgroup %s.\n", newname, work->work_group ));
diff --git a/source3/nmbd/nmbd_browsesync.c b/source3/nmbd/nmbd_browsesync.c
index 5dcc8cce19..3a20f07b05 100644
--- a/source3/nmbd/nmbd_browsesync.c
+++ b/source3/nmbd/nmbd_browsesync.c
@@ -24,9 +24,6 @@
#include "includes.h"
#include "smb.h"
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-
/* This is our local master browser list database. */
extern ubi_dlList lmb_browserlist[];
@@ -129,7 +126,7 @@ static void announce_local_master_browser_to_domain_master_browser( struct work_
SCVAL(p,0,ANN_MasterAnnouncement);
p++;
- StrnCpy(p,global_myname,15);
+ StrnCpy(p,global_myname(),15);
strupper(p);
p = skip_string(p,1);
@@ -142,7 +139,7 @@ static void announce_local_master_browser_to_domain_master_browser( struct work_
}
send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
- global_myname, 0x0, work->dmb_name.name, 0x0,
+ global_myname(), 0x0, work->dmb_name.name, 0x0,
work->dmb_addr, FIRST_SUBNET->myip, DGRAM_PORT);
}
@@ -611,12 +608,12 @@ void collect_all_workgroup_names_from_wins_server(time_t t)
return;
/* Check to see if we are a domain master browser on the unicast subnet. */
- if((work = find_workgroup_on_subnet( unicast_subnet, global_myworkgroup)) == NULL)
+ if((work = find_workgroup_on_subnet( unicast_subnet, lp_workgroup())) == NULL)
{
if( DEBUGLVL( 0 ) )
{
dbgtext( "collect_all_workgroup_names_from_wins_server:\n" );
- dbgtext( "Cannot find my workgroup %s ", global_myworkgroup );
+ dbgtext( "Cannot find my workgroup %s ", lp_workgroup() );
dbgtext( "on subnet %s.\n", unicast_subnet->subnet_name );
}
return;
@@ -660,7 +657,7 @@ void sync_all_dmbs(time_t t)
/* Check to see if we are a domain master browser on the
unicast subnet. */
- work = find_workgroup_on_subnet(unicast_subnet, global_myworkgroup);
+ work = find_workgroup_on_subnet(unicast_subnet, lp_workgroup());
if (!work) return;
if (!AM_DOMAIN_MASTER_BROWSER(work))
@@ -671,14 +668,14 @@ void sync_all_dmbs(time_t t)
/* count how many syncs we might need to do */
for (work=unicast_subnet->workgrouplist; work; work = work->next) {
- if (strcmp(global_myworkgroup, work->work_group)) {
+ if (strcmp(lp_workgroup(), work->work_group)) {
count++;
}
}
/* sync with a probability of 1/count */
for (work=unicast_subnet->workgrouplist; work; work = work->next) {
- if (strcmp(global_myworkgroup, work->work_group)) {
+ if (strcmp(lp_workgroup(), work->work_group)) {
if (((unsigned)sys_random()) % count != 0) continue;
lastrun = t;
diff --git a/source3/nmbd/nmbd_elections.c b/source3/nmbd/nmbd_elections.c
index acff7a72e8..976abbed25 100644
--- a/source3/nmbd/nmbd_elections.c
+++ b/source3/nmbd/nmbd_elections.c
@@ -23,17 +23,14 @@
#include "includes.h"
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-
/* Election parameters. */
extern time_t StartupTime;
/****************************************************************************
Send an election datagram packet.
**************************************************************************/
-static void send_election_dgram(struct subnet_record *subrec, char *workgroup_name,
- uint32 criterion, int timeup,char *server_name)
+static void send_election_dgram(struct subnet_record *subrec, const char *workgroup_name,
+ uint32 criterion, int timeup,const char *server_name)
{
pstring outbuf;
char *p;
@@ -55,7 +52,7 @@ static void send_election_dgram(struct subnet_record *subrec, char *workgroup_na
p = skip_string(p,1);
send_mailslot(False, BROWSE_MAILSLOT, outbuf, PTR_DIFF(p,outbuf),
- global_myname, 0,
+ global_myname(), 0,
workgroup_name, 0x1e,
subrec->bcast_ip, subrec->myip, DGRAM_PORT);
}
@@ -92,7 +89,7 @@ static void check_for_master_browser_fail( struct subnet_record *subrec,
return;
}
- if (strequal(work->work_group, global_myworkgroup))
+ if (strequal(work->work_group, lp_workgroup()))
{
if (lp_local_master())
@@ -128,7 +125,7 @@ void check_master_browser_exists(time_t t)
{
static time_t lastrun=0;
struct subnet_record *subrec;
- char *workgroup_name = global_myworkgroup;
+ const char *workgroup_name = lp_workgroup();
if (!lastrun)
lastrun = t;
@@ -198,7 +195,7 @@ yet registered on subnet %s\n", nmb_namestr(&nmbname), subrec->subnet_name ));
}
send_election_dgram(subrec, work->work_group, work->ElectionCriterion,
- t - StartupTime, global_myname);
+ t - StartupTime, global_myname());
if (work->ElectionCount++ >= 4)
{
@@ -238,7 +235,7 @@ static BOOL win_election(struct work_record *work, int version,
version, ELECTION_VERSION,
criterion, mycriterion,
timeup, mytimeup,
- server_name, global_myname));
+ server_name, global_myname()));
if (version > ELECTION_VERSION)
return(False);
@@ -255,7 +252,7 @@ static BOOL win_election(struct work_record *work, int version,
if (timeup < mytimeup)
return(True);
- if (strcasecmp(global_myname, server_name) > 0)
+ if (strcasecmp(global_myname(), server_name) > 0)
return(False);
return(True);
@@ -290,7 +287,7 @@ void process_election(struct subnet_record *subrec, struct packet_struct *p, cha
goto done;
}
- if (!strequal(work->work_group, global_myworkgroup))
+ if (!strequal(work->work_group, lp_workgroup()))
{
DEBUG(3,("process_election: ignoring election request for workgroup %s on subnet %s as this \
is not my workgroup.\n", work->work_group, subrec->subnet_name ));
@@ -396,7 +393,7 @@ void nmbd_message_election(int msg_type, pid_t src, void *buf, size_t len)
for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec)) {
struct work_record *work;
for (work = subrec->workgrouplist; work; work = work->next) {
- if (strequal(work->work_group, global_myworkgroup)) {
+ if (strequal(work->work_group, lp_workgroup())) {
work->needelection = True;
work->ElectionCount=0;
work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE;
diff --git a/source3/nmbd/nmbd_incomingdgrams.c b/source3/nmbd/nmbd_incomingdgrams.c
index 261200b4c5..cd6954fc62 100644
--- a/source3/nmbd/nmbd_incomingdgrams.c
+++ b/source3/nmbd/nmbd_incomingdgrams.c
@@ -23,8 +23,6 @@
#include "includes.h"
-extern pstring global_myname;
-extern fstring global_myworkgroup;
extern BOOL found_lm_clients;
#if 0
@@ -104,7 +102,7 @@ void process_host_announce(struct subnet_record *subrec, struct packet_struct *p
char *comment = buf+31;
struct work_record *work;
struct server_record *servrec;
- char *work_name;
+ const char *work_name;
char *source_name = dgram->source_name.name;
START_PROFILE(host_announce);
@@ -141,8 +139,8 @@ void process_host_announce(struct subnet_record *subrec, struct packet_struct *p
* to be our primary workgroup name.
*/
- if(strequal(work_name, global_myname))
- work_name = global_myworkgroup;
+ if(strequal(work_name, global_myname()))
+ work_name = lp_workgroup();
/*
* We are being very agressive here in adding a workgroup
@@ -396,10 +394,10 @@ master - ignoring master announce.\n"));
goto done;
}
- if((work = find_workgroup_on_subnet(subrec, global_myworkgroup)) == NULL)
+ if((work = find_workgroup_on_subnet(subrec, lp_workgroup())) == NULL)
{
DEBUG(0,("process_master_browser_announce: Cannot find workgroup %s on subnet %s\n",
- global_myworkgroup, subrec->subnet_name));
+ lp_workgroup(), subrec->subnet_name));
goto done;
}
@@ -439,7 +437,7 @@ void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct
char *announce_name = buf+9;
struct work_record *work;
struct server_record *servrec;
- char *work_name;
+ const char *work_name;
char *source_name = dgram->source_name.name;
pstring comment;
char *s = buf+9;
@@ -489,8 +487,8 @@ originate from OS/2 Warp client. Ignoring packet.\n"));
* not needed in the LanMan announce code, but it won't hurt.
*/
- if(strequal(work_name, global_myname))
- work_name = global_myworkgroup;
+ if(strequal(work_name, global_myname()))
+ work_name = lp_workgroup();
/*
* We are being very agressive here in adding a workgroup
@@ -580,7 +578,7 @@ static void send_backup_list_response(struct subnet_record *subrec,
/* We always return at least one name - our own. */
count = 1;
- StrnCpy(p,global_myname,15);
+ StrnCpy(p,global_myname(),15);
strupper(p);
p = skip_string(p,1);
@@ -605,7 +603,7 @@ static void send_backup_list_response(struct subnet_record *subrec,
if(count >= (unsigned int)max_number_requested)
break;
- if(strnequal(servrec->serv.name, global_myname,15))
+ if(strnequal(servrec->serv.name, global_myname(),15))
continue;
if(!(servrec->serv.type & SV_TYPE_BACKUP_BROWSER))
@@ -629,7 +627,7 @@ static void send_backup_list_response(struct subnet_record *subrec,
send_mailslot(True, BROWSE_MAILSLOT,
outbuf,PTR_DIFF(p,outbuf),
- global_myname, 0,
+ global_myname(), 0,
send_to_name->name,0,
sendto_ip, subrec->myip, port);
}
@@ -664,7 +662,7 @@ void process_get_backup_list_request(struct subnet_record *subrec,
for the requested workgroup. That means it must be our
workgroup. */
- if(strequal(workgroup_name, global_myworkgroup) == False)
+ if(strequal(workgroup_name, lp_workgroup()) == False)
{
DEBUG(7,("process_get_backup_list_request: Ignoring announce request for workgroup %s.\n",
workgroup_name));
@@ -801,7 +799,7 @@ void process_announce_request(struct subnet_record *subrec, struct packet_struct
nmb_namestr(&dgram->dest_name)));
/* We only send announcement requests on our workgroup. */
- if(strequal(workgroup_name, global_myworkgroup) == False)
+ if(strequal(workgroup_name, lp_workgroup()) == False)
{
DEBUG(7,("process_announce_request: Ignoring announce request for workgroup %s.\n",
workgroup_name));
@@ -840,7 +838,7 @@ void process_lm_announce_request(struct subnet_record *subrec, struct packet_str
nmb_namestr(&dgram->dest_name)));
/* We only send announcement requests on our workgroup. */
- if(strequal(workgroup_name, global_myworkgroup) == False)
+ if(strequal(workgroup_name, lp_workgroup()) == False)
{
DEBUG(7,("process_lm_announce_request: Ignoring announce request for workgroup %s.\n",
workgroup_name));
diff --git a/source3/nmbd/nmbd_incomingrequests.c b/source3/nmbd/nmbd_incomingrequests.c
index 834f237a2c..a8168566f1 100644
--- a/source3/nmbd/nmbd_incomingrequests.c
+++ b/source3/nmbd/nmbd_incomingrequests.c
@@ -27,8 +27,6 @@
#include "includes.h"
-extern fstring global_myworkgroup;
-
/****************************************************************************
Send a name release response.
**************************************************************************/
@@ -100,7 +98,7 @@ subnet %s from owner IP %s\n",
* names and *don't set the group bit* !!!!!
*/
- if( !group && !ismyip(owner_ip) && strequal(question->name, global_myworkgroup) &&
+ if( !group && !ismyip(owner_ip) && strequal(question->name, lp_workgroup()) &&
((question->name_type == 0x0) || (question->name_type == 0x1e)))
{
DEBUG(6,("process_name_release_request: FTP OnNet bug workaround. Ignoring \
@@ -292,20 +290,19 @@ We put our own names first, then in alphabetical order.
static int status_compare(char *n1,char *n2)
{
- extern pstring global_myname;
int l1,l2,l3;
/* It's a bit tricky because the names are space padded */
for (l1=0;l1<15 && n1[l1] && n1[l1] != ' ';l1++) ;
for (l2=0;l2<15 && n2[l2] && n2[l2] != ' ';l2++) ;
- l3 = strlen(global_myname);
+ l3 = strlen(global_myname());
- if ((l1==l3) && strncmp(n1,global_myname,l3) == 0 &&
- (l2!=l3 || strncmp(n2,global_myname,l3) != 0))
+ if ((l1==l3) && strncmp(n1,global_myname(),l3) == 0 &&
+ (l2!=l3 || strncmp(n2,global_myname(),l3) != 0))
return -1;
- if ((l2==l3) && strncmp(n2,global_myname,l3) == 0 &&
- (l1!=l3 || strncmp(n1,global_myname,l3) != 0))
+ if ((l2==l3) && strncmp(n2,global_myname(),l3) == 0 &&
+ (l1!=l3 || strncmp(n1,global_myname(),l3) != 0))
return 1;
return memcmp(n1,n2,18);
diff --git a/source3/nmbd/nmbd_logonnames.c b/source3/nmbd/nmbd_logonnames.c
index 28e0e8a02b..b73586aa45 100644
--- a/source3/nmbd/nmbd_logonnames.c
+++ b/source3/nmbd/nmbd_logonnames.c
@@ -23,9 +23,6 @@
#include "includes.h"
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-extern char **my_netbios_names;
extern struct in_addr allones_ip;
extern uint16 samba_nb_type; /* Samba's NetBIOS type. */
@@ -47,11 +44,11 @@ workgroup %s on subnet %s\n", fail_name->name, subrec->subnet_name));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, global_myname())) == NULL)
{
DEBUG(0,("become_logon_server_fail: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, fail_name->name, subrec->subnet_name));
+ global_myname(), fail_name->name, subrec->subnet_name));
work->log_state = LOGON_NONE;
return;
}
@@ -87,11 +84,11 @@ workgroup %s on subnet %s\n", registered_name->name, subrec->subnet_name));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, global_myname())) == NULL)
{
DEBUG(0,("become_logon_server_success: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, registered_name->name, subrec->subnet_name));
+ global_myname(), registered_name->name, subrec->subnet_name));
work->log_state = LOGON_NONE;
return;
}
@@ -115,7 +112,7 @@ in workgroup %s on subnet %s\n",
*/
{
struct nmb_name nmbname;
- make_nmb_name(&nmbname,global_myworkgroup,0x1c);
+ make_nmb_name(&nmbname,lp_workgroup(),0x1c);
insert_permanent_name_into_unicast(subrec, &nmbname, 0x1c);
}
@@ -152,12 +149,12 @@ void add_logon_names(void)
for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec))
{
- struct work_record *work = find_workgroup_on_subnet(subrec, global_myworkgroup);
+ struct work_record *work = find_workgroup_on_subnet(subrec, lp_workgroup());
if (work && (work->log_state == LOGON_NONE))
{
struct nmb_name nmbname;
- make_nmb_name(&nmbname,global_myworkgroup,0x1c);
+ make_nmb_name(&nmbname,lp_workgroup(),0x1c);
if (find_name_on_subnet(subrec, &nmbname, FIND_SELF_NAME) == NULL)
{
@@ -165,7 +162,7 @@ void add_logon_names(void)
{
dbgtext( "add_domain_logon_names:\n" );
dbgtext( "Attempting to become logon server " );
- dbgtext( "for workgroup %s ", global_myworkgroup );
+ dbgtext( "for workgroup %s ", lp_workgroup() );
dbgtext( "on subnet %s\n", subrec->subnet_name );
}
become_logon_server(subrec, work);
diff --git a/source3/nmbd/nmbd_mynames.c b/source3/nmbd/nmbd_mynames.c
index ba7d509a77..dd66821839 100644
--- a/source3/nmbd/nmbd_mynames.c
+++ b/source3/nmbd/nmbd_mynames.c
@@ -23,9 +23,6 @@
#include "includes.h"
-extern char **my_netbios_names;
-extern fstring global_myworkgroup;
-
extern uint16 samba_nb_type; /* Samba's NetBIOS type. */
/****************************************************************************
@@ -51,10 +48,10 @@ void register_my_workgroup_one_subnet(struct subnet_record *subrec)
struct work_record *work;
/* Create the workgroup on the subnet. */
- if((work = create_workgroup_on_subnet(subrec, global_myworkgroup,
+ if((work = create_workgroup_on_subnet(subrec, lp_workgroup(),
PERMANENT_TTL)) == NULL) {
DEBUG(0,("register_my_workgroup_and_names: Failed to create my workgroup %s on subnet %s. \
-Exiting.\n", global_myworkgroup, subrec->subnet_name));
+Exiting.\n", lp_workgroup(), subrec->subnet_name));
return;
}
@@ -63,14 +60,14 @@ Exiting.\n", global_myworkgroup, subrec->subnet_name));
add_samba_names_to_subnet(subrec);
/* Register all our names including aliases. */
- for (i=0; my_netbios_names[i]; i++) {
- register_name(subrec, my_netbios_names[i],0x20,samba_nb_type,
+ for (i=0; my_netbios_names(i); i++) {
+ register_name(subrec, my_netbios_names(i),0x20,samba_nb_type,
NULL,
my_name_register_failed, NULL);
- register_name(subrec, my_netbios_names[i],0x03,samba_nb_type,
+ register_name(subrec, my_netbios_names(i),0x03,samba_nb_type,
NULL,
my_name_register_failed, NULL);
- register_name(subrec, my_netbios_names[i],0x00,samba_nb_type,
+ register_name(subrec, my_netbios_names(i),0x00,samba_nb_type,
NULL,
my_name_register_failed, NULL);
}
@@ -133,7 +130,7 @@ BOOL register_my_workgroup_and_names(void)
add_samba_names_to_subnet(unicast_subnet);
- for (i=0; my_netbios_names[i]; i++)
+ for (i=0; my_netbios_names(i); i++)
{
for(subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec))
{
@@ -142,13 +139,13 @@ BOOL register_my_workgroup_and_names(void)
*/
struct nmb_name nmbname;
- make_nmb_name(&nmbname, my_netbios_names[i],0x20);
+ make_nmb_name(&nmbname, my_netbios_names(i),0x20);
insert_refresh_name_into_unicast(subrec, &nmbname, samba_nb_type);
- make_nmb_name(&nmbname, my_netbios_names[i],0x3);
+ make_nmb_name(&nmbname, my_netbios_names(i),0x3);
insert_refresh_name_into_unicast(subrec, &nmbname, samba_nb_type);
- make_nmb_name(&nmbname, my_netbios_names[i],0x0);
+ make_nmb_name(&nmbname, my_netbios_names(i),0x0);
insert_refresh_name_into_unicast(subrec, &nmbname, samba_nb_type);
}
}
@@ -165,10 +162,10 @@ BOOL register_my_workgroup_and_names(void)
*/
struct nmb_name nmbname;
- make_nmb_name(&nmbname, global_myworkgroup, 0x0);
+ make_nmb_name(&nmbname, lp_workgroup(), 0x0);
insert_refresh_name_into_unicast(subrec, &nmbname, samba_nb_type|NB_GROUP);
- make_nmb_name(&nmbname, global_myworkgroup, 0x1e);
+ make_nmb_name(&nmbname, lp_workgroup(), 0x1e);
insert_refresh_name_into_unicast(subrec, &nmbname, samba_nb_type|NB_GROUP);
}
diff --git a/source3/nmbd/nmbd_namelistdb.c b/source3/nmbd/nmbd_namelistdb.c
index bca79ef0c8..7ff2d4171e 100644
--- a/source3/nmbd/nmbd_namelistdb.c
+++ b/source3/nmbd/nmbd_namelistdb.c
@@ -23,8 +23,6 @@
#include "includes.h"
-extern char **my_netbios_names;
-
uint16 samba_nb_type = 0; /* samba's NetBIOS name type */
@@ -215,7 +213,7 @@ struct name_record *add_name_to_subnet( struct subnet_record *subrec,
namerec->data.wins_flags = WINS_ACTIVE;
/* If it's our primary name, flag it as so. */
- if( strequal( my_netbios_names[0], name ) )
+ if( strequal( my_netbios_names(0), name ) )
namerec->data.nb_flags |= NB_PERM;
/* Copy the IPs. */
diff --git a/source3/nmbd/nmbd_nameregister.c b/source3/nmbd/nmbd_nameregister.c
index b6d3c20d99..7bf2584053 100644
--- a/source3/nmbd/nmbd_nameregister.c
+++ b/source3/nmbd/nmbd_nameregister.c
@@ -23,8 +23,6 @@
#include "includes.h"
-extern fstring global_myworkgroup;
-
/* forward declarations */
static void wins_next_registration(struct response_record *rrec);
@@ -87,7 +85,7 @@ static void register_name_response(struct subnet_record *subrec,
*/
#if 1 /* OLD_SAMBA_SERVER_HACK */
- if((nmb->header.rcode == ACT_ERR) && strequal(global_myworkgroup, answer_name->name) &&
+ if((nmb->header.rcode == ACT_ERR) && strequal(lp_workgroup(), answer_name->name) &&
(answer_name->name_type == 0x1b)) {
/* Pretend we did not get this. */
rrec->num_msgs--;
@@ -463,7 +461,7 @@ static void multihomed_register_name(struct nmb_name *nmbname, uint16 nb_flags,
Try and register one of our names.
****************************************************************************/
void register_name(struct subnet_record *subrec,
- char *name, int type, uint16 nb_flags,
+ const char *name, int type, uint16 nb_flags,
register_name_success_function success_fn,
register_name_fail_function fail_fn,
struct userdata_struct *userdata)
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c
index d252b98ed6..894f6bb7d6 100644
--- a/source3/nmbd/nmbd_packets.c
+++ b/source3/nmbd/nmbd_packets.c
@@ -1080,15 +1080,14 @@ static void process_browse_packet(struct packet_struct *p, char *buf,int len)
struct dgram_packet *dgram = &p->packet.dgram;
int command = CVAL(buf,0);
struct subnet_record *subrec = find_subnet_for_dgram_browse_packet(p);
- extern pstring global_scope;
/* Drop the packet if it's a different NetBIOS scope, or
the source is from one of our names. */
- if (!strequal(dgram->dest_name.scope, global_scope))
+ if (!strequal(dgram->dest_name.scope, global_scope()))
{
DEBUG(7,("process_browse_packet: Discarding datagram from IP %s. Scope (%s) \
-mismatch with our scope (%s).\n", inet_ntoa(p->ip), dgram->dest_name.scope, global_scope));
+mismatch with our scope (%s).\n", inet_ntoa(p->ip), dgram->dest_name.scope, global_scope()));
return;
}
@@ -1193,15 +1192,14 @@ static void process_lanman_packet(struct packet_struct *p, char *buf,int len)
struct dgram_packet *dgram = &p->packet.dgram;
int command = SVAL(buf,0);
struct subnet_record *subrec = find_subnet_for_dgram_browse_packet(p);
- extern pstring global_scope;
/* Drop the packet if it's a different NetBIOS scope, or
the source is from one of our names. */
- if (!strequal(dgram->dest_name.scope, global_scope))
+ if (!strequal(dgram->dest_name.scope, global_scope()))
{
DEBUG(7,("process_lanman_packet: Discarding datagram from IP %s. Scope (%s) \
-mismatch with our scope (%s).\n", inet_ntoa(p->ip), dgram->dest_name.scope, global_scope));
+mismatch with our scope (%s).\n", inet_ntoa(p->ip), dgram->dest_name.scope, global_scope()));
return;
}
@@ -1932,8 +1930,8 @@ BOOL listen_for_packets(BOOL run_election)
Construct and send a netbios DGRAM.
**************************************************************************/
BOOL send_mailslot(BOOL unique, char *mailslot,char *buf,int len,
- char *srcname, int src_type,
- char *dstname, int dest_type,
+ const char *srcname, int src_type,
+ const char *dstname, int dest_type,
struct in_addr dest_ip,struct in_addr src_ip,
int dest_port)
{
diff --git a/source3/nmbd/nmbd_processlogon.c b/source3/nmbd/nmbd_processlogon.c
index b65cebe203..6f2517f39f 100644
--- a/source3/nmbd/nmbd_processlogon.c
+++ b/source3/nmbd/nmbd_processlogon.c
@@ -27,9 +27,6 @@
#include "includes.h"
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-
struct sam_database_info {
uint32 index;
uint32 serial_lo, serial_hi;
@@ -93,8 +90,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
return;
}
- pstrcpy(my_name, global_myname);
- strupper(my_name);
+ pstrcpy(my_name, global_myname());
code = SVAL(buf,0);
DEBUG(1,("process_logon_packet: Logon from %s: code = 0x%x\n", inet_ntoa(p->ip), code));
@@ -131,7 +127,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
send_mailslot(True, getdc,
outbuf,PTR_DIFF(q,outbuf),
- global_myname, 0x0,
+ global_myname(), 0x0,
machine,
dgram->source_name.name_type,
p->ip, *iface_ip(p->ip), p->port);
@@ -198,7 +194,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
q = ALIGN2(q, outbuf);
q += dos_PutUniCode(q, my_name, sizeof(pstring), True); /* PDC name */
- q += dos_PutUniCode(q, global_myworkgroup,sizeof(pstring), True); /* Domain name*/
+ q += dos_PutUniCode(q, lp_workgroup(),sizeof(pstring), True); /* Domain name*/
SIVAL(q, 0, 1); /* our nt version */
SSVAL(q, 4, 0xffff); /* our lmnttoken */
SSVAL(q, 6, 0xffff); /* our lm20token */
@@ -209,7 +205,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
DEBUG(3,("process_logon_packet: GETDC request from %s at IP %s, \
reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
- machine,inet_ntoa(p->ip), reply_name, global_myworkgroup,
+ machine,inet_ntoa(p->ip), reply_name, lp_workgroup(),
QUERYFORPDC_R, (uint32)ntversion, (uint32)lmnttoken,
(uint32)lm20token ));
@@ -217,7 +213,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
send_mailslot(True, getdc,
outbuf,PTR_DIFF(q,outbuf),
- global_myname, 0x0,
+ global_myname(), 0x0,
dgram->source_name.name,
dgram->source_name.name_type,
p->ip, *iface_ip(p->ip), p->port);
@@ -280,7 +276,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
fstrcpy(reply_name+2,my_name);
DEBUG(3,("process_logon_packet: SAMLOGON request from %s(%s) for %s, returning logon svr %s domain %s code %x token=%x\n",
- asccomp,inet_ntoa(p->ip), ascuser, reply_name, global_myworkgroup,
+ asccomp,inet_ntoa(p->ip), ascuser, reply_name, lp_workgroup(),
SAMLOGON_R ,lmnttoken));
/* Construct reply. */
@@ -299,7 +295,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
q += dos_PutUniCode(q, reply_name,sizeof(pstring), True);
q += dos_PutUniCode(q, ascuser, sizeof(pstring), True);
- q += dos_PutUniCode(q, global_myworkgroup,sizeof(pstring), True);
+ q += dos_PutUniCode(q, lp_workgroup(),sizeof(pstring), True);
}
#ifdef HAVE_ADS
else {
@@ -345,7 +341,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
q += 2; /* it must follow the domain name. */
/* Push dns host name */
- size = push_ascii(&q[1], global_myname, -1, 0);
+ size = push_ascii(&q[1], global_myname(), -1, 0);
SCVAL(q, 0, size);
q += (size + 1);
SSVAL(q, 0, 0x18c0); /* not sure what this is for, but */
@@ -397,7 +393,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
send_mailslot(True, getdc,
outbuf,PTR_DIFF(q,outbuf),
- global_myname, 0x0,
+ global_myname(), 0x0,
dgram->source_name.name,
dgram->source_name.name_type,
p->ip, *iface_ip(p->ip), p->port);
diff --git a/source3/nmbd/nmbd_sendannounce.c b/source3/nmbd/nmbd_sendannounce.c
index d4a7070042..de05ee973c 100644
--- a/source3/nmbd/nmbd_sendannounce.c
+++ b/source3/nmbd/nmbd_sendannounce.c
@@ -26,9 +26,6 @@
#include "includes.h"
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-extern char **my_netbios_names;
extern int updatecount;
extern BOOL found_lm_clients;
@@ -52,7 +49,7 @@ void send_browser_reset(int reset_type, char *to_name, int to_type, struct in_ad
p++;
send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
- global_myname, 0x0, to_name, to_type, to_ip,
+ global_myname(), 0x0, to_name, to_type, to_ip,
FIRST_SUBNET->myip, DGRAM_PORT);
}
@@ -78,10 +75,10 @@ to subnet %s\n", work->work_group, subrec->subnet_name));
SCVAL(p,0,work->token); /* (local) Unique workgroup token id. */
p++;
- p += push_string(NULL, p+1, global_myname, 15, STR_ASCII|STR_UPPER|STR_TERMINATE);
+ p += push_string(NULL, p+1, global_myname(), 15, STR_ASCII|STR_UPPER|STR_TERMINATE);
send_mailslot(False, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
- global_myname, 0x0, work->work_group,0x1e, subrec->bcast_ip,
+ global_myname(), 0x0, work->work_group,0x1e, subrec->bcast_ip,
subrec->myip, DGRAM_PORT);
}
@@ -90,9 +87,9 @@ to subnet %s\n", work->work_group, subrec->subnet_name));
**************************************************************************/
static void send_announcement(struct subnet_record *subrec, int announce_type,
- char *from_name, char *to_name, int to_type, struct in_addr to_ip,
+ const char *from_name, const char *to_name, int to_type, struct in_addr to_ip,
time_t announce_interval,
- char *server_name, int server_type, char *server_comment)
+ const char *server_name, int server_type, const char *server_comment)
{
pstring outbuf;
char *p;
@@ -168,14 +165,14 @@ static void send_local_master_announcement(struct subnet_record *subrec, struct
uint32 type = servrec->serv.type & ~SV_TYPE_LOCAL_LIST_ONLY;
DEBUG(3,("send_local_master_announcement: type %x for name %s on subnet %s for workgroup %s\n",
- type, global_myname, subrec->subnet_name, work->work_group));
+ type, global_myname(), subrec->subnet_name, work->work_group));
send_announcement(subrec, ANN_LocalMasterAnnouncement,
- global_myname, /* From nbt name. */
+ global_myname(), /* From nbt name. */
work->work_group, 0x1e, /* To nbt name. */
subrec->bcast_ip, /* To ip. */
work->announce_interval, /* Time until next announce. */
- global_myname, /* Name to announce. */
+ global_myname(), /* Name to announce. */
type, /* Type field. */
servrec->serv.comment);
}
@@ -190,13 +187,13 @@ static void send_workgroup_announcement(struct subnet_record *subrec, struct wor
subrec->subnet_name, work->work_group));
send_announcement(subrec, ANN_DomainAnnouncement,
- global_myname, /* From nbt name. */
+ global_myname(), /* From nbt name. */
MSBROWSE, 0x1, /* To nbt name. */
subrec->bcast_ip, /* To ip. */
work->announce_interval, /* Time until next announce. */
work->work_group, /* Name to announce. */
SV_TYPE_DOMAIN_ENUM|SV_TYPE_NT, /* workgroup announce flags. */
- global_myname); /* From name as comment. */
+ global_myname()); /* From name as comment. */
}
/****************************************************************************
@@ -255,7 +252,7 @@ static void announce_server(struct subnet_record *subrec, struct work_record *wo
/* Only do domain announcements if we are a master and it's
our primary name we're being asked to announce. */
- if (AM_LOCAL_MASTER_BROWSER(work) && strequal(global_myname,servrec->serv.name))
+ if (AM_LOCAL_MASTER_BROWSER(work) && strequal(global_myname(),servrec->serv.name))
{
send_local_master_announcement(subrec, work, servrec);
send_workgroup_announcement(subrec, work);
@@ -277,7 +274,7 @@ void announce_my_server_names(time_t t)
for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec))
{
- struct work_record *work = find_workgroup_on_subnet(subrec, global_myworkgroup);
+ struct work_record *work = find_workgroup_on_subnet(subrec, lp_workgroup());
if(work)
{
@@ -341,7 +338,7 @@ void announce_my_lm_server_names(time_t t)
for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec))
{
- struct work_record *work = find_workgroup_on_subnet(subrec, global_myworkgroup);
+ struct work_record *work = find_workgroup_on_subnet(subrec, lp_workgroup());
if(work)
{
@@ -483,7 +480,8 @@ void announce_my_servers_removed(void)
void announce_remote(time_t t)
{
- char *s,*ptr;
+ char *s;
+ const char *ptr;
static time_t last_time = 0;
pstring s2;
struct in_addr addr;
@@ -505,14 +503,17 @@ void announce_remote(time_t t)
{
/* The entries are of the form a.b.c.d/WORKGROUP with
WORKGROUP being optional */
- char *wgroup;
+ const char *wgroup;
+ char *pwgroup;
int i;
- wgroup = strchr_m(s2,'/');
- if (wgroup)
- *wgroup++ = 0;
- if (!wgroup || !*wgroup)
- wgroup = global_myworkgroup;
+ pwgroup = strchr_m(s2,'/');
+ if (pwgroup)
+ *pwgroup++ = 0;
+ if (!pwgroup || !*pwgroup)
+ wgroup = lp_workgroup();
+ else
+ wgroup = pwgroup;
addr = *interpret_addr2(s2);
@@ -520,9 +521,9 @@ void announce_remote(time_t t)
/* Give the ip address as the address of our first
broadcast subnet. */
- for(i=0; my_netbios_names[i]; i++)
+ for(i=0; my_netbios_names(i); i++)
{
- char *name = my_netbios_names[i];
+ const char *name = my_netbios_names(i);
DEBUG(5,("announce_remote: Doing remote announce for server %s to IP %s.\n",
name, inet_ntoa(addr) ));
@@ -546,7 +547,8 @@ void announce_remote(time_t t)
void browse_sync_remote(time_t t)
{
- char *s,*ptr;
+ char *s;
+ const char *ptr;
static time_t last_time = 0;
pstring s2;
struct in_addr addr;
@@ -568,17 +570,17 @@ void browse_sync_remote(time_t t)
* for our workgroup on the firsst subnet.
*/
- if((work = find_workgroup_on_subnet(FIRST_SUBNET, global_myworkgroup)) == NULL)
+ if((work = find_workgroup_on_subnet(FIRST_SUBNET, lp_workgroup())) == NULL)
{
DEBUG(0,("browse_sync_remote: Cannot find workgroup %s on subnet %s\n",
- global_myworkgroup, FIRST_SUBNET->subnet_name ));
+ lp_workgroup(), FIRST_SUBNET->subnet_name ));
return;
}
if(!AM_LOCAL_MASTER_BROWSER(work))
{
DEBUG(5,("browse_sync_remote: We can only do this if we are a local master browser \
-for workgroup %s on subnet %s.\n", global_myworkgroup, FIRST_SUBNET->subnet_name ));
+for workgroup %s on subnet %s.\n", lp_workgroup(), FIRST_SUBNET->subnet_name ));
return;
}
@@ -587,7 +589,7 @@ for workgroup %s on subnet %s.\n", global_myworkgroup, FIRST_SUBNET->subnet_name
SCVAL(p,0,ANN_MasterAnnouncement);
p++;
- StrnCpy(p,global_myname,15);
+ StrnCpy(p,global_myname(),15);
strupper(p);
p = skip_string(p,1);
@@ -597,9 +599,9 @@ for workgroup %s on subnet %s.\n", global_myworkgroup, FIRST_SUBNET->subnet_name
addr = *interpret_addr2(s2);
DEBUG(5,("announce_remote: Doing remote browse sync announce for server %s to IP %s.\n",
- global_myname, inet_ntoa(addr) ));
+ global_myname(), inet_ntoa(addr) ));
send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
- global_myname, 0x0, "*", 0x0, addr, FIRST_SUBNET->myip, DGRAM_PORT);
+ global_myname(), 0x0, "*", 0x0, addr, FIRST_SUBNET->myip, DGRAM_PORT);
}
}
diff --git a/source3/nmbd/nmbd_serverlistdb.c b/source3/nmbd/nmbd_serverlistdb.c
index a315d80afe..2fee239b2d 100644
--- a/source3/nmbd/nmbd_serverlistdb.c
+++ b/source3/nmbd/nmbd_serverlistdb.c
@@ -26,9 +26,6 @@
extern int ClientNMB;
-extern fstring global_myworkgroup;
-extern char **my_netbios_names;
-
int updatecount = 0;
/*******************************************************************
@@ -91,7 +88,7 @@ static void add_server_to_workgroup(struct work_record *work,
Find a server in a server list.
**************************************************************************/
-struct server_record *find_server_in_workgroup(struct work_record *work, char *name)
+struct server_record *find_server_in_workgroup(struct work_record *work, const char *name)
{
struct server_record *ret;
@@ -128,8 +125,8 @@ void remove_server_from_workgroup(struct work_record *work, struct server_record
****************************************************************************/
struct server_record *create_server_on_workgroup(struct work_record *work,
- char *name,int servertype,
- int ttl,char *comment)
+ const char *name,int servertype,
+ int ttl, const char *comment)
{
struct server_record *servrec;
@@ -256,7 +253,7 @@ static uint32 write_this_server_name( struct subnet_record *subrec,
/*******************************************************************
Decide if we should write out a workgroup record for this workgroup.
- We return zero if we should not. Don't write out global_myworkgroup (we've
+ We return zero if we should not. Don't write out lp_workgroup() (we've
already done it) and also don't write out a second workgroup record
on the unicast subnet that we've already written out on one of the
broadcast subnets.
@@ -267,7 +264,7 @@ static uint32 write_this_workgroup_name( struct subnet_record *subrec,
{
struct subnet_record *ssub;
- if(strequal(global_myworkgroup, work->work_group))
+ if(strequal(lp_workgroup(), work->work_group))
return 0;
/* This is a workgroup we have seen on a broadcast subnet. All
@@ -295,8 +292,8 @@ static uint32 write_this_workgroup_name( struct subnet_record *subrec,
Write out the browse.dat file.
******************************************************************/
-void write_browse_list_entry(XFILE *fp, fstring name, uint32 rec_type,
- fstring local_master_browser_name, fstring description)
+void write_browse_list_entry(XFILE *fp, const char *name, uint32 rec_type,
+ const char *local_master_browser_name, const char *description)
{
fstring tmp;
@@ -368,10 +365,10 @@ void write_browse_list(time_t t, BOOL force_write)
* subnet.
*/
- if((work = find_workgroup_on_subnet(FIRST_SUBNET, global_myworkgroup)) == NULL)
+ if((work = find_workgroup_on_subnet(FIRST_SUBNET, lp_workgroup())) == NULL)
{
DEBUG(0,("write_browse_list: Fatal error - cannot find my workgroup %s\n",
- global_myworkgroup));
+ lp_workgroup()));
x_fclose(fp);
return;
}
@@ -388,22 +385,22 @@ void write_browse_list(time_t t, BOOL force_write)
* once.
*/
- for (i=0; my_netbios_names[i]; i++)
+ for (i=0; my_netbios_names(i); i++)
{
stype = 0;
for (subrec = FIRST_SUBNET; subrec ; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec))
{
- if((work = find_workgroup_on_subnet( subrec, global_myworkgroup )) == NULL)
+ if((work = find_workgroup_on_subnet( subrec, lp_workgroup() )) == NULL)
continue;
- if((servrec = find_server_in_workgroup( work, my_netbios_names[i])) == NULL)
+ if((servrec = find_server_in_workgroup( work, my_netbios_names(i))) == NULL)
continue;
stype |= servrec->serv.type;
}
/* Output server details, plus what workgroup they're in. */
- write_browse_list_entry(fp, my_netbios_names[i], stype,
- string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), global_myworkgroup);
+ write_browse_list_entry(fp, my_netbios_names(i), stype,
+ string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), lp_workgroup());
}
for (subrec = FIRST_SUBNET; subrec ; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec))
diff --git a/source3/nmbd/nmbd_subnetdb.c b/source3/nmbd/nmbd_subnetdb.c
index e68fc1589c..3ca33c4e53 100644
--- a/source3/nmbd/nmbd_subnetdb.c
+++ b/source3/nmbd/nmbd_subnetdb.c
@@ -30,9 +30,6 @@ extern int ClientNMB;
extern int ClientDGRAM;
extern int global_nmb_port;
-extern fstring myworkgroup;
-extern char **my_netbios_names;
-
/* This is the broadcast subnets database. */
struct subnet_record *subnetlist = NULL;
diff --git a/source3/nmbd/nmbd_synclists.c b/source3/nmbd/nmbd_synclists.c
index 24adf4e69f..30c7d579f1 100644
--- a/source3/nmbd/nmbd_synclists.c
+++ b/source3/nmbd/nmbd_synclists.c
@@ -247,7 +247,7 @@ static void complete_sync(struct sync_record *s)
unsigned type;
pstring comment;
pstring line;
- char *ptr;
+ const char *ptr;
int count=0;
f = x_fopen(s->fname,O_RDONLY, 0);
diff --git a/source3/nmbd/nmbd_workgroupdb.c b/source3/nmbd/nmbd_workgroupdb.c
index d1cfc24a31..f2dc80dfe5 100644
--- a/source3/nmbd/nmbd_workgroupdb.c
+++ b/source3/nmbd/nmbd_workgroupdb.c
@@ -26,9 +26,6 @@
extern int ClientNMB;
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-extern char **my_netbios_names;
extern uint16 samba_nb_type;
int workgroup_count = 0; /* unique index key: one for each workgroup */
@@ -226,7 +223,7 @@ void initiate_myworkgroup_startup(struct subnet_record *subrec, struct work_reco
{
int i;
- if(!strequal(global_myworkgroup, work->work_group))
+ if(!strequal(lp_workgroup(), work->work_group))
return;
/* If this is a broadcast subnet then start elections on it
@@ -244,21 +241,21 @@ workgroup %s on subnet %s\n", work->work_group, subrec->subnet_name));
/* Register the WORKGROUP<0> and WORKGROUP<1e> names on the network. */
- register_name(subrec,global_myworkgroup,0x0,samba_nb_type|NB_GROUP,
+ register_name(subrec,lp_workgroup(),0x0,samba_nb_type|NB_GROUP,
NULL,
fail_register,NULL);
- register_name(subrec,global_myworkgroup,0x1e,samba_nb_type|NB_GROUP,
+ register_name(subrec,lp_workgroup(),0x1e,samba_nb_type|NB_GROUP,
NULL,
fail_register,NULL);
- for( i = 0; my_netbios_names[i]; i++)
+ for( i = 0; my_netbios_names(i); i++)
{
- char *name = my_netbios_names[i];
+ const char *name = my_netbios_names(i);
int stype = lp_default_server_announce() | (lp_local_master() ?
SV_TYPE_POTENTIAL_BROWSER : 0 );
- if(!strequal(global_myname, name))
+ if(!strequal(global_myname(), name))
stype &= ~(SV_TYPE_MASTER_BROWSER|SV_TYPE_POTENTIAL_BROWSER|
SV_TYPE_DOMAIN_MASTER|SV_TYPE_DOMAIN_MEMBER);
diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c
index ed51d852cd..f03b0493de 100644
--- a/source3/nsswitch/wbinfo.c
+++ b/source3/nsswitch/wbinfo.c
@@ -62,7 +62,7 @@ static char winbind_separator(void)
return sep;
}
-static char *get_winbind_domain(void)
+static const char *get_winbind_domain(void)
{
struct winbindd_response response;
static fstring winbind_domain;
@@ -206,7 +206,7 @@ static BOOL wbinfo_list_domains(void)
/* Display response */
if (response.extra_data) {
- char *extra_data = (char *)response.extra_data;
+ const char *extra_data = (char *)response.extra_data;
while(next_token(&extra_data, name, ",", sizeof(fstring)))
d_printf("%s\n", name);
@@ -514,7 +514,7 @@ static BOOL wbinfo_auth_crap(char *username)
static BOOL print_domain_users(void)
{
struct winbindd_response response;
- char *extra_data;
+ const char *extra_data;
fstring name;
/* Send request to winbind daemon */
@@ -530,7 +530,7 @@ static BOOL print_domain_users(void)
if (!response.extra_data)
return False;
- extra_data = (char *)response.extra_data;
+ extra_data = (const char *)response.extra_data;
while(next_token(&extra_data, name, ",", sizeof(fstring)))
d_printf("%s\n", name);
@@ -545,7 +545,7 @@ static BOOL print_domain_users(void)
static BOOL print_domain_groups(void)
{
struct winbindd_response response;
- char *extra_data;
+ const char *extra_data;
fstring name;
ZERO_STRUCT(response);
@@ -559,7 +559,7 @@ static BOOL print_domain_groups(void)
if (!response.extra_data)
return False;
- extra_data = (char *)response.extra_data;
+ extra_data = (const char *)response.extra_data;
while(next_token(&extra_data, name, ",", sizeof(fstring)))
d_printf("%s\n", name);
@@ -679,7 +679,6 @@ enum {
int main(int argc, char **argv)
{
- extern pstring global_myname;
int opt;
poptContext pc;
@@ -717,21 +716,15 @@ int main(int argc, char **argv)
/* Samba client initialisation */
- if (!*global_myname) {
- char *p;
-
- fstrcpy(global_myname, myhostname());
- p = strchr(global_myname, '.');
- if (p)
- *p = 0;
- }
-
if (!lp_load(dyn_CONFIGFILE, True, False, False)) {
d_fprintf(stderr, "wbinfo: error opening config file %s. Error was %s\n",
dyn_CONFIGFILE, strerror(errno));
exit(1);
}
+ if (!init_names())
+ return 1;
+
load_interfaces();
/* Parse options */
diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c
index 2bd6d7967c..8ec8bdced6 100644
--- a/source3/nsswitch/winbindd.c
+++ b/source3/nsswitch/winbindd.c
@@ -744,8 +744,6 @@ static void usage(void)
int main(int argc, char **argv)
{
extern BOOL AllowDebugChange;
- extern pstring global_myname;
- extern fstring global_myworkgroup;
pstring logfile;
BOOL interactive = False;
int opt;
@@ -826,16 +824,8 @@ static void usage(void)
/* Setup names. */
- if (!*global_myname) {
- char *p;
-
- fstrcpy(global_myname, myhostname());
- p = strchr(global_myname, '.');
- if (p)
- *p = 0;
- }
-
- fstrcpy(global_myworkgroup, lp_workgroup());
+ if (!init_names())
+ exit(1);
if (!interactive) {
become_daemon();
diff --git a/source3/nsswitch/winbindd_cm.c b/source3/nsswitch/winbindd_cm.c
index b4d5a664b2..d44219d172 100644
--- a/source3/nsswitch/winbindd_cm.c
+++ b/source3/nsswitch/winbindd_cm.c
@@ -356,7 +356,6 @@ static NTSTATUS cm_open_connection(const char *domain, const int pipe_index,
struct winbindd_cm_conn *new_conn)
{
struct failed_connection_cache *fcc;
- extern pstring global_myname;
NTSTATUS result;
char *ipc_username, *ipc_domain, *ipc_password;
struct in_addr dc_ip;
@@ -414,7 +413,7 @@ static NTSTATUS cm_open_connection(const char *domain, const int pipe_index,
cm_get_ipc_userpass(&ipc_username, &ipc_domain, &ipc_password);
DEBUG(5, ("connecting to %s from %s with username [%s]\\[%s]\n",
- new_conn->controller, global_myname, ipc_domain, ipc_username));
+ new_conn->controller, global_myname(), ipc_domain, ipc_username));
for (i = 0; retry && (i < 3); i++) {
@@ -423,7 +422,7 @@ static NTSTATUS cm_open_connection(const char *domain, const int pipe_index,
continue;
}
- result = cli_full_connection(&(new_conn->cli), global_myname, new_conn->controller,
+ result = cli_full_connection(&new_conn->cli, global_myname(), new_conn->controller,
&dc_ip, 0, "IPC$", "IPC", ipc_username, ipc_domain,
ipc_password, 0, &retry);
@@ -585,7 +584,7 @@ done:
/* Return a LSA policy handle on a domain */
-CLI_POLICY_HND *cm_get_lsa_handle(char *domain)
+CLI_POLICY_HND *cm_get_lsa_handle(const char *domain)
{
struct winbindd_cm_conn *conn;
uint32 des_access = SEC_RIGHTS_MAXIMUM_ALLOWED;
@@ -912,7 +911,7 @@ CLI_POLICY_HND *cm_get_sam_group_handle(char *domain, DOM_SID *domain_sid,
/* Get a handle on a netlogon pipe. This is a bit of a hack to re-use the
netlogon pipe as no handle is returned. */
-NTSTATUS cm_get_netlogon_cli(char *domain, unsigned char *trust_passwd,
+NTSTATUS cm_get_netlogon_cli(const char *domain, const unsigned char *trust_passwd,
struct cli_state **cli)
{
NTSTATUS result = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
diff --git a/source3/nsswitch/winbindd_misc.c b/source3/nsswitch/winbindd_misc.c
index 45f2d42f98..079a49a317 100644
--- a/source3/nsswitch/winbindd_misc.c
+++ b/source3/nsswitch/winbindd_misc.c
@@ -26,12 +26,10 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_WINBIND
-extern pstring global_myname;
-
/************************************************************************
Routine to get the trust account password for a domain
************************************************************************/
-static BOOL _get_trust_account_password(char *domain, unsigned char *ret_pwd,
+static BOOL _get_trust_account_password(const char *domain, unsigned char *ret_pwd,
time_t *pass_last_set_time)
{
if (!secrets_fetch_trust_account_password(domain, ret_pwd, pass_last_set_time)) {
diff --git a/source3/nsswitch/winbindd_pam.c b/source3/nsswitch/winbindd_pam.c
index 969cf272a3..733ccb4cd6 100644
--- a/source3/nsswitch/winbindd_pam.c
+++ b/source3/nsswitch/winbindd_pam.c
@@ -68,8 +68,6 @@ enum winbindd_result winbindd_pam_auth(struct winbindd_cli_state *state)
DATA_BLOB lm_resp;
DATA_BLOB nt_resp;
- extern pstring global_myname;
-
/* Ensure null termination */
state->request.data.auth.user[sizeof(state->request.data.auth.user)-1]='\0';
@@ -135,7 +133,7 @@ enum winbindd_result winbindd_pam_auth(struct winbindd_cli_state *state)
result = cli_netlogon_sam_network_logon(cli, mem_ctx,
name_user, name_domain,
- global_myname, chal,
+ global_myname(), chal,
lm_resp, nt_resp,
&info3);
@@ -169,14 +167,12 @@ enum winbindd_result winbindd_pam_auth_crap(struct winbindd_cli_state *state)
struct cli_state *cli = NULL;
TALLOC_CTX *mem_ctx = NULL;
char *user = NULL;
- char *domain = NULL;
- char *contact_domain;
- char *workstation;
+ const char *domain = NULL;
+ const char *contact_domain;
+ const char *workstation;
DATA_BLOB lm_resp, nt_resp;
- extern pstring global_myname;
-
/* Ensure null termination */
state->request.data.auth_crap.user[sizeof(state->request.data.auth_crap.user)-1]='\0';
@@ -194,9 +190,11 @@ enum winbindd_result winbindd_pam_auth_crap(struct winbindd_cli_state *state)
}
if (*state->request.data.auth_crap.domain) {
- if (pull_utf8_talloc(mem_ctx, &domain, state->request.data.auth_crap.domain) < 0) {
+ char *dom = NULL;
+ if (pull_utf8_talloc(mem_ctx, &dom, state->request.data.auth_crap.domain) < 0) {
DEBUG(0, ("winbindd_pam_auth_crap: pull_utf8_talloc failed!\n"));
}
+ domain = dom;
} else if (lp_winbind_use_default_domain()) {
domain = lp_workgroup();
} else {
@@ -216,11 +214,13 @@ enum winbindd_result winbindd_pam_auth_crap(struct winbindd_cli_state *state)
}
if (*state->request.data.auth_crap.workstation) {
- if (pull_utf8_talloc(mem_ctx, &workstation, state->request.data.auth_crap.workstation) < 0) {
+ char *wrk = NULL;
+ if (pull_utf8_talloc(mem_ctx, &wrk, state->request.data.auth_crap.workstation) < 0) {
DEBUG(0, ("winbindd_pam_auth_crap: pull_utf8_talloc failed!\n"));
}
+ workstation = wrk;
} else {
- workstation = global_myname;
+ workstation = global_myname();
}
if (state->request.data.auth_crap.lm_resp_len > sizeof(state->request.data.auth_crap.lm_resp)
diff --git a/source3/nsswitch/winbindd_util.c b/source3/nsswitch/winbindd_util.c
index 1d18e8fda7..5ad4bada37 100644
--- a/source3/nsswitch/winbindd_util.c
+++ b/source3/nsswitch/winbindd_util.c
@@ -402,7 +402,7 @@ BOOL winbindd_param_init(void)
BOOL check_domain_env(char *domain_env, char *domain)
{
fstring name;
- char *tmp = domain_env;
+ const char *tmp = domain_env;
while(next_token(&tmp, name, ",", sizeof(fstring))) {
if (strequal(name, domain))
@@ -413,7 +413,6 @@ BOOL check_domain_env(char *domain_env, char *domain)
}
/* Parse a string of the form DOMAIN/user into a domain and a user */
-extern fstring global_myworkgroup;
BOOL parse_domain_user(const char *domuser, fstring domain, fstring user)
{
@@ -424,7 +423,7 @@ BOOL parse_domain_user(const char *domuser, fstring domain, fstring user)
if(!p && lp_winbind_use_default_domain()) {
fstrcpy(user, domuser);
- fstrcpy(domain, global_myworkgroup);
+ fstrcpy(domain, lp_workgroup());
} else {
fstrcpy(user, p+1);
fstrcpy(domain, domuser);
@@ -439,13 +438,13 @@ BOOL parse_domain_user(const char *domuser, fstring domain, fstring user)
'winbind separator' options.
This means:
- omit DOMAIN when 'winbind use default domain = true' and DOMAIN is
- global_myworkgroup
+ lp_workgroup
*/
void fill_domain_username(fstring name, const char *domain, const char *user)
{
if(lp_winbind_use_default_domain() &&
- !strcmp(global_myworkgroup, domain)) {
+ !strcmp(lp_workgroup(), domain)) {
strlcpy(name, user, sizeof(fstring));
} else {
slprintf(name, sizeof(fstring) - 1, "%s%s%s",
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 1a3c739f6c..57318d03ca 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -56,8 +56,6 @@ BOOL bLoaded = False;
extern userdom_struct current_user_info;
extern pstring user_socket_options;
-extern pstring global_myname;
-pstring global_scope = "";
#ifndef GLOBAL_NAME
#define GLOBAL_NAME "global"
@@ -114,7 +112,6 @@ typedef struct
char **szPassdbBackend;
char *szPasswordServer;
char *szSocketOptions;
- char *szWorkGroup;
char *szRealm;
char *szADSserver;
char *szUsernameMap;
@@ -272,8 +269,6 @@ global;
static global Globals;
-
-
/*
* This structure describes a single service.
*/
@@ -532,6 +527,9 @@ static BOOL handle_winbind_uid(char *pszParmValue, char **ptr);
static BOOL handle_winbind_gid(char *pszParmValue, char **ptr);
static BOOL handle_non_unix_account_range(char *pszParmValue, char **ptr);
static BOOL handle_debug_list( char *pszParmValue, char **ptr );
+static BOOL handle_workgroup( char *pszParmValue, char **ptr );
+static BOOL handle_netbios_aliases( char *pszParmValue, char **ptr );
+static BOOL handle_netbios_scope( char *pszParmValue, char **ptr );
static BOOL handle_ldap_machine_suffix ( char *pszParmValue, char **ptr );
static BOOL handle_ldap_user_suffix ( char *pszParmValue, char **ptr );
@@ -707,12 +705,12 @@ static struct parm_struct parm_table[] = {
{"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
{"path", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
{"directory", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL, FLAG_HIDE},
- {"workgroup", P_USTRING, P_GLOBAL, &Globals.szWorkGroup, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
+ {"workgroup", P_USTRING, P_GLOBAL, NULL, handle_workgroup, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
{"realm", P_USTRING, P_GLOBAL, &Globals.szRealm, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
{"ADS server", P_STRING, P_GLOBAL, &Globals.szADSserver, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
- {"netbios name", P_UGSTRING, P_GLOBAL, global_myname, handle_netbios_name, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
- {"netbios aliases", P_LIST, P_GLOBAL, &Globals.szNetbiosAliases, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
- {"netbios scope", P_UGSTRING, P_GLOBAL, global_scope, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"netbios name", P_UGSTRING, P_GLOBAL, NULL, handle_netbios_name, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
+ {"netbios aliases", P_LIST, P_GLOBAL, &Globals.szNetbiosAliases, handle_netbios_aliases, NULL, FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
+ {"netbios scope", P_UGSTRING, P_GLOBAL, NULL, handle_netbios_scope, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
{"server string", P_STRING, P_GLOBAL, &Globals.szServerString, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_DEVELOPER},
{"interfaces", P_LIST, P_GLOBAL, &Globals.szInterfaces, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
{"bind interfaces only", P_BOOL, P_GLOBAL, &Globals.bBindInterfacesOnly, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
@@ -1092,15 +1090,14 @@ static struct parm_struct parm_table[] = {
{NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
};
-
/***************************************************************************
-Initialise the sDefault parameter structure for the printer values.
+ Initialise the sDefault parameter structure for the printer values.
***************************************************************************/
+
static void init_printer_values(void)
{
/* choose defaults depending on the type of printing */
- switch (sDefault.iPrinting)
- {
+ switch (sDefault.iPrinting) {
case PRINT_BSD:
case PRINT_AIX:
case PRINT_LPRNT:
@@ -1209,15 +1206,15 @@ static void init_printer_values(void)
}
/***************************************************************************
-Initialise the global parameter structure.
+ Initialise the global parameter structure.
***************************************************************************/
+
static void init_globals(void)
{
static BOOL done_init = False;
pstring s;
- if (!done_init)
- {
+ if (!done_init) {
int i;
memset((void *)&Globals, '\0', sizeof(Globals));
@@ -1256,7 +1253,7 @@ static void init_globals(void)
* Allow the default PASSWD_CHAT to be overridden in local.h.
*/
string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
- string_set(&Globals.szWorkGroup, WORKGROUP);
+ set_global_myworkgroup(WORKGROUP);
string_set(&Globals.szPasswdProgram, "");
string_set(&Globals.szPrintcapname, PRINTCAP_NAME);
string_set(&Globals.szPidDir, dyn_PIDDIR);
@@ -1430,8 +1427,9 @@ static void init_globals(void)
static TALLOC_CTX *lp_talloc;
/******************************************************************* a
-free up temporary memory - called from the main loop
+ Free up temporary memory - called from the main loop.
********************************************************************/
+
void lp_talloc_free(void)
{
if (!lp_talloc)
@@ -1441,10 +1439,11 @@ void lp_talloc_free(void)
}
/*******************************************************************
-convenience routine to grab string parameters into temporary memory
-and run standard_sub_basic on them. The buffers can be written to by
-callers without affecting the source string.
+ Convenience routine to grab string parameters into temporary memory
+ and run standard_sub_basic on them. The buffers can be written to by
+ callers without affecting the source string.
********************************************************************/
+
static char *lp_string(const char *s)
{
size_t len = s ? strlen(s) : 0;
@@ -1481,7 +1480,6 @@ static char *lp_string(const char *s)
return (ret);
}
-
/*
In this section all the functions that are used to access the
parameters from the rest of the program are defined
@@ -1492,7 +1490,7 @@ static char *lp_string(const char *s)
#define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
const char *fn_name(void) {return(*(const char **)(ptr) ? *(const char **)(ptr) : "");}
#define FN_GLOBAL_LIST(fn_name,ptr) \
- char **fn_name(void) {return(*(char ***)(ptr));}
+ const char **fn_name(void) {return(*(const char ***)(ptr));}
#define FN_GLOBAL_BOOL(fn_name,ptr) \
BOOL fn_name(void) {return(*(BOOL *)(ptr));}
#define FN_GLOBAL_CHAR(fn_name,ptr) \
@@ -1505,7 +1503,7 @@ static char *lp_string(const char *s)
#define FN_LOCAL_CONST_STRING(fn_name,val) \
const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
#define FN_LOCAL_LIST(fn_name,val) \
- char **fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
+ const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
#define FN_LOCAL_BOOL(fn_name,val) \
BOOL fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
#define FN_LOCAL_CHAR(fn_name,val) \
@@ -1547,7 +1545,6 @@ FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram)
FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
FN_GLOBAL_STRING(lp_passwordserver, &Globals.szPasswordServer)
FN_GLOBAL_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder)
-FN_GLOBAL_STRING(lp_workgroup, &Globals.szWorkGroup)
FN_GLOBAL_STRING(lp_realm, &Globals.szRealm)
FN_GLOBAL_STRING(lp_ads_server, &Globals.szADSserver)
FN_GLOBAL_STRING(lp_username_map, &Globals.szUsernameMap)
@@ -1808,6 +1805,7 @@ static param_opt_struct *param_opt = NULL;
/* Return parametric option from given service. Type is a part of option before ':' */
/* Parametric option has following syntax: 'Type: option = value' */
/* Returned value is allocated in 'lp_talloc' context */
+
char *lp_parm_string(const char *servicename, const char *type, const char *option)
{
param_opt_struct *data;
@@ -1853,34 +1851,33 @@ static void init_copymap(service * pservice);
/***************************************************************************
-initialise a service to the defaults
+ Initialise a service to the defaults.
***************************************************************************/
+
static void init_service(service * pservice)
{
memset((char *)pservice, '\0', sizeof(service));
copy_service(pservice, &sDefault, NULL);
}
-
/***************************************************************************
-free the dynamically allocated parts of a service struct
+ Free the dynamically allocated parts of a service struct.
***************************************************************************/
-static void free_service(service * pservice)
+
+static void free_service(service *pservice)
{
int i;
if (!pservice)
return;
if (pservice->szService)
- DEBUG(5,
- ("free_service: Freeing service %s\n",
+ DEBUG(5, ("free_service: Freeing service %s\n",
pservice->szService));
string_free(&pservice->szService);
SAFE_FREE(pservice->copymap);
- for (i = 0; parm_table[i].label; i++)
- {
+ for (i = 0; parm_table[i].label; i++) {
if ((parm_table[i].type == P_STRING ||
parm_table[i].type == P_USTRING) &&
parm_table[i].class == P_LOCAL)
@@ -1899,10 +1896,11 @@ static void free_service(service * pservice)
}
/***************************************************************************
-add a new service to the services array initialising it with the given
-service.
+ Add a new service to the services array initialising it with the given
+ service.
***************************************************************************/
-static int add_a_service(const service * pservice, const char *name)
+
+static int add_a_service(const service *pservice, const char *name)
{
int i;
service tservice;
@@ -1911,8 +1909,7 @@ static int add_a_service(const service * pservice, const char *name)
tservice = *pservice;
/* it might already exist */
- if (name)
- {
+ if (name) {
i = getservicebyname(name, NULL);
if (i >= 0)
return (i);
@@ -1924,8 +1921,7 @@ static int add_a_service(const service * pservice, const char *name)
break;
/* if not, then create one */
- if (i == iNumServices)
- {
+ if (i == iNumServices) {
service **tsp;
tsp = (service **) Realloc(ServicePtrs,
@@ -1947,8 +1943,7 @@ static int add_a_service(const service * pservice, const char *name)
}
iNumServices++;
- }
- else
+ } else
free_service(ServicePtrs[i]);
ServicePtrs[i]->valid = True;
@@ -1956,16 +1951,15 @@ static int add_a_service(const service * pservice, const char *name)
init_service(ServicePtrs[i]);
copy_service(ServicePtrs[i], &tservice, NULL);
if (name)
- {
string_set(&ServicePtrs[i]->szService, name);
- }
return (i);
}
/***************************************************************************
-add a new home service, with the specified home directory, defaults coming
-from service ifrom.
+ Add a new home service, with the specified home directory, defaults coming
+ from service ifrom.
***************************************************************************/
+
BOOL lp_add_home(const char *pszHomename, int iDefaultService,
const char *user, const char *pszHomedir)
{
@@ -1987,8 +1981,7 @@ BOOL lp_add_home(const char *pszHomename, int iDefaultService,
string_set(&ServicePtrs[i]->szPath, newHomedir);
- if (!(*(ServicePtrs[i]->comment)))
- {
+ if (!(*(ServicePtrs[i]->comment))) {
pstring comment;
slprintf(comment, sizeof(comment) - 1,
"Home directory of %s", user);
@@ -1997,25 +1990,25 @@ BOOL lp_add_home(const char *pszHomename, int iDefaultService,
ServicePtrs[i]->bAvailable = sDefault.bAvailable;
ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
- DEBUG(3,
- ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
+ DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
user, newHomedir));
return (True);
}
/***************************************************************************
-add a new service, based on an old one.
+ Add a new service, based on an old one.
***************************************************************************/
+
int lp_add_service(const char *pszService, int iDefaultService)
{
return (add_a_service(ServicePtrs[iDefaultService], pszService));
}
-
/***************************************************************************
-add the IPC service
+ Add the IPC service.
***************************************************************************/
+
static BOOL lp_add_ipc(char *ipc_name, BOOL guest_ok)
{
pstring comment;
@@ -2045,8 +2038,9 @@ static BOOL lp_add_ipc(char *ipc_name, BOOL guest_ok)
}
/***************************************************************************
-add a new printer service, with defaults coming from service iFrom.
+ Add a new printer service, with defaults coming from service iFrom.
***************************************************************************/
+
BOOL lp_add_printer(const char *pszPrintername, int iDefaultService)
{
const char *comment = "From Printcap";
@@ -2081,9 +2075,10 @@ BOOL lp_add_printer(const char *pszPrintername, int iDefaultService)
}
/***************************************************************************
-Map a parameter's string representation to something we can use.
-Returns False if the parameter string is not recognised, else TRUE.
+ Map a parameter's string representation to something we can use.
+ Returns False if the parameter string is not recognised, else TRUE.
***************************************************************************/
+
static int map_parameter(char *pszParmName)
{
int iIndex;
@@ -2104,12 +2099,12 @@ static int map_parameter(char *pszParmName)
return (-1);
}
-
/***************************************************************************
-Set a boolean variable from the text value stored in the passed string.
-Returns True in success, False if the passed string does not correctly
-represent a boolean.
+ Set a boolean variable from the text value stored in the passed string.
+ Returns True in success, False if the passed string does not correctly
+ represent a boolean.
***************************************************************************/
+
static BOOL set_boolean(BOOL *pb, char *pszParmValue)
{
BOOL bRetval;
@@ -2119,13 +2114,11 @@ static BOOL set_boolean(BOOL *pb, char *pszParmValue)
strwicmp(pszParmValue, "true") == 0 ||
strwicmp(pszParmValue, "1") == 0)
*pb = True;
- else
- if (strwicmp(pszParmValue, "no") == 0 ||
+ else if (strwicmp(pszParmValue, "no") == 0 ||
strwicmp(pszParmValue, "False") == 0 ||
strwicmp(pszParmValue, "0") == 0)
*pb = False;
- else
- {
+ else {
DEBUG(0,
("ERROR: Badly formed boolean in configuration file: \"%s\".\n",
pszParmValue));
@@ -2137,14 +2130,14 @@ static BOOL set_boolean(BOOL *pb, char *pszParmValue)
/***************************************************************************
Find a service by name. Otherwise works like get_service.
***************************************************************************/
+
static int getservicebyname(const char *pszServiceName, service * pserviceDest)
{
int iService;
for (iService = iNumServices - 1; iService >= 0; iService--)
if (VALID(iService) &&
- strwicmp(ServicePtrs[iService]->szService, pszServiceName) == 0)
- {
+ strwicmp(ServicePtrs[iService]->szService, pszServiceName) == 0) {
if (pserviceDest != NULL)
copy_service(pserviceDest, ServicePtrs[iService], NULL);
break;
@@ -2153,23 +2146,19 @@ static int getservicebyname(const char *pszServiceName, service * pserviceDest)
return (iService);
}
-
-
/***************************************************************************
-Copy a service structure to another
-
-If pcopymapDest is NULL then copy all fields
+ Copy a service structure to another.
+ If pcopymapDest is NULL then copy all fields
***************************************************************************/
-static void copy_service(service * pserviceDest,
- service * pserviceSource, BOOL *pcopymapDest)
+
+static void copy_service(service * pserviceDest, service * pserviceSource, BOOL *pcopymapDest)
{
int i;
BOOL bcopyall = (pcopymapDest == NULL);
for (i = 0; parm_table[i].label; i++)
if (parm_table[i].ptr && parm_table[i].class == P_LOCAL &&
- (bcopyall || pcopymapDest[i]))
- {
+ (bcopyall || pcopymapDest[i])) {
void *def_ptr = parm_table[i].ptr;
void *src_ptr =
((char *)pserviceSource) + PTR_DIFF(def_ptr,
@@ -2178,8 +2167,7 @@ static void copy_service(service * pserviceDest,
((char *)pserviceDest) + PTR_DIFF(def_ptr,
&sDefault);
- switch (parm_table[i].type)
- {
+ switch (parm_table[i].type) {
case P_BOOL:
case P_BOOLREV:
*(BOOL *)dest_ptr = *(BOOL *)src_ptr;
@@ -2206,15 +2194,14 @@ static void copy_service(service * pserviceDest,
strupper(*(char **)dest_ptr);
break;
case P_LIST:
- str_list_copy((char ***)dest_ptr, *(char ***)src_ptr);
+ str_list_copy((char ***)dest_ptr, *(const char ***)src_ptr);
break;
default:
break;
}
}
- if (bcopyall)
- {
+ if (bcopyall) {
init_copymap(pserviceDest);
if (pserviceSource->copymap)
memcpy((void *)pserviceDest->copymap,
@@ -2227,15 +2214,14 @@ static void copy_service(service * pserviceDest,
Check a service for consistency. Return False if the service is in any way
incomplete or faulty, else True.
***************************************************************************/
+
static BOOL service_ok(int iService)
{
BOOL bRetval;
bRetval = True;
- if (ServicePtrs[iService]->szService[0] == '\0')
- {
- DEBUG(0,
- ("The following message indicates an internal error:\n"));
+ if (ServicePtrs[iService]->szService[0] == '\0') {
+ DEBUG(0, ("The following message indicates an internal error:\n"));
DEBUG(0, ("No service name in service entry.\n"));
bRetval = False;
}
@@ -2244,8 +2230,7 @@ static BOOL service_ok(int iService)
/* I can't see why you'd want a non-printable printer service... */
if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
if (!ServicePtrs[iService]->bPrint_ok) {
- DEBUG(0,
- ("WARNING: [%s] service MUST be printable!\n",
+ DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
ServicePtrs[iService]->szService));
ServicePtrs[iService]->bPrint_ok = True;
}
@@ -2255,10 +2240,8 @@ static BOOL service_ok(int iService)
}
if (ServicePtrs[iService]->szPath[0] == '\0' &&
- strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0)
- {
- DEBUG(0,
- ("No path in service %s - using %s\n",
+ strwicmp(ServicePtrs[iService]->szService, HOMES_NAME) != 0) {
+ DEBUG(0, ("No path in service %s - using %s\n",
ServicePtrs[iService]->szService, tmpdir()));
string_set(&ServicePtrs[iService]->szPath, tmpdir());
}
@@ -2271,45 +2254,40 @@ static BOOL service_ok(int iService)
return (bRetval);
}
-static struct file_lists
-{
+static struct file_lists {
struct file_lists *next;
char *name;
char *subfname;
time_t modtime;
-}
- *file_lists = NULL;
+} *file_lists = NULL;
/*******************************************************************
-keep a linked list of all config files so we know when one has changed
-it's date and needs to be reloaded
+ Keep a linked list of all config files so we know when one has changed
+ it's date and needs to be reloaded.
********************************************************************/
+
static void add_to_file_list(const char *fname, const char *subfname)
{
struct file_lists *f = file_lists;
- while (f)
- {
+ while (f) {
if (f->name && !strcmp(f->name, fname))
break;
f = f->next;
}
- if (!f)
- {
+ if (!f) {
f = (struct file_lists *)malloc(sizeof(file_lists[0]));
if (!f)
return;
f->next = file_lists;
f->name = strdup(fname);
- if (!f->name)
- {
+ if (!f->name) {
SAFE_FREE(f);
return;
}
f->subfname = strdup(subfname);
- if (!f->subfname)
- {
+ if (!f->subfname) {
SAFE_FREE(f);
return;
}
@@ -2323,8 +2301,9 @@ static void add_to_file_list(const char *fname, const char *subfname)
}
/*******************************************************************
-check if a config file has changed date
+ Check if a config file has changed date.
********************************************************************/
+
BOOL lp_file_list_changed(void)
{
struct file_lists *f = file_lists;
@@ -2369,17 +2348,31 @@ static BOOL handle_netbios_name(char *pszParmValue, char **ptr)
pstrcpy(netbios_name, pszParmValue);
standard_sub_basic(current_user_info.smb_name, netbios_name,sizeof(netbios_name));
- strupper(netbios_name);
- pstrcpy(global_myname, netbios_name);
+ set_global_myname(netbios_name);
- DEBUG(4,
- ("handle_netbios_name: set global_myname to: %s\n",
- global_myname));
+ DEBUG(4, ("handle_netbios_name: set global_myname to: %s\n",
+ global_myname()));
return (True);
}
+static BOOL handle_workgroup(char *pszParmValue, char **ptr)
+{
+ return set_global_myworkgroup(pszParmValue);
+}
+
+static BOOL handle_netbios_scope(char *pszParmValue, char **ptr)
+{
+ return set_global_scope(pszParmValue);
+}
+
+static BOOL handle_netbios_aliases(char *pszParmValue, char **ptr)
+{
+ Globals.szNetbiosAliases = str_list_make(pszParmValue, NULL);
+ return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
+}
+
/***************************************************************************
Do the work of sourcing in environment variable/value pairs.
***************************************************************************/
@@ -2391,8 +2384,7 @@ static BOOL source_env(char **lines)
int i;
char *p;
- for (i = 0; lines[i]; i++)
- {
+ for (i = 0; lines[i]; i++) {
char *line = lines[i];
if ((len = strlen(line)) == 0)
@@ -2401,8 +2393,7 @@ static BOOL source_env(char **lines)
if (line[len - 1] == '\n')
line[--len] = '\0';
- if ((varval = malloc(len + 1)) == NULL)
- {
+ if ((varval = malloc(len + 1)) == NULL) {
DEBUG(0, ("source_env: Not enough memory!\n"));
return (False);
}
@@ -2412,25 +2403,20 @@ static BOOL source_env(char **lines)
varval[len] = '\0';
p = strchr_m(line, (int)'=');
- if (p == NULL)
- {
+ if (p == NULL) {
DEBUG(4, ("source_env: missing '=': %s\n", line));
continue;
}
- if (putenv(varval))
- {
- DEBUG(0,
- ("source_env: Failed to put environment variable %s\n",
+ if (putenv(varval)) {
+ DEBUG(0, ("source_env: Failed to put environment variable %s\n",
varval));
continue;
}
*p = '\0';
p++;
- DEBUG(4,
- ("source_env: getting var %s = %s\n", line,
- getenv(line)));
+ DEBUG(4, ("source_env: getting var %s = %s\n", line, getenv(line)));
}
DEBUG(4, ("source_env: returning successfully\n"));
@@ -2438,7 +2424,7 @@ static BOOL source_env(char **lines)
}
/***************************************************************************
- Handle the source environment operation
+ Handle the source environment operation.
***************************************************************************/
static BOOL handle_source_env(char *pszParmValue, char **ptr)
@@ -2461,18 +2447,12 @@ static BOOL handle_source_env(char *pszParmValue, char **ptr)
*/
if (*p == '|')
- {
lines = file_lines_pload(p + 1, NULL);
- }
else
- {
lines = file_lines_load(fname, NULL);
- }
- if (!lines)
- {
- DEBUG(0,
- ("handle_source_env: Failed to open file %s, Error was %s\n",
+ if (!lines) {
+ DEBUG(0, ("handle_source_env: Failed to open file %s, Error was %s\n",
fname, strerror(errno)));
return (False);
}
@@ -2484,8 +2464,9 @@ static BOOL handle_source_env(char *pszParmValue, char **ptr)
}
/***************************************************************************
- handle the interpretation of the vfs object parameter
- *************************************************************************/
+ Handle the interpretation of the vfs object parameter.
+*************************************************************************/
+
static BOOL handle_vfs_object(char *pszParmValue, char **ptr)
{
/* Set string value */
@@ -2498,9 +2479,8 @@ static BOOL handle_vfs_object(char *pszParmValue, char **ptr)
return True;
}
-
/***************************************************************************
-handle the include operation
+ Handle the include operation.
***************************************************************************/
static BOOL handle_include(char *pszParmValue, char **ptr)
@@ -2522,10 +2502,10 @@ static BOOL handle_include(char *pszParmValue, char **ptr)
return (False);
}
-
/***************************************************************************
-handle the interpretation of the copy parameter
+ Handle the interpretation of the copy parameter.
***************************************************************************/
+
static BOOL handle_copy(char *pszParmValue, char **ptr)
{
BOOL bRetval;
@@ -2540,26 +2520,17 @@ static BOOL handle_copy(char *pszParmValue, char **ptr)
DEBUG(3, ("Copying service from service %s\n", pszParmValue));
- if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0)
- {
- if (iTemp == iServiceIndex)
- {
- DEBUG(0,
- ("Can't copy service %s - unable to copy self!\n",
- pszParmValue));
- }
- else
- {
+ if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
+ if (iTemp == iServiceIndex) {
+ DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
+ } else {
copy_service(ServicePtrs[iServiceIndex],
&serviceTemp,
ServicePtrs[iServiceIndex]->copymap);
bRetval = True;
}
- }
- else
- {
- DEBUG(0, ("Unable to copy service - source not found: %s\n",
- pszParmValue));
+ } else {
+ DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
bRetval = False;
}
@@ -2665,7 +2636,9 @@ static BOOL handle_winbind_gid(char *pszParmValue, char **ptr)
return True;
}
-/* Do some simple checks on "non unix account range" parameter values */
+/***************************************************************************
+ Do some simple checks on "non unix account range" parameter values.
+***************************************************************************/
static BOOL handle_non_unix_account_range(char *pszParmValue, char **ptr)
{
@@ -2685,8 +2658,9 @@ static BOOL handle_non_unix_account_range(char *pszParmValue, char **ptr)
}
/***************************************************************************
- Handle the DEBUG level list
+ Handle the DEBUG level list.
***************************************************************************/
+
static BOOL handle_debug_list( char *pszParmValueIn, char **ptr )
{
pstring pszParmValue;
@@ -2697,8 +2671,9 @@ static BOOL handle_debug_list( char *pszParmValueIn, char **ptr )
}
/***************************************************************************
- Handle the ldap machine suffix option
+ Handle the ldap machine suffix option.
***************************************************************************/
+
static BOOL handle_ldap_machine_suffix( char *pszParmValue, char **ptr)
{
pstring suffix;
@@ -2720,8 +2695,9 @@ static BOOL handle_ldap_machine_suffix( char *pszParmValue, char **ptr)
}
/***************************************************************************
- Handle the ldap user suffix option
+ Handle the ldap user suffix option.
***************************************************************************/
+
static BOOL handle_ldap_user_suffix( char *pszParmValue, char **ptr)
{
pstring suffix;
@@ -2744,8 +2720,9 @@ static BOOL handle_ldap_user_suffix( char *pszParmValue, char **ptr)
/***************************************************************************
Handle setting ldap suffix and determines whether ldap machine suffix needs
- to be set as well
+ to be set as well.
***************************************************************************/
+
static BOOL handle_ldap_suffix( char *pszParmValue, char **ptr)
{
pstring suffix;
@@ -2793,8 +2770,9 @@ static BOOL handle_acl_compatibility(char *pszParmValue, char **ptr)
return True;
}
/***************************************************************************
-initialise a copymap
+ Initialise a copymap.
***************************************************************************/
+
static void init_copymap(service * pservice)
{
int i;
@@ -2809,20 +2787,21 @@ static void init_copymap(service * pservice)
pservice->copymap[i] = True;
}
-
/***************************************************************************
- return the local pointer to a parameter given the service number and the
- pointer into the default structure
+ Return the local pointer to a parameter given the service number and the
+ pointer into the default structure.
***************************************************************************/
+
void *lp_local_ptr(int snum, void *ptr)
{
return (void *)(((char *)ServicePtrs[snum]) + PTR_DIFF(ptr, &sDefault));
}
/***************************************************************************
-Process a parameter for a particular service number. If snum < 0
-then assume we are in the globals
+ Process a parameter for a particular service number. If snum < 0
+ then assume we are in the globals.
***************************************************************************/
+
BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue)
{
int parmnum, i, slen;
@@ -2834,8 +2813,7 @@ BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue)
parmnum = map_parameter(pszParmName);
- if (parmnum < 0)
- {
+ if (parmnum < 0) {
if ((sep=strchr(pszParmName, ':')) != NULL) {
*sep = 0;
ZERO_STRUCT(vfskey);
@@ -2851,13 +2829,11 @@ BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue)
*sep = ':';
return (True);
}
- DEBUG(0,
- ("Ignoring unknown parameter \"%s\"\n", pszParmName));
+ DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
return (True);
}
- if (parm_table[parmnum].flags & FLAG_DEPRECATED)
- {
+ if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
pszParmName));
}
@@ -2865,14 +2841,10 @@ BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue)
def_ptr = parm_table[parmnum].ptr;
/* we might point at a service, the default service or a global */
- if (snum < 0)
- {
+ if (snum < 0) {
parm_ptr = def_ptr;
- }
- else
- {
- if (parm_table[parmnum].class == P_GLOBAL)
- {
+ } else {
+ if (parm_table[parmnum].class == P_GLOBAL) {
DEBUG(0,
("Global parameter %s found in service section!\n",
pszParmName));
@@ -2883,8 +2855,7 @@ BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue)
&sDefault);
}
- if (snum >= 0)
- {
+ if (snum >= 0) {
if (!ServicePtrs[snum]->copymap)
init_copymap(ServicePtrs[snum]);
@@ -2896,8 +2867,7 @@ BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue)
}
/* if it is a special case then go ahead */
- if (parm_table[parmnum].special)
- {
+ if (parm_table[parmnum].special) {
parm_table[parmnum].special(pszParmValue, (char **)parm_ptr);
return (True);
}
@@ -2949,13 +2919,10 @@ BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue)
break;
case P_ENUM:
- for (i = 0; parm_table[parmnum].enum_list[i].name;
- i++)
- {
+ for (i = 0; parm_table[parmnum].enum_list[i].name; i++) {
if (strequal
(pszParmValue,
- parm_table[parmnum].enum_list[i].name))
- {
+ parm_table[parmnum].enum_list[i].name)) {
*(int *)parm_ptr =
parm_table[parmnum].
enum_list[i].value;
@@ -2971,8 +2938,9 @@ BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue)
}
/***************************************************************************
-Process a parameter.
+ Process a parameter.
***************************************************************************/
+
static BOOL do_parameter(char *pszParmName, char *pszParmValue)
{
if (!bInGlobalSection && bGlobalOnly)
@@ -2984,20 +2952,18 @@ static BOOL do_parameter(char *pszParmName, char *pszParmValue)
pszParmName, pszParmValue));
}
-
/***************************************************************************
-print a parameter of the specified type
+ Print a parameter of the specified type.
***************************************************************************/
+
static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
{
int i;
switch (p->type)
{
case P_ENUM:
- for (i = 0; p->enum_list[i].name; i++)
- {
- if (*(int *)ptr == p->enum_list[i].value)
- {
+ for (i = 0; p->enum_list[i].name; i++) {
+ if (*(int *)ptr == p->enum_list[i].value) {
fprintf(f, "%s",
p->enum_list[i].name);
break;
@@ -3053,14 +3019,13 @@ static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
}
}
-
/***************************************************************************
-check if two parameters are equal
+ Check if two parameters are equal.
***************************************************************************/
+
static BOOL equal_parameter(parm_type type, void *ptr1, void *ptr2)
{
- switch (type)
- {
+ switch (type) {
case P_BOOL:
case P_BOOLREV:
return (*((BOOL *)ptr1) == *((BOOL *)ptr2));
@@ -3112,10 +3077,11 @@ void init_locals(void)
}
/***************************************************************************
-Process a new section (service). At this stage all sections are services.
-Later we'll have special sections that permit server parameters to be set.
-Returns True on success, False on failure.
+ Process a new section (service). At this stage all sections are services.
+ Later we'll have special sections that permit server parameters to be set.
+ Returns True on success, False on failure.
***************************************************************************/
+
static BOOL do_section(char *pszSectionName)
{
BOOL bRetval;
@@ -3131,8 +3097,7 @@ static BOOL do_section(char *pszSectionName)
bInGlobalSection = isglobal;
/* check for multiple global sections */
- if (bInGlobalSection)
- {
+ if (bInGlobalSection) {
DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
return (True);
}
@@ -3147,15 +3112,13 @@ static BOOL do_section(char *pszSectionName)
bRetval = service_ok(iServiceIndex);
/* if all is still well, move to the next record in the services array */
- if (bRetval)
- {
+ if (bRetval) {
/* We put this here to avoid an odd message order if messages are */
/* issued by the post-processing of a previous section. */
DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
if ((iServiceIndex = add_a_service(&sDefault, pszSectionName))
- < 0)
- {
+ < 0) {
DEBUG(0, ("Failed to add a new service\n"));
return (False);
}
@@ -3166,14 +3129,14 @@ static BOOL do_section(char *pszSectionName)
/***************************************************************************
-determine if a partcular base parameter is currentl set to the default value.
+ Determine if a partcular base parameter is currentl set to the default value.
***************************************************************************/
+
static BOOL is_default(int i)
{
if (!defaults_saved)
return False;
- switch (parm_table[i].type)
- {
+ switch (parm_table[i].type) {
case P_LIST:
return str_list_compare (parm_table[i].def.lvalue,
*(char ***)parm_table[i].ptr);
@@ -3203,10 +3166,10 @@ static BOOL is_default(int i)
return False;
}
-
/***************************************************************************
Display the contents of the global structure.
***************************************************************************/
+
static void dump_globals(FILE *f)
{
int i;
@@ -3218,14 +3181,13 @@ static void dump_globals(FILE *f)
for (i = 0; parm_table[i].label; i++)
if (parm_table[i].class == P_GLOBAL &&
parm_table[i].ptr &&
- (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
- {
+ (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr))) {
if (defaults_saved && is_default(i))
continue;
fprintf(f, "\t%s = ", parm_table[i].label);
print_parameter(&parm_table[i], parm_table[i].ptr, f);
fprintf(f, "\n");
- }
+ }
if (param_opt != NULL) {
data = param_opt;
while(data) {
@@ -3240,8 +3202,9 @@ static void dump_globals(FILE *f)
}
/***************************************************************************
-return True if a local parameter is currently set to the global default
+ Return True if a local parameter is currently set to the global default.
***************************************************************************/
+
BOOL lp_is_default(int snum, struct parm_struct *parm)
{
int pdiff = PTR_DIFF(parm->ptr, &sDefault);
@@ -3252,8 +3215,9 @@ BOOL lp_is_default(int snum, struct parm_struct *parm)
}
/***************************************************************************
-Display the contents of a single services record.
+ Display the contents of a single services record.
***************************************************************************/
+
static void dump_a_service(service * pService, FILE * f)
{
int i;
@@ -3267,17 +3231,13 @@ static void dump_a_service(service * pService, FILE * f)
if (parm_table[i].class == P_LOCAL &&
parm_table[i].ptr &&
(*parm_table[i].label != '-') &&
- (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
- {
+ (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr))) {
int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault);
- if (pService == &sDefault)
- {
+ if (pService == &sDefault) {
if (defaults_saved && is_default(i))
continue;
- }
- else
- {
+ } else {
if (equal_parameter(parm_table[i].type,
((char *)pService) +
pdiff,
@@ -3290,7 +3250,7 @@ static void dump_a_service(service * pService, FILE * f)
print_parameter(&parm_table[i],
((char *)pService) + pdiff, f);
fprintf(f, "\n");
- }
+ }
if (param_opt != NULL) {
data = param_opt;
sn = (pService == &sDefault) ? "global" : pService->szService;
@@ -3306,17 +3266,15 @@ static void dump_a_service(service * pService, FILE * f)
/***************************************************************************
-return info about the next service in a service. snum==-1 gives the globals
-
-return NULL when out of parameters
+ Return info about the next service in a service. snum==-1 gives the globals.
+ Return NULL when out of parameters.
***************************************************************************/
+
struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
{
- if (snum == -1)
- {
+ if (snum == -1) {
/* do the globals */
- for (; parm_table[*i].label; (*i)++)
- {
+ for (; parm_table[*i].label; (*i)++) {
if (parm_table[*i].class == P_SEPARATOR)
return &parm_table[(*i)++];
@@ -3331,13 +3289,10 @@ struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
return &parm_table[(*i)++];
}
- }
- else
- {
+ } else {
service *pService = ServicePtrs[snum];
- for (; parm_table[*i].label; (*i)++)
- {
+ for (; parm_table[*i].label; (*i)++) {
if (parm_table[*i].class == P_SEPARATOR)
return &parm_table[(*i)++];
@@ -3371,7 +3326,7 @@ struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
#if 0
/***************************************************************************
-Display the contents of a single copy structure.
+ Display the contents of a single copy structure.
***************************************************************************/
static void dump_copy_map(BOOL *pcopymap)
{
@@ -3392,7 +3347,7 @@ static void dump_copy_map(BOOL *pcopymap)
#endif
/***************************************************************************
-Return TRUE if the passed service number is within range.
+ Return TRUE if the passed service number is within range.
***************************************************************************/
BOOL lp_snum_ok(int iService)
@@ -3449,7 +3404,9 @@ void lp_add_one_printer(char *name, char *comment)
}
}
-/* Announce ourselves as a print server */
+/***************************************************************************
+ Announce ourselves as a print server.
+***************************************************************************/
void update_server_announce_as_printserver(void)
{
@@ -3510,7 +3467,7 @@ static void lp_save_defaults(void)
switch (parm_table[i].type) {
case P_LIST:
str_list_copy(&(parm_table[i].def.lvalue),
- *(char ***)parm_table[i].ptr);
+ *(const char ***)parm_table[i].ptr);
break;
case P_STRING:
case P_USTRING:
@@ -3604,12 +3561,11 @@ static void set_server_role(void)
}
}
-
-
/***************************************************************************
-Load the services array from the services file. Return True on success,
-False on failure.
+ Load the services array from the services file. Return True on success,
+ False on failure.
***************************************************************************/
+
BOOL lp_load(const char *pszFname, BOOL global_only, BOOL save_defaults,
BOOL add_ipc)
{
@@ -3684,16 +3640,18 @@ BOOL lp_load(const char *pszFname, BOOL global_only, BOOL save_defaults,
}
/***************************************************************************
-reset the max number of services
+ Reset the max number of services.
***************************************************************************/
+
void lp_resetnumservices(void)
{
iNumServices = 0;
}
/***************************************************************************
-return the max number of services
+ Return the max number of services.
***************************************************************************/
+
int lp_numservices(void)
{
return (iNumServices);
@@ -3702,14 +3660,13 @@ int lp_numservices(void)
/***************************************************************************
Display the contents of the services array in human-readable form.
***************************************************************************/
+
void lp_dump(FILE *f, BOOL show_defaults, int maxtoprint)
{
int iService;
if (show_defaults)
- {
defaults_saved = False;
- }
dump_globals(f);
@@ -3722,33 +3679,31 @@ void lp_dump(FILE *f, BOOL show_defaults, int maxtoprint)
/***************************************************************************
Display the contents of one service in human-readable form.
***************************************************************************/
+
void lp_dump_one(FILE * f, BOOL show_defaults, int snum)
{
- if (VALID(snum))
- {
+ if (VALID(snum)) {
if (ServicePtrs[snum]->szService[0] == '\0')
return;
dump_a_service(ServicePtrs[snum], f);
}
}
-
/***************************************************************************
Return the number of the service with the given name, or -1 if it doesn't
exist. Note that this is a DIFFERENT ANIMAL from the internal function
getservicebyname()! This works ONLY if all services have been loaded, and
does not copy the found service.
***************************************************************************/
+
int lp_servicenumber(const char *pszServiceName)
{
int iService;
fstring serviceName;
- for (iService = iNumServices - 1; iService >= 0; iService--)
- {
- if (VALID(iService) && ServicePtrs[iService]->szService)
- {
+ for (iService = iNumServices - 1; iService >= 0; iService--) {
+ if (VALID(iService) && ServicePtrs[iService]->szService) {
/*
* The substitution here is used to support %U is
* service names
@@ -3782,6 +3737,7 @@ char *volume_label(int snum)
/*******************************************************************
Set the server type we will announce as via nmbd.
********************************************************************/
+
static void set_default_server_announce_type(void)
{
default_server_announce = 0;
@@ -3789,67 +3745,42 @@ static void set_default_server_announce_type(void)
default_server_announce |= SV_TYPE_SERVER;
default_server_announce |= SV_TYPE_SERVER_UNIX;
- switch (lp_announce_as())
- {
+ switch (lp_announce_as()) {
case ANNOUNCE_AS_NT_SERVER:
- {
default_server_announce |= SV_TYPE_SERVER_NT;
/* fall through... */
- }
case ANNOUNCE_AS_NT_WORKSTATION:
- {
default_server_announce |= SV_TYPE_NT;
break;
- }
case ANNOUNCE_AS_WIN95:
- {
default_server_announce |= SV_TYPE_WIN95_PLUS;
break;
- }
case ANNOUNCE_AS_WFW:
- {
default_server_announce |= SV_TYPE_WFW;
break;
- }
default:
- {
break;
- }
}
- switch (lp_server_role())
- {
+ switch (lp_server_role()) {
case ROLE_DOMAIN_MEMBER:
- {
default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
break;
- }
case ROLE_DOMAIN_PDC:
- {
default_server_announce |= SV_TYPE_DOMAIN_CTRL;
break;
- }
case ROLE_DOMAIN_BDC:
- {
default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
break;
- }
case ROLE_STANDALONE:
default:
- {
break;
- }
}
-
if (lp_time_server())
- {
default_server_announce |= SV_TYPE_TIME_SOURCE;
- }
if (lp_host_msdfs())
- {
default_server_announce |= SV_TYPE_DFS_SERVER;
- }
}
/***********************************************************
@@ -3868,9 +3799,7 @@ int lp_server_role(void)
BOOL lp_domain_master(void)
{
if (Globals.bDomainMaster == Auto)
- {
return (lp_server_role() == ROLE_DOMAIN_PDC);
- }
return Globals.bDomainMaster;
}
@@ -3882,32 +3811,29 @@ BOOL lp_domain_master(void)
BOOL lp_preferred_master(void)
{
if (Globals.bPreferredMaster == Auto)
- {
return (lp_local_master() && lp_domain_master());
- }
return Globals.bPreferredMaster;
}
-
-
/*******************************************************************
-remove a service
+ Remove a service.
********************************************************************/
+
void lp_remove_service(int snum)
{
ServicePtrs[snum]->valid = False;
}
/*******************************************************************
-copy a service.
+ Copy a service.
********************************************************************/
+
void lp_copy_service(int snum, char *new_name)
{
char *oldname = lp_servicename(snum);
do_section(new_name);
- if (snum >= 0)
- {
+ if (snum >= 0) {
snum = lp_servicenumber(new_name);
if (snum >= 0)
lp_do_parameter(snum, "copy", oldname);
@@ -3918,6 +3844,7 @@ void lp_copy_service(int snum, char *new_name)
/*******************************************************************
Get the default server type we will announce as via nmbd.
********************************************************************/
+
int lp_default_server_announce(void)
{
return default_server_announce;
@@ -3926,6 +3853,7 @@ int lp_default_server_announce(void)
/*******************************************************************
Split the announce version into major and minor numbers.
********************************************************************/
+
int lp_major_announce_version(void)
{
static BOOL got_major = False;
@@ -3998,30 +3926,6 @@ void get_private_directory(pstring privdir)
pstrcpy (privdir, lp_private_dir());
}
-
-/****************************************************************
- Is netbios alias or name
-*****************************************************************/
-
-BOOL is_netbios_alias_or_name(const char *name)
-{
- char **netbios_aliases = lp_netbios_aliases();
-
- if (StrCaseCmp(name, global_myname) == 0) {
- return True;
- }
-
- for (netbios_aliases = lp_netbios_aliases();
- netbios_aliases && *netbios_aliases;
- netbios_aliases++) {
- if (StrCaseCmp(name, *netbios_aliases) == 0) {
- return True;
- }
- }
-
- return False;
-}
-
/***********************************************************
Allow daemons such as winbindd to fix their logfile name.
************************************************************/
@@ -4043,7 +3947,7 @@ const char *get_called_name(void)
static fstring called_name;
if (! *local_machine)
- return global_myname;
+ return global_myname();
/*
* Windows NT/2k uses "*SMBSERVER" and XP uses "*SMBSERV"
diff --git a/source3/passdb/machine_sid.c b/source3/passdb/machine_sid.c
index e1a1de83a6..071af50877 100644
--- a/source3/passdb/machine_sid.c
+++ b/source3/passdb/machine_sid.c
@@ -79,7 +79,6 @@ static void generate_random_sid(DOM_SID *sid)
static BOOL pdb_generate_sam_sid(void)
{
char *fname = NULL;
- extern pstring global_myname;
BOOL is_dc = False;
if(global_sam_sid==NULL)
@@ -98,7 +97,7 @@ static BOOL pdb_generate_sam_sid(void)
break;
}
- if (secrets_fetch_domain_sid(global_myname, global_sam_sid)) {
+ if (secrets_fetch_domain_sid(global_myname(), global_sam_sid)) {
DOM_SID domain_sid;
/* We got our sid. If not a pdc/bdc, we're done. */
@@ -137,7 +136,7 @@ static BOOL pdb_generate_sam_sid(void)
if (read_sid_from_file(fname, global_sam_sid)) {
/* remember it for future reference and unlink the old MACHINE.SID */
- if (!secrets_store_domain_sid(global_myname, global_sam_sid)) {
+ if (!secrets_store_domain_sid(global_myname(), global_sam_sid)) {
DEBUG(0,("pdb_generate_sam_sid: Failed to store SID from file.\n"));
SAFE_FREE(fname);
return False;
@@ -162,7 +161,7 @@ static BOOL pdb_generate_sam_sid(void)
generate one and save it */
generate_random_sid(global_sam_sid);
- if (!secrets_store_domain_sid(global_myname, global_sam_sid)) {
+ if (!secrets_store_domain_sid(global_myname(), global_sam_sid)) {
DEBUG(0,("pdb_generate_sam_sid: Failed to store generated machine SID.\n"));
return False;
}
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index de737f7df7..ef1c1180dd 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -32,8 +32,6 @@
* responsible.
*/
-extern pstring global_myname;
-
/************************************************************
Fill the SAM_ACCOUNT with default values.
***********************************************************/
@@ -237,28 +235,28 @@ NTSTATUS pdb_fill_sam_pw(SAM_ACCOUNT *sam_account, const struct passwd *pwd)
pdb_set_profile_path(sam_account,
talloc_sub_specified((sam_account)->mem_ctx,
lp_logon_path(),
- pwd->pw_name, global_myname,
+ pwd->pw_name, global_myname(),
pwd->pw_uid, pwd->pw_gid),
PDB_DEFAULT);
pdb_set_homedir(sam_account,
talloc_sub_specified((sam_account)->mem_ctx,
lp_logon_home(),
- pwd->pw_name, global_myname,
+ pwd->pw_name, global_myname(),
pwd->pw_uid, pwd->pw_gid),
PDB_DEFAULT);
pdb_set_dir_drive(sam_account,
talloc_sub_specified((sam_account)->mem_ctx,
lp_logon_drive(),
- pwd->pw_name, global_myname,
+ pwd->pw_name, global_myname(),
pwd->pw_uid, pwd->pw_gid),
PDB_DEFAULT);
pdb_set_logon_script(sam_account,
talloc_sub_specified((sam_account)->mem_ctx,
lp_logon_script(),
- pwd->pw_name, global_myname,
+ pwd->pw_name, global_myname(),
pwd->pw_uid, pwd->pw_gid),
PDB_DEFAULT);
if (!pdb_set_acct_ctrl(sam_account, ACB_NORMAL, PDB_DEFAULT)) {
@@ -625,10 +623,10 @@ BOOL local_lookup_sid(DOM_SID *sid, char *name, enum SID_NAME_USE *psid_name_use
DEBUG(5,("local_lookup_sid: looking up RID %u.\n", (unsigned int)rid));
if (rid == DOMAIN_USER_RID_ADMIN) {
- char **admin_list = lp_admin_users(-1);
+ const char **admin_list = lp_admin_users(-1);
*psid_name_use = SID_NAME_USER;
if (admin_list) {
- char *p = *admin_list;
+ const char *p = *admin_list;
if(!next_token(&p, name, NULL, sizeof(fstring)))
fstrcpy(name, "Administrator");
} else {
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index ca199f8ea6..edc310c0c1 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -458,7 +458,7 @@ static NTSTATUS make_pdb_context(struct pdb_context **context)
Make a pdb_context, given an array of strings
*******************************************************************/
-NTSTATUS make_pdb_context_list(struct pdb_context **context, char **selected)
+NTSTATUS make_pdb_context_list(struct pdb_context **context, const char **selected)
{
int i = 0;
struct pdb_methods *curmethods, *tmpmethods;
@@ -492,7 +492,7 @@ NTSTATUS make_pdb_context_string(struct pdb_context **context, const char *selec
{
NTSTATUS ret;
char **newsel = str_list_make(selected, NULL);
- ret = make_pdb_context_list(context, newsel);
+ ret = make_pdb_context_list(context, (const char **)newsel);
str_list_free(&newsel);
return ret;
}
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index e35775a6da..8097d92364 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -507,7 +507,7 @@ static int ldapsam_retry_open(struct ldapsam_privates *ldap_state, int *attempts
}
-static int ldapsam_search(struct ldapsam_privates *ldap_state, char *base, int scope, char *filter, char *attrs[], int attrsonly, LDAPMessage **res)
+static int ldapsam_search(struct ldapsam_privates *ldap_state, const char *base, int scope, const char *filter, const char *attrs[], int attrsonly, LDAPMessage **res)
{
int rc = LDAP_SERVER_DOWN;
int attempts = 0;
@@ -636,7 +636,7 @@ static int ldapsam_search_one_user (struct ldapsam_privates *ldap_state, const c
DEBUG(2, ("ldapsam_search_one_user: searching for:[%s]\n", filter));
- rc = ldapsam_search(ldap_state, lp_ldap_suffix (), scope, (char *)filter, (char **)attr, 0, result);
+ rc = ldapsam_search(ldap_state, lp_ldap_suffix (), scope, filter, attr, 0, result);
if (rc != LDAP_SUCCESS) {
DEBUG(0,("ldapsam_search_one_user: Problem during the LDAP search: %s\n",
@@ -1412,7 +1412,7 @@ static uint32 search_top_nua_rid(struct ldapsam_privates *ldap_state)
DEBUG(2, ("ldapsam_get_next_available_nua_rid: searching for:[%s]\n", final_filter));
rc = ldapsam_search(ldap_state, lp_ldap_suffix(),
- LDAP_SCOPE_SUBTREE, final_filter, (char **)attr, 0,
+ LDAP_SCOPE_SUBTREE, final_filter, attr, 0,
&result);
if (rc != LDAP_SUCCESS) {
@@ -1486,7 +1486,7 @@ static NTSTATUS ldapsam_setsampwent(struct pdb_methods *my_methods, BOOL update)
all_string_sub(filter, "%u", "*", sizeof(pstring));
rc = ldapsam_search(ldap_state, lp_ldap_suffix(),
- LDAP_SCOPE_SUBTREE, filter, (char **)attr, 0,
+ LDAP_SCOPE_SUBTREE, filter, attr, 0,
&ldap_state->result);
if (rc != LDAP_SUCCESS) {
diff --git a/source3/passdb/util_sam_sid.c b/source3/passdb/util_sam_sid.c
index 60998003f6..0881531db8 100644
--- a/source3/passdb/util_sam_sid.c
+++ b/source3/passdb/util_sam_sid.c
@@ -22,9 +22,6 @@
#include "includes.h"
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-
#define MAX_SID_NAMES 7
typedef struct _known_sid_users {
@@ -98,16 +95,16 @@ static void init_sid_name_map (void)
/* This is not lp_workgroup() for good reason:
it must stay around longer than the lp_*()
strings do */
- sid_name_map[i].name = global_myworkgroup;
+ sid_name_map[i].name = strdup(lp_workgroup());
sid_name_map[i].known_users = NULL;
i++;
sid_name_map[i].sid = get_global_sam_sid();
- sid_name_map[i].name = global_myname;
+ sid_name_map[i].name = strdup(global_myname());
sid_name_map[i].known_users = NULL;
i++;
} else {
sid_name_map[i].sid = get_global_sam_sid();
- sid_name_map[i].name = global_myname;
+ sid_name_map[i].name = strdup(global_myname());
sid_name_map[i].known_users = NULL;
i++;
}
@@ -224,7 +221,7 @@ BOOL map_domain_name_to_sid(DOM_SID *sid, char *nt_domain)
}
if (nt_domain[0] == 0) {
- fstrcpy(nt_domain, global_myname);
+ fstrcpy(nt_domain, global_myname());
DEBUG(5,("map_domain_name_to_sid: overriding blank name to %s\n", nt_domain));
sid_copy(sid, get_global_sam_sid());
return True;
diff --git a/source3/printing/lpq_parse.c b/source3/printing/lpq_parse.c
index 1307cdb3f8..59a844689c 100644
--- a/source3/printing/lpq_parse.c
+++ b/source3/printing/lpq_parse.c
@@ -232,12 +232,11 @@ static BOOL parse_lpq_lprng(char *line,print_queue_struct *buf,BOOL first)
#define LPRNG_MAXTOK 128 /* PFMA just to keep us from running away. */
fstring tokarr[LPRNG_MAXTOK];
- char *cptr;
+ const char *cptr;
+ char *ptr;
int num_tok = 0;
- pstring line2;
- pstrcpy(line2,line);
- cptr = line2;
+ cptr = line;
while(next_token( &cptr, tokarr[num_tok], " \t", sizeof(fstring)) && (num_tok < LPRNG_MAXTOK))
num_tok++;
@@ -273,8 +272,8 @@ static BOOL parse_lpq_lprng(char *line,print_queue_struct *buf,BOOL first)
* for the current user on the taskbar. Plop in a null.
*/
- if ((cptr = strchr_m(buf->fs_user,'@')) != NULL) {
- *cptr = '\0';
+ if ((ptr = strchr_m(buf->fs_user,'@')) != NULL) {
+ *ptr = '\0';
}
StrnCpy(buf->fs_file,tokarr[LPRNG_FILETOK],sizeof(buf->fs_file)-1);
@@ -314,6 +313,7 @@ static BOOL parse_lpq_aix(char *line,print_queue_struct *buf,BOOL first)
{
fstring tok[11];
int count=0;
+ const char *cline = line;
/* handle the case of "(standard input)" as a filename */
string_sub(line,"standard input","STDIN",0);
@@ -322,7 +322,7 @@ static BOOL parse_lpq_aix(char *line,print_queue_struct *buf,BOOL first)
for (count=0;
count<10 &&
- next_token(&line,tok[count],NULL, sizeof(tok[count]));
+ next_token(&cline,tok[count],NULL, sizeof(tok[count]));
count++) ;
/* we must get 6 tokens */
@@ -406,7 +406,7 @@ ljplus-2153 user priority 0 Jan 19 08:14 on ljplus
ljplus-2154 user priority 0 Jan 19 08:14 from client
(standard input) 7551 bytes
****************************************************************************/
-static BOOL parse_lpq_hpux(char * line, print_queue_struct *buf, BOOL first)
+static BOOL parse_lpq_hpux(char *line, print_queue_struct *buf, BOOL first)
{
/* must read two lines to process, therefore keep some values static */
static BOOL header_line_ok=False, base_prio_reset=False;
@@ -418,9 +418,9 @@ static BOOL parse_lpq_hpux(char * line, print_queue_struct *buf, BOOL first)
/* to store minimum priority to print, lpstat command should be invoked
with -p option first, to work */
static int base_prio;
-
int count;
char htab = '\011';
+ const char *cline = line;
fstring tok[12];
/* If a line begins with a horizontal TAB, it is a subline type */
@@ -437,7 +437,7 @@ static BOOL parse_lpq_hpux(char * line, print_queue_struct *buf, BOOL first)
all_string_sub(line,"(","\"",0);
all_string_sub(line,")","\"",0);
- for (count=0; count<2 && next_token(&line,tok[count],NULL,sizeof(tok[count])); count++) ;
+ for (count=0; count<2 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) ;
/* we must get 2 tokens */
if (count < 2) return(False);
@@ -473,7 +473,7 @@ static BOOL parse_lpq_hpux(char * line, print_queue_struct *buf, BOOL first)
/* handle the dash in the job id */
string_sub(line,"-"," ",0);
- for (count=0; count<12 && next_token(&line,tok[count],NULL,sizeof(tok[count])); count++) ;
+ for (count=0; count<12 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) ;
/* we must get 8 tokens */
if (count < 8) return(False);
@@ -519,6 +519,7 @@ static BOOL parse_lpq_sysv(char *line,print_queue_struct *buf,BOOL first)
fstring tok[9];
int count=0;
char *p;
+ const char *cline = line;
/*
* Handle the dash in the job id, but make sure that we skip over
@@ -542,7 +543,7 @@ static BOOL parse_lpq_sysv(char *line,print_queue_struct *buf,BOOL first)
if((p >= line) && (*p == '-'))
*p = ' ';
- for (count=0; count<9 && next_token(&line,tok[count],NULL,sizeof(tok[count])); count++)
+ for (count=0; count<9 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++)
;
/* we must get 7 tokens */
@@ -591,6 +592,7 @@ static BOOL parse_lpq_qnx(char *line,print_queue_struct *buf,BOOL first)
{
fstring tok[7];
int count=0;
+ const char *cline;
DEBUG(4,("antes [%s]\n", line));
@@ -605,9 +607,7 @@ static BOOL parse_lpq_qnx(char *line,print_queue_struct *buf,BOOL first)
string_sub(line,"]","",0);
DEBUG(4,("despues 2 [%s]\n", line));
-
-
- for (count=0; count<7 && next_token(&line,tok[count],NULL,sizeof(tok[count])); count++) ;
+ for (count=0; count<7 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) ;
/* we must get 7 tokens */
if (count < 7)
@@ -656,13 +656,14 @@ static BOOL parse_lpq_plp(char *line,print_queue_struct *buf,BOOL first)
{
fstring tok[11];
int count=0;
+ const char *cline = line;
/* handle the case of "(standard input)" as a filename */
string_sub(line,"stdin","STDIN",0);
all_string_sub(line,"(","\"",0);
all_string_sub(line,")","\"",0);
- for (count=0; count<11 && next_token(&line,tok[count],NULL,sizeof(tok[count])); count++) ;
+ for (count=0; count<11 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) ;
/* we must get 11 tokens */
if (count < 11)
@@ -726,11 +727,12 @@ static BOOL parse_lpq_softq(char *line,print_queue_struct *buf,BOOL first)
{
fstring tok[10];
int count=0;
+ const char *cline = line;
/* mung all the ":"s to spaces*/
string_sub(line,":"," ",0);
- for (count=0; count<10 && next_token(&line,tok[count],NULL,sizeof(tok[count])); count++) ;
+ for (count=0; count<10 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) ;
/* we must get 9 tokens */
if (count < 9)
@@ -958,6 +960,7 @@ static BOOL parse_lpq_vlp(char *line,print_queue_struct *buf,BOOL first)
{
int toknum = 0;
fstring tok;
+ const char *cline = line;
/* First line is printer status */
@@ -965,7 +968,7 @@ static BOOL parse_lpq_vlp(char *line,print_queue_struct *buf,BOOL first)
/* Parse a print job entry */
- while(next_token(&line, tok, NULL, sizeof(fstring))) {
+ while(next_token(&cline, tok, NULL, sizeof(fstring))) {
switch (toknum) {
case 0:
buf->job = atoi(tok);
@@ -997,6 +1000,7 @@ static BOOL parse_lpq_vlp(char *line,print_queue_struct *buf,BOOL first)
/****************************************************************************
parse a lpq line. Choose printing style
****************************************************************************/
+
BOOL parse_lpq_entry(int snum,char *line,
print_queue_struct *buf,
print_status_struct *status,BOOL first)
diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c
index eaee3c26e7..b5ad798755 100644
--- a/source3/rpc_client/cli_netlogon.c
+++ b/source3/rpc_client/cli_netlogon.c
@@ -35,7 +35,6 @@ NTSTATUS cli_net_req_chal(struct cli_state *cli, DOM_CHAL *clnt_chal,
NET_Q_REQ_CHAL q;
NET_R_REQ_CHAL r;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- extern pstring global_myname;
prs_init(&qbuf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
@@ -43,10 +42,10 @@ NTSTATUS cli_net_req_chal(struct cli_state *cli, DOM_CHAL *clnt_chal,
/* create and send a MSRPC command with api NET_REQCHAL */
DEBUG(4,("cli_net_req_chal: LSA Request Challenge from %s to %s: %s\n",
- global_myname, cli->desthost, credstr(clnt_chal->data)));
+ global_myname(), cli->desthost, credstr(clnt_chal->data)));
/* store the parameters */
- init_q_req_chal(&q, cli->srv_name_slash, global_myname, clnt_chal);
+ init_q_req_chal(&q, cli->srv_name_slash, global_myname(), clnt_chal);
/* Marshall data and send request */
@@ -92,7 +91,6 @@ NTSTATUS cli_net_auth2(struct cli_state *cli,
NET_Q_AUTH_2 q;
NET_R_AUTH_2 r;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- extern pstring global_myname;
prs_init(&qbuf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
@@ -100,12 +98,12 @@ NTSTATUS cli_net_auth2(struct cli_state *cli,
/* create and send a MSRPC command with api NET_AUTH2 */
DEBUG(4,("cli_net_auth2: srv:%s acct:%s sc:%x mc: %s chal %s neg: %x\n",
- cli->srv_name_slash, cli->mach_acct, sec_chan, global_myname,
+ cli->srv_name_slash, cli->mach_acct, sec_chan, global_myname(),
credstr(cli->clnt_cred.challenge.data), neg_flags));
/* store the parameters */
init_q_auth_2(&q, cli->srv_name_slash, cli->mach_acct,
- sec_chan, global_myname, &cli->clnt_cred.challenge,
+ sec_chan, global_myname(), &cli->clnt_cred.challenge,
neg_flags);
/* turn parameters into data stream */
@@ -168,7 +166,6 @@ NTSTATUS cli_net_auth3(struct cli_state *cli,
NET_Q_AUTH_3 q;
NET_R_AUTH_3 r;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- extern pstring global_myname;
prs_init(&qbuf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
@@ -176,12 +173,12 @@ NTSTATUS cli_net_auth3(struct cli_state *cli,
/* create and send a MSRPC command with api NET_AUTH2 */
DEBUG(4,("cli_net_auth3: srv:%s acct:%s sc:%x mc: %s chal %s neg: %x\n",
- cli->srv_name_slash, cli->mach_acct, sec_chan, global_myname,
+ cli->srv_name_slash, cli->mach_acct, sec_chan, global_myname(),
credstr(cli->clnt_cred.challenge.data), *neg_flags));
/* store the parameters */
init_q_auth_3(&q, cli->srv_name_slash, cli->mach_acct,
- sec_chan, global_myname, &cli->clnt_cred.challenge,
+ sec_chan, global_myname(), &cli->clnt_cred.challenge,
*neg_flags);
/* turn parameters into data stream */
@@ -500,7 +497,6 @@ NTSTATUS cli_netlogon_sam_logon(struct cli_state *cli, TALLOC_CTX *mem_ctx,
NET_R_SAM_LOGON r;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
DOM_CRED clnt_creds, dummy_rtn_creds;
- extern pstring global_myname;
NET_ID_INFO_CTR ctr;
NET_USER_INFO_3 user;
int validation_level = 3;
@@ -562,7 +558,7 @@ NTSTATUS cli_netlogon_sam_logon(struct cli_state *cli, TALLOC_CTX *mem_ctx,
goto done;
}
- init_sam_info(&q.sam_id, cli->srv_name_slash, global_myname,
+ init_sam_info(&q.sam_id, cli->srv_name_slash, global_myname(),
&clnt_creds, &dummy_rtn_creds, logon_type,
&ctr);
@@ -612,7 +608,6 @@ NTSTATUS cli_netlogon_sam_network_logon(struct cli_state *cli, TALLOC_CTX *mem_c
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
DOM_CRED clnt_creds, dummy_rtn_creds;
NET_ID_INFO_CTR ctr;
- extern pstring global_myname;
int validation_level = 3;
char *workstation_name_slash;
@@ -648,7 +643,7 @@ NTSTATUS cli_netlogon_sam_network_logon(struct cli_state *cli, TALLOC_CTX *mem_c
username, workstation_name_slash, (const uchar*)chal,
lm_response.data, lm_response.length, nt_response.data, nt_response.length);
- init_sam_info(&q.sam_id, cli->srv_name_slash, global_myname,
+ init_sam_info(&q.sam_id, cli->srv_name_slash, global_myname(),
&clnt_creds, &dummy_rtn_creds, NET_LOGON_TYPE,
&ctr);
@@ -683,7 +678,7 @@ LSA Server Password Set.
****************************************************************************/
NTSTATUS cli_net_srv_pwset(struct cli_state *cli, TALLOC_CTX *mem_ctx,
- char* machine_name, uint8 hashed_mach_pwd[16])
+ const char *machine_name, uint8 hashed_mach_pwd[16])
{
prs_struct rbuf;
prs_struct qbuf;
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index f685f38754..90f08148ef 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -27,8 +27,6 @@
#define DBGC_CLASS DBGC_RPC_CLI
extern struct pipe_id_info pipe_names[];
-extern fstring global_myworkgroup;
-extern pstring global_myname;
/********************************************************************
Rpc pipe call id.
@@ -546,7 +544,7 @@ static BOOL rpc_api_pipe(struct cli_state *cli, prs_struct *data, prs_struct *rd
static BOOL create_rpc_bind_req(prs_struct *rpc_out, BOOL do_auth, uint32 rpc_call_id,
RPC_IFACE *abstract, RPC_IFACE *transfer,
- char *my_name, char *domain, uint32 neg_flags)
+ const char *my_name, const char *domain, uint32 neg_flags)
{
RPC_HDR hdr;
RPC_HDR_RB hdr_rb;
@@ -640,7 +638,7 @@ static BOOL create_rpc_bind_req(prs_struct *rpc_out, BOOL do_auth, uint32 rpc_ca
********************************************************************/
static BOOL create_rpc_bind_resp(struct pwd_info *pwd,
- char *domain, char *user_name, char *my_name,
+ const char *domain, const char *user_name, const char *my_name,
uint32 ntlmssp_cli_flgs,
uint32 rpc_call_id,
prs_struct *rpc_out)
@@ -1142,7 +1140,7 @@ static BOOL rpc_send_auth_reply(struct cli_state *cli, prs_struct *rdata, uint32
prs_give_memory( &rpc_out, buffer, sizeof(buffer), False);
create_rpc_bind_resp(&cli->pwd, cli->domain,
- cli->user_name, global_myname,
+ cli->user_name, global_myname(),
cli->ntlmssp_cli_flgs, rpc_call_id,
&rpc_out);
@@ -1194,7 +1192,7 @@ static BOOL rpc_send_auth_reply(struct cli_state *cli, prs_struct *rdata, uint32
Do an rpc bind.
****************************************************************************/
-BOOL rpc_pipe_bind(struct cli_state *cli, const int pipe_idx, char *my_name)
+BOOL rpc_pipe_bind(struct cli_state *cli, int pipe_idx, const char *my_name)
{
RPC_IFACE abstract;
RPC_IFACE transfer;
@@ -1225,7 +1223,7 @@ BOOL rpc_pipe_bind(struct cli_state *cli, const int pipe_idx, char *my_name)
/* Marshall the outgoing data. */
create_rpc_bind_req(&rpc_out, do_auth, rpc_call_id,
&abstract, &transfer,
- global_myname, cli->domain, cli->ntlmssp_cli_flgs);
+ global_myname(), cli->domain, cli->ntlmssp_cli_flgs);
/* Initialize the incoming data struct. */
prs_init(&rdata, 0, cli->mem_ctx, UNMARSHALL);
@@ -1320,7 +1318,7 @@ BOOL cli_nt_session_open(struct cli_state *cli, const int pipe_idx)
/******************* bind request on pipe *****************/
- if (!rpc_pipe_bind(cli, pipe_idx, global_myname)) {
+ if (!rpc_pipe_bind(cli, pipe_idx, global_myname())) {
DEBUG(2,("cli_nt_session_open: rpc bind to %s failed\n",
get_pipe_name_from_index(pipe_idx)));
cli_close(cli, cli->nt_pipe_fnum);
@@ -1336,10 +1334,10 @@ BOOL cli_nt_session_open(struct cli_state *cli, const int pipe_idx)
strupper(cli->srv_name_slash);
fstrcpy(cli->clnt_name_slash, "\\\\");
- fstrcat(cli->clnt_name_slash, global_myname);
+ fstrcat(cli->clnt_name_slash, global_myname());
strupper(cli->clnt_name_slash);
- fstrcpy(cli->mach_acct, global_myname);
+ fstrcpy(cli->mach_acct, global_myname());
fstrcat(cli->mach_acct, "$");
strupper(cli->mach_acct);
diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c
index c20fb85582..5dcb49d399 100644
--- a/source3/rpc_parse/parse_misc.c
+++ b/source3/rpc_parse/parse_misc.c
@@ -244,14 +244,13 @@ BOOL smb_io_dom_sid(char *desc, DOM_SID *sid, prs_struct *ps, int depth)
identauth >= 2^32 can be detected because it will be specified in hex
********************************************************************/
-void init_dom_sid(DOM_SID *sid, char *str_sid)
+void init_dom_sid(DOM_SID *sid, const char *str_sid)
{
pstring domsid;
int identauth;
char *p;
- if (str_sid == NULL)
- {
+ if (str_sid == NULL) {
DEBUG(4,("netlogon domain SID: none\n"));
sid->sid_rev_num = 0;
sid->num_auths = 0;
@@ -592,7 +591,7 @@ void init_buffer3_uint32(BUFFER3 *str, uint32 val)
Inits a BUFFER3 structure.
********************************************************************/
-void init_buffer3_str(BUFFER3 *str, char *buf, int len)
+void init_buffer3_str(BUFFER3 *str, const char *buf, int len)
{
ZERO_STRUCTP(str);
@@ -610,7 +609,7 @@ void init_buffer3_str(BUFFER3 *str, char *buf, int len)
Inits a BUFFER3 structure from a hex string.
********************************************************************/
-void init_buffer3_hex(BUFFER3 *str, char *buf)
+void init_buffer3_hex(BUFFER3 *str, const char *buf)
{
ZERO_STRUCTP(str);
create_buffer3(str, strlen(buf));
@@ -697,7 +696,7 @@ BOOL smb_io_buffer5(char *desc, BUFFER5 *buf5, prs_struct *ps, int depth)
Inits a BUFFER2 structure.
********************************************************************/
-void init_buffer2(BUFFER2 *str, uint8 *buf, int len)
+void init_buffer2(BUFFER2 *str, const uint8 *buf, int len)
{
ZERO_STRUCTP(str);
@@ -963,7 +962,7 @@ void init_unistr2_w(TALLOC_CTX *ctx, UNISTR2 *str, const smb_ucs2_t *buf)
/*******************************************************************
Inits a UNISTR2 structure from a UNISTR
********************************************************************/
-void init_unistr2_from_unistr (UNISTR2 *to, UNISTR *from)
+void init_unistr2_from_unistr (UNISTR2 *to, const UNISTR *from)
{
uint32 i;
@@ -1138,7 +1137,7 @@ void init_dom_rid4(DOM_RID4 *rid4, uint16 unknown, uint16 attr, uint32 rid)
Inits a DOM_CLNT_SRV structure.
********************************************************************/
-static void init_clnt_srv(DOM_CLNT_SRV *log, char *logon_srv, char *comp_name)
+static void init_clnt_srv(DOM_CLNT_SRV *log, const char *logon_srv, const char *comp_name)
{
DEBUG(5,("init_clnt_srv: %d\n", __LINE__));
@@ -1292,16 +1291,16 @@ BOOL smb_io_cred(char *desc, DOM_CRED *cred, prs_struct *ps, int depth)
********************************************************************/
void init_clnt_info2(DOM_CLNT_INFO2 *clnt,
- char *logon_srv, char *comp_name,
- DOM_CRED *clnt_cred)
+ const char *logon_srv, const char *comp_name,
+ const DOM_CRED *clnt_cred)
{
DEBUG(5,("make_clnt_info: %d\n", __LINE__));
- init_clnt_srv(&(clnt->login), logon_srv, comp_name);
+ init_clnt_srv(&clnt->login, logon_srv, comp_name);
if (clnt_cred != NULL) {
clnt->ptr_cred = 1;
- memcpy(&(clnt->cred), clnt_cred, sizeof(clnt->cred));
+ memcpy(&clnt->cred, clnt_cred, sizeof(clnt->cred));
} else {
clnt->ptr_cred = 0;
}
@@ -1341,9 +1340,9 @@ BOOL smb_io_clnt_info2(char *desc, DOM_CLNT_INFO2 *clnt, prs_struct *ps, int dep
********************************************************************/
void init_clnt_info(DOM_CLNT_INFO *clnt,
- char *logon_srv, char *acct_name,
- uint16 sec_chan, char *comp_name,
- DOM_CRED *cred)
+ const char *logon_srv, const char *acct_name,
+ uint16 sec_chan, const char *comp_name,
+ const DOM_CRED *cred)
{
DEBUG(5,("make_clnt_info\n"));
@@ -1413,7 +1412,7 @@ BOOL smb_io_logon_id(char *desc, DOM_LOGON_ID *log, prs_struct *ps, int depth)
Inits an OWF_INFO structure.
********************************************************************/
-void init_owf_info(OWF_INFO *hash, uint8 data[16])
+void init_owf_info(OWF_INFO *hash, const uint8 data[16])
{
DEBUG(5,("init_owf_info: %d\n", __LINE__));
diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c
index e0f710b2d7..c140a1fe01 100644
--- a/source3/rpc_parse/parse_net.c
+++ b/source3/rpc_parse/parse_net.c
@@ -134,7 +134,7 @@ static BOOL net_io_netinfo_1(char *desc, NETLOGON_INFO_1 *info, prs_struct *ps,
********************************************************************/
static void init_netinfo_2(NETLOGON_INFO_2 *info, uint32 flags, uint32 pdc_status,
- uint32 tc_status, char *trusted_dc_name)
+ uint32 tc_status, const char *trusted_dc_name)
{
int len_dc_name = strlen(trusted_dc_name);
info->flags = flags;
@@ -221,7 +221,7 @@ BOOL net_io_q_logon_ctrl2(char *desc, NET_Q_LOGON_CTRL2 *q_l, prs_struct *ps, in
Inits an NET_Q_LOGON_CTRL2 structure.
********************************************************************/
-void init_net_q_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, char *srv_name,
+void init_net_q_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, const char *srv_name,
uint32 query_level)
{
DEBUG(5,("init_q_logon_ctrl2\n"));
@@ -240,7 +240,7 @@ void init_net_q_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, char *srv_name,
void init_net_r_logon_ctrl2(NET_R_LOGON_CTRL2 *r_l, uint32 query_level,
uint32 flags, uint32 pdc_status,
uint32 logon_attempts, uint32 tc_status,
- char *trusted_domain_name)
+ const char *trusted_domain_name)
{
DEBUG(5,("init_r_logon_ctrl2\n"));
@@ -352,7 +352,7 @@ BOOL net_io_q_logon_ctrl(char *desc, NET_Q_LOGON_CTRL *q_l, prs_struct *ps,
Inits an NET_Q_LOGON_CTRL structure.
********************************************************************/
-void init_net_q_logon_ctrl(NET_Q_LOGON_CTRL *q_l, char *srv_name,
+void init_net_q_logon_ctrl(NET_Q_LOGON_CTRL *q_l, const char *srv_name,
uint32 query_level)
{
DEBUG(5,("init_q_logon_ctrl\n"));
@@ -430,7 +430,7 @@ BOOL net_io_r_logon_ctrl(char *desc, NET_R_LOGON_CTRL *r_l, prs_struct *ps,
********************************************************************/
void init_r_trust_dom(NET_R_TRUST_DOM_LIST *r_t,
- uint32 num_doms, char *dom_name)
+ uint32 num_doms, const char *dom_name)
{
int i = 0;
@@ -791,8 +791,10 @@ BOOL net_io_r_auth_3(char *desc, NET_R_AUTH_3 *r_a, prs_struct *ps, int depth)
Inits a NET_Q_SRV_PWSET.
********************************************************************/
-void init_q_srv_pwset(NET_Q_SRV_PWSET *q_s, char *logon_srv, char *sess_key, char *acct_name,
- uint16 sec_chan, char *comp_name, DOM_CRED *cred, uchar hashed_mach_pwd[16])
+void init_q_srv_pwset(NET_Q_SRV_PWSET *q_s,
+ const char *logon_srv, const char *sess_key, const char *acct_name,
+ uint16 sec_chan, const char *comp_name,
+ DOM_CRED *cred, uchar hashed_mach_pwd[16])
{
unsigned char nt_cypher[16];
@@ -857,9 +859,9 @@ BOOL net_io_r_srv_pwset(char *desc, NET_R_SRV_PWSET *r_s, prs_struct *ps, int de
Init DOM_SID2 array from a string containing multiple sids
*************************************************************************/
-static int init_dom_sid2s(TALLOC_CTX *ctx, char *sids_str, DOM_SID2 **ppsids)
+static int init_dom_sid2s(TALLOC_CTX *ctx, const char *sids_str, DOM_SID2 **ppsids)
{
- char *ptr;
+ const char *ptr;
pstring s2;
int count = 0;
@@ -898,10 +900,10 @@ static int init_dom_sid2s(TALLOC_CTX *ctx, char *sids_str, DOM_SID2 **ppsids)
Inits a NET_ID_INFO_1 structure.
********************************************************************/
-void init_id_info1(NET_ID_INFO_1 *id, char *domain_name,
+void init_id_info1(NET_ID_INFO_1 *id, const char *domain_name,
uint32 param_ctrl, uint32 log_id_low, uint32 log_id_high,
- char *user_name, char *wksta_name,
- char *sess_key,
+ const char *user_name, const char *wksta_name,
+ const char *sess_key,
unsigned char lm_cypher[16], unsigned char nt_cypher[16])
{
int len_domain_name = strlen(domain_name);
@@ -1143,7 +1145,8 @@ static BOOL net_io_id_info2(char *desc, NET_ID_INFO_2 *id, prs_struct *ps, int
********************************************************************/
void init_sam_info(DOM_SAM_INFO *sam,
- char *logon_srv, char *comp_name, DOM_CRED *clnt_cred,
+ const char *logon_srv, const char *comp_name,
+ DOM_CRED *clnt_cred,
DOM_CRED *rtn_cred, uint16 logon_level,
NET_ID_INFO_CTR *ctr)
{
@@ -1270,7 +1273,7 @@ void init_net_user_info3(TALLOC_CTX *ctx, NET_USER_INFO_3 *usr,
uint32 num_groups, const DOM_GID *gids,
uint32 user_flgs, uchar *sess_key,
const char *logon_srv, const char *logon_dom,
- const DOM_SID *dom_sid, char *other_sids)
+ const DOM_SID *dom_sid, const char *other_sids)
{
/* only cope with one "other" sid, right now. */
/* need to count the number of space-delimited sids */
diff --git a/source3/rpc_parse/parse_rpc.c b/source3/rpc_parse/parse_rpc.c
index 247c83aecd..e8825a2e14 100644
--- a/source3/rpc_parse/parse_rpc.c
+++ b/source3/rpc_parse/parse_rpc.c
@@ -697,7 +697,7 @@ BOOL smb_io_rpc_auth_verifier(char *desc, RPC_AUTH_VERIFIER *rav, prs_struct *ps
void init_rpc_auth_ntlmssp_neg(RPC_AUTH_NTLMSSP_NEG *neg,
uint32 neg_flgs,
- fstring myname, fstring domain)
+ const char *myname, const char *domain)
{
int len_myname = strlen(myname);
int len_domain = strlen(domain);
@@ -836,7 +836,7 @@ BOOL smb_io_rpc_auth_ntlmssp_chal(char *desc, RPC_AUTH_NTLMSSP_CHAL *chl, prs_st
void init_rpc_auth_ntlmssp_resp(RPC_AUTH_NTLMSSP_RESP *rsp,
uchar lm_resp[24], uchar nt_resp[24],
- char *domain, char *user, char *wks,
+ const char *domain, const char *user, const char *wks,
uint32 neg_flags)
{
uint32 offset;
diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c
index 08ed28e80a..d5ca78bda4 100644
--- a/source3/rpc_parse/parse_samr.c
+++ b/source3/rpc_parse/parse_samr.c
@@ -631,7 +631,7 @@ static BOOL sam_io_unk_info12(char *desc, SAM_UNK_INFO_12 * u_12,
/*******************************************************************
inits a structure.
********************************************************************/
-void init_unk_info5(SAM_UNK_INFO_5 * u_5,char *server)
+void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *server)
{
int len_server = strlen(server);
@@ -666,7 +666,7 @@ static BOOL sam_io_unk_info5(char *desc, SAM_UNK_INFO_5 * u_5,
inits a structure.
********************************************************************/
void init_unk_info2(SAM_UNK_INFO_2 * u_2,
- char *domain, char *server,
+ const char *domain, const char *server,
uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias)
{
int len_domain = strlen(domain);
diff --git a/source3/rpc_parse/parse_srv.c b/source3/rpc_parse/parse_srv.c
index 672db36a28..b3d33645b9 100644
--- a/source3/rpc_parse/parse_srv.c
+++ b/source3/rpc_parse/parse_srv.c
@@ -2686,7 +2686,7 @@ BOOL srv_io_r_net_file_close(char *desc, SRV_R_NET_FILE_CLOSE *q_n,
Inits a SRV_INFO_100 structure.
********************************************************************/
-void init_srv_info_100(SRV_INFO_100 *sv100, uint32 platform_id, char *name)
+void init_srv_info_100(SRV_INFO_100 *sv100, uint32 platform_id, const char *name)
{
DEBUG(5,("init_srv_info_100\n"));
@@ -2725,9 +2725,9 @@ static BOOL srv_io_info_100(char *desc, SRV_INFO_100 *sv100, prs_struct *ps, int
Inits a SRV_INFO_101 structure.
********************************************************************/
-void init_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, char *name,
+void init_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, const char *name,
uint32 ver_major, uint32 ver_minor,
- uint32 srv_type, char *comment)
+ uint32 srv_type, const char *comment)
{
DEBUG(5,("init_srv_info_101\n"));
@@ -2782,11 +2782,11 @@ static BOOL srv_io_info_101(char *desc, SRV_INFO_101 *sv101, prs_struct *ps, int
Inits a SRV_INFO_102 structure.
********************************************************************/
-void init_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, char *name,
- char *comment, uint32 ver_major, uint32 ver_minor,
+void init_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, const char *name,
+ const char *comment, uint32 ver_major, uint32 ver_minor,
uint32 srv_type, uint32 users, uint32 disc, uint32 hidden,
uint32 announce, uint32 ann_delta, uint32 licenses,
- char *usr_path)
+ const char *usr_path)
{
DEBUG(5,("init_srv_info_102\n"));
diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c
index 5edc1222a8..676ad8e3f3 100644
--- a/source3/rpc_server/srv_dfs.c
+++ b/source3/rpc_server/srv_dfs.c
@@ -31,8 +31,6 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
-extern pstring global_myname;
-
/**********************************************************************
api_dfs_exist
**********************************************************************/
diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c
index 65e387176d..da92e5c06b 100644
--- a/source3/rpc_server/srv_dfs_nt.c
+++ b/source3/rpc_server/srv_dfs_nt.c
@@ -29,8 +29,6 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
-extern pstring global_myname;
-
#define MAX_MSDFS_JUNCTIONS 256
/* This function does not return a WERROR or NTSTATUS code but rather 1 if
@@ -197,7 +195,7 @@ static BOOL init_reply_dfs_info_1(struct junction_map* j, DFS_INFO_1* dfs1, int
{
pstring str;
dfs1[i].ptr_entrypath = 1;
- slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname,
+ slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(),
j[i].service_name, j[i].volume_name);
DEBUG(5,("init_reply_dfs_info_1: %d) initing entrypath: %s\n",i,str));
init_unistr2(&dfs1[i].entrypath,str,strlen(str)+1);
@@ -212,7 +210,7 @@ static BOOL init_reply_dfs_info_2(struct junction_map* j, DFS_INFO_2* dfs2, int
{
pstring str;
dfs2[i].ptr_entrypath = 1;
- slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname,
+ slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(),
j[i].service_name, j[i].volume_name);
init_unistr2(&dfs2[i].entrypath, str, strlen(str)+1);
dfs2[i].ptr_comment = 0;
@@ -231,9 +229,9 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, DFS_I
dfs3[i].ptr_entrypath = 1;
if (j[i].volume_name[0] == '\0')
slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s",
- global_myname, j[i].service_name);
+ global_myname(), j[i].service_name);
else
- slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname,
+ slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(),
j[i].service_name, j[i].volume_name);
init_unistr2(&dfs3[i].entrypath, str, strlen(str)+1);
diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c
index c4fc0a5de7..fc51d7ef2f 100644
--- a/source3/rpc_server/srv_lsa_nt.c
+++ b/source3/rpc_server/srv_lsa_nt.c
@@ -30,13 +30,11 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
-extern fstring global_myworkgroup;
-extern pstring global_myname;
extern PRIVS privs[];
struct lsa_info {
- DOM_SID sid;
- uint32 access;
+ DOM_SID sid;
+ uint32 access;
};
struct generic_mapping lsa_generic_mapping = {
@@ -61,7 +59,7 @@ static void free_lsa_info(void *ptr)
Init dom_query
***************************************************************************/
-static void init_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid)
+static void init_dom_query(DOM_QUERY *d_q, const char *dom_name, DOM_SID *dom_sid)
{
int domlen = (dom_name != NULL) ? strlen(dom_name) : 0;
@@ -343,10 +341,11 @@ static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *s
}
/***************************************************************************
- init_dns_dom_info.
- ***************************************************************************/
-static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, char *nb_name,
- char *dns_name, char *forest_name,
+ Init_dns_dom_info.
+***************************************************************************/
+
+static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name,
+ const char *dns_name, const char *forest_name,
GUID *dom_guid, DOM_SID *dom_sid)
{
if (nb_name && *nb_name) {
@@ -513,7 +512,7 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF
struct lsa_info *handle;
LSA_INFO_UNION *info = &r_u->dom;
DOM_SID domain_sid;
- char *name = NULL;
+ const char *name;
DOM_SID *sid = NULL;
r_u->status = NT_STATUS_OK;
@@ -548,20 +547,19 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF
switch (lp_server_role()) {
case ROLE_DOMAIN_PDC:
case ROLE_DOMAIN_BDC:
- name = global_myworkgroup;
+ name = lp_workgroup();
sid = get_global_sam_sid();
break;
case ROLE_DOMAIN_MEMBER:
- name = global_myworkgroup;
+ name = lp_workgroup();
/* We need to return the Domain SID here. */
- if (secrets_fetch_domain_sid(global_myworkgroup,
- &domain_sid))
+ if (secrets_fetch_domain_sid(lp_workgroup(), &domain_sid))
sid = &domain_sid;
else
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
break;
case ROLE_STANDALONE:
- name = global_myworkgroup;
+ name = lp_workgroup();
sid = NULL;
break;
default:
@@ -578,15 +576,15 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF
switch (lp_server_role()) {
case ROLE_DOMAIN_PDC:
case ROLE_DOMAIN_BDC:
- name = global_myworkgroup;
+ name = lp_workgroup();
sid = get_global_sam_sid();
break;
case ROLE_DOMAIN_MEMBER:
- name = global_myname;
+ name = global_myname();
sid = get_global_sam_sid();
break;
case ROLE_STANDALONE:
- name = global_myname;
+ name = global_myname();
sid = get_global_sam_sid();
break;
default:
@@ -1214,7 +1212,7 @@ NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUER
NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_INFO2 *r_u)
{
struct lsa_info *handle;
- char *nb_name = NULL;
+ const char *nb_name;
char *dns_name = NULL;
char *forest_name = NULL;
DOM_SID *sid = NULL;
@@ -1236,13 +1234,12 @@ NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_I
switch (lp_server_role()) {
case ROLE_DOMAIN_PDC:
case ROLE_DOMAIN_BDC:
- nb_name = global_myworkgroup;
+ nb_name = lp_workgroup();
/* ugly temp hack for these next two */
dns_name = lp_realm();
forest_name = lp_realm();
sid = get_global_sam_sid();
- secrets_fetch_domain_guid(global_myworkgroup,
- &guid);
+ secrets_fetch_domain_guid(lp_workgroup(), &guid);
break;
default:
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c
index 69d619a2b0..12841a2e08 100644
--- a/source3/rpc_server/srv_netlog_nt.c
+++ b/source3/rpc_server/srv_netlog_nt.c
@@ -29,8 +29,6 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
-extern pstring global_myname;
-
/*************************************************************************
init_net_r_req_chal:
*************************************************************************/
@@ -687,8 +685,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *
return NT_STATUS_UNSUCCESSFUL;
}
- pstrcpy(my_name, global_myname);
- strupper(my_name);
+ pstrcpy(my_name, global_myname());
/*
* This is the point at which we get the group
diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c
index 0b5870b16c..603dcd0017 100644
--- a/source3/rpc_server/srv_samr_nt.c
+++ b/source3/rpc_server/srv_samr_nt.c
@@ -34,8 +34,6 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
-extern fstring global_myworkgroup;
-extern pstring global_myname;
extern DOM_SID global_sid_Builtin;
extern rid_name domain_group_rids[];
@@ -2123,7 +2121,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA
free_samr_db(info);
/* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */
- init_unk_info2(&ctr->info.inf2, global_myworkgroup, global_myname, (uint32) time(NULL),
+ init_unk_info2(&ctr->info.inf2, lp_workgroup(), global_myname(), (uint32) time(NULL),
num_users, num_groups, num_aliases);
break;
case 0x03:
@@ -2133,7 +2131,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA
init_unk_info3(&ctr->info.inf3, nt_logout);
break;
case 0x05:
- init_unk_info5(&ctr->info.inf5, global_myname);
+ init_unk_info5(&ctr->info.inf5, global_myname());
break;
case 0x06:
init_unk_info6(&ctr->info.inf6);
@@ -2564,7 +2562,7 @@ NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_EN
struct samr_info *info;
uint32 num_entries = 2;
fstring dom[2];
- char *name;
+ const char *name;
r_u->status = NT_STATUS_OK;
@@ -2578,10 +2576,10 @@ NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_EN
switch (lp_server_role()) {
case ROLE_DOMAIN_PDC:
case ROLE_DOMAIN_BDC:
- name = global_myworkgroup;
+ name = lp_workgroup();
break;
default:
- name = global_myname;
+ name = global_myname();
}
fstrcpy(dom[0],name);
@@ -4313,7 +4311,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW
free_samr_db(info);
/* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */
- init_unk_info2(&ctr->info.inf2, global_myworkgroup, global_myname, (uint32) time(NULL),
+ init_unk_info2(&ctr->info.inf2, lp_workgroup(), global_myname(), (uint32) time(NULL),
num_users, num_groups, num_aliases);
break;
case 0x03:
@@ -4325,7 +4323,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW
init_unk_info3(&ctr->info.inf3, nt_logout);
break;
case 0x05:
- init_unk_info5(&ctr->info.inf5, global_myname);
+ init_unk_info5(&ctr->info.inf5, global_myname());
break;
case 0x06:
init_unk_info6(&ctr->info.inf6);
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 871aac8e68..ad55ea6a49 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -2332,8 +2332,6 @@ done:
static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *remote_machine)
{
- extern pstring global_myname;
-
ZERO_STRUCTP(the_cli);
if(cli_initialise(the_cli) == NULL) {
DEBUG(0,("connect_to_client: unable to initialize client connection.\n"));
@@ -2358,7 +2356,7 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *rem
return False;
}
- if (!attempt_netbios_session_request(the_cli, global_myname, remote_machine, &the_cli->dest_ip)) {
+ if (!attempt_netbios_session_request(the_cli, global_myname(), remote_machine, &the_cli->dest_ip)) {
DEBUG(0,("connect_to_client: machine %s rejected the NetBIOS session request.\n",
remote_machine));
cli_shutdown(the_cli);
diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c
index ecde51df9f..0384bb81a3 100644
--- a/source3/rpc_server/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srv_srvsvc_nt.c
@@ -27,8 +27,6 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
-extern pstring global_myname;
-
/*******************************************************************
Utility function to get the 'type' of a share from an snum.
********************************************************************/
@@ -1211,7 +1209,7 @@ WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R
case 102:
init_srv_info_102(&ctr->srv.sv102,
- 500, global_myname,
+ 500, global_myname(),
string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH),
lp_major_announce_version(), lp_minor_announce_version(),
lp_default_server_announce(),
@@ -1225,13 +1223,13 @@ WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R
break;
case 101:
init_srv_info_101(&ctr->srv.sv101,
- 500, global_myname,
+ 500, global_myname(),
lp_major_announce_version(), lp_minor_announce_version(),
lp_default_server_announce(),
string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH));
break;
case 100:
- init_srv_info_100(&ctr->srv.sv100, 500, global_myname);
+ init_srv_info_100(&ctr->srv.sv100, 500, global_myname());
break;
default:
status = WERR_UNKNOWN_LEVEL;
diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c
index 7687e7b00a..bda7b14a42 100644
--- a/source3/rpc_server/srv_wkssvc_nt.c
+++ b/source3/rpc_server/srv_wkssvc_nt.c
@@ -28,8 +28,6 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
-extern pstring global_myname;
-
/*******************************************************************
create_wks_info_100
********************************************************************/
@@ -41,7 +39,7 @@ static void create_wks_info_100(WKS_INFO_100 *inf)
DEBUG(5,("create_wks_info_100: %d\n", __LINE__));
- pstrcpy (my_name, global_myname);
+ pstrcpy (my_name, global_myname());
strupper(my_name);
pstrcpy (domain, lp_workgroup());
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index e23140bdb0..646a6d9035 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -435,7 +435,8 @@ static void add_command_set(struct cmd_set *cmd_set)
static NTSTATUS do_cmd(struct cli_state *cli, struct cmd_set *cmd_entry,
char *cmd)
{
- char *p = cmd, **argv = NULL;
+ char **argv = NULL;
+ const char *p = cmd;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
pstring buf;
int argc = 0, i;
@@ -528,7 +529,7 @@ static NTSTATUS process_cmd(struct cli_state *cli, char *cmd)
struct cmd_list *temp_list;
BOOL found = False;
pstring buf;
- char *p = cmd;
+ const char *p = cmd;
NTSTATUS result = NT_STATUS_OK;
int len = 0;
@@ -578,7 +579,6 @@ static NTSTATUS process_cmd(struct cli_state *cli, char *cmd)
int main(int argc, char *argv[])
{
- extern pstring global_myname;
static int got_pass = 0;
BOOL interactive = True;
int opt;
@@ -694,8 +694,8 @@ static NTSTATUS process_cmd(struct cli_state *cli, char *cmd)
load_interfaces();
- get_myname((*global_myname)?NULL:global_myname);
- strupper(global_myname);
+ if (!init_names())
+ return 1;
/* Resolve the IP address */
@@ -719,7 +719,7 @@ static NTSTATUS process_cmd(struct cli_state *cli, char *cmd)
if (!strlen(username) && !got_pass)
get_username(username);
- nt_status = cli_full_connection(&cli, global_myname, server,
+ nt_status = cli_full_connection(&cli, global_myname(), server,
&server_ip, 0,
"IPC$", "IPC",
username, domain,
diff --git a/source3/script/mkproto.awk b/source3/script/mkproto.awk
index 196715d6b1..9acdf374f1 100644
--- a/source3/script/mkproto.awk
+++ b/source3/script/mkproto.awk
@@ -64,7 +64,7 @@ END {
/^FN_LOCAL_LIST/ {
split($0,a,"[,()]")
- printf "char **%s(int );\n", a[2]
+ printf "const char **%s(int );\n", a[2]
}
/^FN_LOCAL_STRING/ {
@@ -94,7 +94,7 @@ END {
/^FN_GLOBAL_LIST/ {
split($0,a,"[,()]")
- printf "char **%s(void);\n", a[2]
+ printf "const char **%s(void);\n", a[2]
}
/^FN_GLOBAL_STRING/ {
diff --git a/source3/smbd/change_trust_pw.c b/source3/smbd/change_trust_pw.c
index 7cb9084072..e4a7fbae6b 100644
--- a/source3/smbd/change_trust_pw.c
+++ b/source3/smbd/change_trust_pw.c
@@ -24,13 +24,11 @@
#include "includes.h"
-extern pstring global_myname;
-
/*********************************************************
Change the domain password on the PDC.
**********************************************************/
-static NTSTATUS modify_trust_password( char *domain, char *remote_machine,
+static NTSTATUS modify_trust_password( const char *domain, const char *remote_machine,
unsigned char orig_trust_passwd_hash[16])
{
struct cli_state *cli;
@@ -46,7 +44,7 @@ static NTSTATUS modify_trust_password( char *domain, char *remote_machine,
return NT_STATUS_UNSUCCESSFUL;
}
- if (!NT_STATUS_IS_OK(cli_full_connection(&cli, global_myname, remote_machine,
+ if (!NT_STATUS_IS_OK(cli_full_connection(&cli, global_myname(), remote_machine,
NULL, 0,
"IPC$", "IPC",
"", "",
@@ -82,7 +80,7 @@ machine %s. Error was : %s.\n", remote_machine, cli_errstr(cli)));
Change the trust account password for a domain.
************************************************************************/
-NTSTATUS change_trust_account_password( char *domain, char *remote_machine_list)
+NTSTATUS change_trust_account_password( const char *domain, const char *remote_machine_list)
{
fstring remote_machine;
unsigned char old_trust_passwd_hash[16];
@@ -117,7 +115,7 @@ account password for domain %s.\n", domain));
* address used as a string.
*/
- if(!lookup_dc_name(global_myname, domain, &pdc_ip, dc_name))
+ if(!lookup_dc_name(global_myname(), domain, &pdc_ip, dc_name))
continue;
if(NT_STATUS_IS_OK(res = modify_trust_password( domain, dc_name,
old_trust_passwd_hash)))
diff --git a/source3/smbd/chgpasswd.c b/source3/smbd/chgpasswd.c
index a5274862fc..c2a82d1eb6 100644
--- a/source3/smbd/chgpasswd.c
+++ b/source3/smbd/chgpasswd.c
@@ -290,7 +290,7 @@ static void pwd_sub(char *buf)
all_string_sub(buf, "\\t", "\t", 0);
}
-static int talktochild(int master, char *seq)
+static int talktochild(int master, const char *seq)
{
int count = 0;
fstring issue, expected;
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c
index 7ab1be9dd9..6a031dde6f 100644
--- a/source3/smbd/lanman.c
+++ b/source3/smbd/lanman.c
@@ -33,8 +33,6 @@
#define CHECK_TYPES 0
extern fstring local_machine;
-extern pstring global_myname;
-extern fstring global_myworkgroup;
#define NERR_Success 0
#define NERR_badpass 86
@@ -960,7 +958,7 @@ struct srv_info_struct
******************************************************************/
static int get_server_info(uint32 servertype,
struct srv_info_struct **servers,
- char *domain)
+ const char *domain)
{
int count=0;
int alloced=0;
@@ -985,7 +983,7 @@ static int get_server_info(uint32 servertype,
for (i=0;lines[i];i++) {
fstring stype;
struct srv_info_struct *s;
- char *ptr = lines[i];
+ const char *ptr = lines[i];
BOOL ok = True;
if (!*ptr) continue;
@@ -1010,7 +1008,7 @@ static int get_server_info(uint32 servertype,
if (!next_token(&ptr,s->comment, NULL, sizeof(s->comment))) continue;
if (!next_token(&ptr,s->domain , NULL, sizeof(s->domain))) {
/* this allows us to cope with an old nmbd */
- pstrcpy(s->domain,global_myworkgroup);
+ pstrcpy(s->domain,lp_workgroup());
}
if (sscanf(stype,"%X",&s->type) != 1) {
@@ -1206,7 +1204,7 @@ static BOOL api_RNetServerEnum(connection_struct *conn, uint16 vuid, char *param
if (strcmp(str1, "WrLehDz") == 0) {
pull_ascii_fstring(domain, p);
} else {
- fstrcpy(domain, global_myworkgroup);
+ fstrcpy(domain, lp_workgroup());
}
if (lp_browse_list())
@@ -2311,7 +2309,7 @@ static BOOL api_RNetServerGetInfo(connection_struct *conn,uint16 vuid, char *par
pstrcpy(comment,string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH));
- if ((count=get_server_info(SV_TYPE_ALL,&servers,global_myworkgroup))>0) {
+ if ((count=get_server_info(SV_TYPE_ALL,&servers,lp_workgroup()))>0) {
for (i=0;i<count;i++)
if (strequal(servers[i].name,local_machine))
{
@@ -2397,7 +2395,7 @@ static BOOL api_NetWkstaGetInfo(connection_struct *conn,uint16 vuid, char *param
p += 4;
SIVAL(p,0,PTR_DIFF(p2,*rdata)); /* login domain */
- pstrcpy(p2,global_myworkgroup);
+ pstrcpy(p2,lp_workgroup());
strupper(p2);
p2 = skip_string(p2,1);
p += 4;
@@ -2407,7 +2405,7 @@ static BOOL api_NetWkstaGetInfo(connection_struct *conn,uint16 vuid, char *param
p += 2;
SIVAL(p,0,PTR_DIFF(p2,*rdata));
- pstrcpy(p2,global_myworkgroup); /* don't know. login domain?? */
+ pstrcpy(p2,lp_workgroup()); /* don't know. login domain?? */
p2 = skip_string(p2,1);
p += 4;
@@ -2810,7 +2808,7 @@ static BOOL api_WWkstaUserLogon(connection_struct *conn,uint16 vuid, char *param
strupper(mypath);
PACKS(&desc,"z",mypath); /* computer */
}
- PACKS(&desc,"z",global_myworkgroup);/* domain */
+ PACKS(&desc,"z",lp_workgroup());/* domain */
PACKS(&desc,"z", vuser && vuser->logon_script ? vuser->logon_script :""); /* script path */
diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c
index 06a55cb33e..b91c0c0866 100644
--- a/source3/smbd/negprot.c
+++ b/source3/smbd/negprot.c
@@ -22,7 +22,6 @@
extern int Protocol;
extern int max_recv;
-extern fstring global_myworkgroup;
BOOL global_encrypted_passwords_negotiated = False;
BOOL global_spnego_negotiated = False;
struct auth_context *negprot_global_auth_context = NULL;
@@ -168,7 +167,6 @@ static int reply_lanman2(char *inbuf, char *outbuf)
static int negprot_spnego(char *p)
{
DATA_BLOB blob;
- extern pstring global_myname;
uint8 guid[16];
const char *OIDs_krb5[] = {OID_KERBEROS5,
OID_KERBEROS5_OLD,
@@ -181,7 +179,7 @@ static int negprot_spnego(char *p)
global_spnego_negotiated = True;
memset(guid, 0, 16);
- safe_strcpy((char *)guid, global_myname, 16);
+ safe_strcpy((char *)guid, global_myname(), 16);
strlower((char *)guid);
#if 0
@@ -292,7 +290,7 @@ static int reply_nt1(char *inbuf, char *outbuf)
SSVALS(outbuf,smb_vwv16+1,8);
p += 8;
}
- p += srvstr_push(outbuf, p, global_myworkgroup, -1,
+ p += srvstr_push(outbuf, p, lp_workgroup(), -1,
STR_UNICODE|STR_TERMINATE|STR_NOALIGN);
DEBUG(3,("not using SPNEGO\n"));
} else {
diff --git a/source3/smbd/password.c b/source3/smbd/password.c
index 1e87065e31..4ce99e96bb 100644
--- a/source3/smbd/password.c
+++ b/source3/smbd/password.c
@@ -257,23 +257,25 @@ BOOL user_ok(const char *user,int snum)
if (lp_invalid_users(snum)) {
str_list_copy(&invalid, lp_invalid_users(snum));
if (invalid && str_list_substitute(invalid, "%S", lp_servicename(snum))) {
- ret = !user_in_list(user, invalid);
+ ret = !user_in_list(user, (const char **)invalid);
}
}
- if (invalid) str_list_free (&invalid);
+ if (invalid)
+ str_list_free (&invalid);
if (ret && lp_valid_users(snum)) {
str_list_copy(&valid, lp_valid_users(snum));
if (valid && str_list_substitute(valid, "%S", lp_servicename(snum))) {
- ret = user_in_list(user,valid);
+ ret = user_in_list(user, (const char **)valid);
}
}
- if (valid) str_list_free (&valid);
+ if (valid)
+ str_list_free (&valid);
if (ret && lp_onlyuser(snum)) {
char **user_list = str_list_make (lp_username(snum), NULL);
if (user_list && str_list_substitute(user_list, "%S", lp_servicename(snum))) {
- ret = user_in_list(user, user_list);
+ ret = user_in_list(user, (const char **)user_list);
}
if (user_list) str_list_free (&user_list);
}
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 0f7cfd0e9c..c46c4c5509 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -45,8 +45,6 @@ extern int smb_read_error;
SIG_ATOMIC_T reload_after_sighup = 0;
SIG_ATOMIC_T got_sig_term = 0;
extern BOOL global_machine_password_needs_changing;
-extern fstring global_myworkgroup;
-extern pstring global_myname;
extern int max_send;
/****************************************************************************
@@ -1154,16 +1152,16 @@ static BOOL timeout_processing(int deadtime, int *select_timeout, time_t *last_t
* First, open the machine password file with an exclusive lock.
*/
- if (secrets_lock_trust_account_password(global_myworkgroup, True) == False) {
+ if (secrets_lock_trust_account_password(lp_workgroup(), True) == False) {
DEBUG(0,("process: unable to lock the machine account password for \
-machine %s in domain %s.\n", global_myname, global_myworkgroup ));
+machine %s in domain %s.\n", global_myname(), lp_workgroup() ));
return True;
}
- if(!secrets_fetch_trust_account_password(global_myworkgroup, trust_passwd_hash, &lct)) {
+ if(!secrets_fetch_trust_account_password(lp_workgroup(), trust_passwd_hash, &lct)) {
DEBUG(0,("process: unable to read the machine account password for \
-machine %s in domain %s.\n", global_myname, global_myworkgroup ));
- secrets_lock_trust_account_password(global_myworkgroup, False);
+machine %s in domain %s.\n", global_myname(), lp_workgroup() ));
+ secrets_lock_trust_account_password(lp_workgroup(), False);
return True;
}
@@ -1173,15 +1171,15 @@ machine %s in domain %s.\n", global_myname, global_myworkgroup ));
if(t < lct + lp_machine_password_timeout()) {
global_machine_password_needs_changing = False;
- secrets_lock_trust_account_password(global_myworkgroup, False);
+ secrets_lock_trust_account_password(lp_workgroup(), False);
return True;
}
pstrcpy(remote_machine_list, lp_passwordserver());
- change_trust_account_password( global_myworkgroup, remote_machine_list);
+ change_trust_account_password( lp_workgroup(), remote_machine_list);
global_machine_password_needs_changing = False;
- secrets_lock_trust_account_password(global_myworkgroup, False);
+ secrets_lock_trust_account_password(lp_workgroup(), False);
}
/*
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 3371d9b544..2c29ffdf51 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -33,7 +33,6 @@ extern char magic_char;
extern BOOL case_sensitive;
extern BOOL case_preserve;
extern BOOL short_case_preserve;
-extern pstring global_myname;
extern int global_oplock_break;
unsigned int smb_echo_count = 0;
@@ -356,7 +355,7 @@ int reply_ioctl(connection_struct *conn,
{
uint16 rap_jobid = pjobid_to_rap(SNUM(fsp->conn), fsp->print_jobid);
SSVAL(p,0,rap_jobid); /* Job number */
- srvstr_push(outbuf, p+2, global_myname, 15, STR_TERMINATE|STR_ASCII);
+ srvstr_push(outbuf, p+2, global_myname(), 15, STR_TERMINATE|STR_ASCII);
srvstr_push(outbuf, p+18, lp_servicename(SNUM(conn)), 13, STR_TERMINATE|STR_ASCII);
break;
}
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 3d9a4675b2..342c7c85cf 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -22,9 +22,6 @@
#include "includes.h"
-extern fstring global_myworkgroup;
-extern pstring global_myname;
-
int am_parent = 1;
/* the last message the was processed */
@@ -200,7 +197,7 @@ static BOOL open_sockets_smbd(BOOL is_daemon,const char *smb_ports)
for(i = 0; i < num_interfaces; i++) {
struct in_addr *ifip = iface_n_ip(i);
fstring tok;
- char *ptr;
+ const char *ptr;
if(ifip == NULL) {
DEBUG(0,("open_sockets_smbd: interface %d has NULL IP address !\n", i));
@@ -237,7 +234,7 @@ static BOOL open_sockets_smbd(BOOL is_daemon,const char *smb_ports)
from anywhere. */
fstring tok;
- char *ptr;
+ const char *ptr;
num_interfaces = 1;
@@ -582,22 +579,15 @@ void exit_server(char *reason)
Initialise connect, service and file structs.
****************************************************************************/
-static void init_structs(void )
+static BOOL init_structs(void )
{
/*
* Set the machine NETBIOS name if not already
* set from the config file.
*/
- if (!*global_myname) {
- char *p;
- pstrcpy( global_myname, myhostname() );
- p = strchr_m(global_myname, '.' );
- if (p)
- *p = 0;
- }
-
- strupper(global_myname);
+ if (!init_names())
+ return False;
conn_init();
@@ -610,6 +600,7 @@ static void init_structs(void )
secrets_init();
+ return True;
}
/****************************************************************************
@@ -740,8 +731,6 @@ static void init_structs(void )
}
#endif
- fstrcpy(global_myworkgroup, lp_workgroup());
-
DEBUG(3,( "loaded services\n"));
if (!is_daemon && !is_a_socket(0)) {
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index a8a590da80..16e0ad4160 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -271,7 +271,7 @@ static void set_read_only(connection_struct *conn)
if (!str_list_substitute(list, "%S", service)) {
DEBUG(0, ("ERROR: read list substitution failed\n"));
}
- if (user_in_list(conn->user, list))
+ if (user_in_list(conn->user, (const char **)list))
conn->read_only = True;
str_list_free(&list);
}
@@ -281,7 +281,7 @@ static void set_read_only(connection_struct *conn)
if (!str_list_substitute(list, "%S", service)) {
DEBUG(0, ("ERROR: write list substitution failed\n"));
}
- if (user_in_list(conn->user, list))
+ if (user_in_list(conn->user, (const char **)list))
conn->read_only = False;
str_list_free(&list);
}
diff --git a/source3/smbd/sesssetup.c b/source3/smbd/sesssetup.c
index b9af720008..4ab1063217 100644
--- a/source3/smbd/sesssetup.c
+++ b/source3/smbd/sesssetup.c
@@ -247,7 +247,6 @@ static int reply_spnego_negotiate(connection_struct *conn,
const uint8 *cryptkey;
BOOL got_kerberos = False;
NTSTATUS nt_status;
- extern pstring global_myname;
char *cliname=NULL, *domname=NULL;
/* parse out the OIDs and the first sec blob */
@@ -325,14 +324,14 @@ static int reply_spnego_negotiate(connection_struct *conn,
fstrcpy(dnsdomname, (SEC_ADS == lp_security())?lp_realm():"");
strlower(dnsdomname);
- fstrcpy(dnsname, global_myname);
+ fstrcpy(dnsname, global_myname());
fstrcat(dnsname, ".");
fstrcat(dnsname, dnsdomname);
strlower(dnsname);
msrpc_gen(&struct_blob, "aaaaa",
2, lp_workgroup(),
- 1, global_myname,
+ 1, global_myname(),
4, dnsdomname,
3, dnsname,
0, "");
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 8b9728d513..a2627021d9 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -28,7 +28,6 @@ extern int smb_read_error;
extern fstring local_machine;
extern int global_oplock_break;
extern uint32 global_client_caps;
-extern pstring global_myname;
#define get_file_size(sbuf) (sbuf.st_size)
@@ -3021,7 +3020,7 @@ static int call_trans2ioctl(connection_struct *conn, char* inbuf,
rap_jobid = pjobid_to_rap(SNUM(fsp->conn), fsp->print_jobid); /* Job number */
SSVAL(pdata,0,rap_jobid); /* Job number */
- srvstr_push( outbuf, pdata + 2, global_myname, 15, STR_ASCII|STR_TERMINATE); /* Our NetBIOS name */
+ srvstr_push( outbuf, pdata + 2, global_myname(), 15, STR_ASCII|STR_TERMINATE); /* Our NetBIOS name */
srvstr_push( outbuf, pdata+18, lp_servicename(SNUM(conn)), 13, STR_ASCII|STR_TERMINATE); /* Service name */
send_trans2_replies(outbuf,bufsize,*pparams,0,*ppdata,32);
return(-1);
diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c
index 48b9768358..e2cc26e0ae 100644
--- a/source3/smbd/uid.c
+++ b/source3/smbd/uid.c
@@ -445,8 +445,6 @@ void add_supplementary_nt_login_groups(int *n_groups, gid_t **pp_groups, NT_USER
BOOL lookup_name(const char *domain, const char *name, DOM_SID *psid, enum SID_NAME_USE *name_type)
{
- extern pstring global_myname;
- extern fstring global_myworkgroup;
fstring sid;
BOOL local_lookup = False;
@@ -455,11 +453,11 @@ BOOL lookup_name(const char *domain, const char *name, DOM_SID *psid, enum SID_N
/* If we are looking up a domain user, make sure it is
for the local machine only */
- if (strequal(global_myname, domain)) {
+ if (strequal(global_myname(), domain)) {
local_lookup = True;
} else if (lp_server_role() == ROLE_DOMAIN_PDC ||
lp_server_role() == ROLE_DOMAIN_BDC) {
- if (strequal(domain, global_myworkgroup)) {
+ if (strequal(domain, lp_workgroup())) {
local_lookup = True;
}
}
diff --git a/source3/utils/net.c b/source3/utils/net.c
index da98c6455f..37ceadc372 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -61,7 +61,7 @@ char *opt_host = NULL;
char *opt_password = NULL;
char *opt_user_name = NULL;
BOOL opt_user_specified = False;
-char *opt_workgroup = NULL;
+const char *opt_workgroup = NULL;
int opt_long_list_entries = 0;
int opt_reboot = 0;
int opt_force = 0;
@@ -77,7 +77,6 @@ static int opt_machine_pass = 0;
BOOL opt_have_ip = False;
struct in_addr opt_dest_ip;
-extern pstring global_myname;
extern BOOL AllowDebugChange;
/*
@@ -188,7 +187,7 @@ BOOL net_find_server(unsigned flags, struct in_addr *server_ip, char **server_na
if (is_zero_ip(pdc_ip))
return False;
- if (!lookup_dc_name(global_myname, opt_target_workgroup, &pdc_ip, dc_name))
+ if (!lookup_dc_name(global_myname(), opt_target_workgroup, &pdc_ip, dc_name))
return False;
*server_name = strdup(dc_name);
@@ -238,7 +237,7 @@ BOOL net_find_dc(struct in_addr *server_ip, fstring server_name, const char *dom
if (is_zero_ip(*server_ip))
return False;
- if (!lookup_dc_name(global_myname, domain_name, server_ip, dc_name))
+ if (!lookup_dc_name(global_myname(), domain_name, server_ip, dc_name))
return False;
safe_strcpy(server_name, dc_name, FSTRING_LEN);
@@ -335,7 +334,7 @@ static int net_getlocalsid(int argc, const char **argv)
name = argv[0];
}
else {
- name = global_myname;
+ name = global_myname();
}
if (!secrets_fetch_domain_sid(name, &sid)) {
@@ -359,7 +358,7 @@ static int net_setlocalsid(int argc, const char **argv)
return 1;
}
- if (!secrets_store_domain_sid(global_myname, &sid)) {
+ if (!secrets_store_domain_sid(global_myname(), &sid)) {
DEBUG(0,("Can't store domain SID as a pdc/bdc.\n"));
return 1;
}
@@ -372,12 +371,12 @@ static int net_getdomainsid(int argc, const char **argv)
DOM_SID domain_sid;
fstring sid_str;
- if (!secrets_fetch_domain_sid(global_myname, &domain_sid)) {
+ if (!secrets_fetch_domain_sid(global_myname(), &domain_sid)) {
d_printf("Could not fetch local SID\n");
return 1;
}
sid_to_string(sid_str, &domain_sid);
- d_printf("SID for domain %s is: %s\n", global_myname, sid_str);
+ d_printf("SID for domain %s is: %s\n", global_myname(), sid_str);
if (!secrets_fetch_domain_sid(lp_workgroup(), &domain_sid)) {
d_printf("Could not fetch domain SID\n");
@@ -528,19 +527,11 @@ static struct functable net_func[] = {
}
if (!opt_target_workgroup) {
- opt_target_workgroup = lp_workgroup();
+ opt_target_workgroup = strdup(lp_workgroup());
}
- if (!*global_myname) {
- char *p2;
-
- pstrcpy(global_myname, myhostname());
- p2 = strchr_m(global_myname, '.');
- if (p2)
- *p2 = 0;
- }
-
- strupper(global_myname);
+ if (!init_names())
+ exit(1);
load_interfaces();
@@ -553,7 +544,7 @@ static struct functable net_func[] = {
exit(1);
}
- asprintf(&opt_user_name,"%s$", global_myname);
+ asprintf(&opt_user_name,"%s$", global_myname());
opt_password = secrets_fetch_machine_password();
if (!opt_password) {
d_printf("ERROR: Unable to fetch machine password\n");
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index af290ce83c..b138f67aa3 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -513,19 +513,18 @@ static int net_ads_status(int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS rc;
- extern pstring global_myname;
void *res;
if (!(ads = ads_startup())) return -1;
- rc = ads_find_machine_acct(ads, &res, global_myname);
+ rc = ads_find_machine_acct(ads, &res, global_myname());
if (!ADS_ERR_OK(rc)) {
d_printf("ads_find_machine_acct: %s\n", ads_errstr(rc));
return -1;
}
if (ads_count_replies(ads, res) == 0) {
- d_printf("No machine account for '%s' found\n", global_myname);
+ d_printf("No machine account for '%s' found\n", global_myname());
return -1;
}
@@ -538,7 +537,6 @@ static int net_ads_leave(int argc, const char **argv)
{
ADS_STRUCT *ads = NULL;
ADS_STATUS rc;
- extern pstring global_myname;
if (!secrets_init()) {
DEBUG(1,("Failed to initialise secrets database\n"));
@@ -546,7 +544,7 @@ static int net_ads_leave(int argc, const char **argv)
}
if (!opt_password) {
- asprintf(&opt_user_name, "%s$", global_myname);
+ asprintf(&opt_user_name, "%s$", global_myname());
opt_password = secrets_fetch_machine_password();
}
@@ -554,14 +552,14 @@ static int net_ads_leave(int argc, const char **argv)
return -1;
}
- rc = ads_leave_realm(ads, global_myname);
+ rc = ads_leave_realm(ads, global_myname());
if (!ADS_ERR_OK(rc)) {
d_printf("Failed to delete host '%s' from the '%s' realm.\n",
- global_myname, ads->config.realm);
+ global_myname(), ads->config.realm);
return -1;
}
- d_printf("Removed '%s' from realm '%s'\n", global_myname, ads->config.realm);
+ d_printf("Removed '%s' from realm '%s'\n", global_myname(), ads->config.realm);
return 0;
}
@@ -569,14 +567,13 @@ static int net_ads_leave(int argc, const char **argv)
static int net_ads_join_ok(void)
{
ADS_STRUCT *ads = NULL;
- extern pstring global_myname;
if (!secrets_init()) {
DEBUG(1,("Failed to initialise secrets database\n"));
return -1;
}
- asprintf(&opt_user_name, "%s$", global_myname);
+ asprintf(&opt_user_name, "%s$", global_myname());
opt_password = secrets_fetch_machine_password();
if (!(ads = ads_startup())) {
@@ -611,7 +608,6 @@ int net_ads_join(int argc, const char **argv)
ADS_STATUS rc;
char *password;
char *tmp_password;
- extern pstring global_myname;
const char *org_unit = "Computers";
char *dn;
void *res;
@@ -649,7 +645,7 @@ int net_ads_join(int argc, const char **argv)
return -1;
}
- rc = ads_join_realm(ads, global_myname, org_unit);
+ rc = ads_join_realm(ads, global_myname(), org_unit);
if (!ADS_ERR_OK(rc)) {
d_printf("ads_join_realm: %s\n", ads_errstr(rc));
return -1;
@@ -661,7 +657,7 @@ int net_ads_join(int argc, const char **argv)
return -1;
}
- rc = ads_set_machine_password(ads, global_myname, password);
+ rc = ads_set_machine_password(ads, global_myname(), password);
if (!ADS_ERR_OK(rc)) {
d_printf("ads_set_machine_password: %s\n", ads_errstr(rc));
return -1;
@@ -677,7 +673,7 @@ int net_ads_join(int argc, const char **argv)
return -1;
}
- d_printf("Joined '%s' to realm '%s'\n", global_myname, ads->config.realm);
+ d_printf("Joined '%s' to realm '%s'\n", global_myname(), ads->config.realm);
free(password);
@@ -704,7 +700,6 @@ static int net_ads_printer_info(int argc, const char **argv)
ADS_STRUCT *ads;
ADS_STATUS rc;
const char *servername, *printername;
- extern pstring global_myname;
void *res = NULL;
if (!(ads = ads_startup())) return -1;
@@ -717,7 +712,7 @@ static int net_ads_printer_info(int argc, const char **argv)
if (argc > 1)
servername = argv[1];
else
- servername = global_myname;
+ servername = global_myname();
rc = ads_find_printer_on_server(ads, &res, printername, servername);
@@ -750,7 +745,6 @@ static int net_ads_printer_publish(int argc, const char **argv)
ADS_STATUS rc;
char *uncname, *servername;
ADS_PRINTER_ENTRY prt;
- extern pstring global_myname;
char *ports[2] = {"Samba", NULL};
/*
@@ -772,11 +766,11 @@ static int net_ads_printer_publish(int argc, const char **argv)
get_a_printer, because the server name might be
localhost or an ip address */
prt.printerName = argv[0];
- asprintf(&servername, "%s.%s", global_myname, ads->config.realm);
+ asprintf(&servername, "%s.%s", global_myname(), ads->config.realm);
prt.serverName = servername;
- prt.shortServerName = global_myname;
+ prt.shortServerName = global_myname();
prt.versionNumber = "4";
- asprintf(&uncname, "\\\\%s\\%s", global_myname, argv[0]);
+ asprintf(&uncname, "\\\\%s\\%s", global_myname(), argv[0]);
prt.uNCName=uncname;
prt.printBinNames = (char **) bins;
prt.printMediaSupported = (char **) media;
@@ -799,8 +793,8 @@ static int net_ads_printer_remove(int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS rc;
- char *servername, *prt_dn;
- extern pstring global_myname;
+ const char *servername;
+ char *prt_dn;
void *res = NULL;
if (!(ads = ads_startup())) return -1;
@@ -811,7 +805,7 @@ static int net_ads_printer_remove(int argc, const char **argv)
if (argc > 1)
servername = argv[1];
else
- servername = global_myname;
+ servername = global_myname();
rc = ads_find_printer_on_server(ads, &res, argv[0], servername);
@@ -902,7 +896,6 @@ static int net_ads_password(int argc, const char **argv)
static int net_ads_change_localhost_pass(int argc, const char **argv)
{
ADS_STRUCT *ads;
- extern pstring global_myname;
char *host_principal;
char *hostname;
ADS_STATUS ret;
@@ -912,14 +905,14 @@ static int net_ads_change_localhost_pass(int argc, const char **argv)
return -1;
}
- asprintf(&opt_user_name, "%s$", global_myname);
+ asprintf(&opt_user_name, "%s$", global_myname());
opt_password = secrets_fetch_machine_password();
if (!(ads = ads_startup())) {
return -1;
}
- hostname = strdup(global_myname);
+ hostname = strdup(global_myname());
strlower(hostname);
asprintf(&host_principal, "%s@%s", hostname, ads->config.realm);
SAFE_FREE(hostname);
diff --git a/source3/utils/net_ads_cldap.c b/source3/utils/net_ads_cldap.c
index 6821a5902e..f81c763093 100644
--- a/source3/utils/net_ads_cldap.c
+++ b/source3/utils/net_ads_cldap.c
@@ -232,7 +232,6 @@ int ads_cldap_netlogon(ADS_STRUCT *ads)
{
int sock;
int ret;
- extern pstring global_myname;
struct cldap_netlogon_reply reply;
sock = open_udp_socket(inet_ntoa(ads->ldap_ip), ads->ldap_port);
@@ -243,7 +242,7 @@ int ads_cldap_netlogon(ADS_STRUCT *ads)
return -1;
}
- ret = send_cldap_netlogon(sock, ads->config.realm, global_myname, 6);
+ ret = send_cldap_netlogon(sock, ads->config.realm, global_myname(), 6);
if (ret != 0) {
return ret;
}
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index ae1e8dbbac..16caa8d861 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -21,8 +21,6 @@
#include "includes.h"
#include "../utils/net.h"
-extern pstring global_myname;
-
/**
* @file net_rpc.c
*
@@ -240,12 +238,11 @@ static int rpc_changetrustpw(int argc, const char **argv)
static NTSTATUS rpc_join_oldstyle_internals(const DOM_SID *domain_sid, struct cli_state *cli, TALLOC_CTX *mem_ctx,
int argc, const char **argv) {
- extern pstring global_myname;
fstring trust_passwd;
unsigned char orig_trust_passwd_hash[16];
NTSTATUS result;
- fstrcpy(trust_passwd, global_myname);
+ fstrcpy(trust_passwd, global_myname());
strlower(trust_passwd);
/*
@@ -432,7 +429,7 @@ rpc_getsid_internals(const DOM_SID *domain_sid, struct cli_state *cli,
d_printf("Storing SID %s for Domain %s in secrets.tdb\n",
sid_str, lp_workgroup());
- if (!secrets_store_domain_sid(global_myname, domain_sid)) {
+ if (!secrets_store_domain_sid(global_myname(), domain_sid)) {
DEBUG(0,("Can't store domain SID\n"));
return NT_STATUS_UNSUCCESSFUL;
}
@@ -1917,7 +1914,7 @@ static int rpc_trustdom_list(int argc, const char **argv)
if (opt_target_workgroup) SAFE_FREE(opt_target_workgroup);
opt_target_workgroup = opt_workgroup;
} else {
- safe_strcpy(pdc_name, global_myname, FSTRING_LEN);
+ safe_strcpy(pdc_name, global_myname(), FSTRING_LEN);
domain_name = talloc_strdup(mem_ctx, lp_workgroup());
if (opt_target_workgroup) SAFE_FREE(opt_target_workgroup);
opt_target_workgroup = domain_name;
@@ -2165,7 +2162,7 @@ BOOL net_rpc_check(unsigned flags)
if (!cli_connect(&cli, server_name, &server_ip))
goto done;
- if (!attempt_netbios_session_request(&cli, global_myname,
+ if (!attempt_netbios_session_request(&cli, global_myname(),
server_name, &server_ip))
goto done;
if (!cli_negprot(&cli))
diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c
index c209886ef1..4b78b7d283 100644
--- a/source3/utils/net_rpc_join.c
+++ b/source3/utils/net_rpc_join.c
@@ -104,8 +104,6 @@ done:
int net_rpc_join_newstyle(int argc, const char **argv)
{
- extern pstring global_myname;
-
/* libsmb variables */
struct cli_state *cli;
@@ -187,7 +185,7 @@ int net_rpc_join_newstyle(int argc, const char **argv)
"could not open domain");
/* Create domain user */
- acct_name = talloc_asprintf(mem_ctx, "%s$", global_myname);
+ acct_name = talloc_asprintf(mem_ctx, "%s$", global_myname());
strlower(acct_name);
const_acct_name = acct_name;
@@ -347,9 +345,7 @@ done:
**/
int net_rpc_testjoin(int argc, const char **argv)
{
- char *domain = lp_workgroup();
-
- domain = smb_xstrdup(domain);
+ char *domain = smb_xstrdup(lp_workgroup());
/* Display success or failure */
if (net_rpc_join_ok(domain) != 0) {
diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c
index 13c75c80b0..4cf923b1f7 100644
--- a/source3/utils/net_time.c
+++ b/source3/utils/net_time.c
@@ -28,7 +28,6 @@ static time_t cli_servertime(const char *host, struct in_addr *ip, int *zone)
{
struct nmb_name calling, called;
time_t ret = 0;
- extern pstring global_myname;
struct cli_state *cli = NULL;
cli = cli_initialise(NULL);
@@ -39,7 +38,7 @@ static time_t cli_servertime(const char *host, struct in_addr *ip, int *zone)
goto done;
}
- make_nmb_name(&calling, global_myname, 0x0);
+ make_nmb_name(&calling, global_myname(), 0x0);
if (host) {
make_nmb_name(&called, host, 0x20);
} else {
diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c
index cdaa434e3c..8106134699 100644
--- a/source3/utils/nmblookup.c
+++ b/source3/utils/nmblookup.c
@@ -246,12 +246,8 @@ int main(int argc,char *argv[])
translate_addresses = !translate_addresses;
break;
case 'i':
- {
- extern pstring global_scope;
- pstrcpy(global_scope,optarg);
- strupper(global_scope);
- }
- break;
+ set_global_scope(optarg);
+ break;
case 'M':
find_master = True;
break;
diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c
index 1199dec7fb..6a019e73d7 100644
--- a/source3/utils/pdbedit.c
+++ b/source3/utils/pdbedit.c
@@ -50,7 +50,6 @@
#define MASK_ALWAYS_GOOD 0x0000001F
#define MASK_USER_GOOD 0x00001F00
-extern pstring global_myname;
/*********************************************************
Add all currently available users to another db
@@ -176,7 +175,7 @@ static int print_sam_info (SAM_ACCOUNT *sam_pwent, BOOL verbosity, BOOL smbpwdst
Get an Print User Info
**********************************************************/
-static int print_user_info (struct pdb_context *in, char *username, BOOL verbosity, BOOL smbpwdstyle)
+static int print_user_info (struct pdb_context *in, const char *username, BOOL verbosity, BOOL smbpwdstyle)
{
SAM_ACCOUNT *sam_pwent=NULL;
BOOL ret;
@@ -496,7 +495,7 @@ int main (int argc, char **argv)
poptGetArg(pc); /* Drop argv[0], the program name */
if (user_name == NULL) {
- user_name = poptGetArg(pc);
+ user_name = strdup(poptGetArg(pc));
}
if (!lp_load(dyn_CONFIGFILE,True,False,False)) {
@@ -504,16 +503,8 @@ int main (int argc, char **argv)
exit(1);
}
- if (!*global_myname) {
- char *p2;
-
- pstrcpy(global_myname, myhostname());
- p2 = strchr_m(global_myname, '.');
- if (p2)
- *p2 = 0;
- }
-
- strupper(global_myname);
+ if (!init_names())
+ exit(1);
setparms = (backend ? BIT_BACKEND : 0) +
(verbose ? BIT_VERBOSE : 0) +
diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c
index 940187407c..1d681a07f7 100644
--- a/source3/utils/smbcacls.c
+++ b/source3/utils/smbcacls.c
@@ -42,9 +42,6 @@ enum acl_mode {SMB_ACL_SET, SMB_ACL_DELETE, SMB_ACL_MODIFY, SMB_ACL_ADD };
enum chown_mode {REQUEST_NONE, REQUEST_CHOWN, REQUEST_CHGRP};
enum exit_values {EXIT_OK, EXIT_FAILED, EXIT_PARSE_ERROR};
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-
struct perm_value {
char *perm;
uint32 mask;
@@ -232,6 +229,7 @@ static void print_ace(FILE *f, SEC_ACE *ace)
static BOOL parse_ace(SEC_ACE *ace, char *str)
{
char *p;
+ const char *cp;
fstring tok;
unsigned atype, aflags, amask;
DOM_SID sid;
@@ -243,7 +241,6 @@ static BOOL parse_ace(SEC_ACE *ace, char *str)
if (!p) return False;
*p = '\0';
p++;
-
/* Try to parse numeric form */
if (sscanf(p, "%i/%i/%i", &atype, &aflags, &amask) == 3 &&
@@ -257,7 +254,8 @@ static BOOL parse_ace(SEC_ACE *ace, char *str)
return False;
}
- if (!next_token(&p, tok, "/", sizeof(fstring))) {
+ cp = p;
+ if (!next_token(&cp, tok, "/", sizeof(fstring))) {
return False;
}
@@ -271,12 +269,12 @@ static BOOL parse_ace(SEC_ACE *ace, char *str)
/* Only numeric form accepted for flags at present */
- if (!(next_token(&p, tok, "/", sizeof(fstring)) &&
+ if (!(next_token(&cp, tok, "/", sizeof(fstring)) &&
sscanf(tok, "%i", &aflags))) {
return False;
}
- if (!next_token(&p, tok, "/", sizeof(fstring))) {
+ if (!next_token(&cp, tok, "/", sizeof(fstring))) {
return False;
}
@@ -342,7 +340,7 @@ static BOOL add_ace(SEC_ACL **the_acl, SEC_ACE *ace)
/* parse a ascii version of a security descriptor */
static SEC_DESC *sec_desc_parse(char *str)
{
- char *p = str;
+ const char *p = str;
fstring tok;
SEC_DESC *ret;
size_t sd_size;
@@ -718,10 +716,10 @@ static struct cli_state *connect_one(char *share)
}
}
- if (NT_STATUS_IS_OK(nt_status = cli_full_connection(&c, global_myname, server,
+ if (NT_STATUS_IS_OK(nt_status = cli_full_connection(&c, global_myname(), server,
&ip, 0,
share, "?????",
- username, global_myworkgroup,
+ username, lp_workgroup(),
password, 0, NULL))) {
return c;
} else {
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index 7c292dd521..034de91ce0 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -107,7 +107,7 @@ Prints out the current Debug level returned by MSG_DEBUGLEVEL
****************************************************************************/
void debuglevel_function(int msg_type, pid_t src, void *buf, size_t len)
{
- char *levels = (char *)buf;
+ const char *levels = (char *)buf;
pstring dbgcl;
printf("Current debug levels of PID %u are:\n",(unsigned int)src);
diff --git a/source3/utils/smbgroupedit.c b/source3/utils/smbgroupedit.c
index b5033e0384..0faa0513ed 100644
--- a/source3/utils/smbgroupedit.c
+++ b/source3/utils/smbgroupedit.c
@@ -21,9 +21,6 @@
#include "includes.h"
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-
/*
* Next two lines needed for SunOS and don't
* hurt anything else...
@@ -282,17 +279,8 @@ int main (int argc, char **argv)
exit(1);
}
- if (!*global_myname) {
- char *p;
- pstrcpy( global_myname, myhostname() );
- p = strchr_m(global_myname, '.' );
- if (p)
- *p = 0;
- }
-
- strupper(global_myname);
-
- fstrcpy(global_myworkgroup, lp_workgroup());
+ if (!init_names())
+ exit(1);
if(!initialize_password_db(True)) {
fprintf(stderr, "Can't setup password database vectors.\n");
diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c
index 0e822ee7ad..d9f36119f7 100644
--- a/source3/utils/smbpasswd.c
+++ b/source3/utils/smbpasswd.c
@@ -19,7 +19,6 @@
#include "includes.h"
-extern pstring global_myname;
extern BOOL AllowDebugChange;
/*
@@ -585,13 +584,8 @@ int main(int argc, char **argv)
* set from the config file.
*/
- if (!*global_myname) {
- char *p;
- fstrcpy(global_myname, myhostname());
- p = strchr_m(global_myname, '.' );
- if (p) *p = 0;
- }
- strupper(global_myname);
+ if (!init_names())
+ return 1;
/* Check the effective uid - make sure we are not setuid */
if (is_setuid_root()) {
diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c
index 280a7b8853..d30bd916b2 100644
--- a/source3/utils/testparm.c
+++ b/source3/utils/testparm.c
@@ -121,7 +121,7 @@ parameter.\n" );
} else {
pstring passwd_prog;
pstring truncated_prog;
- char *p;
+ const char *p;
pstrcpy( passwd_prog, lp_passwd_program());
p = passwd_prog;
@@ -250,8 +250,8 @@ int main(int argc, const char *argv[])
for (s=0;s<1000;s++) {
if (VALID_SNUM(s)) {
- char **deny_list = lp_hostsdeny(s);
- char **allow_list = lp_hostsallow(s);
+ const char **deny_list = lp_hostsdeny(s);
+ const char **allow_list = lp_hostsallow(s);
int i;
if(deny_list) {
for (i=0; deny_list[i]; i++) {
diff --git a/source3/wrepld/server.c b/source3/wrepld/server.c
index f08674afbb..295eb15596 100644
--- a/source3/wrepld/server.c
+++ b/source3/wrepld/server.c
@@ -21,9 +21,6 @@
#include "includes.h"
#include "wins_repl.h"
-extern fstring global_myworkgroup;
-extern pstring global_myname;
-
extern pstring user_socket_options;
extern WINS_OWNER *global_wins_table;
@@ -163,29 +160,9 @@ void exit_server(char *reason)
}
/****************************************************************************
- initialise connect, service and file structs
+ Usage of the program.
****************************************************************************/
-static void init_structs(void )
-{
- /*
- * Set the machine NETBIOS name if not already
- * set from the config file.
- */
-
- if (!*global_myname) {
- char *p;
- fstrcpy( global_myname, myhostname() );
- p = strchr_m( global_myname, '.' );
- if (p)
- *p = 0;
- }
- strupper( global_myname );
-}
-
-/****************************************************************************
-usage on the program
-****************************************************************************/
static void usage(char *pname)
{
@@ -684,7 +661,8 @@ static void process(void)
if (!reload_services(False))
return(-1);
- init_structs();
+ if (!init_names())
+ return -1;
#ifdef WITH_PROFILE
if (!profile_setup(False)) {
@@ -693,8 +671,6 @@ static void process(void)
}
#endif
- fstrcpy(global_myworkgroup, lp_workgroup());
-
CatchSignal(SIGHUP,SIGNAL_CAST sig_hup);
DEBUG(3,( "loaded services\n"));