View | Details | Raw Unified | Return to bug 17843
Collapse All | Expand All

(-)libexec/ftpd//ftpd.c (-6 / +21 lines)
Lines 1287-1300 Link Here
1287
			goto bad;
1287
			goto bad;
1288
		}
1288
		}
1289
	} else if (chdir(pw->pw_dir) < 0) {
1289
	} else if (chdir(pw->pw_dir) < 0) {
1290
		if (chdir("/") < 0) {
1290
		/*  
1291
			reply(530, "User %s: can't change directory to %s.",
1291
		 * We may have failed to chdir if the user's home
1292
			    pw->pw_name, pw->pw_dir);
1292
		 * directory is mounted over NFS & it is unreadable by
1293
		 * this machines superuser (eg. mode x00) -- set the
1294
		 * uid & try again.  
1295
		 */
1296
		
1297
		if (seteuid((uid_t)pw->pw_uid) < 0) {
1298
			reply(550, "Can't set uid.");
1293
			goto bad;
1299
			goto bad;
1294
		} else
1300
		}
1295
			lreply(230, "No directory! Logging in with home=/");
1301
1302
		if (chdir(pw->pw_dir) < 0) {
1303
			if (chdir("/") < 0) {
1304
				reply(530, "User %s: can't change directory to %s.",
1305
				    pw->pw_name, pw->pw_dir);
1306
				goto bad;
1307
			} else
1308
				lreply(230, "No directory! Logging in with home=/");
1309
		}
1296
	}
1310
	}
1297
	if (seteuid((uid_t)pw->pw_uid) < 0) {
1311
	if (((uid_t)pw->pw_uid != geteuid()) && 
1312
	    seteuid((uid_t)pw->pw_uid) < 0) {
1298
		reply(550, "Can't set uid.");
1313
		reply(550, "Can't set uid.");
1299
		goto bad;
1314
		goto bad;
1300
	}
1315
	}

Return to bug 17843