Skip to content

Commit 89ad327

Browse files
committed
Portability fix for pg_passwd.
1 parent 32cd09a commit 89ad327

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/bin/pg_passwd/pg_passwd.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <strings.h>
99
#include <unistd.h>
1010
#include <errno.h>
11-
#include <sys/time.h>
11+
#include <time.h>
1212
#include <ctype.h>
1313
#define issaltchar(c) (isalnum(c) || (c) == '.' || (c) == '/')
1414

@@ -111,7 +111,7 @@ read_pwd_file(char *filename)
111111

112112
/* get user name */
113113
p = line;
114-
if ((q = index(p, ':')) == NULL)
114+
if ((q = strchr(p, ':')) == NULL)
115115
{
116116
fprintf(stderr, "%s: line %d: illegal format.\n",
117117
filename, npwds + 1);
@@ -138,10 +138,10 @@ read_pwd_file(char *filename)
138138

139139
/* get password field */
140140
p = q;
141-
q = index(p, ':');
141+
q = strchr(p, ':');
142142

143143
/*
144-
* --- don't care ----- if ((q = index(p, ':')) == NULL) {
144+
* --- don't care ----- if ((q = strchr(p, ':')) == NULL) {
145145
* fprintf(stderr, "%s: line %d: illegal format.\n", filename,
146146
* npwds + 1); exit(1); }
147147
*/
@@ -215,10 +215,7 @@ encrypt_pwd(char key[9], char salt[3], char passwd[14])
215215
/* get encrypted password */
216216
if (salt[0] == '\0')
217217
{
218-
struct timeval tm;
219-
220-
gettimeofday(&tm, NULL);
221-
srand(tm.tv_sec ? tm.tv_sec : 1);
218+
srand(time(NULL));
222219
do
223220
{
224221
n = rand() % 256;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy