aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2015-12-05 10:33:11 -0500
committerLibravatar netblue30 <netblue30@yahoo.com>2015-12-05 10:33:11 -0500
commitd10176f4c44333dcf2919e164a9be7a4d6bf2222 (patch)
tree056b3a51c66889a3c27509236b4bf7d06a4af1d4 /src
parent--profile-path option (diff)
downloadfirejail-d10176f4c44333dcf2919e164a9be7a4d6bf2222.tar.gz
firejail-d10176f4c44333dcf2919e164a9be7a4d6bf2222.tar.zst
firejail-d10176f4c44333dcf2919e164a9be7a4d6bf2222.zip
fixed downloads directory
Diffstat (limited to 'src')
-rw-r--r--src/firejail/fs_whitelist.c54
1 files changed, 39 insertions, 15 deletions
diff --git a/src/firejail/fs_whitelist.c b/src/firejail/fs_whitelist.c
index a584cb69d..2a4fc5993 100644
--- a/src/firejail/fs_whitelist.c
+++ b/src/firejail/fs_whitelist.c
@@ -48,7 +48,7 @@ static char *resolve_downloads(void) {
48 if (stat(fname, &s) == 0) { 48 if (stat(fname, &s) == 0) {
49 free(fname); 49 free(fname);
50 if (arg_debug) 50 if (arg_debug)
51 printf("Downloads directory resolved as \"Downloads\"\n"); 51 printf("Downloads directory resolved as \"%s\"\n", fname);
52 52
53 char *rv; 53 char *rv;
54 if (asprintf(&rv, "whitelist ~/%s", dentry[i]) == -1) 54 if (asprintf(&rv, "whitelist ~/%s", dentry[i]) == -1)
@@ -81,17 +81,44 @@ static char *resolve_downloads(void) {
81 continue; 81 continue;
82 82
83 if (strncmp(ptr, "XDG_DOWNLOAD_DIR=\"$HOME/", 24) == 0) { 83 if (strncmp(ptr, "XDG_DOWNLOAD_DIR=\"$HOME/", 24) == 0) {
84 char *ptr1 = strchr(ptr + 24, '"'); 84 char *ptr1 = ptr + 24;
85 if (ptr1) { 85 char *ptr2 = strchr(ptr1, '"');
86 *ptr1 = '\0'; 86 if (ptr2) {
87 fclose(fp); 87 fclose(fp);
88 *ptr2 = '\0';
88 if (arg_debug) 89 if (arg_debug)
89 printf("Downloads directory resolved as \"%s\"\n", ptr + 24); 90 printf("extracted %s from ~/.config/user-dirs.dirs\n", ptr1);
91 if (strlen(ptr1) != 0) {
92 if (arg_debug)
93 printf("Downloads directory resolved as \"%s\"\n", ptr1);
90 94
91 char *rv; 95 if (asprintf(&fname, "%s/%s", cfg.homedir, ptr1) == -1)
92 if (asprintf(&rv, "whitelist ~/%s", ptr + 24) == -1) 96 errExit("asprintf");
93 errExit("asprintf"); 97
94 return rv; 98 if (stat(fname, &s) == -1) {
99 fprintf(stderr, "***\n");
100 fprintf(stderr, "*** Error: directory %s not found.\n", fname);
101 fprintf(stderr, "*** \tThis directory is configured in ~/.config/user-dirs.dirs.\n");
102 fprintf(stderr, "*** \tPlease create a Downloads directory.\n");
103 fprintf(stderr, "***\n");
104 free(fname);
105 return NULL;
106 }
107
108 char *rv;
109 if (asprintf(&rv, "whitelist ~/%s", ptr + 24) == -1)
110 errExit("asprintf");
111 return rv;
112 }
113 else {
114 fprintf(stderr, "***\n");
115 fprintf(stderr, "*** Error: invalid XDG_DOWNLOAD_DIR entry in ~/.config/user-dirs.dirs.\n");
116 fprintf(stderr, "*** \tPlease specify a valid Downloads directory, example:\n");
117 fprintf(stderr, "***\n");
118 fprintf(stderr, "***\t\tXDG_DOWNLOAD_DIR=\"$HOME/Downloads\"\n");
119 fprintf(stderr, "***\n");
120 return NULL;
121 }
95 } 122 }
96 } 123 }
97 } 124 }
@@ -297,12 +324,9 @@ void fs_whitelist(void) {
297 else { 324 else {
298 *entry->data = '\0'; 325 *entry->data = '\0';
299 fprintf(stderr, "***\n"); 326 fprintf(stderr, "***\n");
300 fprintf(stderr, "*** Error: cannot whitelist Downloads directory\n"); 327 fprintf(stderr, "*** Warning: cannot whitelist Downloads directory\n");
301 fprintf(stderr, "***\n"); 328 fprintf(stderr, "*** \tAny file saved will be lost when the sandbox is closed.\n");
302 fprintf(stderr, "*** Any file saved in this directory will be lost when the sandbox is closed.\n"); 329 fprintf(stderr, "*** \tPlease create a proper Downloads directory for your application.\n");
303 fprintf(stderr, "*** Please contact the developer. Workaround:\n");
304 fprintf(stderr, "***\n");
305 fprintf(stderr, "*** firejail --ignore=whitelist program-name\n");
306 fprintf(stderr, "***\n"); 330 fprintf(stderr, "***\n");
307 continue; 331 continue;
308 } 332 }