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
60e7645a
Unverified
Commit
60e7645a
authored
Dec 09, 2020
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confile_utils: cleanup lxc_container_name_to_pid()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
bffb57fc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
22 deletions
+10
-22
confile_utils.c
src/lxc/confile_utils.c
+10
-22
No files found.
src/lxc/confile_utils.c
View file @
60e7645a
...
...
@@ -15,6 +15,7 @@
#include "confile_utils.h"
#include "error.h"
#include "list.h"
#include "lxc.h"
#include "log.h"
#include "lxccontainer.h"
#include "macro.h"
...
...
@@ -852,37 +853,24 @@ static int lxc_container_name_to_pid(const char *lxcname_or_pid,
pid
=
strtol
(
lxcname_or_pid
,
&
err
,
10
);
if
(
*
err
!=
'\0'
||
pid
<
1
)
{
struct
lxc_container
*
c
;
__put_lxc_container
struct
lxc_container
*
c
=
NULL
;
c
=
lxc_container_new
(
lxcname_or_pid
,
lxcpath
);
if
(
!
c
)
{
ERROR
(
"
\"
%s
\"
is not a valid pid nor a container name"
,
lxcname_or_pid
);
return
-
1
;
}
if
(
!
c
)
return
log_error_errno
(
-
EINVAL
,
EINVAL
,
"
\"
%s
\"
is not a valid pid nor a container name"
,
lxcname_or_pid
);
if
(
!
c
->
may_control
(
c
))
{
ERROR
(
"Insufficient privileges to control container "
"
\"
%s
\"
"
,
c
->
name
);
lxc_container_put
(
c
);
return
-
1
;
}
if
(
!
c
->
may_control
(
c
))
return
log_error_errno
(
-
EPERM
,
EPERM
,
"Insufficient privileges to control container
\"
%s
\"
"
,
c
->
name
);
pid
=
c
->
init_pid
(
c
);
if
(
pid
<
1
)
{
ERROR
(
"Container
\"
%s
\"
is not running"
,
c
->
name
);
lxc_container_put
(
c
);
return
-
1
;
}
if
(
pid
<
1
)
return
log_error_errno
(
-
EINVAL
,
EINVAL
,
"Container
\"
%s
\"
is not running"
,
c
->
name
);
lxc_container_put
(
c
);
}
ret
=
kill
(
pid
,
0
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to send signal to pid %d"
,
(
int
)
pid
);
return
-
1
;
}
if
(
ret
<
0
)
return
log_error_errno
(
-
errno
,
errno
,
"Failed to send signal to pid %d"
,
(
int
)
pid
);
return
pid
;
}
...
...
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