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
a588a482
Unverified
Commit
a588a482
authored
Jan 29, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attach: move getcwd() into tighter scope
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
53bca1f3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
attach.c
src/lxc/attach.c
+5
-4
No files found.
src/lxc/attach.c
View file @
a588a482
...
@@ -1030,7 +1030,6 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
...
@@ -1030,7 +1030,6 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
void
*
exec_payload
,
lxc_attach_options_t
*
options
,
void
*
exec_payload
,
lxc_attach_options_t
*
options
,
pid_t
*
attached_process
)
pid_t
*
attached_process
)
{
{
__do_free
char
*
cwd
=
NULL
;
int
ret_parent
=
-
1
;
int
ret_parent
=
-
1
;
struct
attach_clone_payload
payload
=
{};
struct
attach_clone_payload
payload
=
{};
struct
lxc_epoll_descr
descr
=
{};
struct
lxc_epoll_descr
descr
=
{};
...
@@ -1075,8 +1074,6 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
...
@@ -1075,8 +1074,6 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
if
(
!
no_new_privs
(
ctx
->
container
,
options
))
if
(
!
no_new_privs
(
ctx
->
container
,
options
))
WARN
(
"Could not determine whether PR_SET_NO_NEW_PRIVS is set"
);
WARN
(
"Could not determine whether PR_SET_NO_NEW_PRIVS is set"
);
cwd
=
getcwd
(
NULL
,
0
);
/* Determine which namespaces the container was created with
/* Determine which namespaces the container was created with
* by asking lxc-start, if necessary.
* by asking lxc-start, if necessary.
*/
*/
...
@@ -1178,6 +1175,8 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
...
@@ -1178,6 +1175,8 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
}
}
if
(
pid
==
0
)
{
if
(
pid
==
0
)
{
char
*
cwd
;
/* close unneeded file descriptors */
/* close unneeded file descriptors */
close_prot_errno_disarm
(
ipc_sockets
[
0
]);
close_prot_errno_disarm
(
ipc_sockets
[
0
]);
...
@@ -1197,6 +1196,8 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
...
@@ -1197,6 +1196,8 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
TRACE
(
"Intermediate process starting to initialize"
);
TRACE
(
"Intermediate process starting to initialize"
);
cwd
=
getcwd
(
NULL
,
0
);
/* Attach now, create another subprocess later, since pid namespaces
/* Attach now, create another subprocess later, since pid namespaces
* only really affect the children of the current process.
* only really affect the children of the current process.
*/
*/
...
@@ -1221,6 +1222,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
...
@@ -1221,6 +1222,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
if
(
ret
<
0
)
if
(
ret
<
0
)
WARN
(
"Could not change directory to
\"
%s
\"
"
,
new_cwd
);
WARN
(
"Could not change directory to
\"
%s
\"
"
,
new_cwd
);
}
}
free_disarm
(
cwd
);
/* Create attached process. */
/* Create attached process. */
payload
.
ipc_socket
=
ipc_sockets
[
1
];
payload
.
ipc_socket
=
ipc_sockets
[
1
];
...
@@ -1278,7 +1280,6 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
...
@@ -1278,7 +1280,6 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
/* close unneeded file descriptors */
/* close unneeded file descriptors */
close
(
ipc_sockets
[
1
]);
close
(
ipc_sockets
[
1
]);
free_disarm
(
cwd
);
close_nsfds
(
ctx
);
close_nsfds
(
ctx
);
if
(
options
->
attach_flags
&
LXC_ATTACH_TERMINAL
)
if
(
options
->
attach_flags
&
LXC_ATTACH_TERMINAL
)
lxc_attach_terminal_close_pts
(
&
terminal
);
lxc_attach_terminal_close_pts
(
&
terminal
);
...
...
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