Re: module writing / compiling problems?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jason Gerfen wrote:

I am doing something wrong as it comes to writting a pam module. If anyone can tell me what I am doing wrong, it would be greatly appreciated.

This module does one thing, on the pam_sm_authenticate() function it attempts to call the pam_get_user() function and on success or failure it logs it to syslog using a _pam_log() function.

Here is the code:  File is named lame.c
[SNIP]
#include <stdio.h>
#include <syslog.h>
#include <stdarg.h>

#define PAM_SM_AUTH

#include <pam_modules.h>

static void _pam_log(int err, const char *format, ...)
{
   va_list  args;

   va_start(args, format);
   openlog("PAM-lame", LOG_CONS | LOG_PID, LOG_AUTHPRIV);
   syslog(err, format, args);
   va_end(args);
   closelog();
}

PAM_EXTERN
int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc,
           const char **argv)
{
   int retval;
   const char *user;

if((retval = pam_get_user(pamh, &user, "looser login:") != PAM_SUCCESS)) {
_pam_log(LOG_ERR, "Cannot obtain user name: %s",
pam_strerror(pamh, retval));
return(PAM_AUTHINFO_UNAVAIL); }


if((retval = pam_get_user(pamh, &user, "looser login:") == PAM_SUCCESS)) {
_pam_log(LOG_ERR, "Obtained username: %s",
pam_strerror(pamh, retval));
return(PAM_SUCCESS); }


_pam_log(LOG_ERR, "Just checking", pam_strerror(pamh, retval));

return retval;

}

#ifdef PAM_STATIC
struct pam_module _pam_looser_modstruct = {
   "pam_looser",
   pam_sm_authenticate,
   NULL,
   NULL,
   NULL,
   NULL,
   NULL,
};
#endif
[/SNIP]

And I am compiling using a simply Makefile listed below:
Any help tips, pointers etc would be greatly appreciated. Also if there is a "typo" please disregard as on the production box it compiles just fine, and of couse I do have it added to the /etc/pam.d/login file like so:


auth required pam_looser.so

Thanks in advance,

Oops, I forgot the makefile
[SNIP]
CC=gcc
CFLAGS=-fPIC
LDFLAGS=-x --shared
LIBS=-lwrap -lpam -lc
SRCS=lame.c
OBJS=lame.o
LIBSHARED=pam_looser.so
SECUREDIRECTORY=/lib/security
SECUREMODE=644
INSTALL=install

all: $(LIBSHARED)

install: all
   $(INSTALL) -m $(SECUREMODE) $(LIBSHARED) $(SECUREDIRECTORY)

$(LIBSHARED): $(OBJS)
   $(LD) $(LDFLAGS) -o $@ $? $(LIBS)

$(OBJS): $(SRCS)
   $(CC) $(CFLAGS) -o $@ -c $*.c

clean:
   rm -f $(OBJS) $(LIBSHARED) a.out core *~
[/SNIP]

--
Jason Gerfen

"...Sometimes I just yell at myself. And it
makes me sad, sometimes I make myself cry..."
			~ My nephew Dawsyn



_______________________________________________

Pam-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/pam-list

[Index of Archives]     [Fedora Users]     [Kernel]     [Red Hat Install]     [Linux for the blind]     [Gimp]

  Powered by Linux