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
f4da1c37
Unverified
Commit
f4da1c37
authored
Oct 20, 2020
by
Stéphane Graber
Committed by
GitHub
Oct 20, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3558 from brauner/2020-10-20/fixes
conf: always send response to parent waiting for devptfs_fd
parents
1593efb5
68f3899e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
12 deletions
+29
-12
conf.c
src/lxc/conf.c
+26
-8
conf.h
src/lxc/conf.h
+2
-0
start.c
src/lxc/start.c
+1
-4
No files found.
src/lxc/conf.c
View file @
f4da1c37
...
...
@@ -1477,7 +1477,23 @@ static const struct id_map *find_mapped_nsid_entry(const struct lxc_conf *conf,
return
retmap
;
}
static
int
lxc_setup_devpts
(
struct
lxc_handler
*
handler
)
int
lxc_setup_devpts_parent
(
struct
lxc_handler
*
handler
)
{
int
ret
;
if
(
handler
->
conf
->
pty_max
<=
0
)
return
0
;
ret
=
lxc_abstract_unix_recv_fds
(
handler
->
data_sock
[
1
],
&
handler
->
conf
->
devpts_fd
,
1
,
&
handler
->
conf
->
devpts_fd
,
sizeof
(
handler
->
conf
->
devpts_fd
));
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to receive devpts fd from child"
);
TRACE
(
"Received devpts file descriptor %d from child"
,
handler
->
conf
->
devpts_fd
);
return
0
;
}
static
int
lxc_setup_devpts_child
(
struct
lxc_handler
*
handler
)
{
__do_close
int
devpts_fd
=
-
EBADF
;
int
ret
;
...
...
@@ -1533,13 +1549,7 @@ static int lxc_setup_devpts(struct lxc_handler *handler)
if
(
devpts_fd
<
0
)
{
devpts_fd
=
-
EBADF
;
TRACE
(
"Failed to create detached devpts mount"
);
ret
=
lxc_abstract_unix_send_fds
(
sock
,
NULL
,
0
,
&
devpts_fd
,
sizeof
(
int
));
}
else
{
ret
=
lxc_abstract_unix_send_fds
(
sock
,
&
devpts_fd
,
1
,
NULL
,
0
);
}
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to send devpts fd to parent"
);
TRACE
(
"Sent devpts file descriptor %d to parent"
,
devpts_fd
);
/* Remove any pre-existing /dev/ptmx file. */
ret
=
remove
(
"/dev/ptmx"
);
...
...
@@ -1575,6 +1585,14 @@ static int lxc_setup_devpts(struct lxc_handler *handler)
return
log_error_errno
(
-
1
,
errno
,
"Failed to create symlink from
\"
/dev/ptmx
\"
to
\"
/dev/pts/ptmx
\"
"
);
DEBUG
(
"Created symlink from
\"
/dev/ptmx
\"
to
\"
/dev/pts/ptmx
\"
"
);
if
(
devpts_fd
<
0
)
ret
=
lxc_abstract_unix_send_fds
(
sock
,
NULL
,
0
,
&
devpts_fd
,
sizeof
(
int
));
else
ret
=
lxc_abstract_unix_send_fds
(
sock
,
&
devpts_fd
,
1
,
NULL
,
0
);
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to send devpts fd to parent"
);
TRACE
(
"Sent devpts file descriptor %d to parent"
,
devpts_fd
);
return
0
;
}
...
...
@@ -3392,7 +3410,7 @@ int lxc_setup(struct lxc_handler *handler)
if
(
lxc_conf
->
autodev
>
0
)
(
void
)
lxc_setup_boot_id
();
ret
=
lxc_setup_devpts
(
handler
);
ret
=
lxc_setup_devpts
_child
(
handler
);
if
(
ret
<
0
)
return
log_error
(
-
1
,
"Failed to setup new devpts instance"
);
...
...
src/lxc/conf.h
View file @
f4da1c37
...
...
@@ -490,4 +490,6 @@ static inline int chown_mapped_root(const char *path, const struct lxc_conf *con
return
userns_exec_mapped_root
(
path
,
-
EBADF
,
conf
);
}
__hidden
int
lxc_setup_devpts_parent
(
struct
lxc_handler
*
handler
);
#endif
/* __LXC_CONF_H */
src/lxc/start.c
View file @
f4da1c37
...
...
@@ -1953,14 +1953,11 @@ static int lxc_spawn(struct lxc_handler *handler)
}
}
ret
=
lxc_abstract_unix_recv_fds
(
data_sock1
,
&
handler
->
conf
->
devpts_fd
,
1
,
&
handler
->
conf
->
devpts_fd
,
sizeof
(
handler
->
conf
->
devpts_fd
));
ret
=
lxc_setup_devpts_parent
(
handler
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to receive devpts fd from child"
);
goto
out_delete_net
;
}
TRACE
(
"Received devpts file descriptor %d from child"
,
handler
->
conf
->
devpts_fd
);
/* Now all networks are created, network devices are moved into place,
* and the correct names and ifindices in the respective namespaces have
...
...
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