dovecot-1.1: Fix to previous change: Don't lose errno during uid...

dovecot at dovecot.org dovecot at dovecot.org
Thu Dec 18 18:11:04 EET 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/7e8a0ab1e0bc
changeset: 8054:7e8a0ab1e0bc
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Dec 18 18:11:00 2008 +0200
description:
Fix to previous change: Don't lose errno during uid/gid naming.

diffstat:

1 file changed, 12 insertions(+), 4 deletions(-)
src/lib/restrict-access.c |   16 ++++++++++++----

diffs (39 lines):

diff -r a751b71b30d0 -r 7e8a0ab1e0bc src/lib/restrict-access.c
--- a/src/lib/restrict-access.c	Thu Dec 18 18:09:00 2008 +0200
+++ b/src/lib/restrict-access.c	Thu Dec 18 18:11:00 2008 +0200
@@ -53,23 +53,31 @@ static const char *get_uid_str(uid_t uid
 static const char *get_uid_str(uid_t uid)
 {
 	const struct passwd *pw;
+	const char *ret;
+	int old_errno = errno;
 
 	pw = getpwuid(uid);
 	if (pw == NULL)
-		return dec2str(uid);
+		ret = dec2str(uid);
 	else
-		return t_strdup_printf("%s(%s)", dec2str(uid), pw->pw_name);
+		ret = t_strdup_printf("%s(%s)", dec2str(uid), pw->pw_name);
+	errno = old_errno;
+	return ret;
 }
 
 static const char *get_gid_str(gid_t gid)
 {
 	const struct group *group;
+	const char *ret;
+	int old_errno = errno;
 
 	group = getgrgid(gid);
 	if (group == NULL)
-		return dec2str(gid);
+		ret = dec2str(gid);
 	else
-		return t_strdup_printf("%s(%s)", dec2str(gid), group->gr_name);
+		ret = t_strdup_printf("%s(%s)", dec2str(gid), group->gr_name);
+	errno = old_errno;
+	return ret;
 }
 
 static void restrict_init_groups(gid_t primary_gid, gid_t privileged_gid)


More information about the dovecot-cvs mailing list