Re: module writing / compiling problems?

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

 



Nope, no errors, nothing... very strange.

Chris Campbell wrote:

What is it doing or not doing? Any error messages in system logs???

----- Original Message -----
From: "Jason Gerfen" <jason.gerfen@xxxxxxxxxxxx>
To: "Pluggable Authentication Modules" <pam-list@xxxxxxxxxx>
Sent: Wednesday, June 09, 2004 5:34 PM
Subject: module writing / compiling problems?




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:
[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]

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,

--
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





--
Jason Gerfen
Student Computing Group
Marriott Library
University of Utah
(801) 585-9810
jason.Gerfen@xxxxxxxxxxxx

"...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