diff --git a/lib/vfs/mc-vfs/mcserv.c b/lib/vfs/mc-vfs/mcserv.c index 18b79f29d..c0cd7bfa1 100644 --- a/lib/vfs/mc-vfs/mcserv.c +++ b/lib/vfs/mc-vfs/mcserv.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #ifdef HAVE_GETOPT_H @@ -1015,8 +1016,14 @@ do_auth (const char *username, const char *password) if (getuid () != this->pw_uid) return 0; - if (strcmp (username, "ftp") == 0) - chroot (this->pw_dir); + if (strncmp(username, "ftp", 3) == 0) { + errno = 0; + if (chroot(this->pw_dir) != 0 || errno != 0) { + auth = errno; + error(0, errno, strerror(errno)); + return (-auth); + } + } endpwent (); return auth;