/*
* 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 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <security/pam_appl.h>
#include <security/pam_modules.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <pwd.h>
#include <syslog.h>
#include <libintl.h>
#include "sample_utils.h"
/*
*
* Sample module for pam_sm_authenticate.
*
* options -
*
* debug
* use_first_pass
* try_first_pass
* pass=foobar (set good password to "foobar". default good password
* is test)
* always_fail always return PAM_AUTH_ERR
* always_succeed always return PAM_SUCCESS
* always_ignore
*
*
*/
/*
* pam_sm_authenticate - Authenticate user
*/
/*ARGSUSED*/
int
int flags,
int argc,
const char **argv)
{
char *user;
int debug = 0;
int try_first_pass = 0;
int use_first_pass = 0;
int first_pass_good = 0;
int first_pass_bad = 0;
int i, num_msg;
if (debug)
for (i = 0; i < argc; i++) {
debug = 1;
try_first_pass = 1;
first_pass_good = 1;
first_pass_bad = 1;
use_first_pass = 1;
return (PAM_AUTH_ERR);
return (PAM_SUCCESS);
return (PAM_IGNORE);
/*EMPTY*/;
}
else
}
if (err != PAM_SUCCESS)
return (err);
if (err != PAM_SUCCESS)
return (err);
if ((first_pass_good ||
strlen(the_password)) == 0) &&
!first_pass_bad) {
goto out;
}
if (use_first_pass) goto out;
}
/*
* Get the password from the user
*/
if (firstpass) {
} else {
}
num_msg = 1;
if (err != PAM_SUCCESS) {
goto out;
}
goto out;
}
/* one last ditch attempt to "login" to TEST */
/* this is the first password, stash it away */
}
}
out:
if (num_msg > 0) {
if (ret_resp != 0) {
/* avoid leaving password cleartext around */
}
ret_resp = 0;
}
}
return (result);
}