summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2003-03-18 09:52:55 +0000
committerAndrew Bartlett <abartlet@samba.org>2003-03-18 09:52:55 +0000
commitcdc6fc8acb24645ccd0f2862741c9ea9e1c02829 (patch)
tree95656003f6e226490d9605f69190dad8022e2dab /source3
parent50eea935161f0c2b5122d9bea5c95eced0a3c485 (diff)
downloadsamba-cdc6fc8acb24645ccd0f2862741c9ea9e1c02829.tar.gz
samba-cdc6fc8acb24645ccd0f2862741c9ea9e1c02829.tar.bz2
samba-cdc6fc8acb24645ccd0f2862741c9ea9e1c02829.zip
Add an extra parameter to our 'set_remote_machine_name' and
'set_local_machine_name' so that the client can't change it from under us. (.NET RC2 and WinXP install calls the machine 'machinename' during NTLMSSP on the domain join). Andrew Bartlett (This used to be commit 4c7163e7c2cc09bd95faa05156ee480957a7a4d8)
Diffstat (limited to 'source3')
-rw-r--r--source3/auth/auth_ntlmssp.c2
-rw-r--r--source3/client/smbmount.c2
-rw-r--r--source3/lib/substitute.c31
-rw-r--r--source3/nmbd/nmbd.c2
-rw-r--r--source3/smbd/reply.c4
-rw-r--r--source3/smbd/server.c4
-rw-r--r--source3/wrepld/server.c2
7 files changed, 37 insertions, 10 deletions
diff --git a/source3/auth/auth_ntlmssp.c b/source3/auth/auth_ntlmssp.c
index d32d248296..a381219d74 100644
--- a/source3/auth/auth_ntlmssp.c
+++ b/source3/auth/auth_ntlmssp.c
@@ -50,7 +50,7 @@ static NTSTATUS auth_ntlmssp_check_password(struct ntlmssp_state *ntlmssp_state)
/* the client has given us its machine name (which we otherwise would not get on port 445).
we need to possibly reload smb.conf if smb.conf includes depend on the machine name */
- set_remote_machine_name(auth_ntlmssp_state->ntlmssp_state->workstation);
+ set_remote_machine_name(auth_ntlmssp_state->ntlmssp_state->workstation, True);
/* setup the string used by %U */
/* sub_set_smb_name checks for weird internally */
diff --git a/source3/client/smbmount.c b/source3/client/smbmount.c
index e2372d02b4..98302485e4 100644
--- a/source3/client/smbmount.c
+++ b/source3/client/smbmount.c
@@ -398,7 +398,7 @@ static void send_fs_socket(char *the_service, char *mount_point, struct cli_stat
}
/* here we are no longer interactive */
- set_remote_machine_name("smbmount"); /* sneaky ... */
+ set_remote_machine_name("smbmount", False); /* sneaky ... */
setup_logging("mount.smbfs", False);
reopen_logs();
DEBUG(0, ("mount.smbfs: entering daemon mode for service %s, pid=%d\n", the_service, sys_getpid()));
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c
index 2d1b2ab1fa..ef68bce985 100644
--- a/source3/lib/substitute.c
+++ b/source3/lib/substitute.c
@@ -29,21 +29,44 @@ fstring remote_proto="UNKNOWN";
static fstring remote_machine;
static fstring smb_user_name;
+/**
+ * Set the 'local' machine name
+ * @param local_name the name we are being called
+ * @param if this is the 'final' name for us, not be be changed again
+ */
-void set_local_machine_name(const char* local_name)
+void set_local_machine_name(const char* local_name, BOOL perm)
{
+ static BOOL already_perm = False;
fstring tmp_local_machine;
+ if (already_perm)
+ return;
+
+ already_perm = perm;
+
fstrcpy(tmp_local_machine,local_name);
trim_string(tmp_local_machine," "," ");
strlower(tmp_local_machine);
alpha_strcpy(local_machine,tmp_local_machine,SAFE_NETBIOS_CHARS,sizeof(local_machine)-1);
}
-void set_remote_machine_name(const char* remote_name)
+/**
+ * Set the 'remote' machine name
+ * @param remote_name the name our client wants to be called by
+ * @param if this is the 'final' name for them, not be be changed again
+ */
+
+void set_remote_machine_name(const char* remote_name, BOOL perm)
{
+ static BOOL already_perm = False;
fstring tmp_remote_machine;
+ if (already_perm)
+ return;
+
+ already_perm = perm;
+
fstrcpy(tmp_remote_machine,remote_name);
trim_string(tmp_remote_machine," "," ");
strlower(tmp_remote_machine);
@@ -57,6 +80,10 @@ const char* get_remote_machine_name(void)
const char* get_local_machine_name(void)
{
+ if (!*local_machine) {
+ return global_myname();
+ }
+
return local_machine;
}
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 2b7d8033a2..fc08645f1d 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -292,7 +292,7 @@ static BOOL reload_nmbd_services(BOOL test)
{
BOOL ret;
- set_remote_machine_name("nmbd");
+ set_remote_machine_name("nmbd", False);
if ( lp_loaded() ) {
pstring fname;
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index ff1c0e5a52..a738baa9ff 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -87,8 +87,8 @@ int reply_special(char *inbuf,char *outbuf)
name2[15] = 0;
}
- set_local_machine_name(name1);
- set_remote_machine_name(name2);
+ set_local_machine_name(name1, True);
+ set_remote_machine_name(name2, True);
DEBUG(2,("netbios connect: local=%s remote=%s\n",
get_local_machine_name(), get_remote_machine_name() ));
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index f8bfe90ea9..4a79916efe 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -398,7 +398,7 @@ static BOOL open_sockets_smbd(BOOL is_daemon, BOOL interactive, const char *smb_
/* this is needed so that we get decent entries
in smbstatus for port 445 connects */
- set_remote_machine_name(get_socket_addr(smbd_server_fd()));
+ set_remote_machine_name(get_socket_addr(smbd_server_fd()), False);
/* Reset global variables in util.c so
that client substitutions will be
@@ -703,7 +703,7 @@ static BOOL init_structs(void )
load_case_tables();
- set_remote_machine_name("smbd");
+ set_remote_machine_name("smbd", False);
if (interactive) {
Fork = False;
diff --git a/source3/wrepld/server.c b/source3/wrepld/server.c
index 349f2a21ab..31f260e94c 100644
--- a/source3/wrepld/server.c
+++ b/source3/wrepld/server.c
@@ -619,7 +619,7 @@ static void process(void)
lp_set_logfile(logfile);
}
- set_remote_machine_name("wrepld");
+ set_remote_machine_name("wrepld", False);
setup_logging(argv[0],log_stdout);