diff options
author | 2016-03-28 12:40:59 -0400 | |
---|---|---|
committer | 2016-03-28 12:40:59 -0400 | |
commit | db8782f71494204080f99868adc71ace42402b9c (patch) | |
tree | 1dd67d53ef7f5c625be771a5b587189bd2002579 | |
parent | introducing disable-passwdmgr.inc (diff) | |
download | firejail-db8782f71494204080f99868adc71ace42402b9c.tar.gz firejail-db8782f71494204080f99868adc71ace42402b9c.tar.zst firejail-db8782f71494204080f99868adc71ace42402b9c.zip |
pulseaudio fix
-rw-r--r-- | src/firejail/pulseaudio.c | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/src/firejail/pulseaudio.c b/src/firejail/pulseaudio.c index 8bf8d8303..1eb5e59e1 100644 --- a/src/firejail/pulseaudio.c +++ b/src/firejail/pulseaudio.c | |||
@@ -120,9 +120,49 @@ void pulseaudio_init(void) { | |||
120 | if (chown(pulsecfg, getuid(), getgid()) == -1) | 120 | if (chown(pulsecfg, getuid(), getgid()) == -1) |
121 | errExit("chown"); | 121 | errExit("chown"); |
122 | 122 | ||
123 | // set environment | 123 | // create ~/.config/pulse directory if not present |
124 | if (setenv("PULSE_CLIENTCONFIG", pulsecfg, 1) < 0) | 124 | char *dir1; |
125 | errExit("setenv"); | 125 | if (asprintf(&dir1, "%s/.config", cfg.homedir) == -1) |
126 | errExit("asprintf"); | ||
127 | if (stat(dir1, &s) == -1) { | ||
128 | int rv = mkdir(dir1, 0755); | ||
129 | if (rv == 0) { | ||
130 | rv = chown(dir1, getuid(), getgid()); | ||
131 | (void) rv; | ||
132 | rv = chmod(dir1, 0755); | ||
133 | (void) rv; | ||
134 | } | ||
135 | } | ||
136 | free(dir1); | ||
137 | if (asprintf(&dir1, "%s/.config/pulse", cfg.homedir) == -1) | ||
138 | errExit("asprintf"); | ||
139 | if (stat(dir1, &s) == -1) { | ||
140 | int rv = mkdir(dir1, 0700); | ||
141 | if (rv == 0) { | ||
142 | rv = chown(dir1, getuid(), getgid()); | ||
143 | (void) rv; | ||
144 | rv = chmod(dir1, 0700); | ||
145 | (void) rv; | ||
146 | } | ||
147 | } | ||
148 | free(dir1); | ||
126 | 149 | ||
150 | |||
151 | // if we have ~/.config/pulse mount the new directory, else set environment variable | ||
152 | char *homeusercfg; | ||
153 | if (asprintf(&homeusercfg, "%s/.config/pulse", cfg.homedir) == -1) | ||
154 | errExit("asprintf"); | ||
155 | if (stat(homeusercfg, &s) == 0) { | ||
156 | if (mount(RUN_PULSE_DIR, homeusercfg, "none", MS_BIND, NULL) < 0) | ||
157 | errExit("mount pulseaudio"); | ||
158 | fs_logger2("tmpfs", homeusercfg); | ||
159 | } | ||
160 | else { | ||
161 | // set environment | ||
162 | if (setenv("PULSE_CLIENTCONFIG", pulsecfg, 1) < 0) | ||
163 | errExit("setenv"); | ||
164 | } | ||
165 | |||
127 | free(pulsecfg); | 166 | free(pulsecfg); |
167 | free(homeusercfg); | ||
128 | } | 168 | } |