comparison svr-chansession.c @ 204:675f7bf3c391

Seperate out exit errors from setgid()/initgroups(), and errors from setuid(), to make debugging a bit easier
author Matt Johnston <matt@ucc.asn.au>
date Fri, 27 May 2005 16:34:57 +0000
parents 161557a9dde8
children 1a52846ec11f
comparison
equal deleted inserted replaced
193:ca6a7c7a925c 204:675f7bf3c391
860 /* We can only change uid/gid as root ... */ 860 /* We can only change uid/gid as root ... */
861 if (getuid() == 0) { 861 if (getuid() == 0) {
862 862
863 if ((setgid(ses.authstate.pw->pw_gid) < 0) || 863 if ((setgid(ses.authstate.pw->pw_gid) < 0) ||
864 (initgroups(ses.authstate.pw->pw_name, 864 (initgroups(ses.authstate.pw->pw_name,
865 ses.authstate.pw->pw_gid) < 0) || 865 ses.authstate.pw->pw_gid) < 0)) {
866 (setuid(ses.authstate.pw->pw_uid) < 0)) { 866 dropbear_exit("error changing user group");
867 }
868 if (setuid(ses.authstate.pw->pw_uid) < 0) {
867 dropbear_exit("error changing user"); 869 dropbear_exit("error changing user");
868 } 870 }
869 } else { 871 } else {
870 /* ... but if the daemon is the same uid as the requested uid, we don't 872 /* ... but if the daemon is the same uid as the requested uid, we don't
871 * need to */ 873 * need to */