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
7adff31c
Commit
7adff31c
authored
Apr 08, 2010
by
Daniel Lezcano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fork/exec after attach
The command to attach has to be fork/exec. Signed-off-by:
Daniel Lezcano
<
dlezcano@fr.ibm.com
>
parent
91480a0f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
15 deletions
+47
-15
lxc_attach.c
src/lxc/lxc_attach.c
+47
-15
No files found.
src/lxc/lxc_attach.c
View file @
7adff31c
...
@@ -25,6 +25,9 @@
...
@@ -25,6 +25,9 @@
#include <errno.h>
#include <errno.h>
#include <sys/param.h>
#include <sys/param.h>
#include <pwd.h>
#include <pwd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "commands.h"
#include "commands.h"
#include "arguments.h"
#include "arguments.h"
#include "namespace.h"
#include "namespace.h"
...
@@ -106,29 +109,58 @@ int main(int argc, char *argv[], char *envp[])
...
@@ -106,29 +109,58 @@ int main(int argc, char *argv[], char *envp[])
return
-
1
;
return
-
1
;
}
}
if
(
my_args
.
argc
)
{
pid
=
fork
();
execve
(
my_args
.
argv
[
0
],
my_args
.
argv
,
envp
);
SYSERROR
(
"failed to exec '%s'"
,
my_args
.
argv
[
0
]);
if
(
pid
<
0
)
{
SYSERROR
(
"failed to fork"
);
return
-
1
;
return
-
1
;
}
}
uid
=
getuid
();
if
(
pid
)
{
int
status
;
again:
if
(
waitpid
(
pid
,
&
status
,
0
)
<
0
)
{
if
(
errno
==
EINTR
)
goto
again
;
SYSERROR
(
"failed to wait '%d'"
,
pid
);
return
-
1
;
}
if
(
WIFEXITED
(
status
))
return
WEXITSTATUS
(
status
);
passwd
=
getpwuid
(
uid
);
if
(
!
passwd
)
{
SYSERROR
(
"failed to get passwd entry for uid '%d'"
,
uid
);
return
-
1
;
return
-
1
;
}
}
{
if
(
!
pid
)
{
char
*
const
args
[]
=
{
passwd
->
pw_shell
,
if
(
my_args
.
argc
)
{
NULL
,
execve
(
my_args
.
argv
[
0
],
my_args
.
argv
,
envp
);
};
SYSERROR
(
"failed to exec '%s'"
,
my_args
.
argv
[
0
]);
return
-
1
;
}
uid
=
getuid
();
passwd
=
getpwuid
(
uid
);
if
(
!
passwd
)
{
SYSERROR
(
"failed to get passwd "
\
"entry for uid '%d'"
,
uid
);
return
-
1
;
}
{
char
*
const
args
[]
=
{
passwd
->
pw_shell
,
NULL
,
};
execve
(
args
[
0
],
args
,
envp
);
SYSERROR
(
"failed to exec '%s'"
,
args
[
0
]);
return
-
1
;
}
execve
(
args
[
0
],
args
,
envp
);
SYSERROR
(
"failed to exec '%s'"
,
args
[
0
]);
return
-
1
;
}
}
return
0
;
return
0
;
...
...
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