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
49cd0656
Unverified
Commit
49cd0656
authored
Feb 28, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
terminal: lxc_terminal_peer_default()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
1b5e93c4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
25 deletions
+29
-25
terminal.c
src/lxc/terminal.c
+29
-25
No files found.
src/lxc/terminal.c
View file @
49cd0656
...
@@ -671,65 +671,69 @@ static int lxc_terminal_peer_default(struct lxc_terminal *terminal)
...
@@ -671,65 +671,69 @@ static int lxc_terminal_peer_default(struct lxc_terminal *terminal)
int
fd
;
int
fd
;
int
ret
=
0
;
int
ret
=
0
;
/* If no terminal was given, try current controlling terminal, there
if
(
!
path
)
{
* won't be one if we were started as a daemon (-d).
ret
=
access
(
"/dev/tty"
,
F_OK
);
*/
if
(
ret
==
0
)
{
if
(
!
path
&&
!
access
(
"/dev/tty"
,
F_OK
))
{
/* If no terminal was given, try current controlling
fd
=
open
(
"/dev/tty"
,
O_RDWR
);
* terminal, there won't be one if we were started as a
if
(
fd
>=
0
)
{
* daemon (-d).
close
(
fd
);
*/
path
=
"/dev/tty"
;
fd
=
open
(
"/dev/tty"
,
O_RDWR
);
if
(
fd
>=
0
)
{
close
(
fd
);
path
=
"/dev/tty"
;
}
}
}
}
}
if
(
!
path
)
{
if
(
!
path
)
{
errno
=
ENOTTY
;
errno
=
ENOTTY
;
DEBUG
(
"process does not have a controlling terminal"
);
DEBUG
(
"
Theh
process does not have a controlling terminal"
);
goto
o
ut
;
goto
o
n_succes
;
}
}
terminal
->
peer
=
lxc_unpriv
(
open
(
path
,
O_RDWR
|
O_CLOEXEC
));
terminal
->
peer
=
lxc_unpriv
(
open
(
path
,
O_RDWR
|
O_CLOEXEC
));
if
(
terminal
->
peer
<
0
)
{
if
(
terminal
->
peer
<
0
)
{
ERROR
(
"Failed to open
\"
%s
\"
: %s"
,
path
,
strerror
(
errno
));
ERROR
(
"%s - Failed to open proxy terminal
\"
%s
\"
"
,
strerror
(
errno
),
path
);
return
-
ENOTTY
;
return
-
ENOTTY
;
}
}
DEBUG
(
"
using
\"
%s
\"
as peer tty device
"
,
path
);
DEBUG
(
"
Using terminal
\"
%s
\"
as proxy
"
,
path
);
if
(
!
isatty
(
terminal
->
peer
))
{
if
(
!
isatty
(
terminal
->
peer
))
{
ERROR
(
"
file descriptor for file
\"
%s
\"
does not refer to a tty device
"
,
path
);
ERROR
(
"
File descriptor for
\"
%s
\"
does not refer to a terminal
"
,
path
);
goto
on_error
1
;
goto
on_error
_free_tios
;
}
}
ts
=
lxc_terminal_signal_init
(
terminal
->
peer
,
terminal
->
master
);
ts
=
lxc_terminal_signal_init
(
terminal
->
peer
,
terminal
->
master
);
terminal
->
tty_state
=
ts
;
terminal
->
tty_state
=
ts
;
if
(
!
ts
)
{
if
(
!
ts
)
{
WARN
(
"Failed to install signal handler"
);
WARN
(
"Failed to install signal handler"
);
goto
on_error
1
;
goto
on_error
_free_tios
;
}
}
lxc_terminal_winsz
(
terminal
->
peer
,
terminal
->
master
);
lxc_terminal_winsz
(
terminal
->
peer
,
terminal
->
master
);
terminal
->
tios
=
malloc
(
sizeof
(
*
terminal
->
tios
));
terminal
->
tios
=
malloc
(
sizeof
(
*
terminal
->
tios
));
if
(
!
terminal
->
tios
)
{
if
(
!
terminal
->
tios
)
SYSERROR
(
"failed to allocate memory"
);
goto
on_error_free_tios
;
goto
on_error1
;
}
if
(
lxc_setup_tios
(
terminal
->
peer
,
terminal
->
tios
)
<
0
)
ret
=
lxc_setup_tios
(
terminal
->
peer
,
terminal
->
tios
);
goto
on_error2
;
if
(
ret
<
0
)
goto
on_error_close_peer
;
else
else
goto
o
ut
;
goto
o
n_succes
;
on_error
2
:
on_error
_free_tios
:
free
(
terminal
->
tios
);
free
(
terminal
->
tios
);
terminal
->
tios
=
NULL
;
terminal
->
tios
=
NULL
;
on_error
1
:
on_error
_close_peer
:
close
(
terminal
->
peer
);
close
(
terminal
->
peer
);
terminal
->
peer
=
-
1
;
terminal
->
peer
=
-
1
;
ret
=
-
ENOTTY
;
ret
=
-
ENOTTY
;
o
ut
:
o
n_succes
:
return
ret
;
return
ret
;
}
}
...
...
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