--- smtpd/smtpd.c	Thu Apr  6 22:44:25 2000
+++ smtpd_new/smtpd.c	Sat Apr  8 17:52:12 2000
@@ -75,6 +75,11 @@
 */
 #define MAXHOSTNAMELEN   64
 #define MAXLINE        4096
+/* Multi-thread support */
+typedef struct{
+    int sock;
+    struct sockaddr_in sa;
+}thread_data;
 /*
 *   Commands known by this server
 */
@@ -188,6 +193,8 @@
 
    for (;;) {
       thread_id t;
+      thread_data *td = malloc(sizeof(thread_data));
+      
       n = sizeof(sin2);
 
       s = accept(ss, (struct sockaddr *) &sin2, &n);
@@ -195,8 +202,10 @@
          dprintf(SMERR_FATAL, "%ld> Accept failure\n", ss);
          exit(20);
       }
+      td->sock = s;
+      td->sa = sin2;
       dprintf(SMERR_INFO, "%s %ld: START\n", &version_txt[6], s);
-      t = spawn_thread(process_connection, "smtp_worker", B_NORMAL_PRIORITY, (void *) s);
+      t = spawn_thread(process_connection, "smtp_worker", B_NORMAL_PRIORITY, (void *) td);
       if (t > 0) resume_thread(t); 
    }
 
@@ -645,9 +654,13 @@
    return;
 }
 
+ 
 int32 process_connection(void *data)
 {
-   int s = (int) data;
+   thread_data *my_data = (thread_data*)data; 
+   int s = my_data->sock;
+   struct sockaddr_in client = my_data->sa;
+   char *client_ip = inet_ntoa(client.sin_addr);
    int n, sel_result=0;
    char bf[MAXLINE + 16], *buff, *ptr1;
    struct passwd  *pw;
@@ -658,8 +671,6 @@
    char rpath[MAXPATHLEN + 4];
    long len, mailnum, started, idx, ll;
     
-   fd_set read;
-
    buff = &bf[5];
 
    user[0]     = 0;
@@ -713,7 +724,7 @@
                if (ptr1 = strchr(hostname, '\r')) *ptr1 = 0;
                if (ptr1 = strchr(hostname, '\n')) *ptr1 = 0;
                started = 1;
-               putline(s, "250 %s", myhostname);
+               putline(s, "250 %s - Hello %s (%s) pleased to meet you!", myhostname, hostname, client_ip);
             }
             break;
          case MAIL :
@@ -736,8 +747,15 @@
                      strcpy(buff, "553 Incorrect mail box syntax");
                   }
                   else {
+                     int ok = 0;
                      *ptr1++ = 0;
-                     if (strcasecmp(ptr1, myhostname) == 0) {
+                     if (strcasecmp(ptr1, myhostname) == 0)
+                         ok = 1;
+                     if ((strcmp(client_ip, "127.0.0.1") == 0) &&
+                       (strcasecmp(ptr1, "localhost") == 0))
+                         ok = 1;
+                         
+                     if (ok == 1){
                         if (nousercheck ||
                             ((pw = getpwnam(user)) && (strcasecmp(pw->pw_name, user) == 0))) {
                            strcpy(buff, "250 OK");
@@ -747,7 +765,7 @@
                            strcpy(buff, "550 No such user");
                         }
                      }
-                     else {
+                    else {
                         strcpy(buff, "551 User not local");
                      }
                   }
