diff options
Diffstat (limited to 'src/firejail/pulseaudio.c')
-rw-r--r-- | src/firejail/pulseaudio.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/firejail/pulseaudio.c b/src/firejail/pulseaudio.c index ead5dd361..246ba8fd8 100644 --- a/src/firejail/pulseaudio.c +++ b/src/firejail/pulseaudio.c | |||
@@ -27,17 +27,17 @@ | |||
27 | static void disable_file(const char *path, const char *file) { | 27 | static void disable_file(const char *path, const char *file) { |
28 | assert(file); | 28 | assert(file); |
29 | assert(path); | 29 | assert(path); |
30 | 30 | ||
31 | struct stat s; | 31 | struct stat s; |
32 | char *fname; | 32 | char *fname; |
33 | if (asprintf(&fname, "%s/%s", path, file) == -1) | 33 | if (asprintf(&fname, "%s/%s", path, file) == -1) |
34 | errExit("asprintf"); | 34 | errExit("asprintf"); |
35 | if (stat(fname, &s) == -1) | 35 | if (stat(fname, &s) == -1) |
36 | goto doexit; | 36 | goto doexit; |
37 | 37 | ||
38 | if (arg_debug) | 38 | if (arg_debug) |
39 | printf("Disable%s\n", fname); | 39 | printf("Disable%s\n", fname); |
40 | 40 | ||
41 | if (S_ISDIR(s.st_mode)) { | 41 | if (S_ISDIR(s.st_mode)) { |
42 | if (mount(RUN_RO_DIR, fname, "none", MS_BIND, "mode=400,gid=0") < 0) | 42 | if (mount(RUN_RO_DIR, fname, "none", MS_BIND, "mode=400,gid=0") < 0) |
43 | errExit("disable file"); | 43 | errExit("disable file"); |
@@ -71,7 +71,7 @@ void pulseaudio_disable(void) { | |||
71 | errExit("asprintf"); | 71 | errExit("asprintf"); |
72 | disable_file(path, "pulse/native"); | 72 | disable_file(path, "pulse/native"); |
73 | free(path); | 73 | free(path); |
74 | 74 | ||
75 | 75 | ||
76 | 76 | ||
77 | // blacklist any pulse* file in /tmp directory | 77 | // blacklist any pulse* file in /tmp directory |
@@ -99,11 +99,11 @@ void pulseaudio_disable(void) { | |||
99 | // disable shm in pulseaudio | 99 | // disable shm in pulseaudio |
100 | void pulseaudio_init(void) { | 100 | void pulseaudio_init(void) { |
101 | struct stat s; | 101 | struct stat s; |
102 | 102 | ||
103 | // do we have pulseaudio in the system? | 103 | // do we have pulseaudio in the system? |
104 | if (stat("/etc/pulse/client.conf", &s) == -1) | 104 | if (stat("/etc/pulse/client.conf", &s) == -1) |
105 | return; | 105 | return; |
106 | 106 | ||
107 | // create the new user pulseaudio directory | 107 | // create the new user pulseaudio directory |
108 | int rv = mkdir(RUN_PULSE_DIR, 0700); | 108 | int rv = mkdir(RUN_PULSE_DIR, 0700); |
109 | (void) rv; // in --chroot mode the directory can already be there | 109 | (void) rv; // in --chroot mode the directory can already be there |
@@ -134,7 +134,7 @@ void pulseaudio_init(void) { | |||
134 | if (child == 0) { | 134 | if (child == 0) { |
135 | // drop privileges | 135 | // drop privileges |
136 | drop_privs(0); | 136 | drop_privs(0); |
137 | 137 | ||
138 | int rv = mkdir(dir1, 0755); | 138 | int rv = mkdir(dir1, 0755); |
139 | if (rv == 0) { | 139 | if (rv == 0) { |
140 | if (set_perms(dir1, getuid(), getgid(), 0755)) | 140 | if (set_perms(dir1, getuid(), getgid(), 0755)) |
@@ -156,7 +156,7 @@ void pulseaudio_init(void) { | |||
156 | } | 156 | } |
157 | } | 157 | } |
158 | free(dir1); | 158 | free(dir1); |
159 | 159 | ||
160 | if (asprintf(&dir1, "%s/.config/pulse", cfg.homedir) == -1) | 160 | if (asprintf(&dir1, "%s/.config/pulse", cfg.homedir) == -1) |
161 | errExit("asprintf"); | 161 | errExit("asprintf"); |
162 | if (stat(dir1, &s) == -1) { | 162 | if (stat(dir1, &s) == -1) { |
@@ -166,7 +166,7 @@ void pulseaudio_init(void) { | |||
166 | if (child == 0) { | 166 | if (child == 0) { |
167 | // drop privileges | 167 | // drop privileges |
168 | drop_privs(0); | 168 | drop_privs(0); |
169 | 169 | ||
170 | int rv = mkdir(dir1, 0700); | 170 | int rv = mkdir(dir1, 0700); |
171 | if (rv == 0) { | 171 | if (rv == 0) { |
172 | if (set_perms(dir1, getuid(), getgid(), 0700)) | 172 | if (set_perms(dir1, getuid(), getgid(), 0700)) |
@@ -188,8 +188,8 @@ void pulseaudio_init(void) { | |||
188 | } | 188 | } |
189 | } | 189 | } |
190 | free(dir1); | 190 | free(dir1); |
191 | 191 | ||
192 | 192 | ||
193 | // if we have ~/.config/pulse mount the new directory, else set environment variable | 193 | // if we have ~/.config/pulse mount the new directory, else set environment variable |
194 | char *homeusercfg; | 194 | char *homeusercfg; |
195 | if (asprintf(&homeusercfg, "%s/.config/pulse", cfg.homedir) == -1) | 195 | if (asprintf(&homeusercfg, "%s/.config/pulse", cfg.homedir) == -1) |
@@ -204,7 +204,7 @@ void pulseaudio_init(void) { | |||
204 | if (setenv("PULSE_CLIENTCONFIG", pulsecfg, 1) < 0) | 204 | if (setenv("PULSE_CLIENTCONFIG", pulsecfg, 1) < 0) |
205 | errExit("setenv"); | 205 | errExit("setenv"); |
206 | } | 206 | } |
207 | 207 | ||
208 | free(pulsecfg); | 208 | free(pulsecfg); |
209 | free(homeusercfg); | 209 | free(homeusercfg); |
210 | } | 210 | } |