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
ee142207
Unverified
Commit
ee142207
authored
Jan 29, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attach: fix personality handling
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
4eb19ac0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
14 deletions
+30
-14
attach.c
src/lxc/attach.c
+22
-11
attach_options.h
src/lxc/attach_options.h
+1
-1
confile.c
src/lxc/confile.c
+1
-1
confile.h
src/lxc/confile.h
+6
-1
No files found.
src/lxc/attach.c
View file @
ee142207
...
@@ -71,15 +71,24 @@ static struct attach_context *alloc_attach_context(void)
...
@@ -71,15 +71,24 @@ static struct attach_context *alloc_attach_context(void)
return
zalloc
(
sizeof
(
struct
attach_context
));
return
zalloc
(
sizeof
(
struct
attach_context
));
}
}
static
signed
long
get_personality
(
const
char
*
name
,
const
char
*
lxcpath
)
static
int
get_personality
(
const
char
*
name
,
const
char
*
lxcpath
,
signed
long
*
personality
)
{
{
__do_free
char
*
p
=
NULL
;
__do_free
char
*
p
=
NULL
;
signed
long
per
;
p
=
lxc_cmd_get_config_item
(
name
,
"lxc.arch"
,
lxcpath
);
p
=
lxc_cmd_get_config_item
(
name
,
"lxc.arch"
,
lxcpath
);
if
(
!
p
)
if
(
!
p
)
{
return
-
1
;
*
personality
=
LXC_ARCH_UNCHANGED
;
return
0
;
}
per
=
lxc_config_parse_arch
(
p
);
if
(
per
==
LXC_ARCH_UNCHANGED
)
return
ret_errno
(
EINVAL
);
return
lxc_config_parse_arch
(
p
);
*
personality
=
per
;
return
0
;
}
}
static
int
get_attach_context
(
struct
attach_context
*
ctx
,
static
int
get_attach_context
(
struct
attach_context
*
ctx
,
...
@@ -127,9 +136,9 @@ static int get_attach_context(struct attach_context *ctx,
...
@@ -127,9 +136,9 @@ static int get_attach_context(struct attach_context *ctx,
for
(
int
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
for
(
int
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
ctx
->
ns_fd
[
i
]
=
-
EBADF
;
ctx
->
ns_fd
[
i
]
=
-
EBADF
;
ctx
->
personality
=
get_personality
(
container
->
name
,
container
->
config_path
);
ret
=
get_personality
(
container
->
name
,
container
->
config_path
,
&
ctx
->
personality
);
if
(
ctx
->
personality
<
0
)
if
(
ret
)
return
log_error_errno
(
-
ENOENT
,
ENOENT
,
"Failed to get personality of the container"
);
return
log_error_errno
(
ret
,
errno
,
"Failed to get personality of the container"
);
if
(
!
ctx
->
container
->
lxc_conf
)
{
if
(
!
ctx
->
container
->
lxc_conf
)
{
ctx
->
container
->
lxc_conf
=
lxc_conf_init
();
ctx
->
container
->
lxc_conf
=
lxc_conf_init
();
...
@@ -751,11 +760,13 @@ __noreturn static void do_attach(struct attach_clone_payload *payload)
...
@@ -751,11 +760,13 @@ __noreturn static void do_attach(struct attach_clone_payload *payload)
else
else
new_personality
=
options
->
personality
;
new_personality
=
options
->
personality
;
ret
=
personality
(
new_personality
);
if
(
new_personality
!=
LXC_ARCH_UNCHANGED
)
{
if
(
ret
<
0
)
ret
=
personality
(
new_personality
);
goto
on_error
;
if
(
ret
<
0
)
goto
on_error
;
TRACE
(
"Set new personality"
);
TRACE
(
"Set new personality"
);
}
}
}
#endif
#endif
...
...
src/lxc/attach_options.h
View file @
ee142207
...
@@ -124,7 +124,7 @@ typedef struct lxc_attach_options_t {
...
@@ -124,7 +124,7 @@ typedef struct lxc_attach_options_t {
{ \
{ \
/* .attach_flags = */
LXC_ATTACH_DEFAULT, \
/* .attach_flags = */
LXC_ATTACH_DEFAULT, \
/* .namespaces = */
-1, \
/* .namespaces = */
-1, \
/* .personality = */
-1,
\
/* .personality = */
0xffffffff,
\
/* .initial_cwd = */
NULL, \
/* .initial_cwd = */
NULL, \
/* .uid = */
(uid_t)-1, \
/* .uid = */
(uid_t)-1, \
/* .gid = */
(gid_t)-1, \
/* .gid = */
(gid_t)-1, \
...
...
src/lxc/confile.c
View file @
ee142207
...
@@ -3031,7 +3031,7 @@ signed long lxc_config_parse_arch(const char *arch)
...
@@ -3031,7 +3031,7 @@ signed long lxc_config_parse_arch(const char *arch)
return
pername
[
i
].
per
;
return
pername
[
i
].
per
;
#endif
#endif
return
-
1
;
return
LXC_ARCH_UNCHANGED
;
}
}
int
lxc_fill_elevated_privileges
(
char
*
flaglist
,
int
*
flags
)
int
lxc_fill_elevated_privileges
(
char
*
flaglist
,
int
*
flags
)
...
...
src/lxc/confile.h
View file @
ee142207
...
@@ -78,7 +78,12 @@ __hidden extern bool lxc_config_define_load(struct lxc_list *defines, struct lxc
...
@@ -78,7 +78,12 @@ __hidden extern bool lxc_config_define_load(struct lxc_list *defines, struct lxc
__hidden
extern
void
lxc_config_define_free
(
struct
lxc_list
*
defines
);
__hidden
extern
void
lxc_config_define_free
(
struct
lxc_list
*
defines
);
/* needed for lxc-attach */
#define LXC_ARCH_UNCHANGED 0xffffffffL
/*
* Parse personality of the container. Returns LXC_ARCH_UNCHANGED if the
* personality is not know.
* (Used during attach.)
*/
__hidden
extern
signed
long
lxc_config_parse_arch
(
const
char
*
arch
);
__hidden
extern
signed
long
lxc_config_parse_arch
(
const
char
*
arch
);
__hidden
extern
int
lxc_fill_elevated_privileges
(
char
*
flaglist
,
int
*
flags
);
__hidden
extern
int
lxc_fill_elevated_privileges
(
char
*
flaglist
,
int
*
flags
);
...
...
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