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
60dd8ef4
Unverified
Commit
60dd8ef4
authored
Feb 28, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
terminal: lxc_terminal_peer_proxy_alloc()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
e788f4ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
14 deletions
+19
-14
terminal.c
src/lxc/terminal.c
+19
-14
No files found.
src/lxc/terminal.c
View file @
60dd8ef4
...
@@ -542,53 +542,58 @@ static void lxc_terminal_peer_proxy_free(struct lxc_terminal *terminal)
...
@@ -542,53 +542,58 @@ static void lxc_terminal_peer_proxy_free(struct lxc_terminal *terminal)
terminal
->
peer
=
-
1
;
terminal
->
peer
=
-
1
;
}
}
static
int
lxc_terminal_peer_proxy_alloc
(
struct
lxc_terminal
*
terminal
,
int
sockfd
)
static
int
lxc_terminal_peer_proxy_alloc
(
struct
lxc_terminal
*
terminal
,
int
sockfd
)
{
{
int
ret
;
struct
termios
oldtermio
;
struct
termios
oldtermio
;
struct
lxc_terminal_state
*
ts
;
struct
lxc_terminal_state
*
ts
;
int
ret
;
if
(
terminal
->
master
<
0
)
{
if
(
terminal
->
master
<
0
)
{
ERROR
(
"Terminal not set up"
);
ERROR
(
"Terminal not set up"
);
return
-
1
;
return
-
1
;
}
}
if
(
terminal
->
proxy
.
busy
!=
-
1
||
terminal
->
peer
!=
-
1
)
{
if
(
terminal
->
proxy
.
busy
!=
-
1
||
terminal
->
peer
!=
-
1
)
{
NOTICE
(
"Terminal already in use"
);
NOTICE
(
"Terminal already in use"
);
return
-
1
;
return
-
1
;
}
}
if
(
terminal
->
tty_state
)
{
if
(
terminal
->
tty_state
)
{
ERROR
(
"Terminal
already has tty_state
"
);
ERROR
(
"Terminal
has already been initialized
"
);
return
-
1
;
return
-
1
;
}
}
/*
t
his is the proxy pty that will be given to the client, and that
/*
T
his is the proxy pty that will be given to the client, and that
* the real pty master will send to / recv from
* the real pty master will send to / recv from
.
*/
*/
ret
=
openpty
(
&
terminal
->
proxy
.
master
,
&
terminal
->
proxy
.
slave
,
ret
=
openpty
(
&
terminal
->
proxy
.
master
,
&
terminal
->
proxy
.
slave
,
terminal
->
proxy
.
name
,
NULL
,
NULL
);
terminal
->
proxy
.
name
,
NULL
,
NULL
);
if
(
ret
)
{
if
(
ret
<
0
)
{
SYSERROR
(
"
failed to create proxy pty
"
);
SYSERROR
(
"
Failed to open proxy terminal
"
);
return
-
1
;
return
-
1
;
}
}
if
(
lxc_setup_tios
(
terminal
->
proxy
.
slave
,
&
oldtermio
)
<
0
)
ret
=
lxc_setup_tios
(
terminal
->
proxy
.
slave
,
&
oldtermio
);
goto
err1
;
if
(
ret
<
0
)
goto
on_error
;
ts
=
lxc_terminal_signal_init
(
terminal
->
proxy
.
master
,
terminal
->
master
);
ts
=
lxc_terminal_signal_init
(
terminal
->
proxy
.
master
,
terminal
->
master
);
if
(
!
ts
)
if
(
!
ts
)
goto
err1
;
goto
on_error
;
terminal
->
tty_state
=
ts
;
terminal
->
tty_state
=
ts
;
terminal
->
peer
=
terminal
->
proxy
.
slave
;
terminal
->
peer
=
terminal
->
proxy
.
slave
;
terminal
->
proxy
.
busy
=
sockfd
;
terminal
->
proxy
.
busy
=
sockfd
;
ret
=
lxc_terminal_mainloop_add_peer
(
terminal
);
ret
=
lxc_terminal_mainloop_add_peer
(
terminal
);
if
(
ret
<
0
)
if
(
ret
<
0
)
goto
err1
;
goto
on_error
;
DEBUG
(
"%d peermaster:%d sockfd:%d"
,
lxc_raw_getpid
(),
terminal
->
proxy
.
master
,
sockfd
);
NOTICE
(
"Opened proxy terminal with master fd %d and slave fd %d"
,
terminal
->
proxy
.
master
,
terminal
->
proxy
.
slave
);
return
0
;
return
0
;
err1
:
on_error
:
lxc_terminal_peer_proxy_free
(
terminal
);
lxc_terminal_peer_proxy_free
(
terminal
);
return
-
1
;
return
-
1
;
}
}
...
...
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