changeset 13669:08afc14abc21

auth: When complaining about auth-userdb permission errors, log also the wanted UID's name.
author Timo Sirainen <tss@iki.fi>
date Mon, 07 Nov 2011 22:54:32 +0200
parents d0a071b6847c
children d9b89af302e7
files src/auth/auth-master-connection.c
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/auth-master-connection.c	Mon Nov 07 22:17:15 2011 +0200
+++ b/src/auth/auth-master-connection.c	Mon Nov 07 22:54:32 2011 +0200
@@ -12,6 +12,7 @@
 #include "network.h"
 #include "istream.h"
 #include "ostream.h"
+#include "ipwd.h"
 #include "master-service.h"
 #include "userdb.h"
 #include "userdb-blocking.h"
@@ -331,9 +332,17 @@
 
 static const char *auth_restricted_reason(struct auth_master_connection *conn)
 {
-	return t_strdup_printf("%s mode=0666, but not owned by UID %lu",
+	struct passwd pw;
+	const char *namestr;
+
+	if (i_getpwuid(conn->userdb_restricted_uid, &pw) <= 0)
+		namestr = "";
+	else
+		namestr = t_strdup_printf("(%s)", pw.pw_name);
+	return t_strdup_printf("%s mode=0666, but not owned by UID %lu%s",
 			       conn->path,
-			       (unsigned long)conn->userdb_restricted_uid);
+			       (unsigned long)conn->userdb_restricted_uid,
+			       namestr);
 }
 
 static bool