]> PatchyGit - patchyircd.git/commitdiff
passwd: migrate to blowfish strength 12
authorEgor <egor@patchysicp.xyz>
Mon, 27 May 2024 10:24:16 +0000 (13:24 +0300)
committerEgor <egor@patchysicp.xyz>
Mon, 27 May 2024 10:24:16 +0000 (13:24 +0300)
src/job.c
src/passwd.c

index e0e5103..4fc10f4 100644 (file)
--- 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;
index edf9158..31261b1 100644 (file)
@@ -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)
 {