Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liblongpath-rsync
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liblongpath
liblongpath-rsync
Commits
15b84e14
Commit
15b84e14
authored
Oct 25, 2000
by
David Dykstra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure the log file is always opened before root privileges (if any)
are given up.
parent
45a83540
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
11 deletions
+24
-11
log.c
log.c
+16
-10
socket.c
socket.c
+8
-1
No files found.
log.c
View file @
15b84e14
...
...
@@ -30,12 +30,8 @@ static int log_error_fd = -1;
static
void
logit
(
int
priority
,
char
*
buf
)
{
if
(
logfname
)
{
if
(
!
logfile
)
{
extern
int
orig_umask
;
int
old_umask
=
umask
(
022
|
orig_umask
);
logfile
=
fopen
(
logfname
,
"a"
);
umask
(
old_umask
);
}
if
(
!
logfile
)
log_open
();
fprintf
(
logfile
,
"%s [%d] %s"
,
timestring
(
time
(
NULL
)),
(
int
)
getpid
(),
buf
);
fflush
(
logfile
);
...
...
@@ -62,8 +58,10 @@ void log_init(void)
/* optionally use a log file instead of syslog */
logfname
=
lp_log_file
();
if
(
logfname
)
{
if
(
*
logfname
)
if
(
*
logfname
)
{
log_open
();
return
;
}
logfname
=
NULL
;
}
...
...
@@ -82,9 +80,17 @@ void log_init(void)
#endif
}
/* for long runs when using a log file, close it before potential long waits
so it can be trimmed by another process instead of growing forever */
void
log_release
()
void
log_open
()
{
if
(
logfname
&&
!
logfile
)
{
extern
int
orig_umask
;
int
old_umask
=
umask
(
022
|
orig_umask
);
logfile
=
fopen
(
logfname
,
"a"
);
umask
(
old_umask
);
}
}
void
log_close
()
{
if
(
logfile
)
{
fclose
(
logfile
);
...
...
socket.c
View file @
15b84e14
...
...
@@ -247,7 +247,10 @@ void start_accept_loop(int port, int (*fn)(int ))
struct
sockaddr
addr
;
int
in_addrlen
=
sizeof
(
addr
);
log_release
();
/* close log file before the potentially very long select so
file can be trimmed by another process instead of growing
forever */
log_close
();
FD_ZERO
(
&
fds
);
FD_SET
(
s
,
&
fds
);
...
...
@@ -274,6 +277,10 @@ void start_accept_loop(int port, int (*fn)(int ))
if
(
fork
()
==
0
)
{
close
(
s
);
/* open log file in child before possibly giving
up privileges */
log_open
();
_exit
(
fn
(
fd
));
}
...
...
Write
Preview
Markdown
is supported
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