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
69629c82
Unverified
Commit
69629c82
authored
Oct 23, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
console: non-functional changes
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
191d43cc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
16 deletions
+23
-16
console.c
src/lxc/console.c
+23
-16
No files found.
src/lxc/console.c
View file @
69629c82
...
...
@@ -514,9 +514,13 @@ out:
void
lxc_console_delete
(
struct
lxc_console
*
console
)
{
if
(
console
->
tios
&&
console
->
peer
>=
0
&&
tcsetattr
(
console
->
peer
,
TCSAFLUSH
,
console
->
tios
))
WARN
(
"failed to set old terminal settings"
);
int
ret
;
if
(
console
->
tios
&&
console
->
peer
>=
0
)
{
ret
=
tcsetattr
(
console
->
peer
,
TCSAFLUSH
,
console
->
tios
);
if
(
ret
<
0
)
WARN
(
"%s - Failed to set old terminal settings"
,
strerror
(
errno
));
}
free
(
console
->
tios
);
console
->
tios
=
NULL
;
...
...
@@ -525,7 +529,6 @@ void lxc_console_delete(struct lxc_console *console)
close
(
console
->
slave
);
if
(
console
->
log_fd
>=
0
)
close
(
console
->
log_fd
);
console
->
peer
=
-
1
;
console
->
master
=
-
1
;
console
->
slave
=
-
1
;
...
...
@@ -534,57 +537,61 @@ void lxc_console_delete(struct lxc_console *console)
int
lxc_console_create
(
struct
lxc_conf
*
conf
)
{
int
ret
,
saved_errno
;
struct
lxc_console
*
console
=
&
conf
->
console
;
int
ret
;
if
(
!
conf
->
rootfs
.
path
)
{
INFO
(
"container does not have a rootfs, console device will be shared with the host"
);
INFO
(
"Container does not have a rootfs. The console will be "
"shared with the host"
);
return
0
;
}
if
(
console
->
path
&&
!
strcmp
(
console
->
path
,
"none"
))
{
INFO
(
"
no console
requested"
);
INFO
(
"
No console was
requested"
);
return
0
;
}
process_lock
();
ret
=
openpty
(
&
console
->
master
,
&
console
->
slave
,
console
->
name
,
NULL
,
NULL
);
saved_errno
=
errno
;
process_unlock
();
if
(
ret
<
0
)
{
SYSERROR
(
"failed to allocate a pty"
);
ERROR
(
"%s - Failed to allocate a pty"
,
strerror
(
saved_errno
)
);
return
-
1
;
}
if
(
fcntl
(
console
->
master
,
F_SETFD
,
FD_CLOEXEC
))
{
SYSERROR
(
"failed to set console master to close-on-exec"
);
ret
=
fcntl
(
console
->
master
,
F_SETFD
,
FD_CLOEXEC
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to set FD_CLOEXEC flag on console master"
);
goto
err
;
}
if
(
fcntl
(
console
->
slave
,
F_SETFD
,
FD_CLOEXEC
))
{
SYSERROR
(
"failed to set console slave to close-on-exec"
);
ret
=
fcntl
(
console
->
slave
,
F_SETFD
,
FD_CLOEXEC
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to set FD_CLOEXEC flag on console slave"
);
goto
err
;
}
ret
=
lxc_console_peer_default
(
console
);
if
(
ret
<
0
)
{
ERROR
(
"
failed to allocate peer t
ty device"
);
ERROR
(
"
Failed to allocate a peer p
ty device"
);
goto
err
;
}
if
(
console
->
log_path
)
{
console
->
log_fd
=
lxc_unpriv
(
open
(
console
->
log_path
,
O_CLOEXEC
|
O_RDWR
|
O_CREAT
|
O_APPEND
,
0600
));
if
(
console
->
log_fd
<
0
)
{
SYSERROR
(
"
f
ailed to open console log file
\"
%s
\"
"
,
console
->
log_path
);
SYSERROR
(
"
F
ailed to open console log file
\"
%s
\"
"
,
console
->
log_path
);
goto
err
;
}
DEBUG
(
"
u
sing
\"
%s
\"
as console log file"
,
console
->
log_path
);
DEBUG
(
"
U
sing
\"
%s
\"
as console log file"
,
console
->
log_path
);
}
return
0
;
err
:
lxc_console_delete
(
console
);
return
-
1
;
return
-
ENODEV
;
}
int
lxc_console_set_stdfds
(
int
fd
)
...
...
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