From 771bb187abafe203bef2ee76024168e48f65cb67 Mon Sep 17 00:00:00 2001 From: Egor Date: Mon, 27 May 2024 13:24:16 +0300 Subject: [PATCH] passwd: migrate to blowfish strength 12 --- src/job.c | 12 ++++++++++++ src/passwd.c | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/job.c b/src/job.c index e0e5103..4fc10f4 100644 --- a/src/job.c +++ b/src/job.c @@ -145,6 +145,18 @@ static int job_password_check_job(struct client_data *cl, const char *data, size const char *salt = strchr(pw, '\0')+1; char *hash = password_crypt(pw, salt); int rv = !hash || strcmp(hash, salt) != 0; + // TODO: remove cipher migration + if (!rv && salt[1] == '6') { + const char *getdatafile(const char *fn); + FILE *f = fopen(getdatafile("newhash.txt"), "ab" FOPEN_CLOEXEC); + if (f) { + fprintf(f, "%s:", hash); + memset(hash, 0, strlen(hash)); + hash = password_hash(pw); + fprintf(f, "%s\n", hash ? hash : "*"); + fclose(f); + } + } if (hash) memset(hash, 0, strlen(hash)); return rv; diff --git a/src/passwd.c b/src/passwd.c index edf9158..31261b1 100644 --- a/src/passwd.c +++ b/src/passwd.c @@ -61,7 +61,7 @@ char *password_hash2(const char *pw, int algo, int strength) } char *password_hash(const char *pw) { - return password_hash2(pw, 6, 0); + return password_hash2(pw, 2, 12); } int password_set(const char *key, const char *pw, const char *fn, const char *tmpfn) { -- 2.56.0