ftpd: Exit during authentication if an error occurs after chroot().

admbug:		969
Security:	CVE-2020-7468
This commit is contained in:
Mark Johnston 2020-09-15 20:54:18 +00:00
parent 9673f30503
commit 2ac431003b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=365771

View File

@ -1595,13 +1595,20 @@ pass(char *passwd)
* (uid 0 has no root power over NFS if not mapped explicitly.)
*/
if (seteuid(pw->pw_uid) < 0) {
reply(550, "Can't set uid.");
goto bad;
if (guest || dochroot) {
fatalerror("Can't set uid.");
} else {
reply(550, "Can't set uid.");
goto bad;
}
}
/*
* Do not allow the session to live if we're chroot()'ed and chdir()
* fails. Otherwise the chroot jail can be escaped.
*/
if (chdir(homedir) < 0) {
if (guest || dochroot) {
reply(550, "Can't change to base directory.");
goto bad;
fatalerror("Can't change to base directory.");
} else {
if (chdir("/") < 0) {
reply(550, "Root is inaccessible.");