dovecot-1.2: Fix to previous change: Don't lose errno during uid...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Dec 18 18:11:25 EET 2008
details: http://hg.dovecot.org/dovecot-1.2/rev/1c462a3c21ba
changeset: 8566:1c462a3c21ba
user: Timo Sirainen <tss at iki.fi>
date: Thu Dec 18 18:11:21 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 23ae9c63ae47 -r 1c462a3c21ba 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:21 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