changeset 3690:5595ed76d4c9 HEAD

Added %i for UID
author Timo Sirainen <tss@iki.fi>
date Fri, 28 Oct 2005 14:27:43 +0300
parents 8b68997d6e34
children e167b71e37e3
files doc/variables.txt src/master/mail-process.c
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/doc/variables.txt	Fri Oct 28 13:57:17 2005 +0300
+++ b/doc/variables.txt	Fri Oct 28 14:27:43 2005 +0300
@@ -16,6 +16,7 @@
  %l - local IP address
  %r - remote IP address
  %w - plaintext password from plaintext authentication mechanism
+ %i - System UID of the user
 
 You can apply a modifiers for each variable (eg. %Lp = pop3):
 
--- a/src/master/mail-process.c	Fri Oct 28 13:57:17 2005 +0300
+++ b/src/master/mail-process.c	Fri Oct 28 14:27:43 2005 +0300
@@ -82,7 +82,8 @@
 static const struct var_expand_table *
 get_var_expand_table(const char *protocol,
 		     const char *user, const char *home,
-		     const char *local_ip, const char *remote_ip, pid_t pid)
+		     const char *local_ip, const char *remote_ip,
+		     pid_t pid, uid_t uid)
 {
 	static struct var_expand_table static_tab[] = {
 		{ 'u', NULL },
@@ -93,6 +94,7 @@
 		{ 'l', NULL },
 		{ 'r', NULL },
 		{ 'p', NULL },
+		{ 'i', NULL },
 		{ '\0', NULL }
 	};
 	struct var_expand_table *tab;
@@ -109,6 +111,7 @@
 	tab[5].value = local_ip;
 	tab[6].value = remote_ip;
 	tab[7].value = dec2str(pid);
+	tab[8].value = dec2str(uid);
 
 	return tab;
 }
@@ -291,7 +294,8 @@
 	var_expand_table =
 		get_var_expand_table(protocol, getenv("USER"), getenv("HOME"),
 				     getenv("TCPLOCALIP"),
-				     getenv("TCPREMOTEIP"), getpid());
+				     getenv("TCPREMOTEIP"),
+				     getpid(), geteuid());
 
 	mail_process_set_environment(set, getenv("MAIL"), var_expand_table);
         client_process_exec(set->mail_executable, "");
@@ -387,7 +391,7 @@
 				     user, home_dir,
 				     net_ip2addr(local_ip),
 				     net_ip2addr(remote_ip),
-				     pid != 0 ? pid : getpid());
+				     pid != 0 ? pid : getpid(), uid);
 	str = t_str_new(128);
 
 	if (pid != 0) {