/*
 *
 *   pamtest.cc
 *
 *   Test program for C++ PAM library.
 *
 *   Copyright (C) 2001 by Matt Roberts, KK5JY,
 *   All rights reserved.
 *
 *
 */


#include <unistd.h>
#include <vector>
#include <iostream>
#include <my++/auth.h>

/*
 *
 *   int main (int argc, char **argv)
 *
 */

using namespace my;
using namespace std;

int main (int argc, char **argv) {
	std::string username;

	if (argc < 2)
		username = "";
	else
		username = argv[1];

	/* create a PAM session */
	auth::pam::ttysession a ("pamtest", username);
	
	/* check the authenticity of the user */
	try {
		if (!a.doAuth())
			cout << "Not authenticated." << endl;
		else
			cout << "Authentication OK." << endl;
	} catch (const auth::pam::ttysession::exception &e) {
		cerr << e.what() << endl;
	} catch (...) {
		cerr << "Undefined error." << endl;
	}

	return 0;
}
