This is pop_pass.c in view mode; [Download] [Up]
/*
* Copyright (c) 1989 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#ifndef lint
static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
static char SccsId[] = "@(#)@(#)pop_pass.c 2.3 2.3 4/2/91";
#endif not lint
#ifdef SOLARIS2
# define SYSV
#endif
#include <stdio.h>
#include <sys/types.h>
#if defined(SYSV) || defined(AIX)
# include <string.h>
#else
# include <strings.h>
#endif
/* crypt() declaration, including libc.h leads to macro redefine errors */
#if defined(NEXT)
extern char *crypt (char *key, char *salt);
#endif
#include <pwd.h>
#include "popper.h"
#ifdef AUTH
char *crypt();
#ifdef SOLARIS2
#include <shadow.h>
static int
auth_user(p, pw)
POP * p;
struct passwd *pw;
{
struct passwd *pwp;
register struct spwd * pwd;
/* Look for the user in the password file */
if ((pwp = getpwnam(p->user)) == NULL)
return (pop_msg(p,POP_FAILURE,
"Password supplied for \"%s\" is incorrect.",p->user));
*pw = *pwp;
/* Look for the user in the shadow password file */
if ((pwd = getspnam(p->user)) == NULL)
return (pop_msg(p,POP_FAILURE,
"(shadow) Password supplied for \"%s\" is empty.",p->user));
/* We don't accept connections from users with null passwords */
if (pwd->sp_pwdp == NULL || *pwd->sp_pwdp == '\0')
return (pop_msg(p,POP_FAILURE,
"Password supplied for \"%s\" is incorrect.", p->user));
/* Compare the supplied password with the password file entry */
if (strcmp (crypt (p->pop_parm[1], pwd->sp_pwdp), pwd->sp_pwdp) != 0)
return (pop_msg(p,POP_FAILURE,
"Password supplied for \"%s\" is incorrect.",p->user));
return(POP_SUCCESS);
}
#endif /* Solaris 2 */
#ifdef POPSCO
# include <sys/security.h>
# include <sys/audit.h>
# include <prot.h>
#define PASSWD(p) (p->ufld.fd_encrypt)
static int
auth_user(p, pw)
POP * p;
struct passwd *pw;
{
struct passwd *pwp;
register struct pr_passwd *pr;
/* Look for the user in the password file */
if ((pwp = getpwnam(p->user)) == NULL || (pr = getprpwnam(p->user)) == NULL)
return (pop_msg(p,POP_FAILURE,
"Password supplied for \"%s\" is incorrect.",p->user));
*pw = *pwp;
/* We don't accept connections from users with null passwords */
if (PASSWD(pr) == NULL || PASSWD(pr) == '\0')
return (pop_msg(p,POP_FAILURE,
"Password supplied for \"%s\" is incorrect.",p->user));
/* Compare the supplied password with the password file entry */
if (strcmp (crypt (p->pop_parm[1], PASSWD(pr)), PASSWD(pr)) != 0)
return (pop_msg(p,POP_FAILURE,
"Password supplied for \"%s\" is incorrect.",p->user));
return(POP_SUCCESS);
}
#endif /* POPSCO */
#ifdef ULTRIX
#include <auth.h>
static int
auth_user(p, pw)
struct passwd * pw;
POP * p;
{
struct passwd *pwp;
AUTHORIZATION *auth, *getauthuid();
/* Look for the user in the password file */
if ((pwp = getpwnam(p->user)) == NULL)
return (pop_msg(p,POP_FAILURE,
"Password supplied for \"%s\" is incorrect.",p->user));
*pw = *pwp;
auth = getauthuid(pw->pw_uid);
/* We don't accept connections from users with null passwords */
if (auth == NULL || auth->a_password == NULL || *auth->a_password == '\0')
return (pop_msg(p,POP_FAILURE,
"(shadow) Password for \"%s\" is blank.",p->user));
/* Compare the supplied password with the password file entry */
if (strcmp(crypt16(p->pop_parm[1],auth->a_password),auth->a_password) != 0)
return (pop_msg(p,POP_FAILURE,
"Password entered for \"%s\" is incorrect.",p->user));
return(POP_SUCCESS);
}
#endif /* ULTRIX */
#else /* NOT AUTH */
static int
auth_user(p, pw)
POP * p;
struct passwd * pw;
{
struct passwd *pwp;
/* Look for the user in the password file */
if ((pwp = getpwnam(p->user)) == NULL)
return (pop_msg(p,POP_FAILURE,
"Password supplied for \"%s\" is incorrect.",p->user));
*pw = *pwp;
/* We don't accept connections from users with null passwords */
if (pw->pw_passwd == NULL || *pw->pw_passwd == '\0')
return (pop_msg(p,POP_FAILURE,
"Password supplied for \"%s\" is incorrect.",p->user));
/* Compare the supplied password with the password file entry */
if (strcmp (crypt (p->pop_parm[1], pw->pw_passwd), pw->pw_passwd) != 0)
return (pop_msg(p,POP_FAILURE,
"Password supplied for \"%s\" is incorrect.",p->user));
return(POP_SUCCESS);
}
#endif /* AUTH */
/*
* pass: Obtain the user password from a POP client
*/
int pop_pass (p)
POP * p;
{
struct passwd pw;
if (auth_user(p, &pw) != POP_SUCCESS)
return(POP_FAILURE);
/* Build the name of the user's maildrop */
(void)sprintf(p->drop_name,"%s/%s",POP_MAILDIR,p->user);
/* Make a temporary copy of the user's maildrop */
/* and set the group and user id */
/* and get information about the maildrop */
if (pop_dropcopy(p, &pw) != POP_SUCCESS) return (POP_FAILURE);
/* Initialize the last-message-accessed number */
p->last_msg = 0;
/* Authorization completed successfully */
return (pop_msg (p,POP_SUCCESS,
"%s has %d message(s) (%d octets).",
p->user,p->msg_count,p->drop_size));
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.