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
7101cb03
Unverified
Commit
7101cb03
authored
May 04, 2018
by
Christian Brauner
Committed by
GitHub
May 04, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2305 from brauner/2018-05-04/fix_execute_logging
fix logic for execute log file
parents
cef701ed
321614a5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
5 deletions
+39
-5
execute.c
src/lxc/execute.c
+28
-5
utils.h
src/lxc/utils.h
+11
-0
No files found.
src/lxc/execute.c
View file @
7101cb03
...
@@ -21,11 +21,13 @@
...
@@ -21,11 +21,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
*/
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <errno.h>
#include <errno.h>
#include <unistd.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include "conf.h"
#include "conf.h"
#include "log.h"
#include "log.h"
...
@@ -36,10 +38,11 @@ lxc_log_define(lxc_execute, lxc_start);
...
@@ -36,10 +38,11 @@ lxc_log_define(lxc_execute, lxc_start);
static
int
execute_start
(
struct
lxc_handler
*
handler
,
void
*
data
)
static
int
execute_start
(
struct
lxc_handler
*
handler
,
void
*
data
)
{
{
int
j
,
i
=
0
;
int
argc_add
,
j
;
struct
execute_args
*
my_args
=
data
;
char
**
argv
;
char
**
argv
;
int
argc
=
0
,
argc_add
;
int
argc
=
0
,
i
=
0
,
logfd
=
-
1
;
struct
execute_args
*
my_args
=
data
;
char
logfile
[
LXC_PROC_PID_FD_LEN
];
while
(
my_args
->
argv
[
argc
++
]);
while
(
my_args
->
argv
[
argc
++
]);
...
@@ -47,8 +50,10 @@ static int execute_start(struct lxc_handler *handler, void* data)
...
@@ -47,8 +50,10 @@ static int execute_start(struct lxc_handler *handler, void* data)
argc_add
=
5
;
argc_add
=
5
;
if
(
my_args
->
quiet
)
if
(
my_args
->
quiet
)
argc_add
++
;
argc_add
++
;
if
(
!
handler
->
conf
->
rootfs
.
path
)
if
(
!
handler
->
conf
->
rootfs
.
path
)
argc_add
+=
2
;
argc_add
+=
2
;
if
(
lxc_log_has_valid_level
())
if
(
lxc_log_has_valid_level
())
argc_add
+=
2
;
argc_add
+=
2
;
...
@@ -69,9 +74,25 @@ static int execute_start(struct lxc_handler *handler, void* data)
...
@@ -69,9 +74,25 @@ static int execute_start(struct lxc_handler *handler, void* data)
argv
[
i
++
]
=
(
char
*
)
lxc_log_priority_to_string
(
lxc_log_get_level
());
argv
[
i
++
]
=
(
char
*
)
lxc_log_priority_to_string
(
lxc_log_get_level
());
}
}
if
(
handler
->
conf
->
logfile
)
{
if
(
current_config
->
logfd
!=
-
1
||
lxc_log_fd
!=
-
1
)
{
int
ret
;
int
to_dup
=
current_config
->
logfd
;
if
(
current_config
->
logfd
==
-
1
)
to_dup
=
lxc_log_fd
;
logfd
=
dup
(
to_dup
);
if
(
logfd
<
0
)
{
SYSERROR
(
"Failed to duplicate log file descriptor"
);
goto
out2
;
}
ret
=
snprintf
(
logfile
,
sizeof
(
logfile
),
"/proc/1/fd/%d"
,
logfd
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
sizeof
(
logfile
))
goto
out3
;
argv
[
i
++
]
=
"-o"
;
argv
[
i
++
]
=
"-o"
;
argv
[
i
++
]
=
(
char
*
)
handler
->
conf
->
logfile
;
argv
[
i
++
]
=
logfile
;
}
}
if
(
my_args
->
quiet
)
if
(
my_args
->
quiet
)
...
@@ -92,6 +113,8 @@ static int execute_start(struct lxc_handler *handler, void* data)
...
@@ -92,6 +113,8 @@ static int execute_start(struct lxc_handler *handler, void* data)
execvp
(
argv
[
0
],
argv
);
execvp
(
argv
[
0
],
argv
);
SYSERROR
(
"Failed to exec %s"
,
argv
[
0
]);
SYSERROR
(
"Failed to exec %s"
,
argv
[
0
]);
out3:
close
(
logfd
);
out2:
out2:
free
(
argv
);
free
(
argv
);
out1:
out1:
...
...
src/lxc/utils.h
View file @
7101cb03
...
@@ -101,6 +101,17 @@
...
@@ -101,6 +101,17 @@
#define LXC_LINELEN 4096
#define LXC_LINELEN 4096
#define LXC_IDMAPLEN 4096
#define LXC_IDMAPLEN 4096
#define LXC_MAX_BUFFER 4096
#define LXC_MAX_BUFFER 4096
/* /proc/ = 6
* +
* <pid-as-str> = LXC_NUMSTRLEN64
* +
* /fd/ = 4
* +
* <fd-as-str> = LXC_NUMSTRLEN64
* +
* \0 = 1
*/
#define LXC_PROC_PID_FD_LEN (6 + LXC_NUMSTRLEN64 + 4 + LXC_NUMSTRLEN64 + 1)
/* returns 1 on success, 0 if there were any failures */
/* returns 1 on success, 0 if there were any failures */
extern
int
lxc_rmdir_onedev
(
const
char
*
path
,
const
char
*
exclude
);
extern
int
lxc_rmdir_onedev
(
const
char
*
path
,
const
char
*
exclude
);
...
...
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