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
1be8cb04
Unverified
Commit
1be8cb04
authored
Feb 07, 2018
by
Marcos Paulo de Souza
Committed by
Christian Brauner
Feb 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
selinux: simplify check for default label
Signed-off-by:
Marcos Paulo de Souza
<
marcos.souza.org@gmail.com
>
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
ff5976cd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
19 deletions
+23
-19
selinux.c
src/lxc/lsm/selinux.c
+23
-19
No files found.
src/lxc/lsm/selinux.c
View file @
1be8cb04
...
...
@@ -23,13 +23,15 @@
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <selinux/selinux.h>
#include <sys/types.h>
#include "conf.h"
#include "log.h"
#include "lsm.h"
#include "conf.h"
#define DEFAULT_LABEL "unconfined_t"
...
...
@@ -74,29 +76,31 @@ static char *selinux_process_label_get(pid_t pid)
static
int
selinux_process_label_set
(
const
char
*
inlabel
,
struct
lxc_conf
*
conf
,
bool
use_default
,
bool
on_exec
)
{
const
char
*
label
=
inlabel
?
inlabel
:
conf
->
lsm_se_context
;
int
ret
;
const
char
*
label
;
label
=
inlabel
?
inlabel
:
conf
->
lsm_se_context
;
if
(
!
label
)
{
if
(
use_default
)
label
=
DEFAULT_LABE
L
;
else
return
-
1
;
if
(
!
use_default
)
return
-
EINVA
L
;
label
=
DEFAULT_LABEL
;
}
if
(
!
strcmp
(
label
,
"unconfined_t"
))
if
(
strcmp
(
label
,
"unconfined_t"
)
==
0
)
return
0
;
if
(
on_exec
)
{
if
(
setexeccon_raw
((
char
*
)
label
)
<
0
)
{
SYSERROR
(
"failed to set new SELinux exec context %s"
,
label
);
return
-
1
;
}
}
else
{
if
(
setcon_raw
((
char
*
)
label
)
<
0
)
{
SYSERROR
(
"failed to set new SELinux context %s"
,
label
);
return
-
1
;
}
if
(
on_exec
)
ret
=
setexeccon_raw
((
char
*
)
label
);
else
ret
=
setcon_raw
((
char
*
)
label
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to set SELinux%s context to
\"
%s
\"
"
,
on_exec
?
" exec"
:
""
,
label
);
return
-
1
;
}
INFO
(
"
changed SELinux%s context to %s
"
,
on_exec
?
" exec"
:
""
,
label
);
INFO
(
"
Changed SELinux%s context to
\"
%s
\"
"
,
on_exec
?
" exec"
:
""
,
label
);
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