X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=blobdiff_plain;f=etc%2Fuams%2Fuams_dhx2_pam.c;h=8e79b450d4c802e9e6e516c598c2ced645270476;hp=0f0c8a535329b579bac63659a88b41194f481b59;hb=130d356c840ea83c31c4724c8ae92660360eb07b;hpb=26c02c0d56d76a5b775e793e8ec1ea10d0040a7b diff --git a/etc/uams/uams_dhx2_pam.c b/etc/uams/uams_dhx2_pam.c index 0f0c8a53..8e79b450 100644 --- a/etc/uams/uams_dhx2_pam.c +++ b/etc/uams/uams_dhx2_pam.c @@ -136,7 +136,11 @@ error: * echo off means password. */ static int PAM_conv (int num_msg, +#ifdef LINUX const struct pam_message **msg, +#else + struct pam_message **msg, +#endif struct pam_response **resp, void *appdata_ptr _U_) { int count = 0; @@ -242,6 +246,7 @@ static int dhx2_setup(void *obj, char *ibuf _U_, size_t ibuflen _U_, size_t nwritten; gcry_mpi_t Ma; char *Ra_binary = NULL; + uint16_t uint16; *rbuflen = 0; @@ -267,7 +272,8 @@ static int dhx2_setup(void *obj, char *ibuf _U_, size_t ibuflen _U_, /* Session ID first */ ID = dhxhash(obj); - *(uint16_t *)rbuf = htons(ID); + uint16 = htons(ID); + memcpy(rbuf, &uint16, sizeof(uint16_t)); rbuf += 2; *rbuflen += 2; @@ -281,7 +287,9 @@ static int dhx2_setup(void *obj, char *ibuf _U_, size_t ibuflen _U_, *rbuflen += 4; /* len = length of p = PRIMEBITS/8 */ - *(uint16_t *)rbuf = htons((uint16_t) PRIMEBITS/8); + + uint16 = htons((uint16_t) PRIMEBITS/8); + memcpy(rbuf, &uint16, sizeof(uint16_t)); rbuf += 2; *rbuflen += 2; @@ -403,6 +411,7 @@ static int logincont1(void *obj _U_, char *ibuf, size_t ibuflen, char *rbuf, siz char serverNonce_bin[16]; gcry_cipher_hd_t ctx; gcry_error_t ctxerror; + uint16_t uint16; *rbuflen = 0; @@ -488,7 +497,8 @@ static int logincont1(void *obj _U_, char *ibuf, size_t ibuflen, char *rbuf, siz /* ---- Start building reply packet ---- */ /* Session ID + 1 first */ - *(uint16_t *)rbuf = htons(ID+1); + uint16 = htons(ID+1); + memcpy(rbuf, &uint16, sizeof(uint16_t)); rbuf += 2; *rbuflen += 2; @@ -647,6 +657,7 @@ static int logincont2(void *obj_in, struct passwd **uam_pwd, /* solaris craps out if PAM_TTY and PAM_RHOST aren't set. */ pam_set_item(pamh, PAM_TTY, "afpd"); pam_set_item(pamh, PAM_RHOST, hostname); + pam_set_item(pamh, PAM_RUSER, PAM_username); PAM_error = pam_authenticate(pamh, 0); if (PAM_error != PAM_SUCCESS) { @@ -718,7 +729,8 @@ static int pam_logincont(void *obj, struct passwd **uam_pwd, int ret; /* check for session id */ - retID = ntohs(*(uint16_t *)ibuf); + memcpy(&retID, ibuf, sizeof(uint16_t)); + retID = ntohs(retID); if (retID == ID) ret = logincont1(obj, ibuf, ibuflen, rbuf, rbuflen); else if (retID == ID+1) @@ -911,7 +923,7 @@ static int dhx2_changepw(void *obj _U_, char *uname, return ret; } -static int uam_setup(const char *path) +static int uam_setup(void *obj, const char *path) { if (uam_register(UAM_SERVER_LOGIN_EXT, path, "DHX2", pam_login, pam_logincont, pam_logout, pam_login_ext) < 0) @@ -919,9 +931,6 @@ static int uam_setup(const char *path) if (uam_register(UAM_SERVER_CHANGEPW, path, "DHX2", dhx2_changepw) < 0) return -1; - p = gcry_mpi_new(0); - g = gcry_mpi_new(0); - LOG(log_debug, logtype_uams, "DHX2: generating mersenne primes"); /* Generate p and g for DH */ if (dh_params_generate(PRIMEBITS) != 0) { @@ -937,11 +946,12 @@ static void uam_cleanup(void) uam_unregister(UAM_SERVER_LOGIN, "DHX2"); uam_unregister(UAM_SERVER_CHANGEPW, "DHX2"); + LOG(log_debug, logtype_uams, "DHX2: uam_cleanup"); + gcry_mpi_release(p); gcry_mpi_release(g); } - UAM_MODULE_EXPORT struct uam_export uams_dhx2 = { UAM_MODULE_SERVER, UAM_MODULE_VERSION,