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
ea2a070b
Unverified
Commit
ea2a070b
authored
Mar 11, 2020
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands: add ability to audit fd connection and cleanup path
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
ab92468c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
75 deletions
+94
-75
commands.c
src/lxc/commands.c
+80
-65
commands.h
src/lxc/commands.h
+7
-0
commands_utils.c
src/lxc/commands_utils.c
+2
-1
lxccontainer.c
src/lxc/lxccontainer.c
+5
-9
No files found.
src/lxc/commands.c
View file @
ea2a070b
This diff is collapsed.
Click to expand it.
src/lxc/commands.h
View file @
ea2a070b
...
@@ -11,6 +11,13 @@
...
@@ -11,6 +11,13 @@
#include "macro.h"
#include "macro.h"
#include "state.h"
#include "state.h"
/*
* Value command callbacks should return when they want the client fd to be
* cleaned up by the main loop. This is most certainly what you want unless you
* have specific reasons to keep the file descriptor alive.
*/
#define LXC_CMD_REAP_CLIENT_FD 1
typedef
enum
{
typedef
enum
{
LXC_CMD_CONSOLE
,
LXC_CMD_CONSOLE
,
LXC_CMD_TERMINAL_WINCH
,
LXC_CMD_TERMINAL_WINCH
,
...
...
src/lxc/commands_utils.c
View file @
ea2a070b
...
@@ -185,5 +185,6 @@ int lxc_add_state_client(int state_client_fd, struct lxc_handler *handler,
...
@@ -185,5 +185,6 @@ int lxc_add_state_client(int state_client_fd, struct lxc_handler *handler,
move_ptr
(
newclient
);
move_ptr
(
newclient
);
move_ptr
(
tmplist
);
move_ptr
(
tmplist
);
return
log_trace
(
MAX_STATE
,
"Added state client %d to state client list"
,
state_client_fd
);
TRACE
(
"Added state client fd %d to state client list"
,
state_client_fd
);
return
MAX_STATE
;
}
}
src/lxc/lxccontainer.c
View file @
ea2a070b
...
@@ -2064,10 +2064,11 @@ WRAP_API_1(bool, lxcapi_reboot2, int)
...
@@ -2064,10 +2064,11 @@ WRAP_API_1(bool, lxcapi_reboot2, int)
static
bool
do_lxcapi_shutdown
(
struct
lxc_container
*
c
,
int
timeout
)
static
bool
do_lxcapi_shutdown
(
struct
lxc_container
*
c
,
int
timeout
)
{
{
__do_close_prot_errno
int
state_client_fd
=
-
EBADF
;
int
haltsignal
=
SIGPWR
;
lxc_state_t
states
[
MAX_STATE
]
=
{
0
};
int
killret
,
ret
;
int
killret
,
ret
;
pid_t
pid
;
pid_t
pid
;
int
haltsignal
=
SIGPWR
,
state_client_fd
=
-
EBADF
;
lxc_state_t
states
[
MAX_STATE
]
=
{
0
};
if
(
!
c
)
if
(
!
c
)
return
false
;
return
false
;
...
@@ -2107,20 +2108,15 @@ static bool do_lxcapi_shutdown(struct lxc_container *c, int timeout)
...
@@ -2107,20 +2108,15 @@ static bool do_lxcapi_shutdown(struct lxc_container *c, int timeout)
/* Send shutdown signal to container. */
/* Send shutdown signal to container. */
killret
=
kill
(
pid
,
haltsignal
);
killret
=
kill
(
pid
,
haltsignal
);
if
(
killret
<
0
)
{
if
(
killret
<
0
)
if
(
state_client_fd
>=
0
)
return
log_warn
(
false
,
"Failed to send signal %d to pid %d"
,
haltsignal
,
pid
);
close
(
state_client_fd
);
WARN
(
"Failed to send signal %d to pid %d"
,
haltsignal
,
pid
);
return
false
;
}
TRACE
(
"Sent signal %d to pid %d"
,
haltsignal
,
pid
);
TRACE
(
"Sent signal %d to pid %d"
,
haltsignal
,
pid
);
if
(
timeout
==
0
)
if
(
timeout
==
0
)
return
true
;
return
true
;
ret
=
lxc_cmd_sock_rcv_state
(
state_client_fd
,
timeout
);
ret
=
lxc_cmd_sock_rcv_state
(
state_client_fd
,
timeout
);
close
(
state_client_fd
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
false
;
return
false
;
...
...
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