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
e6eb4c3e
Commit
e6eb4c3e
authored
Feb 29, 2016
by
Serge Hallyn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #859 from brauner/bugfix_branch
lxc-attach: always allocate current controlling pty
parents
cadbf1a7
a9d02bb9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
5 deletions
+24
-5
lxc_attach.c
src/lxc/lxc_attach.c
+24
-5
No files found.
src/lxc/lxc_attach.c
View file @
e6eb4c3e
...
@@ -253,10 +253,27 @@ static int get_pty_on_host(struct lxc_container *c, struct wrapargs *wrap, int *
...
@@ -253,10 +253,27 @@ static int get_pty_on_host(struct lxc_container *c, struct wrapargs *wrap, int *
}
}
conf
=
c
->
lxc_conf
;
conf
=
c
->
lxc_conf
;
free
(
conf
->
console
.
log_path
);
conf
->
console
.
log_path
=
NULL
;
/* In the case of lxc-attach our peer pty will always be the current
* controlling terminal. We clear whatever was set by the user for
* lxc.console.path here and set it to "/dev/tty". Doing this will (a)
* prevent segfaults when the container has been setup with
* lxc.console = none and (b) provide an easy way to ensure that we
* always do the correct thing. strdup() must be used since console.path
* is free()ed when we call lxc_container_put(). */
free
(
conf
->
console
.
path
);
conf
->
console
.
path
=
NULL
;
conf
->
console
.
path
=
strdup
(
"/dev/tty"
);
if
(
!
conf
->
console
.
path
)
return
-
1
;
/* Create pty on the host. */
/* Create pty on the host. */
if
(
lxc_console_create
(
conf
)
<
0
)
if
(
lxc_console_create
(
conf
)
<
0
)
return
-
1
;
return
-
1
;
ts
=
conf
->
console
.
tty_state
;
ts
=
conf
->
console
.
tty_state
;
conf
->
console
.
descr
=
&
descr
;
/* Shift ttys to container. */
/* Shift ttys to container. */
if
(
ttys_shift_ids
(
conf
)
<
0
)
{
if
(
ttys_shift_ids
(
conf
)
<
0
)
{
...
@@ -375,14 +392,16 @@ int main(int argc, char *argv[])
...
@@ -375,14 +392,16 @@ int main(int argc, char *argv[])
attach_options
.
extra_env_vars
=
extra_env
;
attach_options
.
extra_env_vars
=
extra_env
;
attach_options
.
extra_keep_env
=
extra_keep
;
attach_options
.
extra_keep_env
=
extra_keep
;
struct
wrapargs
wrap
=
(
struct
wrapargs
){.
command
=
&
command
,
.
options
=
&
attach_options
};
if
(
my_args
.
argc
>
0
)
{
if
(
my_args
.
argc
>
0
)
{
wrap
.
command
->
program
=
my_args
.
argv
[
0
];
command
.
program
=
my_args
.
argv
[
0
];
wrap
.
command
->
argv
=
(
char
**
)
my_args
.
argv
;
command
.
argv
=
(
char
**
)
my_args
.
argv
;
}
}
if
(
isatty
(
STDIN_FILENO
)
||
isatty
(
STDOUT_FILENO
)
||
isatty
(
STDERR_FILENO
))
{
if
(
isatty
(
STDIN_FILENO
)
||
isatty
(
STDOUT_FILENO
)
||
isatty
(
STDERR_FILENO
))
{
struct
wrapargs
wrap
=
(
struct
wrapargs
){
.
command
=
&
command
,
.
options
=
&
attach_options
};
if
(
isatty
(
STDIN_FILENO
))
if
(
isatty
(
STDIN_FILENO
))
wrap
.
ptyfd
=
STDIN_FILENO
;
wrap
.
ptyfd
=
STDIN_FILENO
;
else
if
(
isatty
(
STDOUT_FILENO
))
else
if
(
isatty
(
STDOUT_FILENO
))
...
@@ -391,7 +410,7 @@ int main(int argc, char *argv[])
...
@@ -391,7 +410,7 @@ int main(int argc, char *argv[])
wrap
.
ptyfd
=
STDERR_FILENO
;
wrap
.
ptyfd
=
STDERR_FILENO
;
ret
=
get_pty_on_host
(
c
,
&
wrap
,
&
pid
);
ret
=
get_pty_on_host
(
c
,
&
wrap
,
&
pid
);
}
else
{
}
else
{
if
(
my_args
.
argc
>
1
)
if
(
command
.
program
)
ret
=
c
->
attach
(
c
,
lxc_attach_run_command
,
&
command
,
&
attach_options
,
&
pid
);
ret
=
c
->
attach
(
c
,
lxc_attach_run_command
,
&
command
,
&
attach_options
,
&
pid
);
else
else
ret
=
c
->
attach
(
c
,
lxc_attach_run_shell
,
NULL
,
&
attach_options
,
&
pid
);
ret
=
c
->
attach
(
c
,
lxc_attach_run_shell
,
NULL
,
&
attach_options
,
&
pid
);
...
...
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