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
db609dff
Unverified
Commit
db609dff
authored
Dec 23, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
console: move pty creation to separate function
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
e2b02308
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
17 deletions
+54
-17
console.c
src/lxc/console.c
+48
-17
console.h
src/lxc/console.h
+6
-0
No files found.
src/lxc/console.c
View file @
db609dff
...
@@ -576,24 +576,32 @@ void lxc_console_delete(struct lxc_console *console)
...
@@ -576,24 +576,32 @@ void lxc_console_delete(struct lxc_console *console)
console
->
log_fd
=
-
1
;
console
->
log_fd
=
-
1
;
}
}
int
lxc_console_create
(
struct
lxc_conf
*
conf
)
/**
* This is the console log file. Please note that the console log file is
* (implementation wise not content wise) independent of the console ringbuffer.
*/
int
lxc_console_create_log_file
(
struct
lxc_console
*
console
)
{
{
int
ret
,
saved_errno
;
if
(
!
console
->
log_path
)
struct
lxc_console
*
console
=
&
conf
->
console
;
if
(
!
conf
->
rootfs
.
path
)
{
INFO
(
"Container does not have a rootfs. The console will be "
"shared with the host"
);
return
0
;
return
0
;
console
->
log_fd
=
lxc_unpriv
(
open
(
console
->
log_path
,
O_CLOEXEC
|
O_RDWR
|
O_CREAT
|
O_APPEND
,
0600
));
if
(
console
->
log_fd
<
0
)
{
SYSERROR
(
"Failed to open console log file
\"
%s
\"
"
,
console
->
log_path
);
return
-
1
;
}
}
if
(
console
->
path
&&
!
strcmp
(
console
->
path
,
"none"
))
{
DEBUG
(
"Using
\"
%s
\"
as console log file"
,
console
->
log_path
);
INFO
(
"No console was requested"
);
return
0
;
return
0
;
}
}
int
lxc_pty_create
(
struct
lxc_console
*
console
)
{
int
ret
,
saved_errno
;
process_lock
();
process_lock
();
ret
=
openpty
(
&
console
->
master
,
&
console
->
slave
,
console
->
name
,
NULL
,
NULL
);
ret
=
openpty
(
&
console
->
master
,
&
console
->
slave
,
console
->
name
,
NULL
,
NULL
);
saved_errno
=
errno
;
saved_errno
=
errno
;
process_unlock
();
process_unlock
();
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
...
@@ -619,15 +627,38 @@ int lxc_console_create(struct lxc_conf *conf)
...
@@ -619,15 +627,38 @@ int lxc_console_create(struct lxc_conf *conf)
goto
err
;
goto
err
;
}
}
if
(
console
->
log_path
)
{
return
0
;
console
->
log_fd
=
lxc_unpriv
(
open
(
console
->
log_path
,
O_CLOEXEC
|
O_RDWR
|
O_CREAT
|
O_APPEND
,
0600
));
if
(
console
->
log_fd
<
0
)
{
err
:
SYSERROR
(
"Failed to open console log file
\"
%s
\"
"
,
console
->
log_path
);
lxc_console_delete
(
console
);
goto
err
;
return
-
ENODEV
;
}
int
lxc_console_create
(
struct
lxc_conf
*
conf
)
{
int
ret
;
struct
lxc_console
*
console
=
&
conf
->
console
;
if
(
!
conf
->
rootfs
.
path
)
{
INFO
(
"Container does not have a rootfs. The console will be "
"shared with the host"
);
return
0
;
}
}
DEBUG
(
"Using
\"
%s
\"
as console log file"
,
console
->
log_path
);
if
(
console
->
path
&&
!
strcmp
(
console
->
path
,
"none"
))
{
INFO
(
"No console was requested"
);
return
0
;
}
}
ret
=
lxc_pty_create
(
console
);
if
(
ret
<
0
)
return
-
1
;
/* create console log file */
ret
=
lxc_console_create_log_file
(
console
);
if
(
ret
<
0
)
goto
err
;
return
0
;
return
0
;
err
:
err
:
...
...
src/lxc/console.h
View file @
db609dff
...
@@ -82,6 +82,12 @@ extern int lxc_console_allocate(struct lxc_conf *conf, int sockfd, int *ttynum)
...
@@ -82,6 +82,12 @@ extern int lxc_console_allocate(struct lxc_conf *conf, int sockfd, int *ttynum)
* automatically chowned to the uid/gid of the unprivileged user. For this
* automatically chowned to the uid/gid of the unprivileged user. For this
* ttys_shift_ids() can be called.)
* ttys_shift_ids() can be called.)
*/
*/
extern
int
lxc_pty_create
(
struct
lxc_console
*
console
);
/**
* lxc_console_create: Create a new pty.
* - In addition to lxc_pty_create() also sets up all pty logs.
*/
extern
int
lxc_console_create
(
struct
lxc_conf
*
);
extern
int
lxc_console_create
(
struct
lxc_conf
*
);
/*
/*
...
...
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