netatalk 4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
uams_dhx_pam.c File Reference
`#include <arpa/inet.h>`
`#include <errno.h>`
`#include <signal.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <unistd.h>`
`#include <gcrypt.h>`
`#include <atalk/afp.h>`
`#include <atalk/logger.h>`
`#include <atalk/uam.h>`

## Macros
#define | KEYSIZE 16
#define | PASSWDLEN 64
#define | CRYPTBUFLEN (KEYSIZE*2)
#define | CRYPT2BUFLEN (KEYSIZE + PASSWDLEN)
#define | CHANGEPWBUFLEN (KEYSIZE + 2*PASSWDLEN)
#define | dhxhash(a)
#define | COPY_STRING(s)
#define | PAM_CRED_ESTABLISH PAM_ESTABLISH_CRED

## Functions
static int | PAM_conv (int num_msg, struct pam_message **msg, struct pam_response **resp, void *appdata_ptr)
| PAM conversation function.
static int | dhx_setup (void *obj, const unsigned char *ibuf, size_t ibuflen, unsigned char *rbuf, size_t *rbuflen)
static int | login (void *obj, unsigned char *username, int ulen, struct passwd **uam_pwd, const unsigned char *ibuf, size_t ibuflen, unsigned char *rbuf, size_t *rbuflen)
static int | pam_login (void *obj, struct passwd **uam_pwd, unsigned char *ibuf, size_t ibuflen, unsigned char *rbuf, size_t *rbuflen)
| dhx login
static int | pam_login_ext (void *obj, char *uname, struct passwd **uam_pwd, const unsigned char *ibuf, size_t ibuflen, unsigned char *rbuf, size_t *rbuflen)
static int | pam_logincont (void *obj, struct passwd **uam_pwd, const unsigned char *ibuf, size_t ibuflen, unsigned char *rbuf, size_t *rbuflen)
static void | pam_logout (void)
static int | pam_changepw (void *obj, unsigned char *username, const struct passwd *pwd, unsigned char *ibuf, size_t ibuflen, unsigned char *rbuf, size_t *rbuflen)
| change pw for dhx
static int | uam_setup (void *obj, const char *path)
static void | uam_cleanup (void)

## Variables
gcry_mpi_t | K
static struct passwd * | dhxpwd
static uint8_t | randbuf [KEYSIZE]
static unsigned char | msg2_iv [] = "CJalbert"
static unsigned char | msg3_iv [] = "LWallace"
static const unsigned char | p_binary []
static const unsigned char | g_binary [] = {0x07}
static pam_handle_t * | pamh = NULL
static unsigned char * | PAM_username
static unsigned char * | PAM_password
static struct pam_conv | PAM_conversation
UAM_MODULE_EXPORT struct uam_export | uams_dhx
UAM_MODULE_EXPORT struct uam_export | uams_dhx_pam

## Macro Definition Documentation

## ◆ CHANGEPWBUFLEN

#define CHANGEPWBUFLEN (KEYSIZE + 2*PASSWDLEN)

## ◆ COPY_STRING

#define COPY_STRING | ( |  | s | ) |

Value:
(s) ? strdup(s) : NULL
NULL
#define NULL
Definition utf8util.c:47

## ◆ CRYPT2BUFLEN

#define CRYPT2BUFLEN (KEYSIZE + PASSWDLEN)

## ◆ CRYPTBUFLEN

#define CRYPTBUFLEN (KEYSIZE*2)

## ◆ dhxhash

#define dhxhash | ( |  | a | ) |

Value:
((((unsigned long) (a) >> 8) ^ \
(unsigned long) (a)) & 0xffff)

hash a number to a 16-bit quantity

## ◆ KEYSIZE

#define KEYSIZE 16

## ◆ PAM_CRED_ESTABLISH

#define PAM_CRED_ESTABLISH PAM_ESTABLISH_CRED

## ◆ PASSWDLEN

#define PASSWDLEN 64

## Function Documentation

## ◆ dhx_setup()

int dhx_setup | ( | void * | obj,
|  | const unsigned char * | ibuf,
|  | size_t | ibuflen,
|  | unsigned char * | rbuf,
|  | size_t * | rbuflen )
| static

## ◆ login()

int login | ( | void * | obj,
|  | unsigned char * | username,
|  | int | ulen,
|  | struct passwd ** | uam_pwd,
|  | const unsigned char * | ibuf,
|  | size_t | ibuflen,
|  | unsigned char * | rbuf,
|  | size_t * | rbuflen )
| static

