9a9a6afda14ad89c27f130c4385bce9d695c08e2
[openwrt/staging/wigyori.git] / package / dropbear / patches / 110-change_user.patch
1 Index: dropbear-0.49/svr-chansession.c
2 ===================================================================
3 --- dropbear-0.49.orig/svr-chansession.c 2007-06-04 13:21:39.455978448 +0200
4 +++ dropbear-0.49/svr-chansession.c 2007-06-04 13:21:39.751933456 +0200
5 @@ -908,12 +908,12 @@
6 /* We can only change uid/gid as root ... */
7 if (getuid() == 0) {
8
9 - if ((setgid(ses.authstate.pw->pw_gid) < 0) ||
10 + if ((ses.authstate.pw->pw_gid != 0) && ((setgid(ses.authstate.pw->pw_gid) < 0) ||
11 (initgroups(ses.authstate.pw->pw_name,
12 - ses.authstate.pw->pw_gid) < 0)) {
13 + ses.authstate.pw->pw_gid) < 0))) {
14 dropbear_exit("error changing user group");
15 }
16 - if (setuid(ses.authstate.pw->pw_uid) < 0) {
17 + if ((ses.authstate.pw->pw_uid != 0) && (setuid(ses.authstate.pw->pw_uid) < 0)) {
18 dropbear_exit("error changing user");
19 }
20 } else {