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
74ce42b5
Unverified
Commit
74ce42b5
authored
Jan 29, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attach: coding style fixes
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
338b230f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
19 deletions
+9
-19
attach.c
src/lxc/attach.c
+9
-19
No files found.
src/lxc/attach.c
View file @
74ce42b5
...
...
@@ -1032,7 +1032,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
{
int
ret_parent
=
-
1
;
struct
lxc_epoll_descr
descr
=
{};
int
i
,
ret
,
status
;
int
ret
,
status
;
char
*
name
,
*
lxcpath
,
*
new_cwd
;
int
ipc_sockets
[
2
];
pid_t
attached_pid
,
pid
,
to_cleanup_pid
;
...
...
@@ -1060,9 +1060,8 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
ret
=
get_attach_context
(
ctx
,
container
);
if
(
ret
)
{
ERROR
(
"Failed to get attach context"
);
put_attach_context
(
ctx
);
return
-
1
;
return
log_error
(
-
1
,
"Failed to get attach context"
)
;
}
conf
=
ctx
->
container
->
lxc_conf
;
...
...
@@ -1073,20 +1072,15 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
if
(
!
no_new_privs
(
ctx
->
container
,
options
))
WARN
(
"Could not determine whether PR_SET_NO_NEW_PRIVS is set"
);
/* Determine which namespaces the container was created with
* by asking lxc-start, if necessary.
*/
/* Determine which namespaces the container was created with. */
if
(
options
->
namespaces
==
-
1
)
{
options
->
namespaces
=
lxc_cmd_get_clone_flags
(
name
,
lxcpath
);
/* call failed */
if
(
options
->
namespaces
==
-
1
)
{
ERROR
(
"Failed to automatically determine the "
"namespaces which the container uses"
);
put_attach_context
(
ctx
);
return
-
1
;
return
log_error
(
-
1
,
"Failed to automatically determine the namespaces which the container uses"
)
;
}
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
{
for
(
i
nt
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
{
if
(
ns_info
[
i
].
clone_flag
&
CLONE_NEWCGROUP
)
if
(
!
(
options
->
attach_flags
&
LXC_ATTACH_MOVE_TO_CGROUP
)
||
!
cgns_supported
())
...
...
@@ -1101,17 +1095,15 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
ret
=
get_attach_context_nsfds
(
ctx
,
options
);
if
(
ret
)
{
ERROR
(
"Failed to get namespace file descriptors"
);
lxc_container_put
(
container
);
return
-
1
;
return
log_error
(
-
1
,
"Failed to get namespace file descriptors"
)
;
}
if
(
options
->
attach_flags
&
LXC_ATTACH_TERMINAL
)
{
ret
=
lxc_attach_terminal
(
name
,
lxcpath
,
conf
,
&
terminal
);
if
(
ret
<
0
)
{
ERROR
(
"Failed to setup new terminal"
);
put_attach_context
(
ctx
);
return
-
1
;
return
log_error
(
-
1
,
"Failed to setup new terminal"
)
;
}
terminal
.
log_fd
=
options
->
log_fd
;
...
...
@@ -1154,9 +1146,8 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
*/
ret
=
socketpair
(
PF_LOCAL
,
SOCK_STREAM
|
SOCK_CLOEXEC
,
0
,
ipc_sockets
);
if
(
ret
<
0
)
{
SYSERROR
(
"Could not set up required IPC mechanism for attaching"
);
put_attach_context
(
ctx
);
return
-
1
;
return
log_error_errno
(
-
1
,
errno
,
"Could not set up required IPC mechanism for attaching"
)
;
}
/* Create intermediate subprocess, two reasons:
...
...
@@ -1168,9 +1159,8 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
*/
pid
=
fork
();
if
(
pid
<
0
)
{
SYSERROR
(
"Failed to create first subprocess"
);
put_attach_context
(
ctx
);
return
-
1
;
return
log_error_errno
(
-
1
,
errno
,
"Failed to create first subprocess"
)
;
}
if
(
pid
==
0
)
{
...
...
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