diff options
author | Jeremy Allison <jra@samba.org> | 1998-04-25 01:12:08 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1998-04-25 01:12:08 +0000 |
commit | e7ac86607c80912e55ac7179b100cea22749c16f (patch) | |
tree | 257b85ec9e88be65c95cf82afb1f6e7c4c20e4c7 /source3 | |
parent | 9189005f7f884123d29c8f27db73687b68c80bb9 (diff) | |
download | samba-e7ac86607c80912e55ac7179b100cea22749c16f.tar.gz samba-e7ac86607c80912e55ac7179b100cea22749c16f.tar.bz2 samba-e7ac86607c80912e55ac7179b100cea22749c16f.zip |
This looks like a big change but really isn't.
It is changing the global variables "myname" and "myworkgroup"
to "global_myname" and "global_myworkgroup" respectively.
This is to make it very explicit when we are messing
with a global (don't ask - it makes the domain client
code much clearer :-).
Jeremy.
(This used to be commit 866406bfe399cf757c8275093dacd5ce4843afa0)
Diffstat (limited to 'source3')
36 files changed, 341 insertions, 439 deletions
diff --git a/source3/client/client.c b/source3/client/client.c index 9abdb00350..b7635c1ea3 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -33,7 +33,7 @@ pstring cur_dir = "\\"; pstring cd_path = ""; extern pstring service; extern pstring desthost; -extern pstring myname; +extern pstring global_myname; extern pstring myhostname; extern pstring password; extern pstring username; @@ -3705,7 +3705,7 @@ static void usage(char *pname) } break; case 'n': - strcpy(myname,optarg); + strcpy(global_myname,optarg); break; case 'N': got_pass = True; @@ -3779,8 +3779,8 @@ static void usage(char *pname) strcpy(workgroup,lp_workgroup()); load_interfaces(); - get_myname((*myname)?NULL:myname,NULL); - strupper(myname); + get_myname((*global_myname)?NULL:global_myname,NULL); + strupper(global_myname); if(*new_name_resolve_order) lp_set_name_resolve_order(new_name_resolve_order); diff --git a/source3/client/clientutil.c b/source3/client/clientutil.c index dce34eda2c..ab1b37c72d 100644 --- a/source3/client/clientutil.c +++ b/source3/client/clientutil.c @@ -31,7 +31,7 @@ pstring service=""; pstring desthost=""; -extern pstring myname; +extern pstring global_myname; pstring password = ""; pstring smb_login_passwd = ""; pstring username=""; @@ -331,7 +331,7 @@ BOOL cli_send_session_request(char *inbuf,char *outbuf) /* and my name */ p = outbuf+len; - name_mangle(myname,p,0); + name_mangle(global_myname,p,0); len += name_len(p); /* setup the packet length */ @@ -378,7 +378,7 @@ BOOL cli_send_session_request(char *inbuf,char *outbuf) { int ecode = CVAL(inbuf,4); DEBUG(0,("Session request failed (%d,%d) with myname=%s destname=%s\n", - CVAL(inbuf,0),ecode,myname,desthost)); + CVAL(inbuf,0),ecode,global_myname,desthost)); switch (ecode) { case 0x80: @@ -388,7 +388,7 @@ BOOL cli_send_session_request(char *inbuf,char *outbuf) break; case 0x81: DEBUG(0,("Not listening for calling name\n")); - DEBUG(0,("Try to connect as another name (instead of %s)\n",myname)); + DEBUG(0,("Try to connect as another name (instead of %s)\n",global_myname)); DEBUG(0,("You may find the -n option useful for this\n")); break; case 0x82: @@ -508,7 +508,7 @@ BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup, if (CVAL(inbuf,smb_rcls) != 0 || ((int)SVAL(inbuf,smb_vwv0) >= numprots)) { DEBUG(0,("SMBnegprot failed. myname=%s destname=%s - %s \n", - myname,desthost,smb_errstr(inbuf))); + global_myname,desthost,smb_errstr(inbuf))); if (was_null) { free(inbuf); @@ -665,7 +665,7 @@ BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup, } DEBUG(0,("Session setup failed for username=%s myname=%s destname=%s %s\n", - username,myname,desthost,smb_errstr(inbuf))); + username,global_myname,desthost,smb_errstr(inbuf))); DEBUG(0,("You might find the -U, -W or -n options useful\n")); DEBUG(0,("Sometimes you have to use `-n USERNAME' (particularly with OS/2)\n")); DEBUG(0,("Some servers also insist on uppercase-only passwords\n")); @@ -882,10 +882,10 @@ BOOL cli_open_sockets(int port ) strcpy(desthost,host); } - if (!(*myname)) { - get_myname(myname,NULL); + if (!(*global_myname)) { + get_myname(global_myname,NULL); } - strupper(myname); + strupper(global_myname); DEBUG(3,("Opening sockets\n")); diff --git a/source3/client/smbmount.c b/source3/client/smbmount.c index bab7430859..cdfeb68064 100644 --- a/source3/client/smbmount.c +++ b/source3/client/smbmount.c @@ -44,7 +44,7 @@ pstring cur_dir = "\\"; pstring cd_path = ""; extern pstring service; extern pstring desthost; -extern pstring myname; +extern pstring global_myname; extern pstring myhostname; extern pstring password; extern pstring username; @@ -818,7 +818,7 @@ static void usage(char *pname) } break; case 'n': - strcpy(myname,optarg); + strcpy(global_myname,optarg); break; case 'N': got_pass = True; @@ -880,8 +880,8 @@ static void usage(char *pname) strcpy(workgroup,lp_workgroup()); load_interfaces(); - get_myname((*myname)?NULL:myname,NULL); - strupper(myname); + get_myname((*global_myname)?NULL:global_myname,NULL); + strupper(global_myname); if (cli_open_sockets(port)) { diff --git a/source3/include/includes.h b/source3/include/includes.h index 587d13bd40..5fc2811981 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -383,6 +383,9 @@ char *getwd(char *); #define USE_WAITPID #define USE_SETSID #define USE_SYSV_IPC +#ifndef QSORT_CAST +#define QSORT_CAST (int (*)(const void *, const void *)) +#endif /* QSORT_CAST */ #endif diff --git a/source3/include/smb.h b/source3/include/smb.h index 8d5cc20582..1bf5b318b3 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -251,13 +251,6 @@ typedef fstring string; #define PIPE_LSASS "\\PIPE\\lsass" #define PIPE_LSARPC "\\PIPE\\lsarpc" -/* 32 bit time (sec) since 01jan1970 - cifs6.txt, section 3.5, page 30 */ -typedef struct time_info -{ - uint32 time; - -} UTIME; - /* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */ typedef struct nttime_info { @@ -281,40 +274,69 @@ typedef struct nttime_info struct smb_passwd { - int smb_userid; - char *smb_name; - unsigned char *smb_passwd; /* Null if no password */ - unsigned char *smb_nt_passwd; /* Null if no password */ - /* Other fields / flags may be added later */ - uint16 acct_ctrl; - time_t last_change_time; + int smb_userid; + char *smb_name; + unsigned char *smb_passwd; /* Null if no password */ + unsigned char *smb_nt_passwd; /* Null if no password */ + /* Other fields / flags may be added later */ + uint16 acct_ctrl; + time_t last_change_time; }; +/* DOM_CHAL - challenge info */ +typedef struct chal_info +{ + uchar data[8]; /* credentials */ +} DOM_CHAL; + +/* 32 bit time (sec) since 01jan1970 - cifs6.txt, section 3.5, page 30 */ +typedef struct time_info +{ + uint32 time; + +} UTIME; + +/* DOM_CREDs - timestamped client or server credentials */ +typedef struct cred_info +{ + DOM_CHAL challenge; /* credentials */ + UTIME timestamp; /* credential time-stamp */ + +} DOM_CRED; + struct cli_state { - int fd; - int cnum; - int pid; - int mid; - int uid; - int protocol; - int sec_mode; - int rap_error; - uint32 nt_error; - int privilages; - fstring eff_name; - fstring desthost; - char cryptkey[8]; - uint32 sesskey; - int serverzone; - uint32 servertime; - int readbraw_supported; - int writebraw_supported; - int timeout; - int max_xmit; - char *outbuf; - char *inbuf; - int bufsize; - int initialised; + int fd; + int cnum; + int pid; + int mid; + int uid; + int protocol; + int sec_mode; + int rap_error; + int privilages; + fstring eff_name; + fstring desthost; + char cryptkey[8]; + uint32 sesskey; + int serverzone; + uint32 servertime; + int readbraw_supported; + int writebraw_supported; + int timeout; + int max_xmit; + char *outbuf; + char *inbuf; + int bufsize; + int initialised; + /* + * Only used in NT domain calls. + */ + uint32 nt_error; /* NT RPC error code. */ + uint16 nt_pipe_fnum; /* Pipe handle. */ + unsigned char sess_key[16]; /* Current session key. */ + DOM_CRED clnt_cred; /* Client credential. */ + fstring mach_acct; + fstring srv_name; }; @@ -445,20 +467,6 @@ typedef struct } connection_struct; -/* DOM_CHAL - challenge info */ -typedef struct chal_info -{ - uchar data[8]; /* credentials */ -} DOM_CHAL; - -/* DOM_CREDs - timestamped client or server credentials */ -typedef struct cred_info -{ - DOM_CHAL challenge; /* credentials */ - UTIME timestamp; /* credential time-stamp */ - -} DOM_CRED; - /* Domain controller authentication protocol info */ struct dcinfo { diff --git a/source3/lib/util.c b/source3/lib/util.c index 54bbdfa30a..57370bc67e 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -86,8 +86,8 @@ pstring samlogon_user=""; BOOL sam_logon_in_ssb = False; -pstring myname = ""; -fstring myworkgroup = ""; +pstring global_myname = ""; +fstring global_myworkgroup = ""; char **my_netbios_names; int smb_read_error = 0; diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c index f2aee12615..9c7b260c59 100644 --- a/source3/libsmb/nmblib.c +++ b/source3/libsmb/nmblib.c @@ -27,7 +27,6 @@ extern int DEBUGLEVEL; int num_good_sends = 0; int num_good_receives = 0; extern pstring scope; -extern pstring myname; extern struct in_addr ipzero; static struct opcode_names { diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 5de1d3291d..512504b02d 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -40,8 +40,8 @@ int global_nmb_port = -1; extern pstring myhostname; static pstring host_file; -extern pstring myname; -extern fstring myworkgroup; +extern pstring global_myname; +extern fstring global_myworkgroup; extern char **my_netbios_names; extern BOOL global_in_nmbd; @@ -450,23 +450,23 @@ static BOOL init_structs(void) int nodup; pstring nbname; - if (! *myname) + if (! *global_myname) { - fstrcpy( myname, myhostname ); - p = strchr( myname, '.' ); + fstrcpy( global_myname, myhostname ); + p = strchr( global_myname, '.' ); if (p) *p = 0; } - strupper( myname ); + strupper( global_myname ); /* Add any NETBIOS name aliases. Ensure that the first entry - is equal to myname. + is equal to global_myname. */ /* Work out the max number of netbios aliases that we have */ ptr = lp_netbios_aliases(); for( namecount=0; next_token(&ptr,nbname,NULL); namecount++ ) ; - if ( *myname ) + if ( *global_myname ) namecount++; /* Allocate space for the netbios aliases */ @@ -477,10 +477,10 @@ static BOOL init_structs(void) return( False ); } - /* Use the myname string first */ + /* Use the global_myname string first */ namecount=0; - if ( *myname ) - my_netbios_names[namecount++] = myname; + if ( *global_myname ) + my_netbios_names[namecount++] = global_myname; ptr = lp_netbios_aliases(); while ( next_token( &ptr, nbname, NULL ) ) @@ -508,7 +508,7 @@ static BOOL init_structs(void) /* Terminate name list */ my_netbios_names[namecount++] = NULL; - fstrcpy( local_machine, myname ); + fstrcpy( local_machine, global_myname ); trim_string( local_machine, " ", " " ); p = strchr( local_machine, ' ' ); if (p) @@ -615,8 +615,8 @@ int main(int argc,char *argv[]) pstrcpy(host_file,optarg); break; case 'n': - pstrcpy(myname,optarg); - strupper(myname); + pstrcpy(global_myname,optarg); + strupper(global_myname); break; case 'l': sprintf(debugf,"%s.nmb",optarg); @@ -674,9 +674,9 @@ int main(int argc,char *argv[]) reload_services( True ); - fstrcpy( myworkgroup, lp_workgroup() ); + fstrcpy( global_myworkgroup, lp_workgroup() ); - if (strequal(myworkgroup,"*")) + if (strequal(global_myworkgroup,"*")) { 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 52065758bc..d01bf18310 100644 --- a/source3/nmbd/nmbd_become_dmb.c +++ b/source3/nmbd/nmbd_become_dmb.c @@ -27,8 +27,8 @@ extern int DEBUGLEVEL; extern pstring scope; -extern pstring myname; -extern fstring myworkgroup; +extern pstring global_myname; +extern fstring global_myworkgroup; extern char **my_netbios_names; extern struct in_addr ipzero; extern struct in_addr allones_ip; @@ -56,11 +56,11 @@ static void unbecome_dmb_success(struct subnet_record *subrec, return; } - if((servrec = find_server_in_workgroup( work, myname)) == NULL) + if((servrec = find_server_in_workgroup( work, global_myname)) == NULL) { DEBUG(0,("unbecome_dmb_success: Error - cannot find server %s \ in workgroup %s on subnet %s\n", - myname, released_name->name, subrec->subnet_name)); + global_myname, released_name->name, subrec->subnet_name)); return; } @@ -82,7 +82,7 @@ in workgroup %s on subnet %s\n", putip((char *)&work->dmb_addr, &ipzero); DEBUG(0,("\n%s ***** Samba server %s has stopped being a domain master browser \ -for workgroup %s on subnet %s *****\n\n", timestring(), myname, work->work_group, subrec->subnet_name)); +for workgroup %s on subnet %s *****\n\n", timestring(), global_myname, work->work_group, subrec->subnet_name)); } @@ -157,11 +157,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, 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", - myname, work->work_group, subrec->subnet_name)); + global_myname, work->work_group, subrec->subnet_name)); return; } @@ -196,11 +196,11 @@ workgroup %s on subnet %s\n", registered_name->name, subrec->subnet_name)); return; } - if((servrec = find_server_in_workgroup( work, 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", - myname, registered_name->name, subrec->subnet_name)); + global_myname, registered_name->name, subrec->subnet_name)); work->dom_state = DOMAIN_NONE; return; } @@ -215,7 +215,7 @@ in workgroup %s on subnet %s\n", subrec->work_changed = True; DEBUG(0,("\n%s ***** Samba server %s is now a domain master browser for \ -workgroup %s on subnet %s *****\n\n", timestring(),myname, work->work_group, +workgroup %s on subnet %s *****\n\n", timestring(),global_myname, work->work_group, subrec->subnet_name)); if(subrec == unicast_subnet) @@ -228,7 +228,7 @@ subrec->subnet_name)); will stop us syncing with ourself if we are also a local master browser. */ - make_nmb_name(&nmbname, myname, 0x20, scope); + make_nmb_name(&nmbname, global_myname, 0x20, scope); work->dmb_name = nmbname; /* Pick the first interface ip address as the domain master browser ip. */ @@ -464,9 +464,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(myworkgroup); + become_domain_master_browser_wins(global_myworkgroup); } else - become_domain_master_browser_bcast(myworkgroup); + become_domain_master_browser_bcast(global_myworkgroup); } } diff --git a/source3/nmbd/nmbd_become_lmb.c b/source3/nmbd/nmbd_become_lmb.c index b58244104d..c602789fb8 100644 --- a/source3/nmbd/nmbd_become_lmb.c +++ b/source3/nmbd/nmbd_become_lmb.c @@ -26,7 +26,7 @@ extern int DEBUGLEVEL; extern pstring scope; -extern pstring myname; +extern pstring global_myname; extern uint16 samba_nb_type; /* Samba's NetBIOS name type. */ @@ -90,11 +90,11 @@ subnet %s.\n", workgroup_name, subrec->subnet_name )); return; } - if((servrec = find_server_in_workgroup( work, 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", - 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; } @@ -146,7 +146,7 @@ void unbecome_local_master_success(struct subnet_record *subrec, reset_workgroup_state( subrec, released_name->name ); DEBUG(0,("\n%s ***** Samba name server %s has stopped being a local master browser for workgroup %s \ -on subnet %s *****\n\n", timestring(), myname, released_name->name, subrec->subnet_name)); +on subnet %s *****\n\n", timestring(), global_myname, released_name->name, subrec->subnet_name)); } @@ -171,7 +171,7 @@ Removing from namelist anyway.\n", namestr(fail_name))); reset_workgroup_state( subrec, fail_name->name ); DEBUG(0,("\n%s ***** Samba name server %s has stopped being a local master browser for workgroup %s \ -on subnet %s *****\n\n", timestring(), myname, fail_name->name, subrec->subnet_name)); +on subnet %s *****\n\n", timestring(), global_myname, fail_name->name, subrec->subnet_name)); } @@ -254,11 +254,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((servrec = find_server_in_workgroup( work, myname)) == NULL) + if((servrec = 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", - 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; } @@ -314,11 +314,11 @@ workgroup %s on subnet %s\n", registered_name->name, subrec->subnet_name)); return; } - if((servrec = find_server_in_workgroup( work, 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", - 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; } @@ -336,7 +336,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, 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 @@ -369,7 +369,7 @@ on subnet %s\n", work->work_group, subrec->subnet_name)); reset_announce_timer(); DEBUG(0,("\n%s ***** Samba name server %s is now a local master browser for workgroup %s \ -on subnet %s *****\n\n", timestring(), myname, work->work_group, subrec->subnet_name)); +on subnet %s *****\n\n", timestring(), global_myname, work->work_group, subrec->subnet_name)); } @@ -456,11 +456,11 @@ workgroup %s on subnet %s\n", work_name, subrec->subnet_name)); return; } - if((servrec = find_server_in_workgroup(work, myname)) == NULL) + if((servrec = 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", - myname, work->work_group, subrec->subnet_name)); + global_myname, work->work_group, subrec->subnet_name)); return; } @@ -499,11 +499,11 @@ void become_local_master_browser(struct subnet_record *subrec, struct work_recor return; } - if((servrec = find_server_in_workgroup( work, myname)) == NULL) + if((servrec = 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", - myname, work->work_group, subrec->subnet_name)); + global_myname, work->work_group, subrec->subnet_name)); return; } diff --git a/source3/nmbd/nmbd_browsesync.c b/source3/nmbd/nmbd_browsesync.c index 94bdecb8fc..c78fdfc514 100644 --- a/source3/nmbd/nmbd_browsesync.c +++ b/source3/nmbd/nmbd_browsesync.c @@ -28,8 +28,8 @@ extern int DEBUGLEVEL; extern pstring scope; extern struct in_addr ipzero; -extern pstring myname; -extern fstring myworkgroup; +extern pstring global_myname; +extern fstring global_myworkgroup; /* This is our local master browser list database. */ extern struct browse_cache_record *lmb_browserlist; @@ -244,7 +244,7 @@ Do not announce to ourselves.\n", work->work_group )); CVAL(p,0) = ANN_MasterAnnouncement; p++; - StrnCpy(p,myname,15); + StrnCpy(p,global_myname,15); strupper(p); p = skip_string(p,1); @@ -252,7 +252,7 @@ Do not announce to ourselves.\n", work->work_group )); to %s for workgroup %s.\n", namestr(&work->dmb_name), work->work_group )); send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf), - myname, 0x0, work->dmb_name.name, 0x0, work->dmb_addr, FIRST_SUBNET->myip); + global_myname, 0x0, work->dmb_name.name, 0x0, work->dmb_addr, FIRST_SUBNET->myip); } @@ -640,10 +640,10 @@ 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, myworkgroup)) == NULL) + if((work = find_workgroup_on_subnet( unicast_subnet, global_myworkgroup)) == NULL) { DEBUG(0,("collect_all_workgroup_names_from_wins_server: Cannot find my workgroup %s on subnet %s.\n", - myworkgroup, unicast_subnet->subnet_name )); + global_myworkgroup, unicast_subnet->subnet_name )); return; } diff --git a/source3/nmbd/nmbd_elections.c b/source3/nmbd/nmbd_elections.c index fa1e5986a8..569b653129 100644 --- a/source3/nmbd/nmbd_elections.c +++ b/source3/nmbd/nmbd_elections.c @@ -26,8 +26,8 @@ extern int DEBUGLEVEL; -extern pstring myname; -extern fstring myworkgroup; +extern pstring global_myname; +extern fstring global_myworkgroup; /* Election parameters. */ extern time_t StartupTime; @@ -95,7 +95,7 @@ static void check_for_master_browser_fail( struct subnet_record *subrec, return; } - if (strequal(work->work_group, myworkgroup)) + if (strequal(work->work_group, global_myworkgroup)) { if (lp_local_master()) @@ -117,7 +117,7 @@ static void check_for_master_browser_fail( struct subnet_record *subrec, not to become the local master, but we still need one, having detected that one doesn't exist. */ - send_election_dgram(subrec, work->work_group, 0, 0, myname); + send_election_dgram(subrec, work->work_group, 0, 0, global_myname); } } } @@ -131,7 +131,7 @@ void check_master_browser_exists(time_t t) { static time_t lastrun=0; struct subnet_record *subrec; - char *workgroup_name = myworkgroup; + char *workgroup_name = global_myworkgroup; if (!lastrun) lastrun = t; @@ -186,7 +186,7 @@ void run_elections(time_t t) if (work->RunningElection) { send_election_dgram(subrec, work->work_group, work->ElectionCriterion, - t - StartupTime, myname); + t - StartupTime, global_myname); if (work->ElectionCount++ >= 4) { @@ -225,7 +225,7 @@ static BOOL win_election(struct work_record *work, int version, version, ELECTION_VERSION, criterion, mycriterion, timeup, mytimeup, - server_name, myname)); + server_name, global_myname)); if (version > ELECTION_VERSION) return(False); @@ -242,7 +242,7 @@ static BOOL win_election(struct work_record *work, int version, if (timeup < mytimeup) return(True); - if (strcasecmp(myname, server_name) > 0) + if (strcasecmp(global_myname, server_name) > 0) return(False); return(True); @@ -276,7 +276,7 @@ void process_election(struct subnet_record *subrec, struct packet_struct *p, cha return; } - if (!strequal(work->work_group, myworkgroup)) + if (!strequal(work->work_group, global_myworkgroup)) { 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 )); diff --git a/source3/nmbd/nmbd_incomingdgrams.c b/source3/nmbd/nmbd_incomingdgrams.c index 80057ef12c..62dc444e0c 100644 --- a/source3/nmbd/nmbd_incomingdgrams.c +++ b/source3/nmbd/nmbd_incomingdgrams.c @@ -26,8 +26,8 @@ extern int DEBUGLEVEL; -extern pstring myname; -extern fstring myworkgroup; +extern pstring global_myname; +extern fstring global_myworkgroup; extern BOOL found_lm_clients; #if 0 @@ -143,8 +143,8 @@ void process_host_announce(struct subnet_record *subrec, struct packet_struct *p * to be our primary workgroup name. */ - if(strequal(work_name, myname)) - work_name = myworkgroup; + if(strequal(work_name, global_myname)) + work_name = global_myworkgroup; /* * We are being very agressive here in adding a workgroup @@ -391,10 +391,10 @@ master - ignoring master announce.\n")); return; } - if((work = find_workgroup_on_subnet(subrec, myworkgroup)) == NULL) + if((work = find_workgroup_on_subnet(subrec, global_myworkgroup)) == NULL) { DEBUG(0,("process_master_browser_announce: Cannot find workgroup %s on subnet %s\n", - myworkgroup, subrec->subnet_name)); + global_myworkgroup, subrec->subnet_name)); return; } @@ -481,8 +481,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, myname)) - work_name = myworkgroup; + if(strequal(work_name, global_myname)) + work_name = global_myworkgroup; /* * We are being very agressive here in adding a workgroup @@ -571,7 +571,7 @@ static void send_backup_list_response(struct subnet_record *subrec, /* We always return at least one name - our own. */ count = 1; - StrnCpy(p,myname,15); + StrnCpy(p,global_myname,15); strupper(p); p = skip_string(p,1); @@ -585,7 +585,7 @@ static void send_backup_list_response(struct subnet_record *subrec, if(count >= (unsigned int)max_number_requested) break; - if(strnequal(servrec->serv.name, myname,15)) + if(strnequal(servrec->serv.name, global_myname,15)) continue; if(!(servrec->serv.type & SV_TYPE_BACKUP_BROWSER)) @@ -610,7 +610,7 @@ static void send_backup_list_response(struct subnet_record *subrec, send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf), - myname, 0, + global_myname, 0, send_to_name->name,0, sendto_ip, subrec->myip); } @@ -643,7 +643,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, myworkgroup) == False) + if(strequal(workgroup_name, global_myworkgroup) == False) { DEBUG(7,("process_get_backup_list_request: Ignoring announce request for workgroup %s.\n", workgroup_name)); @@ -769,7 +769,7 @@ void process_announce_request(struct subnet_record *subrec, struct packet_struct namestr(&dgram->dest_name))); /* We only send announcement requests on our workgroup. */ - if(strequal(workgroup_name, myworkgroup) == False) + if(strequal(workgroup_name, global_myworkgroup) == False) { DEBUG(7,("process_announce_request: Ignoring announce request for workgroup %s.\n", workgroup_name)); @@ -806,7 +806,7 @@ void process_lm_announce_request(struct subnet_record *subrec, struct packet_str namestr(&dgram->dest_name))); /* We only send announcement requests on our workgroup. */ - if(strequal(workgroup_name, myworkgroup) == False) + if(strequal(workgroup_name, global_myworkgroup) == 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 ae163c6014..e1c56f591f 100644 --- a/source3/nmbd/nmbd_incomingrequests.c +++ b/source3/nmbd/nmbd_incomingrequests.c @@ -29,7 +29,7 @@ #include "includes.h" extern int DEBUGLEVEL; -extern fstring myworkgroup; +extern fstring global_myworkgroup; /**************************************************************************** Send a name release response. @@ -102,7 +102,7 @@ subnet %s from owner IP %s\n", * names and *don't set the group bit* !!!!! */ - if( !group && !ismyip(owner_ip) && strequal(question->name, myworkgroup) && + if( !group && !ismyip(owner_ip) && strequal(question->name, global_myworkgroup) && ((question->name_type == 0x0) || (question->name_type == 0x1e))) { DEBUG(6,("process_name_release_request: FTP OnNet bug workaround. Ignoring \ @@ -290,20 +290,20 @@ We put our own names first, then in alphabetical order. static int status_compare(char *n1,char *n2) { - extern pstring myname; + 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(myname); + l3 = strlen(global_myname); - if ((l1==l3) && strncmp(n1,myname,l3) == 0 && - (l2!=l3 || strncmp(n2,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,myname,l3) == 0 && - (l1!=l3 || strncmp(n1,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 4128213f97..c5e2e6ca4f 100644 --- a/source3/nmbd/nmbd_logonnames.c +++ b/source3/nmbd/nmbd_logonnames.c @@ -27,8 +27,8 @@ extern int DEBUGLEVEL; extern pstring scope; -extern pstring myname; -extern fstring myworkgroup; +extern pstring global_myname; +extern fstring global_myworkgroup; extern char **my_netbios_names; extern struct in_addr ipzero; extern struct in_addr allones_ip; @@ -52,11 +52,11 @@ workgroup %s on subnet %s\n", fail_name->name, subrec->subnet_name)); return; } - if((servrec = find_server_in_workgroup( work, 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", - myname, fail_name->name, subrec->subnet_name)); + global_myname, fail_name->name, subrec->subnet_name)); work->log_state = LOGON_NONE; return; } @@ -92,11 +92,11 @@ workgroup %s on subnet %s\n", registered_name->name, subrec->subnet_name)); return; } - if((servrec = find_server_in_workgroup( work, 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", - myname, registered_name->name, subrec->subnet_name)); + global_myname, registered_name->name, subrec->subnet_name)); work->log_state = LOGON_NONE; return; } @@ -147,17 +147,17 @@ 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, myworkgroup); + struct work_record *work = find_workgroup_on_subnet(subrec, global_myworkgroup); if (work && (work->log_state == LOGON_NONE)) { struct nmb_name nmbname; - make_nmb_name(&nmbname,myworkgroup,0x1c,scope); + make_nmb_name(&nmbname,global_myworkgroup,0x1c,scope); if (find_name_on_subnet(subrec, &nmbname, FIND_SELF_NAME) == NULL) { DEBUG(0,("add_domain_logon_names: At time %s attempting to become \ -logon server for workgroup %s on subnet %s\n", timestring(), myworkgroup, +logon server for workgroup %s on subnet %s\n", timestring(), global_myworkgroup, subrec->subnet_name)); become_logon_server(subrec, work); } diff --git a/source3/nmbd/nmbd_mynames.c b/source3/nmbd/nmbd_mynames.c index cf21fafd87..92ea3ea154 100644 --- a/source3/nmbd/nmbd_mynames.c +++ b/source3/nmbd/nmbd_mynames.c @@ -27,8 +27,7 @@ extern int DEBUGLEVEL; extern char **my_netbios_names; -extern pstring myname; -extern fstring myworkgroup; +extern fstring global_myworkgroup; extern pstring scope; extern uint16 samba_nb_type; /* Samba's NetBIOS type. */ @@ -58,10 +57,10 @@ BOOL register_my_workgroup_and_names(void) for(subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec)) { /* Create the workgroup on the subnet. */ - if((work = create_workgroup_on_subnet(subrec, myworkgroup, PERMANENT_TTL)) == NULL) + if((work = create_workgroup_on_subnet(subrec, global_myworkgroup, PERMANENT_TTL)) == NULL) { DEBUG(0,("register_my_workgroup_and_names: Failed to create my workgroup %s on subnet %s. \ -Exiting.\n", myworkgroup, subrec->subnet_name)); +Exiting.\n", global_myworkgroup, subrec->subnet_name)); return False; } @@ -128,10 +127,10 @@ Exiting.\n", myworkgroup, subrec->subnet_name)); */ struct nmb_name nmbname; - make_nmb_name(&nmbname, myworkgroup, 0x0, scope); + make_nmb_name(&nmbname, global_myworkgroup, 0x0, scope); insert_permanent_name_into_unicast(subrec, &nmbname, samba_nb_type|NB_GROUP); - make_nmb_name(&nmbname, myworkgroup, 0x1e, scope); + make_nmb_name(&nmbname, global_myworkgroup, 0x1e, scope); insert_permanent_name_into_unicast(subrec, &nmbname, samba_nb_type|NB_GROUP); } } diff --git a/source3/nmbd/nmbd_nameregister.c b/source3/nmbd/nmbd_nameregister.c index a3e4208cdc..8eae5e0f1c 100644 --- a/source3/nmbd/nmbd_nameregister.c +++ b/source3/nmbd/nmbd_nameregister.c @@ -27,7 +27,7 @@ extern int DEBUGLEVEL; extern pstring scope; -extern fstring myworkgroup; +extern fstring global_myworkgroup; /**************************************************************************** Deal with a response packet when registering one of our names. @@ -73,7 +73,7 @@ name %s.\n", namestr(answer_name), namestr(question_name))); */ #if 1 /* OLD_SAMBA_SERVER_HACK */ - if((nmb->header.rcode == ACT_ERR) && strequal(myworkgroup, answer_name->name) && + if((nmb->header.rcode == ACT_ERR) && strequal(global_myworkgroup, answer_name->name) && (answer_name->name_type == 0x1b)) { /* Pretend we did not get this. */ diff --git a/source3/nmbd/nmbd_processlogon.c b/source3/nmbd/nmbd_processlogon.c index bc9fcb5921..f647687db8 100644 --- a/source3/nmbd/nmbd_processlogon.c +++ b/source3/nmbd/nmbd_processlogon.c @@ -28,8 +28,8 @@ extern int DEBUGLEVEL; -extern pstring myname; -extern fstring myworkgroup; +extern pstring global_myname; +extern fstring global_myworkgroup; /**************************************************************************** Process a domain logon packet @@ -68,7 +68,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) )); return; } - strcpy(my_name, myname); + strcpy(my_name, global_myname); strupper(my_name); code = SVAL(buf,0); @@ -145,7 +145,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) )); PutUniCode(q, my_name); /* PDC name */ q = skip_unicode_string(q, 1); - PutUniCode(q, myworkgroup); /* Domain name*/ + PutUniCode(q, global_myworkgroup); /* Domain name*/ q = skip_unicode_string(q, 1); SIVAL(q, 0, ntversion); q += 4; @@ -218,7 +218,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n", else { DEBUG(3,("process_logon_packet: SAMLOGON request from %s(%s) for %s, returning logon svr %s domain %s code %x token=%x\n", - unistr(unicomp),inet_ntoa(p->ip), ascuser, reply_name, myworkgroup, + unistr(unicomp),inet_ntoa(p->ip), ascuser, reply_name, global_myworkgroup, SAMLOGON_R ,lmnttoken)); } diff --git a/source3/nmbd/nmbd_responserecordsdb.c b/source3/nmbd/nmbd_responserecordsdb.c index ceace36a61..6dae0d43e9 100644 --- a/source3/nmbd/nmbd_responserecordsdb.c +++ b/source3/nmbd/nmbd_responserecordsdb.c @@ -29,7 +29,6 @@ extern int ClientNMB; extern int DEBUGLEVEL; extern pstring scope; -extern pstring myname; extern struct in_addr ipzero; int num_response_packets = 0; diff --git a/source3/nmbd/nmbd_sendannounce.c b/source3/nmbd/nmbd_sendannounce.c index 48072650c2..3936b7e92e 100644 --- a/source3/nmbd/nmbd_sendannounce.c +++ b/source3/nmbd/nmbd_sendannounce.c @@ -28,8 +28,8 @@ #include "includes.h" extern int DEBUGLEVEL; -extern pstring myname; -extern fstring myworkgroup; +extern pstring global_myname; +extern fstring global_myworkgroup; extern char **my_netbios_names; extern int updatecount; extern BOOL found_lm_clients; @@ -54,7 +54,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), - myname, 0x0, to_name, to_type, to_ip, FIRST_SUBNET->myip); + global_myname, 0x0, to_name, to_type, to_ip, FIRST_SUBNET->myip); } /**************************************************************************** @@ -79,12 +79,12 @@ to subnet %s\n", work->work_group, subrec->subnet_name)); CVAL(p,0) = work->token; /* (local) Unique workgroup token id. */ p++; - StrnCpy(p,myname,15); + StrnCpy(p,global_myname,15); strupper(p); p = skip_string(p,1); send_mailslot(False, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf), - myname, 0x0, work->work_group,0x1e, subrec->bcast_ip, subrec->myip); + global_myname, 0x0, work->work_group,0x1e, subrec->bcast_ip, subrec->myip); } /**************************************************************************** @@ -169,14 +169,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, myname, subrec->subnet_name, work->work_group)); + type, global_myname, subrec->subnet_name, work->work_group)); send_announcement(subrec, ANN_LocalMasterAnnouncement, - 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. */ - myname, /* Name to announce. */ + global_myname, /* Name to announce. */ type, /* Type field. */ servrec->serv.comment); } @@ -191,13 +191,13 @@ static void send_workgroup_announcement(struct subnet_record *subrec, struct wor subrec->subnet_name, work->work_group)); send_announcement(subrec, ANN_DomainAnnouncement, - 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. */ - myname); /* From name as comment. */ + global_myname); /* From name as comment. */ } /**************************************************************************** @@ -256,7 +256,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(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); @@ -278,7 +278,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, myworkgroup); + struct work_record *work = find_workgroup_on_subnet(subrec, global_myworkgroup); if(work) { @@ -342,7 +342,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, myworkgroup); + struct work_record *work = find_workgroup_on_subnet(subrec, global_myworkgroup); if(work) { @@ -512,7 +512,7 @@ void announce_remote(time_t t) if (wgroup) *wgroup++ = 0; if (!wgroup || !*wgroup) - wgroup = myworkgroup; + wgroup = global_myworkgroup; addr = *interpret_addr2(s2); @@ -568,17 +568,17 @@ void browse_sync_remote(time_t t) * for our workgroup on the firsst subnet. */ - if((work = find_workgroup_on_subnet(FIRST_SUBNET, myworkgroup)) == NULL) + if((work = find_workgroup_on_subnet(FIRST_SUBNET, global_myworkgroup)) == NULL) { DEBUG(0,("browse_sync_remote: Cannot find workgroup %s on subnet %s\n", - myworkgroup, FIRST_SUBNET->subnet_name )); + global_myworkgroup, 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", myworkgroup, FIRST_SUBNET->subnet_name )); +for workgroup %s on subnet %s.\n", global_myworkgroup, FIRST_SUBNET->subnet_name )); return; } @@ -587,7 +587,7 @@ for workgroup %s on subnet %s.\n", myworkgroup, FIRST_SUBNET->subnet_name )); CVAL(p,0) = ANN_MasterAnnouncement; p++; - StrnCpy(p,myname,15); + StrnCpy(p,global_myname,15); strupper(p); p = skip_string(p,1); @@ -597,9 +597,9 @@ for workgroup %s on subnet %s.\n", 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", - myname, inet_ntoa(addr) )); + global_myname, inet_ntoa(addr) )); send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf), - myname, 0x0, "*", 0x0, addr, FIRST_SUBNET->myip); + global_myname, 0x0, "*", 0x0, addr, FIRST_SUBNET->myip); } } diff --git a/source3/nmbd/nmbd_serverlistdb.c b/source3/nmbd/nmbd_serverlistdb.c index e94cb1da6e..ea1948cece 100644 --- a/source3/nmbd/nmbd_serverlistdb.c +++ b/source3/nmbd/nmbd_serverlistdb.c @@ -29,8 +29,7 @@ extern int ClientNMB; extern int DEBUGLEVEL; -extern pstring myname; -extern fstring myworkgroup; +extern fstring global_myworkgroup; extern char **my_netbios_names; int updatecount = 0; @@ -259,7 +258,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 myworkgroup (we've + We return zero if we should not. Don't write out global_myworkgroup (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. @@ -270,7 +269,7 @@ static uint32 write_this_workgroup_name( struct subnet_record *subrec, { struct subnet_record *ssub; - if(strequal(myworkgroup, work->work_group)) + if(strequal(global_myworkgroup, work->work_group)) return 0; /* This is a workgroup we have seen on a broadcast subnet. All @@ -358,10 +357,10 @@ void write_browse_list(time_t t, BOOL force_write) * subnet. */ - if((work = find_workgroup_on_subnet(FIRST_SUBNET, myworkgroup)) == NULL) + if((work = find_workgroup_on_subnet(FIRST_SUBNET, global_myworkgroup)) == NULL) { DEBUG(0,("write_browse_list: Fatal error - cannot find my workgroup %s\n", - myworkgroup)); + global_myworkgroup)); fclose(fp); return; } @@ -386,7 +385,7 @@ void write_browse_list(time_t t, BOOL force_write) stype = 0; for (subrec = FIRST_SUBNET; subrec ; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec)) { - if((work = find_workgroup_on_subnet( subrec, myworkgroup )) == NULL) + if((work = find_workgroup_on_subnet( subrec, global_myworkgroup )) == NULL) continue; if((servrec = find_server_in_workgroup( work, my_netbios_names[i])) == NULL) continue; @@ -400,7 +399,7 @@ void write_browse_list(time_t t, BOOL force_write) fprintf(fp, "%08x ", stype); sprintf(tmp, "\"%s\" ", lp_serverstring()); fprintf(fp, "%-30s", tmp); - fprintf(fp, "\"%s\"\n", myworkgroup); + fprintf(fp, "\"%s\"\n", global_myworkgroup); } 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 d8e8dd4ab9..34287bbe69 100644 --- a/source3/nmbd/nmbd_subnetdb.c +++ b/source3/nmbd/nmbd_subnetdb.c @@ -33,7 +33,6 @@ extern int global_nmb_port; extern int DEBUGLEVEL; -extern pstring myname; extern fstring myworkgroup; extern char **my_netbios_names; extern struct in_addr ipzero; diff --git a/source3/nmbd/nmbd_workgroupdb.c b/source3/nmbd/nmbd_workgroupdb.c index b834525747..0b392680df 100644 --- a/source3/nmbd/nmbd_workgroupdb.c +++ b/source3/nmbd/nmbd_workgroupdb.c @@ -29,8 +29,8 @@ extern int ClientNMB; extern int DEBUGLEVEL; -extern pstring myname; -extern fstring myworkgroup; +extern pstring global_myname; +extern fstring global_myworkgroup; extern char **my_netbios_names; extern uint16 samba_nb_type; extern struct in_addr ipzero; @@ -246,7 +246,7 @@ void initiate_myworkgroup_startup(struct subnet_record *subrec, struct work_reco { int i; - if(!strequal(myworkgroup, work->work_group)) + if(!strequal(global_myworkgroup, work->work_group)) return; /* If this is a broadcast subnet then start elections on it @@ -264,11 +264,11 @@ 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,myworkgroup,0x0,samba_nb_type|NB_GROUP, + register_name(subrec,global_myworkgroup,0x0,samba_nb_type|NB_GROUP, NULL, fail_register,NULL); - register_name(subrec,myworkgroup,0x1e,samba_nb_type|NB_GROUP, + register_name(subrec,global_myworkgroup,0x1e,samba_nb_type|NB_GROUP, NULL, fail_register,NULL); @@ -278,7 +278,7 @@ workgroup %s on subnet %s\n", work->work_group, subrec->subnet_name)); int stype = lp_default_server_announce() | (lp_local_master() ? SV_TYPE_POTENTIAL_BROWSER : 0 ); - if(!strequal(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/param/loadparm.c b/source3/param/loadparm.c index 661ca901fa..c96669dba4 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -69,7 +69,7 @@ BOOL bLoaded = False; extern int DEBUGLEVEL; extern pstring user_socket_options; -extern pstring myname; +extern pstring global_myname; #ifndef GLOBAL_NAME #define GLOBAL_NAME "global" @@ -432,7 +432,7 @@ static struct parm_struct parm_table[] = {"path", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL, FLAG_BASIC|FLAG_PRINT}, {"directory", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL, 0}, {"workgroup", P_USTRING, P_GLOBAL, &Globals.szWorkGroup, NULL, NULL, FLAG_BASIC}, - {"netbios name", P_UGSTRING,P_GLOBAL, myname, NULL, NULL, FLAG_BASIC}, + {"netbios name", P_UGSTRING,P_GLOBAL, global_myname, NULL, NULL, FLAG_BASIC}, {"netbios aliases", P_STRING, P_GLOBAL, &Globals.szNetbiosAliases, NULL, NULL, 0}, {"server string", P_STRING, P_GLOBAL, &Globals.szServerString, NULL, NULL, FLAG_BASIC}, {"interfaces", P_STRING, P_GLOBAL, &Globals.szInterfaces, NULL, NULL, FLAG_BASIC}, diff --git a/source3/rpc_client/cli_login.c b/source3/rpc_client/cli_login.c index 771ff7108e..ad176ffe8f 100644 --- a/source3/rpc_client/cli_login.c +++ b/source3/rpc_client/cli_login.c @@ -26,13 +26,10 @@ extern int DEBUGLEVEL; /**************************************************************************** -Initialize domain session. +Initialize domain session credentials. ****************************************************************************/ -BOOL do_nt_session_open(struct cli_state *cli, uint16 fnum, - char *dest_host, char *myhostname, - char *mach_acct, - uchar sess_key[16], DOM_CRED *clnt_cred) +BOOL cli_nt_setup_creds(struct cli_state *cli, unsigned char mach_pwd[16]) { DOM_CHAL clnt_chal; DOM_CHAL srv_chal; @@ -41,57 +38,19 @@ BOOL do_nt_session_open(struct cli_state *cli, uint16 fnum, UTIME zerotime; - char nt_owf_mach_pwd[16]; - RPC_IFACE abstract; RPC_IFACE transfer; - fstring mach_pwd; - fstring dest_srv; - /******************** initialise ********************************/ zerotime.time = 0; - DEBUG(10,("do_nt_session_open: %d\n", __LINE__)); - - /**************** Set Named Pipe State ***************/ - if (!rpc_pipe_set_hnd_state(cli, PIPE_NETLOGON, fnum, 0x4300)) - { - DEBUG(0,("do_nt_session_open: pipe hnd state failed\n")); - return False; - } - - /******************* bind request on \PIPE\NETLOGON *****************/ - - if (!rpc_pipe_bind(cli, PIPE_NETLOGON, fnum, &abstract, &transfer, - False, NULL, NULL)) - { - DEBUG(0,("do_nt_session_open: rpc bind failed\n")); - return False; - } - - /************ Check workstation trust account *******************/ - -FIXME !! - /* default machine password is lower-case machine name (really secure) */ - fstrcpy(mach_pwd, myhostname); - strlower(mach_pwd); - - /* default machine password is lower-case machine name (really secure) */ - fstrcpy(prev_mpd, myhostname); - strlower(prev_mpd); - /******************* Request Challenge ********************/ generate_random_buffer( clnt_chal.data, 8, False); - strcpy(dest_srv, "\\\\"); - strcat(dest_srv, dest_host); - strupper(dest_srv); - /* send a client challenge; receive a server challenge */ - if (!do_net_req_chal(cli, fnum, dest_srv, myhostname, &clnt_chal, &srv_chal)) + if (!cli_net_req_chal(cli, &clnt_chal, &srv_chal)) { DEBUG(0,("do_nt_session_open: request challenge failed\n")); return False; @@ -99,17 +58,8 @@ FIXME !! /**************** Long-term Session key **************/ -#ifdef DEBUG_PASSWORD - DEBUG(100,("generating nt owf from initial machine pwd: %s\n", mach_pwd)); -#endif - nt_owf_gen( mach_pwd, nt_owf_mach_pwd); - -#ifdef DEBUG_PASSWORD - dump_data(6, nt_owf_mach_pwd, 16); -#endif - /* calculate the session key */ - cred_session_key(&clnt_chal, &srv_chal, nt_owf_mach_pwd, sess_key); + cred_session_key(&clnt_chal, &srv_chal, mach_pwd, sess_key); bzero(sess_key+8, 8); /******************* Authenticate 2 ********************/ @@ -118,22 +68,22 @@ FIXME !! cred_create(sess_key, &clnt_chal, zerotime, &(clnt_cred->challenge)); /* send client auth-2 challenge; receive an auth-2 challenge */ - if (!do_net_auth2(cli, fnum, dest_srv, mach_acct, - SEC_CHAN_WKSTA, myhostname, - &(clnt_cred->challenge), 0x000001ff, &auth2_srv_chal)) + if (!cli_net_auth2(cli, SEC_CHAN_WKSTA, 0x000001ff, + &(cli->clnt_cred->challenge), &auth2_srv_chal)) { - DEBUG(0,("do_nt_session_open: request challenge failed\n")); + DEBUG(0,("do_nt_session_open: auth2 challenge failed\n")); return False; } return True; } +#if 0 /**************************************************************************** server password set ****************************************************************************/ -BOOL do_nt_srv_pwset(struct cli_state *cli, int t_idx, uint16 fnum, +BOOL do_nt_srv_pwset(struct cli_state *cli, uint8 sess_key[16], DOM_CRED *clnt_cred, DOM_CRED *rtn_cred, char *new_mach_pwd, char *dest_host, char *mach_acct, char *myhostname) @@ -208,14 +158,13 @@ void make_nt_login_interactive(NET_ID_INFO_CTR *ctr, smb_userid, 0, username, myhostname, sess_key, lm_owf_user_pwd, nt_owf_user_pwd); } +#endif /**************************************************************************** make network sam login info ****************************************************************************/ -void make_nt_login_network(NET_ID_INFO_CTR *ctr, - char *workgroup, char *myhostname, - uint32 smb_userid, char *username, +void make_nt_login_network(NET_ID_INFO_CTR *ctr, uint32 smb_userid, char *username, char lm_chal[8], char lm_chal_resp[24], char nt_chal_resp[24]) { @@ -223,7 +172,7 @@ void make_nt_login_network(NET_ID_INFO_CTR *ctr, ctr->switch_value = 2; /* this is used in both the SAM Logon and the SAM Logoff */ - make_id_info2(&ctr->auth.id2, workgroup, 0, smb_userid, 0, + make_id_info2(&ctr->auth.id2, myworkgroup, 0, smb_userid, 0, username, myhostname, lm_chal, lm_chal_resp, nt_chal_resp); } @@ -232,10 +181,9 @@ void make_nt_login_network(NET_ID_INFO_CTR *ctr, NT login. ****************************************************************************/ -BOOL do_nt_login(struct cli_state *cli, uint16 fnum, - uint8 sess_key[16], DOM_CRED *clnt_cred, DOM_CRED *rtn_cred, - NET_ID_INFO_CTR *ctr, char *dest_host, char *myhostname, - NET_USER_INFO_3 *user_info3) +BOOL cli_nt_login(struct cli_state *cli, + DOM_CRED *clnt_cred, DOM_CRED *rtn_cred, + NET_ID_INFO_CTR *ctr, NET_USER_INFO_3 *user_info3) { DOM_CRED sam_logon_rtn_cred; DOM_CRED cred; @@ -246,12 +194,12 @@ BOOL do_nt_login(struct cli_state *cli, uint16 fnum, /*********************** SAM Logon **********************/ - clnt_cred->timestamp.time = time(NULL); + cli->clnt_cred->timestamp.time = time(NULL); - memcpy(&cred, clnt_cred, sizeof(cred)); + memcpy(&cred, cli->clnt_cred, sizeof(cred)); /* calculate sam logon credentials */ - cred_create(sess_key, &(clnt_cred->challenge), + cred_create(sess_key, &(cli->clnt_cred->challenge), cred.timestamp, &(cred.challenge)); strcpy(dest_srv, "\\\\"); @@ -262,8 +210,7 @@ BOOL do_nt_login(struct cli_state *cli, uint16 fnum, strupper(my_host_name); /* send client sam-logon challenge */ - return do_net_sam_logon(cli, fnum, sess_key, clnt_cred, - dest_srv, my_host_name, + return cli_net_sam_logon(cli, dest_srv, my_host_name, &cred, &sam_logon_rtn_cred, ctr->switch_value, ctr, 3, user_info3, rtn_cred); @@ -273,8 +220,7 @@ BOOL do_nt_login(struct cli_state *cli, uint16 fnum, nt sam logoff ****************************************************************************/ -BOOL do_nt_logoff(struct cli_state *cli, uint16 fnum, - uint8 sess_key[16], DOM_CRED *clnt_cred, DOM_CRED *rtn_cred, +BOOL cli_nt_logoff(struct cli_state *cli, DOM_CRED *rtn_cred, NET_ID_INFO_CTR *ctr, char *dest_host, char *myhostname) { DOM_CRED sam_logoff_rtn_cred; @@ -288,10 +234,10 @@ BOOL do_nt_logoff(struct cli_state *cli, uint16 fnum, clnt_cred->timestamp.time = time(NULL); - memcpy(&cred, clnt_cred, sizeof(cred)); + memcpy(&cred, cli->clnt_cred, sizeof(cred)); /* calculate sam logoff credentials */ - cred_create(sess_key, &(clnt_cred->challenge), + cred_create(sess_key, &(cli->clnt_cred->challenge), cred.timestamp, &(cred.challenge)); strcpy(dest_srv, "\\\\"); @@ -302,22 +248,9 @@ BOOL do_nt_logoff(struct cli_state *cli, uint16 fnum, strupper(my_host_name); /* send client sam-logoff challenge; receive a sam-logoff challenge */ - return do_net_sam_logoff(cli, fnum, sess_key, clnt_cred, + return cli_net_sam_logoff(cli, fnum, sess_key, clnt_cred, dest_srv, my_host_name, &cred, &sam_logoff_rtn_cred, ctr->switch_value, ctr, 3, rtn_cred); } - -/**************************************************************************** -Close the NT pipe. -****************************************************************************/ - -void do_nt_session_close(struct cli_state *cli, uint16 fnum) -{ - /******************** close the \PIPE\NETLOGON file **************/ - if (fnum != 0xffff) - { - cli_close(cli, fnum); - } -} diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index a1a868ce96..654445b31d 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -65,7 +65,7 @@ BOOL do_net_logon_ctrl2(struct cli_state *cli, uint16 fnum, net_io_q_logon_ctrl2("", &q_l, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, NET_LOGON_CTRL2, &buf, &rbuf)) + if (rpc_api_pipe_req(cli, NET_LOGON_CTRL2, &buf, &rbuf)) { NET_R_LOGON_CTRL2 r_l; BOOL ok; @@ -77,6 +77,7 @@ BOOL do_net_logon_ctrl2(struct cli_state *cli, uint16 fnum, { /* report error code */ DEBUG(0,("NET_R_LOGON_CTRL: %s\n", get_nt_error_msg(r_l.status))); + cli->nt_error = r_l.status; ok = False; } @@ -96,38 +97,32 @@ BOOL do_net_logon_ctrl2(struct cli_state *cli, uint16 fnum, do a LSA Authenticate 2 ****************************************************************************/ -BOOL do_net_auth2(struct cli_state *cli, uint16 fnum, - char *logon_srv, char *acct_name, uint16 sec_chan, - char *comp_name, DOM_CHAL *clnt_chal, uint32 neg_flags, - DOM_CHAL *srv_chal) +BOOL cli_net_auth2(struct cli_state *cli, uint16 sec_chan, + uint32 neg_flags, DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal) { prs_struct rbuf; prs_struct buf; NET_Q_AUTH_2 q_a; BOOL valid_chal = False; - if (srv_chal == NULL || clnt_chal == NULL) - return False; - prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); prs_init(&rbuf, 0, 4, SAFETY_MARGIN, True ); - /* create and send a MSRPC command with api NET_AUTH2 */ DEBUG(4,("LSA Authenticate 2: srv:%s acct:%s sc:%x mc: %s chal %s neg: %lx\n", - logon_srv, acct_name, sec_chan, comp_name, + cli->srv_name, cli->mach_acct, sec_chan, global_myname, credstr(clnt_chal->data), neg_flags)); /* store the parameters */ - make_q_auth_2(&q_a, logon_srv, acct_name, sec_chan, comp_name, + make_q_auth_2(&q_a, cli->srv_name, cli->mach_acct, sec_chan, global_myname, clnt_chal, neg_flags); /* turn parameters into data stream */ net_io_q_auth_2("", &q_a, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, NET_AUTH2, &buf, &rbuf)) + if (rpc_api_pipe_req(cli, NET_AUTH2, &buf, &rbuf)) { NET_R_AUTH_2 r_a; BOOL ok; @@ -139,6 +134,7 @@ BOOL do_net_auth2(struct cli_state *cli, uint16 fnum, { /* report error code */ DEBUG(0,("NET_AUTH2: %s\n", get_nt_error_msg(r_a.status))); + cli->nt_error = r_a.status; ok = False; } @@ -168,9 +164,7 @@ BOOL do_net_auth2(struct cli_state *cli, uint16 fnum, do a LSA Request Challenge ****************************************************************************/ -BOOL do_net_req_chal(struct cli_state *cli, uint16 fnum, - char *desthost, char *myhostname, - DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal) +BOOL cli_net_req_chal(struct cli_state *cli, DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal) { prs_struct rbuf; prs_struct buf; @@ -183,20 +177,19 @@ BOOL do_net_req_chal(struct cli_state *cli, uint16 fnum, prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); prs_init(&rbuf, 0, 4, SAFETY_MARGIN, True ); - /* create and send a MSRPC command with api NET_REQCHAL */ - DEBUG(4,("LSA Request Challenge from %s to %s: %s\n", - desthost, myhostname, credstr(clnt_chal->data))); + DEBUG(4,("cli_net_req_chal: LSA Request Challenge from %s to %s: %s\n", + cli->desthost, global_myname, credstr(clnt_chal->data))); /* store the parameters */ - make_q_req_chal(&q_c, desthost, myhostname, clnt_chal); + make_q_req_chal(&q_c, desthost, global_myname, clnt_chal); /* turn parameters into data stream */ net_io_q_req_chal("", &q_c, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, NET_REQCHAL, &buf, &rbuf)) + if (rpc_api_pipe_req(cli, NET_REQCHAL, &buf, &rbuf)) { NET_R_REQ_CHAL r_c; BOOL ok; @@ -208,6 +201,7 @@ BOOL do_net_req_chal(struct cli_state *cli, uint16 fnum, { /* report error code */ DEBUG(0,("NET_REQ_CHAL: %s\n", get_nt_error_msg(r_c.status))); + cli->nt_error = r_a.status; ok = False; } @@ -261,7 +255,7 @@ BOOL do_net_srv_pwset(struct cli_state *cli, uint16 fnum, net_io_q_srv_pwset("", &q_s, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, NET_SRVPWSET, &buf, &rbuf)) + if (rpc_api_pipe_req(cli, NET_SRVPWSET, &buf, &rbuf)) { NET_R_SRV_PWSET r_s; BOOL ok; @@ -273,6 +267,7 @@ BOOL do_net_srv_pwset(struct cli_state *cli, uint16 fnum, { /* report error code */ DEBUG(0,("NET_R_SRV_PWSET: %s\n", get_nt_error_msg(r_s.status))); + cli->nt_error = r_s.status; ok = False; } @@ -302,8 +297,7 @@ BOOL do_net_srv_pwset(struct cli_state *cli, uint16 fnum, do a LSA SAM Logon ****************************************************************************/ -BOOL do_net_sam_logon(struct cli_state *cli, uint16 fnum, - uchar sess_key[8], DOM_CRED *sto_clnt_cred, +BOOL cli_net_sam_logon(struct cli_state *cli, DOM_CRED *sto_clnt_cred, char *logon_srv, char *comp_name, DOM_CRED *clnt_cred, DOM_CRED *rtn_cred, uint16 logon_level, NET_ID_INFO_CTR *ctr, @@ -321,24 +315,23 @@ BOOL do_net_sam_logon(struct cli_state *cli, uint16 fnum, prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); prs_init(&rbuf, 0, 4, SAFETY_MARGIN, True ); - /* create and send a MSRPC command with api NET_SAMLOGON */ DEBUG(4,("LSA SAM Logon: srv:%s mc:%s clnt %s %lx rtn: %s %lx ll: %d\n", - logon_srv, comp_name, - credstr(clnt_cred->challenge.data), clnt_cred->timestamp.time, + cli->srv_name, global_myname, + credstr(cli->clnt_cred->challenge.data), cli->clnt_cred->timestamp.time, credstr(rtn_cred->challenge.data), rtn_cred ->timestamp.time, logon_level)); /* store the parameters */ - make_sam_info(&(q_s.sam_id), logon_srv, comp_name, - clnt_cred, rtn_cred, logon_level, ctr, validation_level); + make_sam_info(&(q_s.sam_id), cli->srv_name, global_myname, + cli->clnt_cred, rtn_cred, logon_level, ctr, validation_level); /* turn parameters into data stream */ net_io_q_sam_logon("", &q_s, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, NET_SAMLOGON, &buf, &rbuf)) + if (rpc_api_pipe_req(cli, NET_SAMLOGON, &buf, &rbuf)) { NET_R_SAM_LOGON r_s; BOOL ok; @@ -352,6 +345,7 @@ BOOL do_net_sam_logon(struct cli_state *cli, uint16 fnum, { /* report error code */ DEBUG(0,("NET_SAMLOGON: %s\n", get_nt_error_msg(r_s.status))); + cli->nt_error = r_s.status; ok = False; } @@ -365,7 +359,7 @@ BOOL do_net_sam_logon(struct cli_state *cli, uint16 fnum, if (ok) { - if (clnt_deal_with_creds(sess_key, sto_clnt_cred, &(r_s.srv_creds))) + if (clnt_deal_with_creds(cli->sess_key, sto_clnt_cred, &(r_s.srv_creds))) { DEBUG(5, ("do_net_sam_logon: server credential check OK\n")); /* ok, at last: we're happy. return the challenge */ @@ -423,7 +417,7 @@ BOOL do_net_sam_logoff(struct cli_state *cli, uint16 fnum, net_io_q_sam_logoff("", &q_s, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, NET_SAMLOGOFF, &buf, &rbuf)) + if (rpc_api_pipe_req(cli, NET_SAMLOGOFF, &buf, &rbuf)) { NET_R_SAM_LOGOFF r_s; BOOL ok; @@ -435,6 +429,7 @@ BOOL do_net_sam_logoff(struct cli_state *cli, uint16 fnum, { /* report error code */ DEBUG(0,("NET_SAMLOGOFF: %s\n", get_nt_error_msg(r_s.status))); + cli->nt_error = r_s.status; ok = False; } diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index 7ac0f72c77..d57009a47a 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -46,7 +46,7 @@ uint32 get_rpc_call_id(void) uses SMBreadX to get rest of rpc data ********************************************************************/ -static BOOL rpc_read(struct cli_state *cli, uint16 fnum, +static BOOL rpc_read(struct cli_state *cli, prs_struct *rdata, uint32 data_to_read, uint32 rdata_offset) { @@ -83,7 +83,7 @@ static BOOL rpc_read(struct cli_state *cli, uint16 fnum, DEBUG(5,("rpc_read: grow buffer to %d\n", rdata->data->data_used)); } - num_read = cli_read(cli, fnum, data, file_offset + 0x100000, size); + num_read = cli_read(cli, cli->nt_pipe_fnum, data, file_offset + 0x100000, size); DEBUG(5,("rpc_read: read offset: %d read: %d to read: %d\n", file_offset, num_read, data_to_read)); @@ -153,7 +153,7 @@ static BOOL rpc_check_hdr(prs_struct *rdata, uint8 *pkt_type, ****************************************************************************/ -BOOL rpc_api_pipe(struct cli_state *cli, uint16 cmd, uint16 fnum, +BOOL rpc_api_pipe(struct cli_state *cli, uint16 cmd, prs_struct *param , prs_struct *data, prs_struct *rparam, prs_struct *rdata) { @@ -184,7 +184,7 @@ BOOL rpc_api_pipe(struct cli_state *cli, uint16 cmd, uint16 fnum, /* create setup parameters. */ setup[0] = cmd; - setup[1] = fnum; /* pipe file handle. got this from an SMBcreateX. */ + setup[1] = cli->nt_pipe_fnum; /* pipe file handle. got this from an SMBOpenX. */ /* send the data: receive a response. */ if (!cli_api_pipe(cli, "\\PIPE\\\0\0\0", 8, @@ -231,7 +231,7 @@ BOOL rpc_api_pipe(struct cli_state *cli, uint16 cmd, uint16 fnum, /* err status is only informational: the _real_ check is on the length */ if (len > 0) /* || err == (0x80000000 | STATUS_BUFFER_OVERFLOW)) */ { - if (!rpc_read(cli, fnum, rdata, len, rdata->data->data_used)) + if (!rpc_read(cli, rdata, len, rdata->data->data_used)) return False; } @@ -251,7 +251,7 @@ BOOL rpc_api_pipe(struct cli_state *cli, uint16 cmd, uint16 fnum, prs_init(&hps, 0x18, 4, 0, True); - num_read = cli_read(cli, fnum, hps.data->data, 0, 0x18); + num_read = cli_read(cli, cli->nt_pipe_fnum, hps.data->data, 0, 0x18); DEBUG(5,("rpc_api_pipe: read header (size:%d)\n", num_read)); if (num_read != 0x18) @@ -275,7 +275,7 @@ BOOL rpc_api_pipe(struct cli_state *cli, uint16 cmd, uint16 fnum, } len = rhdr.frag_len - hps.offset; - if (!rpc_read(cli, fnum, rdata, len, rdata->data->data_used)) + if (!rpc_read(cli, rdata, len, rdata->data->data_used)) return False; } @@ -400,7 +400,7 @@ static BOOL create_rpc_request(prs_struct *rhdr, uint8 op_num, int data_len) /**************************************************************************** send a request on an rpc pipe. ****************************************************************************/ -BOOL rpc_api_pipe_req(struct cli_state *cli, uint16 fnum, uint8 op_num, +BOOL rpc_api_pipe_req(struct cli_state *cli, uint8 op_num, prs_struct *data, prs_struct *rdata) { /* fudge this, at the moment: create the header; memcpy the data. oops. */ @@ -421,7 +421,7 @@ BOOL rpc_api_pipe_req(struct cli_state *cli, uint16 fnum, uint8 op_num, hdr.data->offset.end = data_len; mem_buf_copy(mem_data(&(hdr.data), 0x18), data->data, 0, data->offset); - ret = rpc_api_pipe(cli, 0x0026, fnum, NULL, &hdr, &rparam, rdata); + ret = rpc_api_pipe(cli, 0x0026, NULL, &hdr, &rparam, rdata); prs_mem_free(&rparam); prs_mem_free(&hdr); @@ -434,8 +434,7 @@ BOOL rpc_api_pipe_req(struct cli_state *cli, uint16 fnum, uint8 op_num, do an rpc bind ****************************************************************************/ -BOOL rpc_pipe_set_hnd_state(struct cli_state *cli, char *pipe_name, - uint16 fnum, uint16 device_state) +BOOL rpc_pipe_set_hnd_state(struct cli_state *cli, char *pipe_name, uint16 device_state) { BOOL state_set = False; char param[2]; @@ -448,14 +447,14 @@ BOOL rpc_pipe_set_hnd_state(struct cli_state *cli, char *pipe_name, return False; DEBUG(5,("Set Handle state Pipe[%x]: %s - device state:%x\n", - fnum, pipe_name, device_state)); + cli->nt_pipe_fnum, pipe_name, device_state)); /* create parameters: device state */ SSVAL(param, 0, device_state); /* create setup parameters. */ setup[0] = 0x0001; - setup[1] = fnum; /* pipe file handle. got this from an SMBcreateX. */ + setup[1] = cli->nt_pipe_fnum; /* pipe file handle. got this from an SMBOpenX. */ /* send the data on \PIPE\ */ if (cli_api_pipe(cli, "\\PIPE\\\0\0\0", 8, @@ -575,9 +574,8 @@ static BOOL check_bind_response(RPC_HDR_BA *hdr_ba, char *pipe_name, RPC_IFACE * do an rpc bind ****************************************************************************/ -BOOL rpc_pipe_bind(struct cli_state *cli, char *pipe_name, uint16 fnum, - RPC_IFACE *abstract, RPC_IFACE *transfer, BOOL ntlmssp_auth, - char *my_name, char *domain) +BOOL rpc_pipe_bind(struct cli_state *cli, char *pipe_name, + RPC_IFACE *abstract, RPC_IFACE *transfer, BOOL ntlmssp_auth) { prs_struct hdr; prs_struct hdr_rb; @@ -591,7 +589,7 @@ BOOL rpc_pipe_bind(struct cli_state *cli, char *pipe_name, uint16 fnum, if (pipe_name == NULL || abstract == NULL || transfer == NULL) return False; - DEBUG(5,("Bind RPC Pipe[%x]: %s\n", fnum, pipe_name)); + DEBUG(5,("Bind RPC Pipe[%x]: %s\n", cli->nt_pipe_fnum, pipe_name)); if (!valid_pipe_name(pipe_name, abstract, transfer)) return False; @@ -604,14 +602,14 @@ BOOL rpc_pipe_bind(struct cli_state *cli, char *pipe_name, uint16 fnum, prs_init(&rparam, 0 , 4, SAFETY_MARGIN, True ); create_rpc_bind_req(&hdr, &hdr_rb, ntlmssp_auth ? &auth_req : NULL, - abstract, transfer, my_name, domain); + abstract, transfer, myname, myworkgroup); /* this is a hack due to limitations in rpc_api_pipe */ prs_init(&data, mem_buf_len(hdr.data), 4, 0x0, False); mem_buf_copy(data.data->data, hdr.data, 0, mem_buf_len(hdr.data)); /* send data on \PIPE\. receive a response */ - if (rpc_api_pipe(cli, 0x0026, fnum, NULL, &data, &rparam, &rdata)) + if (rpc_api_pipe(cli, 0x0026, NULL, &data, &rparam, &rdata)) { RPC_HDR_BA hdr_ba; @@ -637,67 +635,44 @@ BOOL rpc_pipe_bind(struct cli_state *cli, char *pipe_name, uint16 fnum, open a session ****************************************************************************/ -BOOL do_session_open(struct cli_state *cli, char *pipe_name, uint16 *fnum) +BOOL cli_nt_session_open(struct cli_state *cli, char *pipe_name, BOOL encrypted) { RPC_IFACE abstract; RPC_IFACE transfer; + int fnum; /******************* open the pipe *****************/ - if (((*fnum) = cli_open(cli, pipe_name, O_CREAT|O_WRONLY, DENY_NONE)) == 0xffff) + if ((fnum = cli_open(cli, pipe_name, O_CREAT|O_RDWR, DENY_NONE)) == -1) { - DEBUG(1,("do_session_open: cli_open failed\n")); + DEBUG(1,("do_session_open: cli_open failed on pipe %s to machine %s. \ +Error was %s.\n", pipe_name, cli->desthost, cli_errstr(&cli))); return False; } + cli->nt_pipe_fnum = (uint16)fnum; + /**************** Set Named Pipe State ***************/ - if (!rpc_pipe_set_hnd_state(cli, pipe_name, (*fnum), 0x4300)) + if (!rpc_pipe_set_hnd_state(cli, pipe_name, 0x4300)) { - DEBUG(1,("do_session_open: pipe hnd state failed\n")); + DEBUG(1,("do_session_open: pipe hnd state failed.\n")); return False; } /******************* bind request on pipe *****************/ - if (!rpc_pipe_bind(cli, pipe_name, (*fnum), &abstract, &transfer, - False, NULL, NULL)) + if (!rpc_pipe_bind(cli, pipe_name, &abstract, &transfer, encrypted)) { - DEBUG(1,("do_session_open: rpc bind failed\n")); + DEBUG(1,("do_session_open: rpc bind failed.\n")); return False; } - return True; -} - -/**************************************************************************** - open an encrypted session - ****************************************************************************/ - -BOOL do_ntlm_session_open(struct cli_state *cli, char *pipe_name, uint16 *fnum, - char *my_name, char *domain) -{ - RPC_IFACE abstract; - RPC_IFACE transfer; - - /******************* open the pipe *****************/ - if (((*fnum) = cli_open(cli, pipe_name, O_CREAT|O_WRONLY, DENY_NONE)) == 0xffff) - { - DEBUG(1,("do_ntlm_session_open: cli_open failed\n")); - return False; - } + /* + * Setup the remote server name prefixed by \ and the machine account name. + */ - /**************** Set Named Pipe State ***************/ - if (!rpc_pipe_set_hnd_state(cli, pipe_name, (*fnum), 0x4300)) - { - DEBUG(1,("do_ntlm_session_open: pipe hnd state failed\n")); - return False; - } + sprintf(cli->srv_name, "\\\\%s", cli->desthost); + strupper(cli->srv_name); - /******************* bind request on pipe *****************/ - if (!rpc_pipe_bind(cli, pipe_name, (*fnum), &abstract, &transfer, - True, my_name, domain)) - { - DEBUG(1,("do_ntlm_session_open: rpc bind failed\n")); - return False; - } + sprintf(cli->mach_acct, "%s$", myname); return True; } @@ -706,10 +681,7 @@ BOOL do_ntlm_session_open(struct cli_state *cli, char *pipe_name, uint16 *fnum, close the session ****************************************************************************/ -void do_session_close(struct cli_state *cli, uint16 fnum) +void nt_session_close(struct cli_state *cli) { - if (fnum != 0xffff) - { - cli_close(cli, fnum); - } + cli_close(cli, cli->nt_pipe_fnum); } diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index eb4dfb4a26..6aa1cd707e 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -30,8 +30,7 @@ extern int DEBUGLEVEL; extern BOOL sam_logon_in_ssb; extern pstring samlogon_user; - - +extern pstring global_myname; /************************************************************************* make_net_r_req_chal: @@ -683,7 +682,6 @@ static void api_net_sam_logon( int uid, pstring domain_groups; pstring dom_sid; pstring other_sids; - extern pstring myname; uint32 r_uid; uint32 r_gid; @@ -706,7 +704,7 @@ static void api_net_sam_logon( int uid, pstrcpy(home_drive , lp_logon_drive ()); pstrcpy(home_dir , lp_logon_home ()); - pstrcpy(my_name , myname ); + pstrcpy(my_name , global_myname ); strupper(my_name); get_domain_user_groups(domain_groups, samlogon_user); diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 236b70dc82..d06e2ac660 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -27,7 +27,7 @@ #include "nterr.h" extern int DEBUGLEVEL; - +extern pstring global_myname; /******************************************************************* fill in a share info level 1 structure. @@ -858,7 +858,6 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, uint32 status = 0x0; SRV_INFO_CTR ctr; - extern pstring myname; DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); @@ -867,7 +866,7 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, case 102: { make_srv_info_102(&ctr.srv.sv102, - 500, myname, lp_serverstring(), + 500, global_myname, lp_serverstring(), 5, 4, /* major/minor version - NT 5.4 :-) */ 0x4100b, /* browsing stuff SV_TYPE_XXXX */ 0xffffffff, /* users */ @@ -882,7 +881,7 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, case 101: { make_srv_info_101(&ctr.srv.sv101, - 500, myname, + 500, global_myname, 5, 4, /* major/minor version - NT 5.4 :-) */ 0x4100b, /* browsing stuff SV_TYPE_XXXX */ lp_serverstring()); diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 8a8647d0a9..5bea006b2c 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -27,6 +27,7 @@ #include "nterr.h" extern int DEBUGLEVEL; +extern pstring global_myname; /******************************************************************* @@ -34,13 +35,12 @@ extern int DEBUGLEVEL; ********************************************************************/ static void create_wks_info_100(WKS_INFO_100 *inf) { - extern pstring myname; pstring my_name; pstring domain; DEBUG(5,("create_wks_info_100: %d\n", __LINE__)); - pstrcpy (my_name, myname); + pstrcpy (my_name, global_myname); strupper(my_name); pstrcpy (domain , lp_workgroup()); diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c index 74ae115217..e3dcda9004 100644 --- a/source3/smbd/ipc.c +++ b/source3/smbd/ipc.c @@ -40,7 +40,7 @@ extern files_struct Files[]; extern connection_struct Connections[]; extern fstring local_machine; -extern fstring myworkgroup; +extern fstring global_myworkgroup; #define NERR_Success 0 #define NERR_badpass 86 @@ -1035,7 +1035,7 @@ static int get_server_info(uint32 servertype, if (!next_token(&ptr,s->comment, NULL)) continue; if (!next_token(&ptr,s->domain , NULL)) { /* this allows us to cope with an old nmbd */ - strcpy(s->domain,myworkgroup); + strcpy(s->domain,global_myworkgroup); } if (sscanf(stype,"%X",&s->type) != 1) { @@ -1231,7 +1231,7 @@ static BOOL api_RNetServerEnum(int cnum, uint16 vuid, char *param, char *data, if (strcmp(str1, "WrLehDz") == 0) { StrnCpy(domain, p, sizeof(fstring)-1); } else { - StrnCpy(domain, myworkgroup, sizeof(fstring)-1); + StrnCpy(domain, global_myworkgroup, sizeof(fstring)-1); } if (lp_browse_list()) @@ -2039,7 +2039,7 @@ static BOOL api_RNetServerGetInfo(int cnum,uint16 vuid, char *param,char *data, pstrcpy(comment,lp_serverstring()); - if ((count=get_server_info(SV_TYPE_ALL,&servers,myworkgroup))>0) { + if ((count=get_server_info(SV_TYPE_ALL,&servers,global_myworkgroup))>0) { for (i=0;i<count;i++) if (strequal(servers[i].name,local_machine)) { @@ -2125,7 +2125,7 @@ static BOOL api_NetWkstaGetInfo(int cnum,uint16 vuid, char *param,char *data, p += 4; SIVAL(p,0,PTR_DIFF(p2,*rdata)); /* login domain */ - strcpy(p2,myworkgroup); + strcpy(p2,global_myworkgroup); strupper(p2); p2 = skip_string(p2,1); p += 4; @@ -2135,7 +2135,7 @@ static BOOL api_NetWkstaGetInfo(int cnum,uint16 vuid, char *param,char *data, p += 2; SIVAL(p,0,PTR_DIFF(p2,*rdata)); - strcpy(p2,myworkgroup); /* don't know. login domain?? */ + strcpy(p2,global_myworkgroup); /* don't know. login domain?? */ p2 = skip_string(p2,1); p += 4; @@ -2578,7 +2578,7 @@ static BOOL api_WWkstaUserLogon(int cnum,uint16 vuid, char *param,char *data, strupper(mypath); PACKS(&desc,"z",mypath); /* computer */ } - PACKS(&desc,"z",myworkgroup);/* domain */ + PACKS(&desc,"z",global_myworkgroup);/* domain */ /* JHT - By calling lp_logon_script() and standard_sub() we have */ /* made sure all macros are fully substituted and available */ diff --git a/source3/smbd/password.c b/source3/smbd/password.c index 11ffe4afd1..0e9ec620b1 100644 --- a/source3/smbd/password.c +++ b/source3/smbd/password.c @@ -31,7 +31,7 @@ extern int Protocol; /* users from session setup */ static pstring session_users=""; -extern pstring myname; +extern pstring global_myname; /* these are kept here to keep the string_combinations function simple */ static char this_user[100]=""; @@ -1783,8 +1783,8 @@ BOOL server_validate(char *user, char *domain, * need to detect this as some versions of NT4.x are broken. JRA. */ - if (cli_session_setup(&pw_cli, user, badpass, sizeof(badpass), badpass, sizeof(badpass), - domain)) { + if (cli_session_setup(&pw_cli, user, (char *)badpass, sizeof(badpass), + (char *)badpass, sizeof(badpass), domain)) { if ((SVAL(pw_cli.inbuf,smb_vwv2) & 1) == 0) { DEBUG(0,("server_validate: password server %s allows users as non-guest \ with a bad password.\n", pw_cli.desthost)); @@ -1886,7 +1886,6 @@ BOOL domain_client_validate( char *user, char *domain, struct in_addr dest_ip; struct cli_state cli; BOOL connected_ok = False; - int fnum; /* * Check that the requested domain is not our own machine name. @@ -1894,7 +1893,7 @@ BOOL domain_client_validate( char *user, char *domain, * password file. */ - if(strequal( domain, myname)) { + if(strequal( domain, global_myname)) { DEBUG(3,("domain_client_validate: Requested domain was for this machine.\n")); return False; } @@ -1972,7 +1971,7 @@ machine %s. Error was : %s.\n", remote_machine, cli_errstr(&cli) )); continue; } - if (!cli_session_request(&cli, remote_machine, 0x20, myname)) { + if (!cli_session_request(&cli, remote_machine, 0x20, global_myname)) { DEBUG(0,("domain_client_validate: machine %s rejected the session setup. \ Error was : %s.\n", remote_machine, cli_errstr(&cli) )); cli_shutdown(&cli); @@ -2033,23 +2032,23 @@ Error was : %s.\n", remote_machine, cli_errstr(&cli) )); return False; } +#if 0 /* for now... JRA */ /* * Ok - we have an anonymous connection to the IPC$ share. * Now start the NT Domain stuff :-). */ - /* - * First, open the pipe to \PIPE\NETLOGON. - */ - - if((fnum = cli_open(&cli, PIPE_NETLOGON, O_CREAT, DENY_NONE)) == -1) { - DEBUG(0,("domain_client_validate: cli_open on %s on machine %s failed. Error was :%s.\n", - PIPE_NETLOGON, remote_machine, cli_errstr(&cli))); + if(cli_nt_session_open(&cli, PIPE_NETLOGON, False) == False) { + DEBUG(0,("domain_client_validate: unable to open the domain client session to \ +machine %s. Error was : %s.\n", remote_machine, cli_errstr(&cli))); + cli_close(&cli, fnum); cli_ulogoff(&cli); cli_shutdown(&cli); - return False; + return False; } + if(cli_nt_setup_creds(&cli,) HERE +#endif return False; } #endif /* DOMAIN_CLIENT */ diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c index 4d425cc2c0..fa11060ade 100644 --- a/source3/smbd/pipes.c +++ b/source3/smbd/pipes.c @@ -41,7 +41,6 @@ extern char magic_char; extern BOOL case_sensitive; extern pstring sesssetup_user; extern int Client; -extern fstring myworkgroup; #define VALID_PNUM(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_PIPES)) #define OPEN_PNUM(pnum) (VALID_PNUM(pnum) && Pipes[pnum].open) diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 4472aa16e6..fe1de65be3 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -41,7 +41,7 @@ extern BOOL case_sensitive; extern BOOL case_preserve; extern BOOL short_case_preserve; extern pstring sesssetup_user; -extern fstring myworkgroup; +extern fstring global_myworkgroup; extern int Client; extern int global_oplock_break; @@ -671,7 +671,7 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize) p = smb_buf(outbuf); strcpy(p,"Unix"); p = skip_string(p,1); strcpy(p,"Samba "); strcat(p,VERSION); p = skip_string(p,1); - strcpy(p,myworkgroup); p = skip_string(p,1); + strcpy(p,global_myworkgroup); p = skip_string(p,1); set_message(outbuf,3,PTR_DIFF(p,smb_buf(outbuf)),False); /* perhaps grab OS version here?? */ } diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 81fe5c9306..167911e497 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -25,7 +25,7 @@ pstring servicesf = CONFIGFILE; extern pstring debugf; extern pstring sesssetup_user; -extern fstring myworkgroup; +extern fstring global_myworkgroup; char *InBuffer = NULL; char *OutBuffer = NULL; @@ -3961,10 +3961,10 @@ int reply_nt1(char *outbuf) /* decide where (if) to put the encryption challenge, and follow it with the OEM'd domain name */ - data_len = crypt_len + strlen(myworkgroup) + 1; + data_len = crypt_len + strlen(global_myworkgroup) + 1; set_message(outbuf,17,data_len,True); - strcpy(smb_buf(outbuf)+crypt_len, myworkgroup); + strcpy(smb_buf(outbuf)+crypt_len, global_myworkgroup); CVAL(outbuf,smb_vwv1) = secword; SSVALS(outbuf,smb_vwv16+1,crypt_len); @@ -5154,7 +5154,7 @@ static void usage(char *pname) codepage_initialise(lp_client_code_page()); - strcpy(myworkgroup, lp_workgroup()); + strcpy(global_myworkgroup, lp_workgroup()); #ifndef NO_SIGNAL_TEST signal(SIGHUP,SIGNAL_CAST sig_hup); diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c index 91ccb609bb..8086253349 100644 --- a/source3/utils/smbpasswd.c +++ b/source3/utils/smbpasswd.c @@ -19,6 +19,8 @@ #include "includes.h" +extern pstring global_myname; + /********************************************************* Print command usage on stderr and die. **********************************************************/ @@ -294,9 +296,8 @@ int main(int argc, char **argv) if(remote_machine != NULL) { struct cli_state cli; struct in_addr ip; - fstring myname; - if(get_myname(myname,NULL) == False) { + if(get_myname(global_myname,NULL) == False) { fprintf(stderr, "%s: unable to get my hostname.\n", prog_name ); exit(1); } @@ -315,7 +316,7 @@ int main(int argc, char **argv) exit(1); } - if (!cli_session_request(&cli, remote_machine, 0x20, myname)) { + if (!cli_session_request(&cli, remote_machine, 0x20, global_myname)) { fprintf(stderr, "%s: machine %s rejected the session setup. Error was : %s.\n", prog_name, remote_machine, cli_errstr(&cli) ); cli_shutdown(&cli); |