## ◆ pam_changepw()

int pam_changepw | ( | void * | obj,
|  | unsigned char * | username,
|  | const struct passwd * | pwd,
|  | unsigned char * | ibuf,
|  | size_t | ibuflen,
|  | unsigned char * | rbuf,
|  | size_t * | rbuflen )
| static

change pw for dhx

Note
  needs a couple passes to get everything all right. basically, it's like the login/logincont sequence

## ◆ PAM_conv()

int PAM_conv | ( | int | num_msg,
|  | struct pam_message ** | msg,
|  | struct pam_response ** | resp,
|  | void * | appdata_ptr )
| static

PAM conversation function.

Note
  Here we assume (for now, at least) that echo on means login name, and echo off means password.

## ◆ pam_login()

int pam_login | ( | void * | obj,
|  | struct passwd ** | uam_pwd,
|  | unsigned char * | ibuf,
|  | size_t | ibuflen,
|  | unsigned char * | rbuf,
|  | size_t * | rbuflen )
| static

dhx login

Note
  things are done in a slightly bizarre order to avoid having to clean things up if there's an error.

## ◆ pam_login_ext()

int pam_login_ext | ( | void * | obj,
|  | char * | uname,
|  | struct passwd ** | uam_pwd,
|  | const unsigned char * | ibuf,
|  | size_t | ibuflen,
|  | unsigned char * | rbuf,
|  | size_t * | rbuflen )
| static

## ◆ pam_logincont()

int pam_logincont | ( | void * | obj,
|  | struct passwd ** | uam_pwd,
|  | const unsigned char * | ibuf,
|  | size_t | ibuflen,
|  | unsigned char * | rbuf,
|  | size_t * | rbuflen )
| static

## ◆ pam_logout()

void pam_logout | ( | void |  | ) |
| static

## ◆ uam_cleanup()

void uam_cleanup | ( | void |  | ) |
| static

## ◆ uam_setup()

int uam_setup | ( | void * | obj,
|  | const char * | path )
| static

## Variable Documentation

## ◆ dhxpwd

struct passwd* dhxpwd
| static

## ◆ g_binary

const unsigned char g_binary[] = {0x07}
| static

## ◆ K

gcry_mpi_t K

the secret key

## ◆ msg2_iv

unsigned char msg2_iv[] = "CJalbert"
| static

## ◆ msg3_iv

unsigned char msg3_iv[] = "LWallace"
| static

## ◆ p_binary

const unsigned char p_binary[]
| static

Initial value:
= {0xBA, 0x28, 0x73, 0xDF, 0xB0, 0x60, 0x57, 0xD4,
0x3F, 0x20, 0x24, 0x74, 0x4C, 0xEE, 0xE7, 0x5B
}

## ◆ PAM_conversation

struct pam_conv PAM_conversation
| static

Initial value:
= {
&PAM_conv,
NULL
}
PAM_conv
static int PAM_conv(int num_msg, struct pam_message **msg, struct pam_response **resp, void *appdata_ptr)
PAM conversation function.
Definition uams_dhx2_pam.c:142

## ◆ PAM_password

unsigned char* PAM_password
| static

## ◆ PAM_username

unsigned char* PAM_username
| static

## ◆ pamh

pam_handle_t* pamh = NULL
| static

## ◆ randbuf

uint8_t randbuf[KEYSIZE]
| static

## ◆ uams_dhx

UAM_MODULE_EXPORT struct uam_export uams_dhx

Initial value:
= {
UAM_MODULE_SERVER,
UAM_MODULE_VERSION,
uam_setup, uam_cleanup
}
UAM_MODULE_VERSION
#define UAM_MODULE_VERSION
Definition uam.h:21
UAM_MODULE_SERVER
#define UAM_MODULE_SERVER
Definition uam.h:17
uam_setup
static int uam_setup(void *obj, const char *path)
Definition uams_dhx2_pam.c:1018
uam_cleanup
static void uam_cleanup(void)
Definition uams_dhx2_pam.c:1040

## ◆ uams_dhx_pam

UAM_MODULE_EXPORT struct uam_export uams_dhx_pam

Initial value:
= {
UAM_MODULE_SERVER,
UAM_MODULE_VERSION,
uam_setup, uam_cleanup
}