aboutsummaryrefslogtreecommitdiffstats
path: root/src/firecfg/sound.c
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2017-09-25 07:38:01 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2017-09-25 07:38:01 -0400
commita6341b904c08b1feb51e264ab487d1f125222a10 (patch)
tree35ea50b8c8e561b710272a0e8ae9418541a32925 /src/firecfg/sound.c
parentRemove whitelist from pinta (diff)
downloadfirejail-a6341b904c08b1feb51e264ab487d1f125222a10.tar.gz
firejail-a6341b904c08b1feb51e264ab487d1f125222a10.tar.zst
firejail-a6341b904c08b1feb51e264ab487d1f125222a10.zip
disable DBus activation in firecfg
Diffstat (limited to 'src/firecfg/sound.c')
-rw-r--r--src/firecfg/sound.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/firecfg/sound.c b/src/firecfg/sound.c
new file mode 100644
index 000000000..9dfb305cd
--- /dev/null
+++ b/src/firecfg/sound.c
@@ -0,0 +1,65 @@
1/*
2 * Copyright (C) 2014-2017 Firejail Authors
3 *
4 * This file is part of firejail project
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20
21#include "firecfg.h"
22
23void sound(void) {
24 struct passwd *pw = getpwuid(getuid());
25 if (!pw) {
26 goto errexit;
27 }
28 char *home = pw->pw_dir;
29 if (!home) {
30 goto errexit;
31 }
32
33 // the input file is /etc/pulse/client.conf
34 FILE *fpin = fopen("/etc/pulse/client.conf", "r");
35 if (!fpin) {
36 fprintf(stderr, "PulseAudio is not available on this platform, there is nothing to fix...\n");
37 return;
38 }
39
40 // the dest is PulseAudio user config file
41 char *fname;
42 if (asprintf(&fname, "%s/.config/pulse/client.conf", home) == -1)
43 errExit("asprintf");
44 FILE *fpout = fopen(fname, "w");
45 free(fname);
46 if (!fpout)
47 goto errexit;
48
49 // copy default config
50 char buf[MAX_BUF];
51 while (fgets(buf, MAX_BUF, fpin))
52 fputs(buf, fpout);
53
54 // disable shm
55 fprintf(fpout, "\nenable-shm = no\n");
56 fclose(fpin);
57 fclose(fpout);
58 printf("PulseAudio configured, please logout and login back again\n");
59 return;
60
61errexit:
62 fprintf(stderr, "Error: cannot configure sound file\n");
63 exit(1);
64}
65