Hello!
It's been two days in a row now, trying to find a simple Makefile that does nothing more than, compile a c application, that uses pam libraries.
I've been through:
- kernel.org/pub/linux/libs/pam/
- kernel.org/pub/linux/libs/pam/Linux-PAM-html/pam_appl.html
- users.linuxbourg.ch/fvgoto/informatica/tbsc/welcome.php
- and much more
and all they talk about is: how to install a pam module, or how to create your own pam module, but none of them clearly explains how to compile the damn thing!
I've made the simplest thing I could think off:
simple_pam_app.c
Code:
#include <security/pam_appl.h>
#include <security/pam_misc.h>
#include <stdio.h>
static struct pam_conv conv = { NULL, NULL };
int main(int argc, char *argv[])
{
pam_handle_t *pamh=NULL;
int retval = pam_start("check_user", argv[1], &conv, &pamh);
printf("User %sfound!\n", (retval == PAM_SUCCESS ? "" : "not ") );
pam_end(pamh,retval);
return 0;
}
It does nothing more, than inform if the requested user, exists or not.
Through my search I've come to this simple makefile:
Code:
all:
gcc -c <source>.c
ld -x --shared -o <source>.so <source>.o -lpam
gcc <source>.c -lc -o <source>
using it to compile the “simple_pam_app.c”, it returns the following error:
Code:
/tmp/ccOSRcLc.o: In function `main':
simple_pam_app.c:(.text+0x3b): undefined reference to `pam_start'
simple_pam_app.c:(.text+0x79): undefined reference to `pam_end'
collect2: ld returned 1 exit status
make: *** [all] Error 1
It seems that the “pam_start” and “pam_end”, are considered to be prototype functions, can anyone explain, why this is happening?, or even better: can anyone, please, supply a simple Makefile that works, with the program above?
Sorry if I haven't been completely clear.
Thanks in advance.