/* SMArT Check username/password combination using PAM Copyright 2001 Wilmer van der Gaast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include int my_conv(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr); static struct pam_conv conv = { my_conv, NULL }; char *user; char *pass; int main( int argc, char **argv ) { pam_handle_t *pamh; int retval, st = 1; user = argv[1]; pass = argv[2]; retval = pam_start( "smart", user, &conv, &pamh ); if ( retval == PAM_SUCCESS ) retval = pam_authenticate( pamh, PAM_SILENT ); if ( retval == PAM_SUCCESS ) st = retval = pam_acct_mgmt( pamh, PAM_SILENT ); if ( pam_end( pamh, retval ) != PAM_SUCCESS ) return( 1 ); return( st != PAM_SUCCESS ); } int my_conv(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr) { struct pam_response *reply; int i; reply = (struct pam_response *) calloc( num_msg, sizeof( struct pam_response ) ); for( i = 0; i < num_msg; i ++ ) { reply[i].resp = (char *) strdup( pass ); /* Just give the password... It's all we know */ reply[i].resp_retcode = 0; } *resp = reply; return( PAM_SUCCESS ); }