aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/firejail/selinux.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/firejail/selinux.c b/src/firejail/selinux.c
index 52d6788ef..c761916b7 100644
--- a/src/firejail/selinux.c
+++ b/src/firejail/selinux.c
@@ -35,7 +35,7 @@ static int selinux_enabled = -1;
35void selinux_relabel_path(const char *path, const char *inside_path) 35void selinux_relabel_path(const char *path, const char *inside_path)
36{ 36{
37#if HAVE_SELINUX 37#if HAVE_SELINUX
38 char procfs_path[64]; 38 char procfs_path[64];
39 char *fcon = NULL; 39 char *fcon = NULL;
40 int fd; 40 int fd;
41 struct stat st; 41 struct stat st;
@@ -50,19 +50,19 @@ void selinux_relabel_path(const char *path, const char *inside_path)
50 label_hnd = selabel_open(SELABEL_CTX_FILE, NULL, 0); 50 label_hnd = selabel_open(SELABEL_CTX_FILE, NULL, 0);
51 51
52 /* Open the file as O_PATH, to pin it while we determine and adjust the label */ 52 /* Open the file as O_PATH, to pin it while we determine and adjust the label */
53 fd = open(path, O_NOFOLLOW|O_CLOEXEC|O_PATH); 53 fd = open(path, O_NOFOLLOW|O_CLOEXEC|O_PATH);
54 if (fd < 0) 54 if (fd < 0)
55 return; 55 return;
56 if (fstat(fd, &st) < 0) 56 if (fstat(fd, &st) < 0)
57 goto close; 57 goto close;
58 58
59 if (selabel_lookup_raw(label_hnd, &fcon, inside_path, st.st_mode) == 0) { 59 if (selabel_lookup_raw(label_hnd, &fcon, inside_path, st.st_mode) == 0) {
60 sprintf(procfs_path, "/proc/self/fd/%i", fd); 60 sprintf(procfs_path, "/proc/self/fd/%i", fd);
61 if (arg_debug) 61 if (arg_debug)
62 printf("Relabeling %s as %s (%s)\n", path, inside_path, fcon); 62 printf("Relabeling %s as %s (%s)\n", path, inside_path, fcon);
63 63
64 setfilecon_raw(procfs_path, fcon); 64 setfilecon_raw(procfs_path, fcon);
65 } 65 }
66 freecon(fcon); 66 freecon(fcon);
67 close: 67 close:
68 close(fd); 68 close(fd);