Commit 89ad3270 authored by Bruce Momjian's avatar Bruce Momjian

Portability fix for pg_passwd.

parent 32cd09ac
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <strings.h> #include <strings.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <sys/time.h> #include <time.h>
#include <ctype.h> #include <ctype.h>
#define issaltchar(c) (isalnum(c) || (c) == '.' || (c) == '/') #define issaltchar(c) (isalnum(c) || (c) == '.' || (c) == '/')
...@@ -111,7 +111,7 @@ try_again: ...@@ -111,7 +111,7 @@ try_again:
/* get user name */ /* get user name */
p = line; p = line;
if ((q = index(p, ':')) == NULL) if ((q = strchr(p, ':')) == NULL)
{ {
fprintf(stderr, "%s: line %d: illegal format.\n", fprintf(stderr, "%s: line %d: illegal format.\n",
filename, npwds + 1); filename, npwds + 1);
...@@ -138,10 +138,10 @@ try_again: ...@@ -138,10 +138,10 @@ try_again:
/* get password field */ /* get password field */
p = q; p = q;
q = index(p, ':'); q = strchr(p, ':');
/* /*
* --- don't care ----- if ((q = index(p, ':')) == NULL) { * --- don't care ----- if ((q = strchr(p, ':')) == NULL) {
* fprintf(stderr, "%s: line %d: illegal format.\n", filename, * fprintf(stderr, "%s: line %d: illegal format.\n", filename,
* npwds + 1); exit(1); } * npwds + 1); exit(1); }
*/ */
...@@ -215,10 +215,7 @@ encrypt_pwd(char key[9], char salt[3], char passwd[14]) ...@@ -215,10 +215,7 @@ encrypt_pwd(char key[9], char salt[3], char passwd[14])
/* get encrypted password */ /* get encrypted password */
if (salt[0] == '\0') if (salt[0] == '\0')
{ {
struct timeval tm; srand(time(NULL));
gettimeofday(&tm, NULL);
srand(tm.tv_sec ? tm.tv_sec : 1);
do do
{ {
n = rand() % 256; n = rand() % 256;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment