Could someone who knows C programming, finish off this module to create =
a pam_localhost module for PAM

pam_localhost.c
/*
* $Id: pam_localhost.c,v 1.0 2006/03/30 0:0:0 Exp $
* built to compile as part of 0.77 of LINUX-PAM
*/

/*
* checks to see if the user is logged in from one to the private IP =
addresses
* 10.0.0.0 through 10.255.255.255
* 172.16.0.0 through 172.31.255.255
* 192.168.0.0 through 192.168.255.255=20
* Returns PAM_SUCCESS if the person is logging in locally(private IP =
address)
* Returns PAM_AUTH_ERR if not
* This code began life a modified pam_listfile (0.77) module
* by Elliot Lee , Red Hat Software. July 25, 1996.
* log refused access error christopher mccrory =
1998/7/11
* which began life as the pam_rootok module.
*/

#include

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

#ifdef DEBUG
#include
#endif

/*
* here, we make a definition for the externally accessible function
* in this file (this definition is required for static a module
* but strongly encouraged generally) it is used to instruct the
* modules include file to define the function prototypes.
*/

#define PAM_SM_AUTH
#define PAM_SM_ACCOUNT
#define PAM_SM_PASWORD
#define PAM_SM_SESSION
#define PAM_SM_CHAUTHTOK

#include
#include

/* some syslogging */

#define LOCAL_LOG_PREFIX "PAM-listfile: "

static void _pam_log(int err, const char *format, ...)
{
va_list args;
=20
va_start(args, format);
vsyslog(LOG_AUTH | err, format, args);
va_end(args);
}


/* --- authentication management functions (only) --- */

/* Extended Items that are not directly available via pam_get_item() */
#define EI_GROUP (1 << 0)
#define EI_SHELL (1 << 1)

/* Constants for apply=3D parameter */
#define APPLY_TYPE_NULL 0
#define APPLY_TYPE_NONE 1
#define APPLY_TYPE_USER 2
#define APPLY_TYPE_GROUP 3

#define LESSER(a, b) ((a) < (b) ? (a) : (b))

PAM_EXTERN
int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const =
char **argv)
{

/* main authentication code. Is called by all of the pam_sm_* modules=20
*
* psuedocode
*
* get the rhost
* (void) pam_get_item(pamh, PAM_RHOST, (const void **)&service);

* get the ip from the server's default dns
* switch on the first byte of the ip
* case 10 =3D> return PAM_SUCCESS
* case 168
* switch on second byte
* case 192 =3D> return PAM_SUCCESS
* default =3D> return PAM_AUTH_ERR
* case 172
* switch on second byte
* case 16 =3D> return PAM_SUCCESS
* case 17 =3D> return PAM_SUCCESS
* case 18 =3D> return PAM_SUCCESS
* case 19 =3D> return PAM_SUCCESS
* case 20 =3D> return PAM_SUCCESS
* case 21 =3D> return PAM_SUCCESS
* case 22 =3D> return PAM_SUCCESS
* case 23 =3D> return PAM_SUCCESS
* case 24 =3D> return PAM_SUCCESS
* case 25 =3D> return PAM_SUCCESS
* case 26 =3D> return PAM_SUCCESS
* case 27 =3D> return PAM_SUCCESS
* case 28 =3D> return PAM_SUCCESS
* case 29 =3D> return PAM_SUCCESS
* case 30 =3D> return PAM_SUCCESS
* case 31 =3D> return PAM_SUCCESS
* DEFAULT =3D> return PAM_AUTH_ERR
* deafult=3D> return PAM_AUTH_ERR
*/
}
PAM_EXTERN
int pam_sm_setcred(pam_handle_t *pamh, int flags, int argc, const char =
**argv)
{
return PAM_SUCCESS;
}

PAM_EXTERN
int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, int argc,
const char **argv)
{
return pam_sm_authenticate(pamh, flags, argc, argv);
}
PAM_EXTERN
int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc,
const char **argv)
{
return pam_sm_authenticate(pamh, flags, argc, argv);
}
PAM_EXTERN
int pam_sm_close_session(pam_handle_t *pamh, int flags, int argc,
const char **argv)
{
return pam_sm_authenticate(pamh, flags, argc, argv);
}
PAM_EXTERN
int pam_sm_chauthtok(pam_handle_t *pamh, int flags, int argc,
const char **argv)
{
return pam_sm_authenticate(pamh, flags, argc, argv);
}

#ifdef PAM_STATIC

/* static module data */

struct pam_module _pam_listfile_modstruct =3D {
"pam_listfile",
pam_sm_authenticate,
pam_sm_setcred,
pam_sm_acct_mgmt,
pam_sm_open_session,
pam_sm_close_session,
pam_sm_chauthtok,
};

#endif /* PAM_STATIC */

/* end of module definition */