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;
}
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)
{