diff options
author | netblue30 <netblue30@yahoo.com> | 2017-03-24 07:55:44 -0400 |
---|---|---|
committer | netblue30 <netblue30@yahoo.com> | 2017-03-24 07:55:44 -0400 |
commit | 5ff53a2ca729ad687a323f782594420065148588 (patch) | |
tree | ba8241b684fc70cef6ef8b30ad50b25feabaf505 /src/firejail/appimage.c | |
parent | merge #1100 from zackw: xvfb support in /etc/firejail/firejail.config (diff) | |
download | firejail-5ff53a2ca729ad687a323f782594420065148588.tar.gz firejail-5ff53a2ca729ad687a323f782594420065148588.tar.zst firejail-5ff53a2ca729ad687a323f782594420065148588.zip |
testing
Diffstat (limited to 'src/firejail/appimage.c')
-rw-r--r-- | src/firejail/appimage.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/firejail/appimage.c b/src/firejail/appimage.c index 4cc5cc180..2368d7992 100644 --- a/src/firejail/appimage.c +++ b/src/firejail/appimage.c | |||
@@ -31,6 +31,11 @@ | |||
31 | static char *devloop = NULL; // device file | 31 | static char *devloop = NULL; // device file |
32 | static char *mntdir = NULL; // mount point in /tmp directory | 32 | static char *mntdir = NULL; // mount point in /tmp directory |
33 | 33 | ||
34 | static void err_loop(void) { | ||
35 | fprintf(stderr, "Error: cannot configure loopback device\n"); | ||
36 | exit(1); | ||
37 | } | ||
38 | |||
34 | void appimage_set(const char *appimage) { | 39 | void appimage_set(const char *appimage) { |
35 | assert(appimage); | 40 | assert(appimage); |
36 | assert(devloop == NULL); // don't call this twice! | 41 | assert(devloop == NULL); // don't call this twice! |
@@ -61,35 +66,27 @@ void appimage_set(const char *appimage) { | |||
61 | // find or allocate a free loop device to use | 66 | // find or allocate a free loop device to use |
62 | EUID_ROOT(); | 67 | EUID_ROOT(); |
63 | int cfd = open("/dev/loop-control", O_RDWR); | 68 | int cfd = open("/dev/loop-control", O_RDWR); |
64 | if (cfd == -1) { | 69 | if (cfd == -1) |
65 | fprintf(stderr, "Error: /dev/loop-control interface is not supported by your kernel\n"); | 70 | err_loop(); |
66 | exit(1); | ||
67 | } | ||
68 | int devnr = ioctl(cfd, LOOP_CTL_GET_FREE); | 71 | int devnr = ioctl(cfd, LOOP_CTL_GET_FREE); |
69 | if (devnr == -1) { | 72 | if (devnr == -1) |
70 | fprintf(stderr, "Error: cannot allocate a new loopback device\n"); | 73 | err_loop(); |
71 | exit(1); | ||
72 | } | ||
73 | close(cfd); | 74 | close(cfd); |
74 | if (asprintf(&devloop, "/dev/loop%d", devnr) == -1) | 75 | if (asprintf(&devloop, "/dev/loop%d", devnr) == -1) |
75 | errExit("asprintf"); | 76 | errExit("asprintf"); |
76 | 77 | ||
77 | int lfd = open(devloop, O_RDONLY); | 78 | int lfd = open(devloop, O_RDONLY); |
78 | if (lfd == -1) { | 79 | if (lfd == -1) |
79 | fprintf(stderr, "Error: cannot open %s\n", devloop); | 80 | err_loop(); |
80 | exit(1); | 81 | if (ioctl(lfd, LOOP_SET_FD, ffd) == -1) |
81 | } | 82 | err_loop(); |
82 | if (ioctl(lfd, LOOP_SET_FD, ffd) == -1) { | ||
83 | fprintf(stderr, "Error: cannot configure the loopback device\n"); | ||
84 | exit(1); | ||
85 | } | ||
86 | 83 | ||
87 | if (size) { | 84 | if (size) { |
88 | struct loop_info64 info; | 85 | struct loop_info64 info; |
89 | memset(&info, 0, sizeof(struct loop_info64)); | 86 | memset(&info, 0, sizeof(struct loop_info64)); |
90 | info.lo_offset = size; | 87 | info.lo_offset = size; |
91 | if (ioctl(lfd, LOOP_SET_STATUS64, &info) == -1) | 88 | if (ioctl(lfd, LOOP_SET_STATUS64, &info) == -1) |
92 | errExit("configure appimage offset"); | 89 | err_loop(); |
93 | } | 90 | } |
94 | 91 | ||
95 | close(lfd); | 92 | close(lfd); |