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

Developing PAM modules?



I have been trying to get a working PAM module written. It doesn't do anything real fancy just creates a file so I know that I am working with the functions correctly, as of yet I have not been able to get it to do anything.

[SNIP]
#include <stdio.h>

#define PAM_SM_AUTH
#define PAM_SM_ACCOUNT
#define PAM_SM_SESSION
#define PAM_SM_PASSWORD

#include <pam_modules.h>

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

pam_get_user(pamh, &user, &prompt);

  FILE *fp;
  int i;

fp = fopen("/tmp/log", "a");

  fprintf(fp, "\nSample code\n\n");
  for(i = 1; i <= 10; i++)
   fprintf(fp, "i = %d\n", i);
  fclose(fp);

  return PAM_IGNORE;
}

PAM_EXTERN
int pam_sm_setcred(pam_handle_t *pamh, int flags, int argc,
          const char **argv)
{
  return PAM_IGNORE;
}

PAM_EXTERN
int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, int argc,
            const char **argv)
{
  return PAM_IGNORE;
}

PAM_EXTERN
int pam_sm_cauthtok(pam_handle_t *pamh, int flags, int argc,
           const char **argv)
{
  return PAM_IGNORE;
}

PAM_EXTERN
int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc,
           const char **argv)
{
  return PAM_IGNORE;
}

PAM_EXTERN
int pam_sm_close_session(pam_handle_t *pamh, int flags, int argc,
            const char **argv)
{
  return PAM_IGNORE;
}

#ifdef PAM_STATIC

struct pam_module _pam_permit_modstruct = {
  "pam_permit",
  pam_sm_authenticate,
  pam_sm_setcred,
  pam_sm_acct_mgmt,
  pam_sm_open_session,
  pam_sm_close_session,
  pam_sm_chauthtok
};

#endif
[/SNIP]

Am I missing something? The PAM module writters guide is kinda vague on details, and I have only been able to google up a couple of tutorials on this subject so any help, pointers, howto's are definately appreciated.

--
Jason Gerfen

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




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