(pop_pass): put login code in separate function
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14044 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -108,12 +108,45 @@ krb5_verify_password (POP *p)
|
|||||||
* pass: Obtain the user password from a POP client
|
* pass: Obtain the user password from a POP client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
login_user(POP *p)
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
struct passwd *pw;
|
||||||
|
|
||||||
|
/* Look for the user in the password file */
|
||||||
|
if ((pw = k_getpwnam(p->user)) == NULL) {
|
||||||
|
pop_log(p, POP_PRIORITY, "user %s (from %s) not found",
|
||||||
|
p->user, p->ipaddr);
|
||||||
|
return pop_msg(p, POP_FAILURE, "Login incorrect.");
|
||||||
|
}
|
||||||
|
|
||||||
|
pop_log(p, POP_INFO, "login from %s as %s", p->ipaddr, p->user);
|
||||||
|
|
||||||
|
/* Build the name of the user's maildrop */
|
||||||
|
snprintf(p->drop_name, sizeof(p->drop_name), "%s/%s", POP_MAILDIR, p->user);
|
||||||
|
if(stat(p->drop_name, &st) < 0 || !S_ISDIR(st.st_mode)){
|
||||||
|
/* Make a temporary copy of the user's maildrop */
|
||||||
|
/* and set the group and user id */
|
||||||
|
if (pop_dropcopy(p, pw) != POP_SUCCESS) return (POP_FAILURE);
|
||||||
|
|
||||||
|
/* Get information about the maildrop */
|
||||||
|
if (pop_dropinfo(p) != POP_SUCCESS) return(POP_FAILURE);
|
||||||
|
} else {
|
||||||
|
if(changeuser(p, pw) != POP_SUCCESS) return POP_FAILURE;
|
||||||
|
if(pop_maildir_info(p) != POP_SUCCESS) return POP_FAILURE;
|
||||||
|
}
|
||||||
|
/* Initialize the last-message-accessed number */
|
||||||
|
p->last_msg = 0;
|
||||||
|
return POP_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pop_pass (POP *p)
|
pop_pass (POP *p)
|
||||||
{
|
{
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
int i;
|
int i;
|
||||||
struct stat st;
|
int status;
|
||||||
|
|
||||||
/* Make one string of all these parameters */
|
/* Make one string of all these parameters */
|
||||||
|
|
||||||
@@ -199,25 +232,9 @@ pop_pass (POP *p)
|
|||||||
"Password incorrect");
|
"Password incorrect");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pop_log(p, POP_INFO, "login from %s as %s",
|
status = login_user(p);
|
||||||
p->ipaddr, p->user);
|
if(status != POP_SUCCESS)
|
||||||
|
return status;
|
||||||
/* Build the name of the user's maildrop */
|
|
||||||
snprintf(p->drop_name, sizeof(p->drop_name), "%s/%s", POP_MAILDIR, p->user);
|
|
||||||
|
|
||||||
if(stat(p->drop_name, &st) < 0 || !S_ISDIR(st.st_mode)){
|
|
||||||
/* Make a temporary copy of the user's maildrop */
|
|
||||||
/* and set the group and user id */
|
|
||||||
if (pop_dropcopy(p, pw) != POP_SUCCESS) return (POP_FAILURE);
|
|
||||||
|
|
||||||
/* Get information about the maildrop */
|
|
||||||
if (pop_dropinfo(p) != POP_SUCCESS) return(POP_FAILURE);
|
|
||||||
} else {
|
|
||||||
if(changeuser(p, pw) != POP_SUCCESS) return POP_FAILURE;
|
|
||||||
if(pop_maildir_info(p) != POP_SUCCESS) return POP_FAILURE;
|
|
||||||
}
|
|
||||||
/* Initialize the last-message-accessed number */
|
|
||||||
p->last_msg = 0;
|
|
||||||
|
|
||||||
/* Authorization completed successfully */
|
/* Authorization completed successfully */
|
||||||
return (pop_msg (p, POP_SUCCESS,
|
return (pop_msg (p, POP_SUCCESS,
|
||||||
|
Reference in New Issue
Block a user