Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Shawn McKinney
OpenLDAP
Commits
25e74062
Commit
25e74062
authored
Apr 24, 2000
by
Ben Collins
Browse files
when opening files in /tmp use O_CREAT|O_EXCL to overcome race conditions
parent
a132d14f
Changes
1
Hide whitespace changes
Inline
Side-by-side
servers/slurpd/rq.c
View file @
25e74062
...
...
@@ -35,8 +35,16 @@
#include
<stdio.h>
#include
<stdlib.h>
#include
<sys/stat.h>
#include
<ac/unistd.h>
/* get ftruncate() */
#ifdef HAVE_SYS_TYPES_H
#include
<sys/types.h>
#endif
#ifdef HAVE_FCNTL_H
#include
<fcntl.h>
#endif
#include
"slurp.h"
#include
"globals.h"
...
...
@@ -227,17 +235,28 @@ Rq_dump(
{
Re
*
re
;
FILE
*
fp
;
int
tmpfd
;
if
(
rq
==
NULL
)
{
Debug
(
LDAP_DEBUG_ANY
,
"Rq_dump: rq is NULL!
\n
"
,
0
,
0
,
0
);
return
;
}
if
((
fp
=
fopen
(
SLURPD_DUMPFILE
,
"w"
))
==
NULL
)
{
if
(
unlink
(
SLURPD_DUMPFILE
)
==
-
1
&&
errno
!=
ENOENT
)
{
Debug
(
LDAP_DEBUG_ANY
,
"Rq_dump:
\"
%s
\"
exists, and cannot unlink
\n
"
,
SLURPD_DUMPFILE
,
0
,
0
);
return
;
}
if
((
tmpfd
=
open
(
SLURPD_DUMPFILE
,
O_CREAT
|
O_RDWR
|
O_EXCL
,
0600
))
==
-
1
)
{
Debug
(
LDAP_DEBUG_ANY
,
"Rq_dump: cannot open
\"
%s
\"
for write
\n
"
,
SLURPD_DUMPFILE
,
0
,
0
);
return
;
}
if
((
fp
=
fdopen
(
tmpfd
,
"w"
))
==
NULL
)
{
Debug
(
LDAP_DEBUG_ANY
,
"Rq_dump: cannot fdopen
\"
%s
\"
for write
\n
"
,
SLURPD_DUMPFILE
,
0
,
0
);
return
;
}
rq
->
rq_lock
(
rq
);
for
(
re
=
rq
->
rq_gethead
(
rq
);
re
!=
NULL
;
re
=
rq
->
rq_getnext
(
re
))
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment