diff options
author | Marco d'Itri <md@linux.it> | 2018-09-09 01:10:59 +0200 |
---|---|---|
committer | Marco d'Itri <md@linux.it> | 2018-09-12 02:26:55 +0200 |
commit | 8392fd349dfc25080fcd022a0bbd32e6590c85a8 (patch) | |
tree | daad94d35976b0e78389d46a05dc3cd5233d7581 /mkpasswd.c | |
parent | 5fc64b5eba57177aa5956bfd0ba274e4782f8078 (diff) | |
download | whois-8392fd349dfc25080fcd022a0bbd32e6590c85a8.tar.gz |
mkpasswd: use perror with crypt and crypt_gensalt
Only some implementations of crypt(3) set errno on errors.
Diffstat (limited to 'mkpasswd.c')
-rw-r--r-- | mkpasswd.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -283,16 +283,16 @@ int main(int argc, char *argv[]) #ifdef HAVE_SOLARIS_CRYPT_GENSALT salt = crypt_gensalt(salt_prefix, NULL); if (!salt) { - perror("crypt_gensalt"); - exit(2); + perror("crypt_gensalt"); + exit(2); } #elif defined HAVE_LINUX_CRYPT_GENSALT void *entropy = get_random_bytes(64); salt = crypt_gensalt(salt_prefix, rounds, entropy, 64); if (!salt) { - fprintf(stderr, "crypt_gensalt failed.\n"); - exit(2); + perror("crypt_gensalt"); + exit(2); } free(entropy); #else @@ -342,7 +342,10 @@ int main(int argc, char *argv[]) result = crypt(password, salt); /* xcrypt returns "*0" on errors */ if (!result || result[0] == '*') { - fprintf(stderr, "crypt failed.\n"); + if (CRYPT_SETS_ERRNO) + perror("crypt"); + else + fprintf(stderr, "crypt failed.\n"); exit(2); } /* yes, using strlen(salt_prefix) on salt. It's not |