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
5288a74f
Unverified
Commit
5288a74f
authored
Jan 22, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apparmor: do not call aa_change_profile()
We can simply write the label ourselves. There's no magic happening. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
d3ba7c98
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
5 deletions
+24
-5
apparmor.c
src/lxc/lsm/apparmor.c
+15
-5
utils.h
src/lxc/utils.h
+9
-0
No files found.
src/lxc/lsm/apparmor.c
View file @
5288a74f
...
@@ -25,11 +25,10 @@
...
@@ -25,11 +25,10 @@
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <sys/mount.h>
#include <sys/apparmor.h>
#include <sys/vfs.h>
#include <sys/vfs.h>
#include "log.h"
#include "log.h"
#include "lsm
/lsm
.h"
#include "lsm.h"
#include "conf.h"
#include "conf.h"
#include "utils.h"
#include "utils.h"
...
@@ -174,6 +173,8 @@ static bool aa_needs_transition(char *curlabel)
...
@@ -174,6 +173,8 @@ static bool aa_needs_transition(char *curlabel)
static
int
apparmor_process_label_set
(
const
char
*
inlabel
,
struct
lxc_conf
*
conf
,
static
int
apparmor_process_label_set
(
const
char
*
inlabel
,
struct
lxc_conf
*
conf
,
bool
use_default
,
bool
on_exec
)
bool
use_default
,
bool
on_exec
)
{
{
int
label_fd
,
ret
;
pid_t
tid
;
const
char
*
label
=
inlabel
?
inlabel
:
conf
->
lsm_aa_profile
;
const
char
*
label
=
inlabel
?
inlabel
:
conf
->
lsm_aa_profile
;
char
*
curlabel
;
char
*
curlabel
;
...
@@ -230,12 +231,21 @@ static int apparmor_process_label_set(const char *inlabel, struct lxc_conf *conf
...
@@ -230,12 +231,21 @@ static int apparmor_process_label_set(const char *inlabel, struct lxc_conf *conf
return
0
;
return
0
;
}
}
if
(
aa_change_profile
(
label
)
<
0
)
{
tid
=
lxc_raw_gettid
();
SYSERROR
(
"failed to change apparmor profile to %s"
,
label
);
label_fd
=
lsm_process_label_fd_get
(
tid
,
on_exec
);
if
(
label_fd
<
0
)
{
SYSERROR
(
"Failed to change apparmor profile to %s"
,
label
);
return
-
1
;
return
-
1
;
}
}
INFO
(
"changed apparmor profile to %s"
,
label
);
ret
=
lsm_process_label_set_at
(
label_fd
,
label
,
on_exec
);
close
(
label_fd
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to change apparmor profile to %s"
,
label
);
return
-
1
;
}
INFO
(
"Changed apparmor profile to %s"
,
label
);
return
0
;
return
0
;
}
}
...
...
src/lxc/utils.h
View file @
5288a74f
...
@@ -541,4 +541,13 @@ static inline uint64_t lxc_getpagesize(void)
...
@@ -541,4 +541,13 @@ static inline uint64_t lxc_getpagesize(void)
*/
*/
extern
uint64_t
lxc_find_next_power2
(
uint64_t
n
);
extern
uint64_t
lxc_find_next_power2
(
uint64_t
n
);
static
inline
pid_t
lxc_raw_gettid
(
void
)
{
#ifdef SYS_gettid
return
syscall
(
SYS_gettid
);
#else
return
lxc_raw_getpid
();
#endif
}
#endif
/* __LXC_UTILS_H */
#endif
/* __LXC_UTILS_H */
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