diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2006-01-20 11:19:43 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2006-01-20 11:19:43 +0000 |
commit | c42f9ecf7d9829739bbaa8efe7a098637ece4b89 (patch) | |
tree | 869192cc5852fb1c3a0253e012e687ca6cdb74c5 | |
parent | b6ceda56ffaa96350f03e04728096ba053779863 (diff) | |
download | mailutils-c42f9ecf7d9829739bbaa8efe7a098637ece4b89.tar.gz mailutils-c42f9ecf7d9829739bbaa8efe7a098637ece4b89.tar.bz2 |
(imap4d_login): Call imap4d_check_home_dir before switching to user's
privileges. Bail out if it returns with an error. Use util_chdir
instead of chdir to change to user's home directory.
-rw-r--r-- | imap4d/login.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/imap4d/login.c b/imap4d/login.c index 48d7ace19..207457402 100644 --- a/imap4d/login.c +++ b/imap4d/login.c @@ -1,5 +1,5 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002, 2006 Free Software Foundation, Inc. GNU Mailutils is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -54,12 +54,17 @@ imap4d_login (struct imap4d_command *command, char *arg) syslog (LOG_INFO, _("Login failed: %s"), username); return util_finish (command, RESP_NO, "User name or passwd rejected"); } - + + homedir = mu_normalize_path (strdup (auth_data->dir), "/"); + if (imap4d_check_home_dir (homedir, auth_data->uid, auth_data->gid)) + return util_finish (command, RESP_NO, + "User name or passwd rejected"); + if (auth_data->change_uid) setuid (auth_data->uid); - homedir = mu_normalize_path (strdup (auth_data->dir), "/"); - chdir (homedir); + util_chdir (homedir); + namespace_init (homedir); syslog (LOG_INFO, _("User `%s' logged in"), username); return util_finish (command, RESP_OK, "Completed"); |