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
1 /* GNU Mailutils -- a suite of utilities for electronic mail 1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 1999, 2001, 2005 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001, 2005, 2006 Free Software Foundation, Inc.
3 3
4 GNU Mailutils is free software; you can redistribute it and/or modify 4 GNU Mailutils is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 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) ...@@ -124,12 +124,15 @@ imap4d_authenticate (struct imap4d_command *command, char *arg)
124 return util_finish (command, RESP_NO, 124 return util_finish (command, RESP_NO,
125 "User name or passwd rejected"); 125 "User name or passwd rejected");
126 126
127 homedir = mu_normalize_path (strdup (auth_data->dir), "/");
128 if (imap4d_check_home_dir (homedir, auth_data->uid, auth_data->gid))
129 return util_finish (command, RESP_NO,
130 "User name or passwd rejected");
131
127 if (auth_data->change_uid) 132 if (auth_data->change_uid)
128 setuid (auth_data->uid); 133 setuid (auth_data->uid);
129 134
130 homedir = mu_normalize_path (strdup (auth_data->dir), "/"); 135 util_chdir (homedir);
131 /* FIXME: Check for errors. */
132 chdir (homedir);
133 namespace_init (homedir); 136 namespace_init (homedir);
134 syslog (LOG_INFO, _("User `%s' logged in"), adata.username); 137 syslog (LOG_INFO, _("User `%s' logged in"), adata.username);
135 138
......