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
d92c8e40
Unverified
Commit
d92c8e40
authored
Jan 28, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attach: move get_personality() into get_attach_context()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
500ed813
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
20 deletions
+15
-20
attach.c
src/lxc/attach.c
+15
-20
No files found.
src/lxc/attach.c
View file @
d92c8e40
...
...
@@ -71,6 +71,17 @@ static struct attach_context *alloc_attach_context(void)
return
zalloc
(
sizeof
(
struct
attach_context
));
}
static
signed
long
get_personality
(
const
char
*
name
,
const
char
*
lxcpath
)
{
__do_free
char
*
p
=
NULL
;
p
=
lxc_cmd_get_config_item
(
name
,
"lxc.arch"
,
lxcpath
);
if
(
!
p
)
return
-
1
;
return
lxc_config_parse_arch
(
p
);
}
static
int
get_attach_context
(
struct
attach_context
*
ctx
,
struct
lxc_container
*
container
)
{
...
...
@@ -116,6 +127,10 @@ static int get_attach_context(struct attach_context *ctx,
for
(
int
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
ctx
->
ns_fd
[
i
]
=
-
EBADF
;
ctx
->
personality
=
get_personality
(
container
->
name
,
container
->
config_path
);
if
(
ctx
->
personality
<
0
)
return
log_error_errno
(
-
ENOENT
,
ENOENT
,
"Failed to get personality of the container"
);
return
0
;
}
...
...
@@ -632,17 +647,6 @@ static bool no_new_privs(struct lxc_container *c, lxc_attach_options_t *options)
return
c
->
set_config_item
(
c
,
"lxc.no_new_privs"
,
val
);
}
static
signed
long
get_personality
(
const
char
*
name
,
const
char
*
lxcpath
)
{
__do_free
char
*
p
=
NULL
;
p
=
lxc_cmd_get_config_item
(
name
,
"lxc.arch"
,
lxcpath
);
if
(
!
p
)
return
-
1
;
return
lxc_config_parse_arch
(
p
);
}
struct
attach_clone_payload
{
int
ipc_socket
;
int
terminal_pts_fd
;
...
...
@@ -976,7 +980,6 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
int
i
,
ret
,
status
;
char
*
name
,
*
lxcpath
,
*
new_cwd
;
int
ipc_sockets
[
2
];
signed
long
personality
;
pid_t
attached_pid
,
pid
,
to_cleanup_pid
;
struct
attach_context
*
ctx
;
struct
lxc_terminal
terminal
;
...
...
@@ -1011,14 +1014,6 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
return
-
1
;
}
personality
=
get_personality
(
name
,
lxcpath
);
if
(
ctx
->
personality
<
0
)
{
ERROR
(
"Failed to get personality of the container"
);
put_attach_context
(
ctx
);
return
-
1
;
}
ctx
->
personality
=
personality
;
if
(
!
ctx
->
container
->
lxc_conf
)
{
ctx
->
container
->
lxc_conf
=
lxc_conf_init
();
if
(
!
ctx
->
container
->
lxc_conf
)
{
...
...
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