Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
570a58f4
Commit
570a58f4
authored
25 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Don't leak a file descriptor when updating pg_pwd file. Also, check for
failure of rename() call.
parent
8bd6c1f8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/commands/user.c
+21
-11
21 additions, 11 deletions
src/backend/commands/user.c
with
21 additions
and
11 deletions
src/backend/commands/user.c
+
21
−
11
View file @
570a58f4
...
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: user.c,v 1.5
2
2000/0
4/12 17:14:59 momjian
Exp $
* $Id: user.c,v 1.5
3
2000/0
5/04 20:06:07 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -56,6 +56,7 @@ write_password_file(Relation rel)
*
tempname
;
int
bufsize
;
FILE
*
fp
;
int
flagfd
;
mode_t
oumask
;
HeapScanDesc
scan
;
HeapTuple
tuple
;
...
...
@@ -75,7 +76,7 @@ write_password_file(Relation rel)
fp
=
AllocateFile
(
tempname
,
"w"
);
umask
(
oumask
);
if
(
fp
==
NULL
)
elog
(
ERROR
,
"%s: %
s
"
,
tempname
,
strerror
(
errno
)
);
elog
(
ERROR
,
"%s: %
m
"
,
tempname
);
/* read table */
scan
=
heap_beginscan
(
rel
,
false
,
SnapshotSelf
,
0
,
NULL
);
...
...
@@ -129,29 +130,38 @@ write_password_file(Relation rel)
null_v
?
"
\\
N"
:
nabstimeout
((
AbsoluteTime
)
datum_v
)
/* this is how the
* parser wants it */
);
if
(
ferror
(
fp
))
elog
(
ERROR
,
"%s: %s"
,
tempname
,
strerror
(
errno
));
fflush
(
fp
);
}
heap_endscan
(
scan
);
fflush
(
fp
);
if
(
ferror
(
fp
))
elog
(
ERROR
,
"%s: %m"
,
tempname
);
FreeFile
(
fp
);
/*
* And rename the temp file to its final name, deleting the old
* pg_pwd.
*/
rename
(
tempname
,
filename
);
if
(
rename
(
tempname
,
filename
))
elog
(
ERROR
,
"rename %s to %s: %m"
,
tempname
,
filename
);
pfree
((
void
*
)
tempname
);
pfree
((
void
*
)
filename
);
/*
* Create a flag file the postmaster will detect the next time it
* tries to authenticate a user. The postmaster will know to reload
* the pg_pwd file contents.
* the pg_pwd file contents. Note: we used to elog(ERROR) if the
* creat() call failed, but it's a little silly to abort the transaction
* at this point, so let's just make it a NOTICE.
*/
filename
=
crypt_getpwdreloadfilename
();
if
(
creat
(
filename
,
S_IRUSR
|
S_IWUSR
)
==
-
1
)
elog
(
ERROR
,
"%s: %s"
,
filename
,
strerror
(
errno
));
pfree
((
void
*
)
tempname
);
flagfd
=
creat
(
filename
,
S_IRUSR
|
S_IWUSR
);
if
(
flagfd
==
-
1
)
elog
(
NOTICE
,
"%s: %m"
,
filename
);
else
close
(
flagfd
);
pfree
((
void
*
)
filename
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment