Add $auth1, $auth2, $auth3 variables.
[exim.git] / src / src / expand.c
index 048b87a096104c5106a701a300fd09100139b902..1d82a150ca949a0c092e16f77e51c56a329efae6 100644 (file)
@@ -1,10 +1,10 @@
-/* $Cambridge: exim/src/src/expand.c,v 1.51 2005/12/12 15:58:53 ph10 Exp $ */
+/* $Cambridge: exim/src/src/expand.c,v 1.54 2006/02/10 14:25:43 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2005 */
+/* Copyright (c) University of Cambridge 1995 - 2006 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 
@@ -1230,12 +1230,15 @@ int first = 0;
 int last = var_table_size;
 
 /* Handle ACL variables, which are not in the table because their number may
-vary depending on a build-time setting. */
+vary depending on a build-time setting. If the variable's name is not of the
+form acl_mddd or acl_cddd, where the d's are digits, fall through to look for
+other names that start with acl_. */
 
 if (Ustrncmp(name, "acl_", 4) == 0)
   {
-  int offset, max, n;
   uschar *endptr;
+  int offset = -1;
+  int max = 0;
 
   if (name[4] == 'm')
     {
@@ -1247,11 +1250,23 @@ if (Ustrncmp(name, "acl_", 4) == 0)
     offset = 0;
     max = ACL_CVARS;
     }
-  else return NULL;
 
-  n = Ustrtoul(name + 5, &endptr, 10);
-  if (*endptr != 0 || n >= max) return NULL;
-  return (acl_var[offset + n] == NULL)? US"" : acl_var[offset + n];
+  if (offset >= 0)
+    {
+    int n = Ustrtoul(name + 5, &endptr, 10);
+    if (*endptr == 0 && n < max)
+      return (acl_var[offset + n] == NULL)? US"" : acl_var[offset + n];
+    }
+  }
+
+/* Similarly for $auth<n> variables. */
+
+if (Ustrncmp(name, "auth", 4) == 0)
+  {
+  uschar *endptr;
+  int n = Ustrtoul(name + 4, &endptr, 10);
+  if (*endptr == 0 && n != 0 && n <= AUTH_VARS)
+    return (auth_vars[n-1] == NULL)? US"" : auth_vars[n-1];
   }
 
 /* For all other variables, search the table */