Correct error in previous patch.
[exim.git] / src / src / expand.c
index 31791a888107f4ee7b254f66b8ecefcc4c70e101..11582529a854fc0f35679fabe22c65c0ef728293 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/expand.c,v 1.69 2006/11/13 11:26:37 ph10 Exp $ */
+/* $Cambridge: exim/src/src/expand.c,v 1.72 2006/11/13 12:32:58 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -436,6 +436,8 @@ static var_entry var_table[] = {
   { "rcpt_fail_count",     vtype_int,         &rcpt_fail_count },
   { "received_count",      vtype_int,         &received_count },
   { "received_for",        vtype_stringptr,   &received_for },
+  { "received_ip_address", vtype_stringptr,   &interface_address },
+  { "received_port",       vtype_int,         &interface_port },
   { "received_protocol",   vtype_stringptr,   &received_protocol },
   { "received_time",       vtype_int,         &received_time },
   { "recipient_data",      vtype_stringptr,   &recipient_data },
@@ -3912,6 +3914,7 @@ while (*s != 0)
 
         else
           {
+          int rc;
           if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) == -1)
             {
             expand_string_message = string_sprintf("failed to create socket: %s",
@@ -3922,7 +3925,17 @@ while (*s != 0)
           sockun.sun_family = AF_UNIX;
           sprintf(sockun.sun_path, "%.*s", (int)(sizeof(sockun.sun_path)-1),
             sub_arg[0]);
-          if(connect(fd, (struct sockaddr *)(&sockun), sizeof(sockun)) == -1)
+
+          sigalrm_seen = FALSE;
+          alarm(timeout);
+          rc = connect(fd, (struct sockaddr *)(&sockun), sizeof(sockun));
+          alarm(0);
+          if (sigalrm_seen)
+            {
+            expand_string_message = US "socket connect timed out";
+            goto SOCK_FAIL;
+            }
+          if (rc < 0)
             {
             expand_string_message = string_sprintf("failed to connect to socket "
               "%s: %s", sub_arg[0], strerror(errno));