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
8e534be6
Unverified
Commit
8e534be6
authored
Dec 24, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attach: minor tweaks
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
dcb579a2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
22 deletions
+26
-22
attach.c
src/lxc/attach.c
+26
-22
No files found.
src/lxc/attach.c
View file @
8e534be6
...
...
@@ -252,10 +252,16 @@ static inline void lxc_proc_close_ns_fd(struct lxc_proc_context_info *ctx)
static
void
lxc_proc_put_context_info
(
struct
lxc_proc_context_info
*
ctx
)
{
free
(
ctx
->
lsm_label
);
if
(
ctx
->
container
)
ctx
->
lsm_label
=
NULL
;
if
(
ctx
->
container
)
{
lxc_container_put
(
ctx
->
container
);
ctx
->
container
=
NULL
;
}
lxc_proc_close_ns_fd
(
ctx
);
free
(
ctx
);
ctx
=
NULL
;
}
/**
...
...
@@ -855,6 +861,12 @@ static int attach_child_main(struct attach_clone_payload *payload)
TRACE
(
"Received LSM label file descriptor %d from parent"
,
lsm_fd
);
}
if
(
options
->
stdin_fd
>
0
&&
isatty
(
options
->
stdin_fd
))
{
ret
=
lxc_make_controlling_pty
(
options
->
stdin_fd
);
if
(
ret
<
0
)
goto
on_error
;
}
/* Set {u,g}id. */
new_uid
=
0
;
new_gid
=
0
;
...
...
@@ -869,18 +881,6 @@ static int attach_child_main(struct attach_clone_payload *payload)
if
(
options
->
gid
!=
(
gid_t
)
-
1
)
new_gid
=
options
->
gid
;
if
(
options
->
stdin_fd
&&
isatty
(
options
->
stdin_fd
))
{
ret
=
setsid
();
if
(
ret
<
0
)
goto
on_error
;
TRACE
(
"Became session leader"
);
ret
=
ioctl
(
options
->
stdin_fd
,
TIOCSCTTY
,
(
char
*
)
NULL
);
if
(
ret
<
0
)
goto
on_error
;
TRACE
(
"Set controlling terminal"
);
}
/* Try to set the {u,g}id combination. */
if
(
new_uid
!=
0
||
new_gid
!=
0
||
options
->
namespaces
&
CLONE_NEWUSER
)
{
ret
=
lxc_switch_uid_gid
(
new_uid
,
new_gid
);
...
...
@@ -924,19 +924,23 @@ static int attach_child_main(struct attach_clone_payload *payload)
/* Fd handling for stdin, stdout and stderr; ignore errors here, user
* may want to make sure the fds are closed, for example.
*/
if
(
options
->
stdin_fd
>=
0
&&
options
->
stdin_fd
!=
0
)
dup2
(
options
->
stdin_fd
,
0
);
if
(
options
->
stdout_fd
>=
0
&&
options
->
stdout_fd
!=
1
)
dup2
(
options
->
stdout_fd
,
1
);
if
(
options
->
stderr_fd
>=
0
&&
options
->
stderr_fd
!=
2
)
dup2
(
options
->
stderr_fd
,
2
);
if
(
options
->
stdin_fd
>=
0
&&
options
->
stdin_fd
!=
STDIN_FILENO
)
dup2
(
options
->
stdin_fd
,
STDIN_FILENO
);
if
(
options
->
stdout_fd
>=
0
&&
options
->
stdout_fd
!=
STDOUT_FILENO
)
dup2
(
options
->
stdout_fd
,
STDOUT_FILENO
);
if
(
options
->
stderr_fd
>=
0
&&
options
->
stderr_fd
!=
STDERR_FILENO
)
dup2
(
options
->
stderr_fd
,
STDERR_FILENO
);
/* close the old fds */
if
(
options
->
stdin_fd
>
2
)
if
(
options
->
stdin_fd
>
STDERR_FILENO
)
close
(
options
->
stdin_fd
);
if
(
options
->
stdout_fd
>
2
)
if
(
options
->
stdout_fd
>
STDERR_FILENO
)
close
(
options
->
stdout_fd
);
if
(
options
->
stderr_fd
>
2
)
if
(
options
->
stderr_fd
>
STDERR_FILENO
)
close
(
options
->
stderr_fd
);
/* Try to remove FD_CLOEXEC flag from stdin/stdout/stderr, but also
...
...
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