summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-11-12 23:15:52 +0000
committerJeremy Allison <jra@samba.org>2002-11-12 23:15:52 +0000
commit250c9801197ea1c949bd94c1c891f81ab118b130 (patch)
tree3a0ec79c71a010961d78726e223a70e1bc75c73f /source3/smbd
parent477025a6f628fd1a8d3bfacd30726e7a41819e50 (diff)
downloadsamba-250c9801197ea1c949bd94c1c891f81ab118b130.tar.gz
samba-250c9801197ea1c949bd94c1c891f81ab118b130.tar.bz2
samba-250c9801197ea1c949bd94c1c891f81ab118b130.zip
Removed global_myworkgroup, global_myname, global_myscope. Added liberal
dashes of const. This is a rather large check-in, some things may break. It does compile though :-). Jeremy. (This used to be commit 82b8f749a36b42e22186297482aad2abb04fab8a)
Diffstat (limited to 'source3/smbd')
-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
12 files changed, 44 insertions, 66 deletions
diff --git a/source3/smbd/change_trust_pw.c b/source3/smbd/change_trust_pw.c
index 4811083c2d..28a004eba8 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;
}
}