summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2004-09-18 00:03:17 +0000
committerStef Walter <stef@memberwebs.com>2004-09-18 00:03:17 +0000
commit5d5eab6f91c923881168d740b263206a3976a85f (patch)
tree364b0ad8b1c07685caf64d6900318ab9933361e4 /common
parent4f078c1accf0fcc0c7feec6a55b3ba89adade829 (diff)
Better error messages for 'run as user'
Diffstat (limited to 'common')
-rw-r--r--common/smtppass.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/common/smtppass.c b/common/smtppass.c
index b13bdac..d1a62a0 100644
--- a/common/smtppass.c
+++ b/common/smtppass.c
@@ -372,11 +372,9 @@ static void drop_privileges()
if(pw == NULL)
errx(1, "couldn't look up user: %s", g_state.user);
- if(setgid(pw->pw_gid) == -1)
- err(1, "unable to switch group: %d", pw->pw_gid);
-
- if(setuid(pw->pw_uid) == -1)
- err(1, "unable to switch user: %d", pw->pw_uid);
+ if(setgid(pw->pw_gid) == -1 ||
+ setuid(pw->pw_uid) == -1)
+ err(1, "unable to switch to user: %s (uid %d, gid %d)", g_state.user, pw->pw_uid, pw->pw_gid);
/* A paranoia check */
if(setreuid(-1, 0) == 0)
@@ -1421,7 +1419,10 @@ static void vmessage(spctx_t* ctx, int level, int err,
{
/* TODO: strerror_r doesn't want to work for us
strerror_r(e, m + strlen(m), MAX_MSGLEN); */
- strncat(m, strerror(e), len);
+
+ sp_lock();
+ strncat(m, strerror(e), len);
+ sp_unlock();
}
m[len - 1] = 0;