LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-26-2006, 06:08 AM   #1
gatsu
LQ Newbie
 
Registered: Apr 2006
Posts: 1

Rep: Reputation: 0
Angry how to compile a pam application


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.
 
Old 04-26-2006, 07:07 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You could install the pam source. It includes a short sample called check_user that includes a Makefile. The check_user.c and Makefile of this sample could serve as a model.

Last edited by jschiwal; 04-26-2006 at 01:17 PM.
 
Old 04-26-2006, 01:48 PM   #3
jyoung4
LQ Newbie
 
Registered: Apr 2006
Location: Minneapolis, Minnesota, USA
Posts: 16

Rep: Reputation: 1
How to compile a pam program

Do you need the shared library generated by the "ld -x ..." line for some reason? If not, you can simplify by doing just the following:

all:
gcc -o <source> -lpam <source>.c
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
application won't compile. Help needed ASAP nunation Programming 1 03-22-2005 03:46 PM
How to compile win32 application? dmigh Programming 3 11-20-2004 10:00 AM
vsftpd + pam + virtual users - Pam cannot load database file. mdkelly069 Linux - Networking 3 09-22-2004 11:07 PM
I can't compile any QT depending C++ application! Paulo Góes Programming 1 04-17-2003 04:11 PM
compile an X-Qt-KDE application-- failed paulten Linux - Software 1 01-25-2003 10:16 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration