From e509c5af6f70eb3cfd846004b82caaca24fd4a3b Mon Sep 17 00:00:00 2001 From: "Andrew G. Morgan" Date: Wed, 29 May 2002 06:35:46 +0000 Subject: Relevant BUGIDs: 491466 Purpose of commit: cleanup Commit summary: --------------- These were all suggestions from the OS X patch provided by Luke Howard. There is another proposed patch for OS X support which promises to be a little cleaner with the heavy stuff, so I am committing these simple changes now, with the intention of moving to the other patch for the big stuff (see 534205). --- examples/test.c | 88 --------------------------------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 examples/test.c (limited to 'examples/test.c') diff --git a/examples/test.c b/examples/test.c deleted file mode 100644 index 7e166b48..00000000 --- a/examples/test.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Marc Ewing (marc@redhat.com) - original test code - * Alexander O. Yuriev (alex@bach.cis.temple.edu) - * Andrew Morgan (morgan@physics.ucla.edu) - */ - -#include -#include -#include - -#include - -/* this program is not written to the PAM spec: it tests the - * pam_[sg]et_data() functions. Which is usually reserved for modules */ - -#include -#include - -#define USERNAMESIZE 1024 - -static int test_conv( int num_msg, - const struct pam_message **msgm, - struct pam_response **response, - void *appdata_ptr ) -{ - return 0; -} - -static struct pam_conv conv = { - test_conv, - NULL -}; - -static int cleanup_func(pam_handle_t *pamh, void *data, int error_status) -{ - printf("Cleaning up!\n"); - return PAM_SUCCESS; -} - -void main( void ) -{ - pam_handle_t *pamh; - char *name = ( char *) malloc( USERNAMESIZE + 1 ); - char *p = NULL; - char *s = NULL; - - if (! name ) - { - perror( "Ouch, don't have enough memory"); - exit( -1 ); - } - - - - - fprintf( stdout, "Enter a name of a user to authenticate : "); - name = fgets( name , USERNAMESIZE, stdin ); - if ( !name ) - { - perror ( "Hey, how can authenticate " - "someone whos name I don't know?" ); - exit ( -1 ); - } - - *( name + strlen ( name ) - 1 ) = 0; - - pam_start( "login", name, &conv, &pamh ); - - p = x_strdup( getpass ("Password: ") ); - if ( !p ) - { - perror ( "You love NULL pointers, " - "don't you? I don't "); - exit ( -1 ); - } - pam_set_item ( pamh, PAM_AUTHTOK, p ); - pam_get_item ( pamh, PAM_USER, (void**) &s); - pam_set_data(pamh, "DATA", "Hi there! I'm data!", cleanup_func); - pam_get_data(pamh, "DATA", (void **) &s); - printf("%s\n", s); - - fprintf( stdout, "*** Attempting to perform " - "PAM authentication...\n"); - fprintf( stdout, "%s\n", - pam_strerror( pam_authenticate( pamh, 0 ) ) ) ; - - pam_end(pamh, PAM_SUCCESS); -} -- cgit v1.2.3