netatalk: uams_dhx2_pam.c File Reference

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

## Macros
#define | PRIMEBITS 1024
#define | dhxhash(a)
#define | COPY_STRING(s)
#define | PAM_CRED_ESTABLISH PAM_ESTABLISH_CRED

## Enumerations
enum | dhx2_state { DHX2_STATE_IDLE , DHX2_STATE_EXPECT_CONT1 , DHX2_STATE_EXPECT_CONT2 }

## Functions
static void | dhx2_release_mpi (gcry_mpi_t *mpi)
static void | dhx2_clear_session (void)
static int | dh_params_generate (unsigned int bits)
| Generate a new pair of prime and generator for use in the Diffie-Hellman key exchange.
static int | PAM_conv (int num_msg, struct pam_message **msg, struct pam_response **resp, void *appdata_ptr)
| PAM conversation function.
static int | dhx2_setup (void *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
static int | login (void *obj, char *username, int ulen, struct passwd **uam_pwd, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
static int | pam_login (void *obj, struct passwd **uam_pwd, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
| dhx login
static int | pam_login_ext (void *obj, char *uname, struct passwd **uam_pwd, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
static int | logincont1 (void *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
static int | logincont2 (void *obj_in, struct passwd **uam_pwd, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
static int | pam_logincont (void *obj, struct passwd **uam_pwd, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
static void | pam_logout (void)
static int | changepw_1 (void *obj, char *uname, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
static int | changepw_2 (void *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
static int | changepw_3 (void *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
static int | dhx2_changepw (void *obj, char *uname, struct passwd *pwd, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
static int | uam_setup (void *obj, const char *path)
static void | uam_cleanup (void)

## Variables
static gcry_mpi_t | p
static gcry_mpi_t | g
static gcry_mpi_t | Ra
static gcry_mpi_t | serverNonce
static char * | K_MD5hash = NULL
static int | K_hash_len
static uint16_t | ID
static enum dhx2_state | dhx2_state = DHX2_STATE_IDLE
static unsigned char | dhx_c2siv [] = { 'L', 'W', 'a', 'l', 'l', 'a', 'c', 'e' }
static unsigned char | dhx_s2civ [] = { 'C', 'J', 'a', 'l', 'b', 'e', 'r', 't' }
static pam_handle_t * | pamh = NULL
static char * | PAM_username
static char * | PAM_password
static struct passwd * | dhxpwd
static struct pam_conv | PAM_conversation
UAM_MODULE_EXPORT struct uam_export | uams_dhx2
UAM_MODULE_EXPORT struct uam_export | uams_dhx2_pam

## Macro Definition Documentation

## ◆ COPY_STRING

#define COPY_STRING | ( |  | s | ) |

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

## ◆ dhxhash

#define dhxhash | ( |  | a | ) |

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

hash a number to a 16-bit quantity

## ◆ PAM_CRED_ESTABLISH

#define PAM_CRED_ESTABLISH PAM_ESTABLISH_CRED

## ◆ PRIMEBITS

#define PRIMEBITS 1024

Number of bits for p which we generate. Everybody out there uses 512, so we beat them

## Enumeration Type Documentation

## ◆ dhx2_state

enum dhx2_state

Enumerator
DHX2_STATE_IDLE |
DHX2_STATE_EXPECT_CONT1 |
DHX2_STATE_EXPECT_CONT2 |

## Function Documentation

## ◆ changepw_1()

int changepw_1 | ( | void * | obj,
|  | char * | uname,
|  | char * | ibuf,
|  | size_t | ibuflen,
|  | char * | rbuf,
|  | size_t * | rbuflen )
| static

## ◆ changepw_2()

int changepw_2 | ( | void * | obj,
|  | char * | ibuf,
|  | size_t | ibuflen,
|  | char * | rbuf,
|  | size_t * | rbuflen )
| static

## ◆ changepw_3()

int changepw_3 | ( | void * | obj,
|  | char * | ibuf,
|  | size_t | ibuflen,
|  | char * | rbuf,
|  | size_t * | rbuflen )
| static

## ◆ dh_params_generate()

int dh_params_generate | ( | unsigned int | bits | ) |
| static

Generate a new pair of prime and generator for use in the Diffie-Hellman key exchange.

The bits value should be one of 768, 1024, 2048, 3072 or 4096.

## ◆ dhx2_changepw()

int dhx2_changepw | ( | void * | obj,
|  | char * | uname,
|  | struct passwd * | pwd,
|  | char * | ibuf,
|  | size_t | ibuflen,
|  | char * | rbuf,
|  | size_t * | rbuflen )
| static

## ◆ dhx2_clear_session()

void dhx2_clear_session | ( | void |  | ) |
| static

## ◆ dhx2_release_mpi()

void dhx2_release_mpi | ( | gcry_mpi_t * | mpi | ) |
| static

## ◆ dhx2_setup()

int dhx2_setup | ( | void * | obj,
|  | char * | ibuf,
|  | size_t | ibuflen,
|  | char * | rbuf,
|  | size_t * | rbuflen )
| static

## ◆ login()

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

## ◆ logincont1()

int logincont1 | ( | void * | obj,
|  | char * | ibuf,
|  | size_t | ibuflen,
|  | char * | rbuf,
|  | size_t * | rbuflen )
| static

## ◆ logincont2()

int logincont2 | ( | void * | obj_in,
|  | struct passwd ** | uam_pwd,
|  | char * | ibuf,
|  | size_t | ibuflen,
|  | char * | rbuf,
|  | size_t * | rbuflen )
| static

## ◆ 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,
|  | char * | ibuf,
|  | size_t | ibuflen,
|  | 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,
|  | char * | ibuf,
|  | size_t | ibuflen,
|  | char * | rbuf,
|  | size_t * | rbuflen )
| static

## ◆ pam_logincont()

int pam_logincont | ( | void * | obj,
|  | struct passwd ** | uam_pwd,
|  | char * | ibuf,
|  | size_t | ibuflen,
|  | 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

## ◆ dhx2_state

enum dhx2_state dhx2_state = DHX2_STATE_IDLE
| static

## ◆ dhx_c2siv

unsigned char dhx_c2siv[] = { 'L', 'W', 'a', 'l', 'l', 'a', 'c', 'e' }
| static

## ◆ dhx_s2civ

unsigned char dhx_s2civ[] = { 'C', 'J', 'a', 'l', 'b', 'e', 'r', 't' }
| static

## ◆ dhxpwd

struct passwd* dhxpwd
| static

## ◆ g

gcry_mpi_t g
| static

## ◆ ID

uint16_t ID
| static

## ◆ K_hash_len

int K_hash_len
| static

## ◆ K_MD5hash

char* K_MD5hash = NULL
| static

## ◆ p

gcry_mpi_t p
| static

## ◆ 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:169

## ◆ PAM_password

char* PAM_password
| static

## ◆ PAM_username

char* PAM_username
| static

## ◆ pamh

pam_handle_t* pamh = NULL
| static

## ◆ Ra

gcry_mpi_t Ra
| static

## ◆ serverNonce

gcry_mpi_t serverNonce
| static

## ◆ uams_dhx2

UAM_MODULE_EXPORT struct uam_export uams_dhx2

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:1077
uam_cleanup
static void uam_cleanup(void)
Definition uams_dhx2_pam.c:1099

## ◆ uams_dhx2_pam

UAM_MODULE_EXPORT struct uam_export uams_dhx2_pam

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