1
0

110-change_user.patch 650 B

123456789101112131415161718
  1. --- a/svr-chansession.c
  2. +++ b/svr-chansession.c
  3. @@ -922,12 +922,12 @@ static void execchild(void *user_data) {
  4. /* We can only change uid/gid as root ... */
  5. if (getuid() == 0) {
  6. - if ((setgid(ses.authstate.pw_gid) < 0) ||
  7. + if ((ses.authstate.pw_gid != 0) && ((setgid(ses.authstate.pw_gid) < 0) ||
  8. (initgroups(ses.authstate.pw_name,
  9. - ses.authstate.pw_gid) < 0)) {
  10. + ses.authstate.pw_gid) < 0))) {
  11. dropbear_exit("Error changing user group");
  12. }
  13. - if (setuid(ses.authstate.pw_uid) < 0) {
  14. + if ((ses.authstate.pw_uid != 0) && (setuid(ses.authstate.pw_uid) < 0)) {
  15. dropbear_exit("Error changing user");
  16. }
  17. } else {