aboutsummaryrefslogtreecommitdiffstats
path: root/src/firejail/appimage.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/firejail/appimage.c')
-rw-r--r--src/firejail/appimage.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/firejail/appimage.c b/src/firejail/appimage.c
index 6b9fed765..d194eeafb 100644
--- a/src/firejail/appimage.c
+++ b/src/firejail/appimage.c
@@ -30,6 +30,7 @@
30 30
31static char *devloop = NULL; // device file 31static char *devloop = NULL; // device file
32static long unsigned size = 0; // offset into appimage file 32static long unsigned size = 0; // offset into appimage file
33#define MAXBUF 4096
33 34
34#ifdef LOOP_CTL_GET_FREE // test for older kernels; this definition is found in /usr/include/linux/loop.h 35#ifdef LOOP_CTL_GET_FREE // test for older kernels; this definition is found in /usr/include/linux/loop.h
35static void err_loop(void) { 36static void err_loop(void) {
@@ -38,6 +39,32 @@ static void err_loop(void) {
38} 39}
39#endif 40#endif
40 41
42// return 1 if found
43int appimage_find_profile(const char *archive) {
44 assert(archive);
45 assert(strlen(archive));
46
47 // try to match the name of the archive with the list of programs in /usr/lib/firejail/firecfg.config
48 FILE *fp = fopen(LIBDIR "/firejail/firecfg.config", "r");
49 if (!fp) {
50 fprintf(stderr, "Error: cannot find %s, firejail is not correctly installed\n", LIBDIR "/firejail/firecfg.config");
51 exit(1);
52 }
53 char buf[MAXBUF];
54 while (fgets(buf, MAXBUF, fp)) {
55 if (*buf == '#')
56 continue;
57 char *ptr = strchr(buf, '\n');
58 if (ptr)
59 *ptr = '\0';
60 if (strcasestr(archive, buf))
61 return profile_find_firejail(buf, 1);
62 }
63 return 0;
64
65}
66
67
41void appimage_set(const char *appimage) { 68void appimage_set(const char *appimage) {
42 assert(appimage); 69 assert(appimage);
43 assert(devloop == NULL); // don't call this twice! 70 assert(devloop == NULL); // don't call this twice!