Commit b6ceda56 b6ceda56ffaa96350f03e04728096ba053779863 by Sergey Poznyakoff

(imap4d_authenticate): 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.
1 parent f58d1a93
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2001, 2005 Free Software Foundation, Inc.
Copyright (C) 1999, 2001, 2005, 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
......@@ -124,12 +124,15 @@ imap4d_authenticate (struct imap4d_command *command, char *arg)
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), "/");
/* FIXME: Check for errors. */
chdir (homedir);
util_chdir (homedir);
namespace_init (homedir);
syslog (LOG_INFO, _("User `%s' logged in"), adata.username);
......