Submitted by: Damon Harper
Date: 2006-08-28, 2007-09-21 Summary: Check for errors in comsatd change_user and exit if anything fails In the change_user function of comsatd, no checks were performed on the exit values of setgid, setuid and chdir. This could theoretically lead to privilege escalation if setuid or setgid fails. With this patch, comsatd will exit if one of these commands fails. diff -urN mailutils-1.2.orig/comsat/comsat.c mailutils-1.2/comsat/comsat.c --- mailutils-1.2.orig/comsat/comsat.c 2007-06-27 05:07:16.000000000 -0700 +++ mailutils-1.2/comsat/comsat.c 2007-09-21 01:38:05.000000000 -0700 @@ -584,9 +584,21 @@ exit (1); } - setgid (pw->pw_gid); - setuid (pw->pw_uid); - chdir (pw->pw_dir); + if (setgid (pw->pw_gid)) + { + syslog (LOG_CRIT, _("Cannot set GID %d for user %s: %m"), pw->pw_gid, user); + exit (1); + } + if (setuid (pw->pw_uid)) + { + syslog (LOG_CRIT, _("Cannot set UID %d for user %s: %m"), pw->pw_uid, user); + exit (1); + } + if(chdir (pw->pw_dir)) + { + syslog (LOG_CRIT, _("Cannot chdir to %s for user %s: %m"), pw->pw_dir, user); + exit (1); + } username = user; }