Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
0912bf6b
Unverified
Commit
0912bf6b
authored
Mar 26, 2021
by
Stéphane Graber
Committed by
GitHub
Mar 26, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3732 from brauner/2021-03-26/fixes
log: dont create log file for fuzz builds
parents
27df2528
2f6d3099
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
4 deletions
+25
-4
confile.c
src/lxc/confile.c
+3
-0
log.c
src/lxc/log.c
+17
-4
parse_config_file.c
src/tests/parse_config_file.c
+5
-0
No files found.
src/lxc/confile.c
View file @
0912bf6b
...
@@ -1600,6 +1600,9 @@ static int set_config_log_file(const char *key, const char *value,
...
@@ -1600,6 +1600,9 @@ static int set_config_log_file(const char *key, const char *value,
return
0
;
return
0
;
}
}
if
(
!
abspath
(
value
))
return
ret_errno
(
EINVAL
);
/*
/*
* Store these values in the lxc_conf, and then try to set for actual
* Store these values in the lxc_conf, and then try to set for actual
* current logging.
* current logging.
...
...
src/lxc/log.c
View file @
0912bf6b
...
@@ -489,6 +489,12 @@ static int build_dir(const char *name)
...
@@ -489,6 +489,12 @@ static int build_dir(const char *name)
__do_free
char
*
n
=
NULL
;
__do_free
char
*
n
=
NULL
;
char
*
e
,
*
p
;
char
*
e
,
*
p
;
if
(
is_empty_string
(
name
))
return
ret_errno
(
EINVAL
);
if
(
!
abspath
(
name
))
return
ret_errno
(
EINVAL
);
/* Make copy of the string since we'll be modifying it. */
/* Make copy of the string since we'll be modifying it. */
n
=
strdup
(
name
);
n
=
strdup
(
name
);
if
(
!
n
)
if
(
!
n
)
...
@@ -502,7 +508,11 @@ static int build_dir(const char *name)
...
@@ -502,7 +508,11 @@ static int build_dir(const char *name)
continue
;
continue
;
*
p
=
'\0'
;
*
p
=
'\0'
;
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
ret
=
lxc_unpriv
(
mkdir
(
n
,
0755
));
ret
=
lxc_unpriv
(
mkdir
(
n
,
0755
));
#else
ret
=
errno
=
EEXIST
;
#endif
/*!FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
*
p
=
'/'
;
*
p
=
'/'
;
if
(
ret
&&
errno
!=
EEXIST
)
if
(
ret
&&
errno
!=
EEXIST
)
return
log_error_errno
(
-
errno
,
errno
,
"Failed to create directory
\"
%s
\"
"
,
n
);
return
log_error_errno
(
-
errno
,
errno
,
"Failed to create directory
\"
%s
\"
"
,
n
);
...
@@ -513,8 +523,9 @@ static int build_dir(const char *name)
...
@@ -513,8 +523,9 @@ static int build_dir(const char *name)
static
int
log_open
(
const
char
*
name
)
static
int
log_open
(
const
char
*
name
)
{
{
int
newfd
=
-
EBADF
;
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
__do_close
int
fd
=
-
EBADF
;
__do_close
int
fd
=
-
EBADF
;
int
newfd
;
fd
=
lxc_unpriv
(
open
(
name
,
O_CREAT
|
O_WRONLY
|
O_APPEND
|
O_CLOEXEC
,
0660
));
fd
=
lxc_unpriv
(
open
(
name
,
O_CREAT
|
O_WRONLY
|
O_APPEND
|
O_CLOEXEC
,
0660
));
if
(
fd
<
0
)
if
(
fd
<
0
)
...
@@ -526,7 +537,7 @@ static int log_open(const char *name)
...
@@ -526,7 +537,7 @@ static int log_open(const char *name)
newfd
=
fcntl
(
fd
,
F_DUPFD_CLOEXEC
,
STDERR_FILENO
);
newfd
=
fcntl
(
fd
,
F_DUPFD_CLOEXEC
,
STDERR_FILENO
);
if
(
newfd
<
0
)
if
(
newfd
<
0
)
return
log_error_errno
(
-
errno
,
errno
,
"Failed to dup log fd %d"
,
fd
);
return
log_error_errno
(
-
errno
,
errno
,
"Failed to dup log fd %d"
,
fd
);
#endif
/* !FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
return
newfd
;
return
newfd
;
}
}
...
@@ -599,7 +610,7 @@ static int __lxc_log_set_file(const char *fname, int create_dirs)
...
@@ -599,7 +610,7 @@ static int __lxc_log_set_file(const char *fname, int create_dirs)
if
(
lxc_log_fd
>=
0
)
if
(
lxc_log_fd
>=
0
)
lxc_log_close
();
lxc_log_close
();
if
(
!
fname
)
if
(
is_empty_string
(
fname
)
)
return
ret_errno
(
EINVAL
);
return
ret_errno
(
EINVAL
);
if
(
strlen
(
fname
)
==
0
)
{
if
(
strlen
(
fname
)
==
0
)
{
...
@@ -815,13 +826,15 @@ int lxc_log_set_file(int *fd, const char *fname)
...
@@ -815,13 +826,15 @@ int lxc_log_set_file(int *fd, const char *fname)
if
(
*
fd
>=
0
)
if
(
*
fd
>=
0
)
close_prot_errno_disarm
(
*
fd
);
close_prot_errno_disarm
(
*
fd
);
if
(
is_empty_string
(
fname
))
return
ret_errno
(
EINVAL
);
if
(
build_dir
(
fname
))
if
(
build_dir
(
fname
))
return
-
errno
;
return
-
errno
;
*
fd
=
log_open
(
fname
);
*
fd
=
log_open
(
fname
);
if
(
*
fd
<
0
)
if
(
*
fd
<
0
)
return
-
errno
;
return
-
errno
;
return
0
;
return
0
;
}
}
...
...
src/tests/parse_config_file.c
View file @
0912bf6b
...
@@ -899,6 +899,11 @@ int main(int argc, char *argv[])
...
@@ -899,6 +899,11 @@ int main(int argc, char *argv[])
return
-
1
;
return
-
1
;
}
}
if
(
c
->
set_config_item
(
c
,
"lxc.log.file="
,
"./"
))
{
lxc_error
(
"%s
\n
"
,
"Managed to set to set invalid config item
\"
lxc.log.file
\"
to
\"
./
\"
"
);
return
-
1
;
}
fret
=
EXIT_SUCCESS
;
fret
=
EXIT_SUCCESS
;
non_test_error:
non_test_error:
...
...
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