Make sure that the 'remote' machine name can only be set once. For some weird
authorAndrew Bartlett <abartlet@samba.org>
Sat, 8 Mar 2003 10:22:50 +0000 (10:22 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 8 Mar 2003 10:22:50 +0000 (10:22 +0000)
reason, during a Win2003 installation, when you select 'domain join' it sends
one machine name in the name exchange, and litraly 'machinename' during the
NTLMSSP login.

Also fix up winbindd's logfile handling, so that it matches smbd and nmbd.

(This helps me, by seperating the logs by pid).

Andrew Bartlett
(This used to be commit afe5a3832f79131fb74461577f1db0e5e8bf4b6d)

source3/auth/auth_ntlmssp.c
source3/client/smbmount.c
source3/lib/substitute.c
source3/nmbd/nmbd.c
source3/nsswitch/winbindd.c
source3/smbd/reply.c
source3/smbd/server.c
source3/wrepld/server.c

index d32d2482966992e293629276ad3450a53be15a88..a381219d74e24655011dea49e7c03d71234cd114 100644 (file)
@@ -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 */
index e2372d02b4e1e33d0062c9ed06f114af8239330c..98302485e435fb9e69ff2abeb3ae57cf9f0cb284 100644 (file)
@@ -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()));
index 2d1b2ab1fa1fd0bc6f4a9bef4854ae86e21122af..1e3f51e2d8d6d7a71dcc11cc8f18ae83a41feb9d 100644 (file)
@@ -29,9 +29,20 @@ 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;
+       if (already_perm)
+               return;
+
+       already_perm = perm;
+
        fstring tmp_local_machine;
 
        fstrcpy(tmp_local_machine,local_name);
@@ -40,8 +51,20 @@ void set_local_machine_name(const char* local_name)
        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;
+       if (already_perm)
+               return;
+
+       already_perm = perm;
+
        fstring tmp_remote_machine;
 
        fstrcpy(tmp_remote_machine,remote_name);
@@ -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;
 }
 
index 2b7d8033a2a8a7e8300fadd78b4cf066419e4dc9..fc08645f1ddfde7030aaf42340e8171e0efd17d6 100644 (file)
@@ -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;
index ad37768c09097f36a32c2df1bea0012ab17175ba..921f7d28642cdcad794276840e8165f97cc1d7ea 100644 (file)
@@ -43,15 +43,9 @@ static BOOL reload_services_file(BOOL test)
                }
        }
 
-       snprintf(logfile, sizeof(logfile), "%s/log.winbindd", dyn_LOGFILEBASE);
-       lp_set_logfile(logfile);
-
        reopen_logs();
        ret = lp_load(dyn_CONFIGFILE,False,False,True);
 
-       snprintf(logfile, sizeof(logfile), "%s/log.winbindd", dyn_LOGFILEBASE);
-       lp_set_logfile(logfile);
-
        reopen_logs();
        load_interfaces();
 
@@ -823,13 +817,12 @@ static void usage(void)
 
        fault_setup((void (*)(void *))fault_quit );
 
-       snprintf(logfile, sizeof(logfile), "%s/log.winbindd", dyn_LOGFILEBASE);
-       lp_set_logfile(logfile);
-
        /* Initialise for running in non-root mode */
 
        sec_init();
 
+       set_remote_machine_name("winbindd", False);
+
        /* Set environment variable so we don't recursively call ourselves.
           This may also be useful interactively. */
 
index 71e880476cf69583ad7a37c1cffade7a2dfd46d2..fb730bc625d64f79df5ba03773ebb5793ead17d6 100644 (file)
@@ -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() ));
index 0bcfcb9c78ecdd7b5f12f910910d75d959fb4d0b..aff402df6686b5525c28c04ee327eca7458bfd32 100644 (file)
@@ -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
@@ -706,7 +706,7 @@ static BOOL init_structs(void )
 
        load_case_tables();
 
-       set_remote_machine_name("smbd");
+       set_remote_machine_name("smbd", False);
 
        if (interactive) {
                Fork = False;
index 349f2a21abf16f39d07ecb6e8b6ede0bfc002201..31f260e94c0d791fba98e48d1b613af8a6dae660 100644 (file)
@@ -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);