comparison svr-agentfwd.c @ 464:4317be8b7cf9

Make a copy of passwd fields since getpwnam()'s retval isn't safe to keep
author Matt Johnston <matt@ucc.asn.au>
date Sun, 13 Jan 2008 03:55:59 +0000
parents 0cfba3034be5
children 52a644e7b8e1
comparison
equal deleted inserted replaced
461:db4f6adcb7e2 464:4317be8b7cf9
148 148
149 /* Remove the dir as the user. That way they can't cause problems except 149 /* Remove the dir as the user. That way they can't cause problems except
150 * for themselves */ 150 * for themselves */
151 uid = getuid(); 151 uid = getuid();
152 gid = getgid(); 152 gid = getgid();
153 if ((setegid(ses.authstate.pw->pw_gid)) < 0 || 153 if ((setegid(ses.authstate.pw_gid)) < 0 ||
154 (seteuid(ses.authstate.pw->pw_uid)) < 0) { 154 (seteuid(ses.authstate.pw_uid)) < 0) {
155 dropbear_exit("failed to set euid"); 155 dropbear_exit("failed to set euid");
156 } 156 }
157 157
158 /* 2 for "/" and "\0" */ 158 /* 2 for "/" and "\0" */
159 len = strlen(chansess->agentdir) + strlen(chansess->agentfile) + 2; 159 len = strlen(chansess->agentdir) + strlen(chansess->agentfile) + 2;
211 int ret = DROPBEAR_FAILURE; 211 int ret = DROPBEAR_FAILURE;
212 212
213 /* drop to user privs to make the dir/file */ 213 /* drop to user privs to make the dir/file */
214 uid = getuid(); 214 uid = getuid();
215 gid = getgid(); 215 gid = getgid();
216 if ((setegid(ses.authstate.pw->pw_gid)) < 0 || 216 if ((setegid(ses.authstate.pw_gid)) < 0 ||
217 (seteuid(ses.authstate.pw->pw_uid)) < 0) { 217 (seteuid(ses.authstate.pw_uid)) < 0) {
218 dropbear_exit("failed to set euid"); 218 dropbear_exit("failed to set euid");
219 } 219 }
220 220
221 memset((void*)&addr, 0x0, sizeof(addr)); 221 memset((void*)&addr, 0x0, sizeof(addr));
222 addr.sun_family = AF_UNIX; 222 addr.sun_family = AF_UNIX;