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
eed7e917
Unverified
Commit
eed7e917
authored
Jul 05, 2020
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tree-wide: s/pts/pty/g
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
2be8b365
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
91 additions
and
91 deletions
+91
-91
lxc.container.conf.sgml.in
doc/ja/lxc.container.conf.sgml.in
+2
-2
lxc.container.conf.sgml.in
doc/ko/lxc.container.conf.sgml.in
+1
-1
lxc.container.conf.sgml.in
doc/lxc.container.conf.sgml.in
+1
-1
openpty.c
src/include/openpty.c
+7
-7
openpty.h
src/include/openpty.h
+1
-1
attach.c
src/lxc/attach.c
+2
-2
conf.c
src/lxc/conf.c
+35
-35
criu.c
src/lxc/criu.c
+2
-2
start.c
src/lxc/start.c
+7
-7
terminal.c
src/lxc/terminal.c
+25
-25
terminal.h
src/lxc/terminal.h
+8
-8
No files found.
doc/ja/lxc.container.conf.sgml.in
View file @
eed7e917
...
...
@@ -1144,11 +1144,11 @@ by KATOH Yasufumi <karma at jazz.email.ne.jp>
<!--
If set, the container will have a new pseudo tty
instance, making this private to it. The value specifies
the maximum number of pseudo ttys allowed for a pt
s
the maximum number of pseudo ttys allowed for a pt
y
instance (this limitation is not implemented yet).
-->
もし設定された場合、コンテナは新しい pseudo tty インスタンスを持ち、それを自身のプライベートとします。
この値は pt
s
インスタンスに許可される pseudo tty の最大数を指定します (この制限はまだ実装されていません)。
この値は pt
y
インスタンスに許可される pseudo tty の最大数を指定します (この制限はまだ実装されていません)。
</para>
</listitem>
</varlistentry>
...
...
doc/ko/lxc.container.conf.sgml.in
View file @
eed7e917
...
...
@@ -844,7 +844,7 @@ by Sungbae Yoo <sungbae.yoo at samsung.com>
<!--
If set, the container will have a new pseudo tty
instance, making this private to it. The value specifies
the maximum number of pseudo ttys allowed for a pt
s
the maximum number of pseudo ttys allowed for a pt
y
instance (this limitation is not implemented yet).
-->
만약 지정되었다면, 컨테이너는 새 pseudo tty 인스턴스를 갖는다. 그리고 이것을 자기자신 전용으로 만든다. 지정하는 값은 pseudo tty의 최대 개수를 지정한다. (이 제한은 아직 구현되지 않았다)
...
...
doc/lxc.container.conf.sgml.in
View file @
eed7e917
...
...
@@ -867,7 +867,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
<para>
If set, the container will have a new pseudo tty
instance, making this private to it. The value specifies
the maximum number of pseudo ttys allowed for a pt
s
the maximum number of pseudo ttys allowed for a pt
y
instance (this limitation is not implemented yet).
</para>
</listitem>
...
...
src/include/openpty.c
View file @
eed7e917
...
...
@@ -38,7 +38,7 @@ int openpty (int *aptx, int *apts, char *name, struct termios *termp,
struct
winsize
*
winp
)
{
char
buf
[
PATH_MAX
];
int
ptx
,
pt
s
;
int
ptx
,
pt
y
;
ptx
=
open
(
_PATH_DEVPTMX
,
O_RDWR
);
if
(
ptx
==
-
1
)
...
...
@@ -50,21 +50,21 @@ int openpty (int *aptx, int *apts, char *name, struct termios *termp,
if
(
unlockpt
(
ptx
))
goto
fail
;
if
(
pt
s
name_r
(
ptx
,
buf
,
sizeof
buf
))
if
(
pt
y
name_r
(
ptx
,
buf
,
sizeof
buf
))
goto
fail
;
pt
s
=
open
(
buf
,
O_RDWR
|
O_NOCTTY
);
if
(
pt
s
==
-
1
)
pt
y
=
open
(
buf
,
O_RDWR
|
O_NOCTTY
);
if
(
pt
y
==
-
1
)
goto
fail
;
/* XXX Should we ignore errors here? */
if
(
termp
)
tcsetattr
(
pt
s
,
TCSAFLUSH
,
termp
);
tcsetattr
(
pt
y
,
TCSAFLUSH
,
termp
);
if
(
winp
)
ioctl
(
pt
s
,
TIOCSWINSZ
,
winp
);
ioctl
(
pt
y
,
TIOCSWINSZ
,
winp
);
*
aptx
=
ptx
;
*
apts
=
pt
s
;
*
apts
=
pt
y
;
if
(
name
!=
NULL
)
strcpy
(
name
,
buf
);
...
...
src/include/openpty.h
View file @
eed7e917
...
...
@@ -28,7 +28,7 @@
#include <sys/ioctl.h>
/*
* Create pseudo tty ptx pt
s
pair with @__name and set terminal
* Create pseudo tty ptx pt
y
pair with @__name and set terminal
* attributes according to @__termp and @__winp and return handles for both
* ends in @__aptx and @__apts.
*/
...
...
src/lxc/attach.c
View file @
eed7e917
...
...
@@ -939,7 +939,7 @@ static inline void lxc_attach_terminal_close_ptx(struct lxc_terminal *terminal)
static
inline
void
lxc_attach_terminal_close_pts
(
struct
lxc_terminal
*
terminal
)
{
close_prot_errno_disarm
(
terminal
->
pt
s
);
close_prot_errno_disarm
(
terminal
->
pt
y
);
}
static
inline
void
lxc_attach_terminal_close_peer
(
struct
lxc_terminal
*
terminal
)
...
...
@@ -1377,7 +1377,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
payload
.
ipc_socket
=
ipc_sockets
[
1
];
payload
.
options
=
options
;
payload
.
init_ctx
=
init_ctx
;
payload
.
terminal_pts_fd
=
terminal
.
pt
s
;
payload
.
terminal_pts_fd
=
terminal
.
pt
y
;
payload
.
exec_function
=
exec_function
;
payload
.
exec_payload
=
exec_payload
;
...
...
src/lxc/conf.c
View file @
eed7e917
...
...
@@ -922,21 +922,21 @@ int lxc_allocate_ttys(struct lxc_conf *conf)
struct
lxc_terminal_info
*
tty
=
&
ttys
->
tty
[
i
];
tty
->
ptx
=
-
EBADF
;
tty
->
pt
s
=
-
EBADF
;
ret
=
openpty
(
&
tty
->
ptx
,
&
tty
->
pt
s
,
NULL
,
NULL
,
NULL
);
tty
->
pt
y
=
-
EBADF
;
ret
=
openpty
(
&
tty
->
ptx
,
&
tty
->
pt
y
,
NULL
,
NULL
,
NULL
);
if
(
ret
<
0
)
{
ttys
->
max
=
i
;
return
log_error_errno
(
-
ENOTTY
,
ENOTTY
,
"Failed to create tty %zu"
,
i
);
}
ret
=
ttyname_r
(
tty
->
pt
s
,
tty
->
name
,
sizeof
(
tty
->
name
));
ret
=
ttyname_r
(
tty
->
pt
y
,
tty
->
name
,
sizeof
(
tty
->
name
));
if
(
ret
<
0
)
{
ttys
->
max
=
i
;
return
log_error_errno
(
-
ENOTTY
,
ENOTTY
,
"Failed to retrieve name of tty %zu pt
s
"
,
i
);
return
log_error_errno
(
-
ENOTTY
,
ENOTTY
,
"Failed to retrieve name of tty %zu pt
y
"
,
i
);
}
DEBUG
(
"Created tty
\"
%s
\"
with ptx fd %d and pt
s
fd %d"
,
tty
->
name
,
tty
->
ptx
,
tty
->
pt
s
);
DEBUG
(
"Created tty
\"
%s
\"
with ptx fd %d and pt
y
fd %d"
,
tty
->
name
,
tty
->
ptx
,
tty
->
pt
y
);
/* Prevent leaking the file descriptors to the container */
ret
=
fd_cloexec
(
tty
->
ptx
,
true
);
...
...
@@ -944,10 +944,10 @@ int lxc_allocate_ttys(struct lxc_conf *conf)
SYSWARN
(
"Failed to set FD_CLOEXEC flag on ptx fd %d of tty device
\"
%s
\"
"
,
tty
->
ptx
,
tty
->
name
);
ret
=
fd_cloexec
(
tty
->
pt
s
,
true
);
ret
=
fd_cloexec
(
tty
->
pt
y
,
true
);
if
(
ret
<
0
)
SYSWARN
(
"Failed to set FD_CLOEXEC flag on pt
s
fd %d of tty device
\"
%s
\"
"
,
tty
->
pt
s
,
tty
->
name
);
SYSWARN
(
"Failed to set FD_CLOEXEC flag on pt
y
fd %d of tty device
\"
%s
\"
"
,
tty
->
pt
y
,
tty
->
name
);
tty
->
busy
=
-
1
;
}
...
...
@@ -965,7 +965,7 @@ void lxc_delete_tty(struct lxc_tty_info *ttys)
for
(
int
i
=
0
;
i
<
ttys
->
max
;
i
++
)
{
struct
lxc_terminal_info
*
tty
=
&
ttys
->
tty
[
i
];
close_prot_errno_disarm
(
tty
->
ptx
);
close_prot_errno_disarm
(
tty
->
pt
s
);
close_prot_errno_disarm
(
tty
->
pt
y
);
}
free_disarm
(
ttys
->
tty
);
...
...
@@ -987,14 +987,14 @@ static int lxc_send_ttys_to_parent(struct lxc_handler *handler)
struct
lxc_terminal_info
*
tty
=
&
ttys
->
tty
[
i
];
ttyfds
[
0
]
=
tty
->
ptx
;
ttyfds
[
1
]
=
tty
->
pt
s
;
ttyfds
[
1
]
=
tty
->
pt
y
;
ret
=
lxc_abstract_unix_send_fds
(
sock
,
ttyfds
,
2
,
NULL
,
0
);
if
(
ret
<
0
)
break
;
TRACE
(
"Sent tty
\"
%s
\"
with ptx fd %d and pt
s
fd %d to parent"
,
tty
->
name
,
tty
->
ptx
,
tty
->
pt
s
);
TRACE
(
"Sent tty
\"
%s
\"
with ptx fd %d and pt
y
fd %d to parent"
,
tty
->
name
,
tty
->
ptx
,
tty
->
pt
y
);
}
if
(
ret
<
0
)
...
...
@@ -1582,7 +1582,7 @@ static inline bool wants_console(const struct lxc_terminal *terminal)
static
int
lxc_setup_dev_console
(
const
struct
lxc_rootfs
*
rootfs
,
const
struct
lxc_terminal
*
console
,
int
pt
s
_mnt_fd
)
int
pt
y
_mnt_fd
)
{
int
ret
;
char
path
[
PATH_MAX
];
...
...
@@ -1615,12 +1615,12 @@ static int lxc_setup_dev_console(const struct lxc_rootfs *rootfs,
if
(
ret
<
0
&&
errno
!=
EEXIST
)
return
log_error_errno
(
-
errno
,
errno
,
"Failed to create console"
);
ret
=
fchmod
(
console
->
pt
s
,
S_IXUSR
|
S_IXGRP
);
ret
=
fchmod
(
console
->
pt
y
,
S_IXUSR
|
S_IXGRP
);
if
(
ret
<
0
)
return
log_error_errno
(
-
errno
,
errno
,
"Failed to set mode
\"
0%o
\"
to
\"
%s
\"
"
,
S_IXUSR
|
S_IXGRP
,
console
->
name
);
if
(
pt
s
_mnt_fd
>=
0
)
{
ret
=
move_mount
(
pt
s
_mnt_fd
,
""
,
-
EBADF
,
path
,
MOVE_MOUNT_F_EMPTY_PATH
);
if
(
pt
y
_mnt_fd
>=
0
)
{
ret
=
move_mount
(
pt
y
_mnt_fd
,
""
,
-
EBADF
,
path
,
MOVE_MOUNT_F_EMPTY_PATH
);
if
(
!
ret
)
{
DEBUG
(
"Moved mount
\"
%s
\"
onto
\"
%s
\"
"
,
console
->
name
,
path
);
goto
finish
;
...
...
@@ -1629,21 +1629,21 @@ static int lxc_setup_dev_console(const struct lxc_rootfs *rootfs,
if
(
ret
&&
errno
!=
ENOSYS
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to mount %d(%s) on
\"
%s
\"
"
,
pt
s
_mnt_fd
,
console
->
name
,
path
);
pt
y
_mnt_fd
,
console
->
name
,
path
);
}
ret
=
safe_mount
(
console
->
name
,
path
,
"none"
,
MS_BIND
,
0
,
rootfs_path
);
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to mount %d(%s) on
\"
%s
\"
"
,
pt
s
_mnt_fd
,
console
->
name
,
path
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to mount %d(%s) on
\"
%s
\"
"
,
pt
y
_mnt_fd
,
console
->
name
,
path
);
finish:
DEBUG
(
"Mounted pt
s device %d(%s) onto
\"
%s
\"
"
,
pts
_mnt_fd
,
console
->
name
,
path
);
DEBUG
(
"Mounted pt
y device %d(%s) onto
\"
%s
\"
"
,
pty
_mnt_fd
,
console
->
name
,
path
);
return
0
;
}
static
int
lxc_setup_ttydir_console
(
const
struct
lxc_rootfs
*
rootfs
,
const
struct
lxc_terminal
*
console
,
char
*
ttydir
,
int
pt
s
_mnt_fd
)
char
*
ttydir
,
int
pt
y
_mnt_fd
)
{
int
ret
;
char
path
[
PATH_MAX
],
lxcpath
[
PATH_MAX
];
...
...
@@ -1686,13 +1686,13 @@ static int lxc_setup_ttydir_console(const struct lxc_rootfs *rootfs,
if
(
ret
<
0
&&
errno
!=
EEXIST
)
return
log_error_errno
(
-
errno
,
errno
,
"Failed to create console"
);
ret
=
fchmod
(
console
->
pt
s
,
S_IXUSR
|
S_IXGRP
);
ret
=
fchmod
(
console
->
pt
y
,
S_IXUSR
|
S_IXGRP
);
if
(
ret
<
0
)
return
log_error_errno
(
-
errno
,
errno
,
"Failed to set mode
\"
0%o
\"
to
\"
%s
\"
"
,
S_IXUSR
|
S_IXGRP
,
console
->
name
);
/* bind mount console->name to '/dev/<ttydir>/console' */
if
(
pt
s
_mnt_fd
>=
0
)
{
ret
=
move_mount
(
pt
s
_mnt_fd
,
""
,
-
EBADF
,
lxcpath
,
MOVE_MOUNT_F_EMPTY_PATH
);
if
(
pt
y
_mnt_fd
>=
0
)
{
ret
=
move_mount
(
pt
y
_mnt_fd
,
""
,
-
EBADF
,
lxcpath
,
MOVE_MOUNT_F_EMPTY_PATH
);
if
(
!
ret
)
{
DEBUG
(
"Moved mount
\"
%s
\"
onto
\"
%s
\"
"
,
console
->
name
,
lxcpath
);
goto
finish
;
...
...
@@ -1701,12 +1701,12 @@ static int lxc_setup_ttydir_console(const struct lxc_rootfs *rootfs,
if
(
ret
&&
errno
!=
ENOSYS
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to mount %d(%s) on
\"
%s
\"
"
,
pt
s
_mnt_fd
,
console
->
name
,
lxcpath
);
pt
y
_mnt_fd
,
console
->
name
,
lxcpath
);
}
ret
=
safe_mount
(
console
->
name
,
lxcpath
,
"none"
,
MS_BIND
,
0
,
rootfs_path
);
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to mount %d(%s) on
\"
%s
\"
"
,
pt
s
_mnt_fd
,
console
->
name
,
lxcpath
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to mount %d(%s) on
\"
%s
\"
"
,
pt
y
_mnt_fd
,
console
->
name
,
lxcpath
);
DEBUG
(
"Mounted
\"
%s
\"
onto
\"
%s
\"
"
,
console
->
name
,
lxcpath
);
finish:
...
...
@@ -1722,13 +1722,13 @@ finish:
static
int
lxc_setup_console
(
const
struct
lxc_rootfs
*
rootfs
,
const
struct
lxc_terminal
*
console
,
char
*
ttydir
,
int
pt
s
_mnt_fd
)
int
pt
y
_mnt_fd
)
{
if
(
!
ttydir
)
return
lxc_setup_dev_console
(
rootfs
,
console
,
pt
s
_mnt_fd
);
return
lxc_setup_dev_console
(
rootfs
,
console
,
pt
y
_mnt_fd
);
return
lxc_setup_ttydir_console
(
rootfs
,
console
,
ttydir
,
pt
s
_mnt_fd
);
return
lxc_setup_ttydir_console
(
rootfs
,
console
,
ttydir
,
pt
y
_mnt_fd
);
}
static
int
parse_mntopt
(
char
*
opt
,
unsigned
long
*
flags
,
char
**
data
,
size_t
size
)
...
...
@@ -2547,9 +2547,9 @@ struct lxc_conf *lxc_conf_init(void)
new
->
console
.
peer
=
-
1
;
new
->
console
.
proxy
.
busy
=
-
1
;
new
->
console
.
proxy
.
ptx
=
-
1
;
new
->
console
.
proxy
.
pt
s
=
-
1
;
new
->
console
.
proxy
.
pt
y
=
-
1
;
new
->
console
.
ptx
=
-
1
;
new
->
console
.
pt
s
=
-
1
;
new
->
console
.
pt
y
=
-
1
;
new
->
console
.
name
[
0
]
=
'\0'
;
memset
(
&
new
->
console
.
ringbuf
,
0
,
sizeof
(
struct
lxc_ringbuf
));
new
->
maincmd_fd
=
-
1
;
...
...
@@ -3182,7 +3182,7 @@ static int lxc_setup_boot_id(void)
int
lxc_setup
(
struct
lxc_handler
*
handler
)
{
__do_close
int
pt
s
_mnt_fd
=
-
EBADF
;
__do_close
int
pt
y
_mnt_fd
=
-
EBADF
;
int
ret
;
const
char
*
lxcpath
=
handler
->
lxcpath
,
*
name
=
handler
->
name
;
struct
lxc_conf
*
lxc_conf
=
handler
->
conf
;
...
...
@@ -3222,9 +3222,9 @@ int lxc_setup(struct lxc_handler *handler)
}
if
(
wants_console
(
&
lxc_conf
->
console
))
{
pt
s
_mnt_fd
=
open_tree
(
-
EBADF
,
lxc_conf
->
console
.
name
,
pt
y
_mnt_fd
=
open_tree
(
-
EBADF
,
lxc_conf
->
console
.
name
,
OPEN_TREE_CLONE
|
OPEN_TREE_CLOEXEC
|
AT_EMPTY_PATH
);
if
(
pt
s
_mnt_fd
<
0
)
if
(
pt
y
_mnt_fd
<
0
)
SYSTRACE
(
"Failed to create detached mount for container's console
\"
%s
\"
"
,
lxc_conf
->
console
.
name
);
else
...
...
@@ -3309,7 +3309,7 @@ int lxc_setup(struct lxc_handler *handler)
return
log_error
(
-
1
,
"Failed to
\"
/proc
\"
LSMs"
);
ret
=
lxc_setup_console
(
&
lxc_conf
->
rootfs
,
&
lxc_conf
->
console
,
lxc_conf
->
ttys
.
dir
,
pt
s
_mnt_fd
);
lxc_conf
->
ttys
.
dir
,
pt
y
_mnt_fd
);
if
(
ret
<
0
)
return
log_error
(
-
1
,
"Failed to setup console"
);
...
...
src/lxc/criu.c
View file @
eed7e917
...
...
@@ -67,7 +67,7 @@ struct criu_opts {
struct
lxc_handler
*
handler
;
int
console_fd
;
/* The path that is bind mounted from /dev/console, if any. We don't
* want to use `--ext-mount-map auto`'s result here because the pt
s
* want to use `--ext-mount-map auto`'s result here because the pt
y
* device may have a different path (e.g. if the pty number is
* different) on the target host. NULL if lxc.console.path = "none".
*/
...
...
@@ -1020,7 +1020,7 @@ static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_
os
.
action
=
"restore"
;
os
.
user
=
opts
;
os
.
c
=
c
;
os
.
console_fd
=
c
->
lxc_conf
->
console
.
pt
s
;
os
.
console_fd
=
c
->
lxc_conf
->
console
.
pt
y
;
os
.
criu_version
=
criu_version
;
os
.
handler
=
handler
;
...
...
src/lxc/start.c
View file @
eed7e917
...
...
@@ -1248,14 +1248,14 @@ static int do_start(void *data)
* setup on its console ie. the pty allocated in lxc_terminal_setup() so
* make sure that that pty is stdin,stdout,stderr.
*/
if
(
handler
->
conf
->
console
.
pt
s
>=
0
)
{
if
(
handler
->
conf
->
console
.
pt
y
>=
0
)
{
if
(
handler
->
daemonize
||
!
handler
->
conf
->
is_execute
)
ret
=
set_stdfds
(
handler
->
conf
->
console
.
pt
s
);
ret
=
set_stdfds
(
handler
->
conf
->
console
.
pt
y
);
else
ret
=
lxc_terminal_set_stdfds
(
handler
->
conf
->
console
.
pt
s
);
ret
=
lxc_terminal_set_stdfds
(
handler
->
conf
->
console
.
pt
y
);
if
(
ret
<
0
)
{
ERROR
(
"Failed to redirect std{in,out,err} to pty file descriptor %d"
,
handler
->
conf
->
console
.
pt
s
);
handler
->
conf
->
console
.
pt
y
);
goto
out_warn_father
;
}
}
...
...
@@ -1282,7 +1282,7 @@ static int do_start(void *data)
close_prot_errno_disarm
(
handler
->
sigfd
);
if
(
handler
->
conf
->
console
.
pt
s
<
0
&&
handler
->
daemonize
)
{
if
(
handler
->
conf
->
console
.
pt
y
<
0
&&
handler
->
daemonize
)
{
if
(
devnull_fd
<
0
)
{
devnull_fd
=
open_devnull
();
if
(
devnull_fd
<
0
)
...
...
@@ -1435,8 +1435,8 @@ static int lxc_recv_ttys_from_child(struct lxc_handler *handler)
tty
=
&
ttys
->
tty
[
i
];
tty
->
busy
=
-
1
;
tty
->
ptx
=
ttyfds
[
0
];
tty
->
pt
s
=
ttyfds
[
1
];
TRACE
(
"Received pty with ptx fd %d and pt
s fd %d from child"
,
tty
->
ptx
,
tty
->
pts
);
tty
->
pt
y
=
ttyfds
[
1
];
TRACE
(
"Received pty with ptx fd %d and pt
y fd %d from child"
,
tty
->
ptx
,
tty
->
pty
);
}
if
(
ret
<
0
)
...
...
src/lxc/terminal.c
View file @
eed7e917
...
...
@@ -486,8 +486,8 @@ static void lxc_terminal_peer_proxy_free(struct lxc_terminal *terminal)
close
(
terminal
->
proxy
.
ptx
);
terminal
->
proxy
.
ptx
=
-
1
;
close
(
terminal
->
proxy
.
pt
s
);
terminal
->
proxy
.
pt
s
=
-
1
;
close
(
terminal
->
proxy
.
pt
y
);
terminal
->
proxy
.
pt
y
=
-
1
;
terminal
->
proxy
.
busy
=
-
1
;
...
...
@@ -521,17 +521,17 @@ static int lxc_terminal_peer_proxy_alloc(struct lxc_terminal *terminal,
/* This is the proxy terminal that will be given to the client, and
* that the real terminal ptx will send to / recv from.
*/
ret
=
openpty
(
&
terminal
->
proxy
.
ptx
,
&
terminal
->
proxy
.
pt
s
,
NULL
,
ret
=
openpty
(
&
terminal
->
proxy
.
ptx
,
&
terminal
->
proxy
.
pt
y
,
NULL
,
NULL
,
NULL
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to open proxy terminal"
);
return
-
1
;
}
ret
=
ttyname_r
(
terminal
->
proxy
.
pt
s
,
terminal
->
proxy
.
name
,
ret
=
ttyname_r
(
terminal
->
proxy
.
pt
y
,
terminal
->
proxy
.
name
,
sizeof
(
terminal
->
proxy
.
name
));
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to retrieve name of proxy terminal pt
s
"
);
SYSERROR
(
"Failed to retrieve name of proxy terminal pt
y
"
);
goto
on_error
;
}
...
...
@@ -541,13 +541,13 @@ static int lxc_terminal_peer_proxy_alloc(struct lxc_terminal *terminal,
goto
on_error
;
}
ret
=
fd_cloexec
(
terminal
->
proxy
.
pt
s
,
true
);
ret
=
fd_cloexec
(
terminal
->
proxy
.
pt
y
,
true
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to set FD_CLOEXEC flag on proxy terminal pt
s
"
);
SYSERROR
(
"Failed to set FD_CLOEXEC flag on proxy terminal pt
y
"
);
goto
on_error
;
}
ret
=
lxc_setup_tios
(
terminal
->
proxy
.
pt
s
,
&
oldtermio
);
ret
=
lxc_setup_tios
(
terminal
->
proxy
.
pt
y
,
&
oldtermio
);
if
(
ret
<
0
)
goto
on_error
;
...
...
@@ -556,14 +556,14 @@ static int lxc_terminal_peer_proxy_alloc(struct lxc_terminal *terminal,
goto
on_error
;
terminal
->
tty_state
=
ts
;
terminal
->
peer
=
terminal
->
proxy
.
pt
s
;
terminal
->
peer
=
terminal
->
proxy
.
pt
y
;
terminal
->
proxy
.
busy
=
sockfd
;
ret
=
lxc_terminal_mainloop_add_peer
(
terminal
);
if
(
ret
<
0
)
goto
on_error
;
NOTICE
(
"Opened proxy terminal with ptx fd %d and pt
s
fd %d"
,
terminal
->
proxy
.
ptx
,
terminal
->
proxy
.
pt
s
);
NOTICE
(
"Opened proxy terminal with ptx fd %d and pt
y
fd %d"
,
terminal
->
proxy
.
ptx
,
terminal
->
proxy
.
pt
y
);
return
0
;
on_error:
...
...
@@ -633,7 +633,7 @@ void lxc_terminal_free(struct lxc_conf *conf, int fd)
if
(
terminal
->
proxy
.
busy
!=
fd
)
return
;
lxc_mainloop_del_handler
(
terminal
->
descr
,
terminal
->
proxy
.
pt
s
);
lxc_mainloop_del_handler
(
terminal
->
descr
,
terminal
->
proxy
.
pt
y
);
lxc_terminal_peer_proxy_free
(
terminal
);
}
...
...
@@ -753,9 +753,9 @@ void lxc_terminal_delete(struct lxc_terminal *terminal)
close
(
terminal
->
ptx
);
terminal
->
ptx
=
-
1
;
if
(
terminal
->
pt
s
>=
0
)
close
(
terminal
->
pt
s
);
terminal
->
pt
s
=
-
1
;
if
(
terminal
->
pt
y
>=
0
)
close
(
terminal
->
pt
y
);
terminal
->
pt
y
=
-
1
;
if
(
terminal
->
log_fd
>=
0
)
close
(
terminal
->
log_fd
);
...
...
@@ -832,15 +832,15 @@ int lxc_terminal_create(struct lxc_terminal *terminal)
{
int
ret
;
ret
=
openpty
(
&
terminal
->
ptx
,
&
terminal
->
pt
s
,
NULL
,
NULL
,
NULL
);
ret
=
openpty
(
&
terminal
->
ptx
,
&
terminal
->
pt
y
,
NULL
,
NULL
,
NULL
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to open terminal"
);
return
-
1
;
}
ret
=
ttyname_r
(
terminal
->
pt
s
,
terminal
->
name
,
sizeof
(
terminal
->
name
));
ret
=
ttyname_r
(
terminal
->
pt
y
,
terminal
->
name
,
sizeof
(
terminal
->
name
));
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to retrieve name of terminal pt
s
"
);
SYSERROR
(
"Failed to retrieve name of terminal pt
y
"
);
goto
err
;
}
...
...
@@ -850,9 +850,9 @@ int lxc_terminal_create(struct lxc_terminal *terminal)
goto
err
;
}
ret
=
fd_cloexec
(
terminal
->
pt
s
,
true
);
ret
=
fd_cloexec
(
terminal
->
pt
y
,
true
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to set FD_CLOEXEC flag on terminal pt
s
"
);
SYSERROR
(
"Failed to set FD_CLOEXEC flag on terminal pt
y
"
);
goto
err
;
}
...
...
@@ -1134,14 +1134,14 @@ void lxc_terminal_info_init(struct lxc_terminal_info *terminal)
{
terminal
->
name
[
0
]
=
'\0'
;
terminal
->
ptx
=
-
EBADF
;
terminal
->
pt
s
=
-
EBADF
;
terminal
->
pt
y
=
-
EBADF
;
terminal
->
busy
=
-
1
;
}
void
lxc_terminal_init
(
struct
lxc_terminal
*
terminal
)
{
memset
(
terminal
,
0
,
sizeof
(
*
terminal
));
terminal
->
pt
s
=
-
EBADF
;
terminal
->
pt
y
=
-
EBADF
;
terminal
->
ptx
=
-
EBADF
;
terminal
->
peer
=
-
EBADF
;
terminal
->
log_fd
=
-
EBADF
;
...
...
@@ -1167,13 +1167,13 @@ int lxc_terminal_map_ids(struct lxc_conf *c, struct lxc_terminal *terminal)
if
(
strcmp
(
terminal
->
name
,
""
)
==
0
)
return
0
;
ret
=
userns_exec_mapped_root
(
terminal
->
name
,
terminal
->
pt
s
,
c
);
ret
=
userns_exec_mapped_root
(
terminal
->
name
,
terminal
->
pt
y
,
c
);
if
(
ret
<
0
)
{
return
log_error
(
-
1
,
"Failed to chown terminal %d(%s)"
,
terminal
->
pt
s
,
terminal
->
name
);
terminal
->
pt
y
,
terminal
->
name
);
}
TRACE
(
"Chowned terminal %d(%s)"
,
terminal
->
pt
s
,
terminal
->
name
);
TRACE
(
"Chowned terminal %d(%s)"
,
terminal
->
pt
y
,
terminal
->
name
);
return
0
;
}
src/lxc/terminal.h
View file @
eed7e917
...
...
@@ -15,14 +15,14 @@ struct lxc_conf;
struct
lxc_epoll_descr
;
struct
lxc_terminal_info
{
/* the path name of the pt
s
side */
/* the path name of the pt
y
side */
char
name
[
PATH_MAX
];
/* the file descriptor of the ptx */
int
ptx
;
/* the file descriptor of the pt
s
*/
int
pt
s
;
/* the file descriptor of the pt
y
*/
int
pt
y
;
/* whether the terminal is currently used */
int
busy
;
...
...
@@ -57,7 +57,7 @@ struct lxc_terminal_state {
};
struct
lxc_terminal
{
int
pt
s
;
int
pt
y
;
int
ptx
;
int
peer
;
struct
lxc_terminal_info
proxy
;
...
...
@@ -102,10 +102,10 @@ extern int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttynum
/**
* Create a new terminal:
* - calls openpty() to allocate a ptx/pt
s
pair
* - sets the FD_CLOEXEC flag on the ptx/pt
s
fds
* - calls openpty() to allocate a ptx/pt
y
pair
* - sets the FD_CLOEXEC flag on the ptx/pt
y
fds
* - allocates either the current controlling terminal (default) or a user
* specified terminal as proxy for the newly created ptx/pt
s
pair
* specified terminal as proxy for the newly created ptx/pt
y
pair
* - sets up SIGWINCH handler, winsz, and new terminal settings
* (Handlers for SIGWINCH and I/O are not registered in a mainloop.)
*/
...
...
@@ -202,7 +202,7 @@ extern int lxc_setup_tios(int fd, struct termios *oldtios);
* lxc_terminal_winsz: propagate winsz from one terminal to another
*
* @srcfd
* - terminal to get size from (typically a pt
s
pty)
* - terminal to get size from (typically a pt
y
pty)
* @dstfd
* - terminal to set size on (typically a ptx pty)
*/
...
...
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