Skip to content

Commit

Permalink
Merge branch 'v0.8.x' of github.com:NigelCunningham/pam-MySQL into v0…
Browse files Browse the repository at this point in the history
….8.x
  • Loading branch information
NigelCunningham committed May 24, 2017
2 parents 8cd8db3 + 9f72c84 commit 8d569a2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,6 @@ AC_SEARCH_LIBS([crypt],[crypt],,[AC_MSG_ERROR([unable to find the crypt() functi

AC_SUBST(PAM_MODS_DIR)
AC_CONFIG_FILES([Makefile pam_mysql.spec])
AC_SEARCH_LIBS([my_make_scrambled_password],[mysql],[AC_DEFINE([HAVE_MY_MAKE_SCRAMBLED_PASSWORD], [1], [Build own SHA1 support.])])
AC_SEARCH_LIBS([make_scrambled_password],[mysql],[AC_DEFINE([HAVE_MAKE_SCRAMBLED_PASSWORD], [1], [Build own SHA1 support.])])

AC_OUTPUT
2 changes: 1 addition & 1 deletion crypto-md5.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ documentation and/or software.

#include <config.h>

#ifndef HAVE_MY_MAKE_SCRAMBLED_PASSWORD
#ifndef HAVE_MAKE_SCRAMBLED_PASSWORD

#include <string.h>
#include "crypto.h"
Expand Down
2 changes: 1 addition & 1 deletion crypto-sha1.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include <config.h>

#ifndef HAVE_MY_MAKE_SCRAMBLED_PASSWORD
#ifndef HAVE_MAKE_SCRAMBLED_PASSWORD

#include <string.h>
#include "crypto.h"
Expand Down
4 changes: 2 additions & 2 deletions crypto.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <config.h>

#ifndef HAVE_MY_MAKE_SCRAMBLED_PASSWORD
#ifndef HAVE_MAKE_SCRAMBLED_PASSWORD

#include <stdint.h>
#include <string.h>
Expand Down Expand Up @@ -37,7 +37,7 @@ char *hexify(char * const result, const unsigned char *digest,
char *hexify(char * const result, const unsigned char *digest,
const size_t size_result, size_t size_digest)
{
static const char * const hexchars = "0123456789abcdef";
static const char * const hexchars = "0123456789ABCDEF";
char *result_pnt = result;

if (size_digest <= (size_t) 0 ||
Expand Down
18 changes: 8 additions & 10 deletions pam_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,12 @@
#define PAM_AUTHTOK_RECOVERY_ERR PAM_AUTHTOK_RECOVER_ERR
#endif

#ifdef HAVE_MY_MAKE_SCRAMBLED_PASSWORD
void my_make_scrambled_password(char scrambled_password[42], const char password[255], int len);
#else
#ifndef HAVE_MAKE_SCRAMBLED_PASSWORD
#include "crypto.h"
#include "crypto-sha1.h"

// Implementation from commit 2db6b50c7b7c638104bd9639994f0574e8f4813c in Pure-ftp source.
static void my_make_scrambled_password(char scrambled_password[42], const char password[255], int len)
void make_scrambled_password(char scrambled_password[42], const char password[255])
{
SHA1_CTX ctx;
unsigned char h0[20], h1[20];
Expand All @@ -186,12 +184,12 @@ static void my_make_scrambled_password(char scrambled_password[42], const char p
SHA1Init(&ctx);
SHA1Update(&ctx, h0, sizeof h0);
# ifdef HAVE_EXPLICIT_BZERO
explicit_bzero(h0, len);
explicit_bzero(h0, strlen(password));
# else
volatile unsigned char *pnt_ = (volatile unsigned char *) h0;
size_t i = (size_t) 0U;

while (i < len) {
while (i < strlen(password)) {
pnt_[i++] = 0U;
}
# endif
Expand Down Expand Up @@ -2927,10 +2925,10 @@ static pam_mysql_err_t pam_mysql_check_passwd(pam_mysql_ctx_t *ctx,
if (ctx->use_323_passwd) {
make_scrambled_password_323(buf, passwd);
} else {
my_make_scrambled_password(buf, passwd, strlen(passwd));
make_scrambled_password(buf, passwd);
}
#else
my_make_scrambled_password(buf, passwd, strlen(passwd));
make_scrambled_password(buf, passwd);
#endif

vresult = strcmp(row[0], buf);
Expand Down Expand Up @@ -3172,10 +3170,10 @@ static pam_mysql_err_t pam_mysql_update_passwd(pam_mysql_ctx_t *ctx, const char
if (ctx->use_323_passwd) {
make_scrambled_password_323(encrypted_passwd, new_passwd);
} else {
my_make_scrambled_password(encrypted_passwd, new_passwd, strlen(new_passwd));
make_scrambled_password(encrypted_passwd, new_passwd);
}
#else
my_make_scrambled_password(encrypted_passwd, new_passwd, strlen(new_passwd));
make_scrambled_password(encrypted_passwd, new_passwd);
#endif
break;

Expand Down

0 comments on commit 8d569a2

Please sign in to comment.