authtok_get.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <string.h>
#include <stdlib.h>
#include <syslog.h>
#include <security/pam_appl.h>
#include <security/pam_modules.h>
#include <security/pam_impl.h>
#include <libintl.h>
#include <passwdutil.h>
/*PRINTFLIKE2*/
void
{
}
int
{
int res;
char *authtok;
char *pwd;
/*
* We are about to read the new AUTHTOK. Store the AUTHTOK that
* the user used to authenticate in OLDAUTHTOK, so it is available
* to future modules. If OLDAUTHTOK is already set, we leave it alone
*/
if (res != PAM_SUCCESS)
return (res);
if (res != PAM_SUCCESS)
return (res);
(void *)authtok);
if (res == PAM_SUCCESS)
if (debug)
"AUTHTOK to OLDAUTHTOK");
if (res != PAM_SUCCESS)
goto out;
}
} else {
/*
* OLDAUTHTOK was filled in. If AUTHTOK is also filled
* in, we either succeed a module that has done our
* work, or we're here because one of the modules
* that are stacked beyond us has returned PAM_TRY_AGAIN.
* In either case, we should *not* prompt for another
* password.
*/
if (res != PAM_SUCCESS)
goto out;
goto out;
}
}
/*
* Make sure PAM_AUTHTOK is empty, or the framework will not
* put the value read by __pam_get_authtok into it
*/
if (res != PAM_SUCCESS)
goto out;
char *service;
service);
}
} else {
}
out:
if (res != PAM_SUCCESS) {
} else {
/*
* Since we don't actually check the password, we should
* not return PAM_SUCCESS if everything went OK.
* We should return PAM_IGNORE instead.
*/
res = PAM_IGNORE;
}
return (res);
}
int
{
int res;
char *authtok;
char *pwd;
if (debug)
/*
* All we need to do, is make sure that the user re-enters
* the password correctly.
*/
return (PAM_AUTHTOK_ERR);
"Re-enter new Password: "), &pwd);
if (res != PAM_SUCCESS)
return (res);
char *service;
"%s: They don't match."), service);
}
return (PAM_AUTHTOK_ERR);
}
if (debug)
return (PAM_IGNORE);
}
int
{
int i;
int debug = 0;
int res;
for (i = 0; i < argc; i++)
debug = 1;
else
return (res);
}
/*
* int pam_sm_authenticate(pamh, flags, argc, argv)
*
* Read authentication token from user.
*/
int
{
char *user;
char *password;
int i;
int debug = 0;
int res;
int fail = 0;
for (i = 0; i < argc; i++)
debug = 1;
if (debug)
"flags = %d", flags);
if (debug)
"pam_authtok_get: get user failed: %s",
return (res);
}
"PAM_USER NULL or empty");
return (PAM_SYSTEM_ERR);
}
if (res != PAM_SUCCESS)
return (res);
return (PAM_IGNORE);
/*
* No password has been entered yet. Check to see if we need
* to obtain a password
*/
if (res != PAM_SUCCESS) {
return (PAM_SYSTEM_ERR);
}
} else {
return (PAM_BUF_ERR);
}
if (pwu_rep != PWU_DEFAULT_REP)
if (res == PWU_SUCCESS &&
/*
* if PAM_DIASALLOW_NULL_AUTHTOK has not been set, we
* simply return IGNORE
*/
if ((flags & PAM_DISALLOW_NULL_AUTHTOK) == 0)
return (PAM_IGNORE);
/*
* NULL authtoks are not allowed, so we need to
* fail. We will ask for a password to mask the
* failure however.
*/
fail = 1;
}
}
if (res != PAM_SUCCESS)
return (res);
} else if (debug) {
"got NULL password from get_authtok()");
}
if (fail) {
"failing because NULL authtok not allowed");
return (PAM_AUTH_ERR);
} else
return (PAM_IGNORE);
}
/*ARGSUSED*/
int
{
return (PAM_IGNORE);
}