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
de6af062
Unverified
Commit
de6af062
authored
Sep 17, 2018
by
Christian Brauner
Committed by
GitHub
Sep 17, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2611 from 2xsec/bugfix
add compile flags for dlog
parents
fd734188
de1c05f3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
38 deletions
+79
-38
lxc.spec.in
lxc.spec.in
+7
-0
Makefile.am
src/lxc/Makefile.am
+7
-3
log.c
src/lxc/log.c
+65
-35
No files found.
lxc.spec.in
View file @
de6af062
...
@@ -91,6 +91,13 @@ BuildRequires: libseccomp-devel
...
@@ -91,6 +91,13 @@ BuildRequires: libseccomp-devel
%endif
%endif
%endif
%endif
#
# Additional package for Tizen
#
%if %{defined tizen_version}
BuildRequires: pkgconfig(dlog)
%endif
%description
%description
Containers are insulated areas inside a system, which have their own namespace
Containers are insulated areas inside a system, which have their own namespace
for filesystem, network, PID, IPC, CPU and memory allocation and which can be
for filesystem, network, PID, IPC, CPU and memory allocation and which can be
...
...
src/lxc/Makefile.am
View file @
de6af062
...
@@ -212,7 +212,8 @@ AM_CFLAGS += -DHAVE_SELINUX
...
@@ -212,7 +212,8 @@ AM_CFLAGS += -DHAVE_SELINUX
endif
endif
if
ENABLE_DLOG
if
ENABLE_DLOG
AM_CFLAGS
+=
-DHAVE_DLOG
AM_CFLAGS
+=
-DHAVE_DLOG
\
$(DLOG_CFLAGS)
endif
endif
if
USE_CONFIGPATH_LOGS
if
USE_CONFIGPATH_LOGS
...
@@ -233,7 +234,8 @@ liblxc_la_LDFLAGS = -pthread \
...
@@ -233,7 +234,8 @@ liblxc_la_LDFLAGS = -pthread \
liblxc_la_LIBADD
=
$(CAP_LIBS)
\
liblxc_la_LIBADD
=
$(CAP_LIBS)
\
$(GNUTLS_LIBS)
\
$(GNUTLS_LIBS)
\
$(SELINUX_LIBS)
\
$(SELINUX_LIBS)
\
$(SECCOMP_LIBS)
$(SECCOMP_LIBS)
\
$(DLOG_LIBS)
bin_SCRIPTS
=
bin_SCRIPTS
=
...
@@ -285,7 +287,8 @@ LDADD = liblxc.la \
...
@@ -285,7 +287,8 @@ LDADD = liblxc.la \
@CAP_LIBS@
\
@CAP_LIBS@
\
@GNUTLS_LIBS@
\
@GNUTLS_LIBS@
\
@SECCOMP_LIBS@
\
@SECCOMP_LIBS@
\
@SELINUX_LIBS@
@SELINUX_LIBS@
\
@DLOG_LIBS@
if
ENABLE_TOOLS
if
ENABLE_TOOLS
lxc_attach_SOURCES
=
tools/lxc_attach.c
\
lxc_attach_SOURCES
=
tools/lxc_attach.c
\
...
@@ -421,6 +424,7 @@ pam_cgfs_la_CFLAGS = $(AM_CFLAGS) -DNO_LXC_CONF
...
@@ -421,6 +424,7 @@ pam_cgfs_la_CFLAGS = $(AM_CFLAGS) -DNO_LXC_CONF
pam_cgfs_la_LIBADD
=
$(AM_LIBS)
\
pam_cgfs_la_LIBADD
=
$(AM_LIBS)
\
$(PAM_LIBS)
\
$(PAM_LIBS)
\
$(DLOG_LIBS)
\
-L
$(top_srcdir)
-L
$(top_srcdir)
pam_cgfs_la_LDFLAGS
=
$(AM_LDFLAGS)
\
pam_cgfs_la_LDFLAGS
=
$(AM_LDFLAGS)
\
...
...
src/lxc/log.c
View file @
de6af062
...
@@ -101,37 +101,58 @@ static int lxc_log_priority_to_syslog(int priority)
...
@@ -101,37 +101,58 @@ static int lxc_log_priority_to_syslog(int priority)
return
LOG_NOTICE
;
return
LOG_NOTICE
;
}
}
/*---------------------------------------------------------------------------*/
static
const
char
*
lxc_log_get_container_name
()
static
int
log_append_syslog
(
const
struct
lxc_log_appender
*
appender
,
{
struct
lxc_log_event
*
event
)
#ifndef NO_LXC_CONF
if
(
current_config
&&
!
log_vmname
)
return
current_config
->
name
;
#endif
return
log_vmname
;
}
static
char
*
lxc_log_get_va_msg
(
struct
lxc_log_event
*
event
)
{
{
char
*
msg
;
char
*
msg
;
int
rc
,
len
;
int
rc
,
len
;
va_list
args
;
va_list
args
;
const
char
*
log_container_name
=
log_vmname
;
#ifndef NO_LXC_CONF
if
(
current_config
&&
!
log_container_name
)
log_container_name
=
current_config
->
name
;
#endif
if
(
!
syslog_enable
)
if
(
!
event
)
return
0
;
return
NULL
;
va_copy
(
args
,
*
event
->
vap
);
va_copy
(
args
,
*
event
->
vap
);
len
=
vsnprintf
(
NULL
,
0
,
event
->
fmt
,
args
)
+
1
;
len
=
vsnprintf
(
NULL
,
0
,
event
->
fmt
,
args
)
+
1
;
va_end
(
args
);
va_end
(
args
);
msg
=
malloc
(
len
*
sizeof
(
char
));
msg
=
malloc
(
len
*
sizeof
(
char
));
if
(
msg
==
NULL
)
if
(
!
msg
)
return
0
;
return
NULL
;
rc
=
vsnprintf
(
msg
,
len
,
event
->
fmt
,
*
event
->
vap
);
rc
=
vsnprintf
(
msg
,
len
,
event
->
fmt
,
*
event
->
vap
);
if
(
rc
==
-
1
||
rc
>=
len
)
{
if
(
rc
==
-
1
||
rc
>=
len
)
{
free
(
msg
);
free
(
msg
);
return
0
;
return
NULL
;
}
}
return
msg
;
}
/*---------------------------------------------------------------------------*/
static
int
log_append_syslog
(
const
struct
lxc_log_appender
*
appender
,
struct
lxc_log_event
*
event
)
{
char
*
msg
;
const
char
*
log_container_name
;
if
(
!
syslog_enable
)
return
0
;
log_container_name
=
lxc_log_get_container_name
();
msg
=
lxc_log_get_va_msg
(
event
);
if
(
!
msg
)
return
0
;
syslog
(
lxc_log_priority_to_syslog
(
event
->
priority
),
syslog
(
lxc_log_priority_to_syslog
(
event
->
priority
),
"%s%s %s - %s:%s:%d - %s"
,
"%s%s %s - %s:%s:%d - %s"
,
log_container_name
?
log_container_name
:
""
,
log_container_name
?
log_container_name
:
""
,
...
@@ -154,12 +175,7 @@ static int log_append_stderr(const struct lxc_log_appender *appender,
...
@@ -154,12 +175,7 @@ static int log_append_stderr(const struct lxc_log_appender *appender,
if
(
event
->
priority
<
LXC_LOG_LEVEL_ERROR
)
if
(
event
->
priority
<
LXC_LOG_LEVEL_ERROR
)
return
0
;
return
0
;
log_container_name
=
log_vmname
;
log_container_name
=
lxc_log_get_container_name
();
#ifndef NO_LXC_CONF
if
(
current_config
&&
!
log_container_name
)
log_container_name
=
current_config
->
name
;
#endif
fprintf
(
stderr
,
"%s: %s%s"
,
log_prefix
,
fprintf
(
stderr
,
"%s: %s%s"
,
log_prefix
,
log_container_name
?
log_container_name
:
""
,
log_container_name
?
log_container_name
:
""
,
...
@@ -299,18 +315,16 @@ static int log_append_logfile(const struct lxc_log_appender *appender,
...
@@ -299,18 +315,16 @@ static int log_append_logfile(const struct lxc_log_appender *appender,
int
n
;
int
n
;
ssize_t
ret
;
ssize_t
ret
;
int
fd_to_use
=
-
1
;
int
fd_to_use
=
-
1
;
const
char
*
log_container_name
=
log_vmname
;
const
char
*
log_container_name
;
#ifndef NO_LXC_CONF
#ifndef NO_LXC_CONF
if
(
current_config
)
{
if
(
current_config
)
if
(
!
lxc_log_use_global_fd
)
if
(
!
lxc_log_use_global_fd
)
fd_to_use
=
current_config
->
logfd
;
fd_to_use
=
current_config
->
logfd
;
if
(
!
log_container_name
)
log_container_name
=
current_config
->
name
;
}
#endif
#endif
log_container_name
=
lxc_log_get_container_name
();
if
(
fd_to_use
==
-
1
)
if
(
fd_to_use
==
-
1
)
fd_to_use
=
lxc_log_fd
;
fd_to_use
=
lxc_log_fd
;
...
@@ -358,33 +372,49 @@ again:
...
@@ -358,33 +372,49 @@ again:
static
int
log_append_dlog
(
const
struct
lxc_log_appender
*
appender
,
static
int
log_append_dlog
(
const
struct
lxc_log_appender
*
appender
,
struct
lxc_log_event
*
event
)
struct
lxc_log_event
*
event
)
{
{
if
(
event
->
priority
<
LXC_LOG_LEVEL_ERROR
)
char
*
msg
=
lxc_log_get_va_msg
(
event
);
return
0
;
const
char
*
log_container_name
=
lxc_log_get_container_name
()
;
switch
(
event
->
priority
)
{
switch
(
event
->
priority
)
{
case
LXC_LOG_LEVEL_TRACE
:
case
LXC_LOG_LEVEL_TRACE
:
case
LXC_LOG_LEVEL_DEBUG
:
case
LXC_LOG_LEVEL_DEBUG
:
LOG_VA
(
LOG_DEBUG
,
LOG_TAG
,
event
->
fmt
,
*
event
->
vap
);
print_log
(
DLOG_DEBUG
,
LOG_TAG
,
"%s: %s(%d) > [%s] %s"
,
event
->
locinfo
->
file
,
event
->
locinfo
->
func
,
event
->
locinfo
->
line
,
log_container_name
?
log_container_name
:
"-"
,
msg
?
msg
:
"-"
);
break
;
break
;
case
LXC_LOG_LEVEL_INFO
:
case
LXC_LOG_LEVEL_INFO
:
LOG_VA
(
LOG_INFO
,
LOG_TAG
,
event
->
fmt
,
*
event
->
vap
);
print_log
(
DLOG_INFO
,
LOG_TAG
,
"%s: %s(%d) > [%s] %s"
,
event
->
locinfo
->
file
,
event
->
locinfo
->
func
,
event
->
locinfo
->
line
,
log_container_name
?
log_container_name
:
"-"
,
msg
?
msg
:
"-"
);
break
;
break
;
case
LXC_LOG_LEVEL_NOTICE
:
case
LXC_LOG_LEVEL_NOTICE
:
case
LXC_LOG_LEVEL_WARN
:
case
LXC_LOG_LEVEL_WARN
:
LOG_VA
(
LOG_WARN
,
LOG_TAG
,
event
->
fmt
,
*
event
->
vap
);
print_log
(
DLOG_WARN
,
LOG_TAG
,
"%s: %s(%d) > [%s] %s"
,
event
->
locinfo
->
file
,
event
->
locinfo
->
func
,
event
->
locinfo
->
line
,
log_container_name
?
log_container_name
:
"-"
,
msg
?
msg
:
"-"
);
break
;
break
;
case
LXC_LOG_LEVEL_ERROR
:
case
LXC_LOG_LEVEL_ERROR
:
LOG_VA
(
LOG_ERROR
,
LOG_TAG
,
event
->
fmt
,
*
event
->
vap
);
print_log
(
DLOG_ERROR
,
LOG_TAG
,
"%s: %s(%d) > [%s] %s"
,
event
->
locinfo
->
file
,
event
->
locinfo
->
func
,
event
->
locinfo
->
line
,
log_container_name
?
log_container_name
:
"-"
,
msg
?
msg
:
"-"
);
break
;
break
;
case
LXC_LOG_LEVEL_CRIT
:
case
LXC_LOG_LEVEL_CRIT
:
case
LXC_LOG_LEVEL_ALERT
:
case
LXC_LOG_LEVEL_ALERT
:
case
LXC_LOG_LEVEL_FATAL
:
case
LXC_LOG_LEVEL_FATAL
:
LOG_VA
(
LOG_FATAL
,
LOG_TAG
,
event
->
fmt
,
*
event
->
vap
);
print_log
(
DLOG_FATAL
,
LOG_TAG
,
"%s: %s(%d) > [%s] %s"
,
event
->
locinfo
->
file
,
event
->
locinfo
->
func
,
event
->
locinfo
->
line
,
log_container_name
?
log_container_name
:
"-"
,
msg
?
msg
:
"-"
);
break
;
break
;
default:
default:
break
;
break
;
}
}
free
(
msg
);
return
0
;
return
0
;
}
}
#endif
#endif
...
@@ -425,7 +455,7 @@ static struct lxc_log_category log_root = {
...
@@ -425,7 +455,7 @@ static struct lxc_log_category log_root = {
#if HAVE_DLOG
#if HAVE_DLOG
struct
lxc_log_category
lxc_log_category_lxc
=
{
struct
lxc_log_category
lxc_log_category_lxc
=
{
.
name
=
"lxc"
,
.
name
=
"lxc"
,
.
priority
=
LXC_LOG_LEVEL_
ERROR
,
.
priority
=
LXC_LOG_LEVEL_
TRACE
,
.
appender
=
&
log_appender_dlog
,
.
appender
=
&
log_appender_dlog
,
.
parent
=
&
log_root
.
parent
=
&
log_root
};
};
...
...
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