diff options
author | Marcin Bukat <marcin.bukat@gmail.com> | 2018-03-02 21:45:52 +0100 |
---|---|---|
committer | Marcin Bukat <marcin.bukat@gmail.com> | 2018-06-12 10:31:15 +0200 |
commit | 0538ba3d59a1a29adcee0b4656b204fda102ad89 (patch) | |
tree | 50f070b0dc506f160f4007c8e7943072e0ee00e6 | |
parent | 09fde79ec840ef9021ddbc28a58e6b1234d9de8f (diff) | |
download | rockbox-0538ba3d59a1a29adcee0b4656b204fda102ad89.tar.gz rockbox-0538ba3d59a1a29adcee0b4656b204fda102ad89.zip |
Agptek Rocker: Restrict root directory to SD only
Actual / of underlying linux OS should not be available to user.
I am still not sure if implementation is correct. It doesn't
perform any relative path sandboxing for example.
Change-Id: Ic577a10f3947f6e950e2c4d03173f9f207395eb7
-rw-r--r-- | firmware/export/rbpaths.h | 2 | ||||
-rw-r--r-- | firmware/target/hosted/filesystem-app.c | 8 | ||||
-rw-r--r-- | firmware/target/hosted/lc-unix.c | 7 | ||||
-rwxr-xr-x | tools/configure | 1 |
4 files changed, 14 insertions, 4 deletions
diff --git a/firmware/export/rbpaths.h b/firmware/export/rbpaths.h index 6623461639..165dd37494 100644 --- a/firmware/export/rbpaths.h +++ b/firmware/export/rbpaths.h | |||
@@ -51,8 +51,6 @@ | |||
51 | #elif defined(DX50) || defined(DX90) | 51 | #elif defined(DX50) || defined(DX90) |
52 | /* Where to put save files like recordings, playlists, screen dumps ...*/ | 52 | /* Where to put save files like recordings, playlists, screen dumps ...*/ |
53 | #define HOME_DIR "/mnt/sdcard" | 53 | #define HOME_DIR "/mnt/sdcard" |
54 | #elif defined(AGPTEK_ROCKER) | ||
55 | #define HOME_DIR "/mnt/sd_0" | ||
56 | #else | 54 | #else |
57 | #define HOME_DIR "/" | 55 | #define HOME_DIR "/" |
58 | #endif | 56 | #endif |
diff --git a/firmware/target/hosted/filesystem-app.c b/firmware/target/hosted/filesystem-app.c index 4f1019c7a1..d9fcd64e2d 100644 --- a/firmware/target/hosted/filesystem-app.c +++ b/firmware/target/hosted/filesystem-app.c | |||
@@ -37,6 +37,10 @@ | |||
37 | #include "logf.h" | 37 | #include "logf.h" |
38 | 38 | ||
39 | 39 | ||
40 | #if defined(AGPTEK_ROCKER) && !defined(BOOTLOADER) | ||
41 | #define PIVOT_ROOT "/mnt/sd_0" | ||
42 | #endif | ||
43 | |||
40 | #if (CONFIG_PLATFORM & PLATFORM_ANDROID) | 44 | #if (CONFIG_PLATFORM & PLATFORM_ANDROID) |
41 | static const char rbhome[] = "/sdcard"; | 45 | static const char rbhome[] = "/sdcard"; |
42 | #elif (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA)) \ | 46 | #elif (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA)) \ |
@@ -206,6 +210,10 @@ const char * handle_special_dirs(const char *dir, unsigned flags, | |||
206 | #ifdef HAVE_MULTIDRIVE | 210 | #ifdef HAVE_MULTIDRIVE |
207 | dir = handle_special_links(dir, flags, buf, bufsize); | 211 | dir = handle_special_links(dir, flags, buf, bufsize); |
208 | #endif | 212 | #endif |
213 | #ifdef PIVOT_ROOT | ||
214 | snprintf(buf, bufsize, "%s/%s", PIVOT_ROOT, dir); | ||
215 | dir = buf; | ||
216 | #endif | ||
209 | return dir; | 217 | return dir; |
210 | } | 218 | } |
211 | 219 | ||
diff --git a/firmware/target/hosted/lc-unix.c b/firmware/target/hosted/lc-unix.c index 810dc9f92c..1061883832 100644 --- a/firmware/target/hosted/lc-unix.c +++ b/firmware/target/hosted/lc-unix.c | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include <string.h> /* size_t */ | 22 | #include <string.h> /* size_t */ |
23 | #include <dlfcn.h> | 23 | #include <dlfcn.h> |
24 | #include "file.h" | ||
24 | #include "debug.h" | 25 | #include "debug.h" |
25 | #include "load_code.h" | 26 | #include "load_code.h" |
26 | 27 | ||
@@ -28,7 +29,11 @@ void *lc_open(const char *filename, unsigned char *buf, size_t buf_size) | |||
28 | { | 29 | { |
29 | (void)buf; | 30 | (void)buf; |
30 | (void)buf_size; | 31 | (void)buf_size; |
31 | void *handle = dlopen(filename, RTLD_NOW); | 32 | char path[MAX_PATH]; |
33 | |||
34 | const char *fpath = handle_special_dirs(filename, 0, path, sizeof(path)); | ||
35 | |||
36 | void *handle = dlopen(fpath, RTLD_NOW); | ||
32 | if (handle == NULL) | 37 | if (handle == NULL) |
33 | { | 38 | { |
34 | DEBUGF("failed to load %s\n", filename); | 39 | DEBUGF("failed to load %s\n", filename); |
diff --git a/tools/configure b/tools/configure index 27c1e71f23..963bb62804 100755 --- a/tools/configure +++ b/tools/configure | |||
@@ -4212,7 +4212,6 @@ fi | |||
4212 | t_cpu="hosted" | 4212 | t_cpu="hosted" |
4213 | t_manufacturer="agptek" | 4213 | t_manufacturer="agptek" |
4214 | t_model="rocker" | 4214 | t_model="rocker" |
4215 | rbdir='/mnt/sd_0/.rockbox' | ||
4216 | mipsellinuxcc | 4215 | mipsellinuxcc |
4217 | ;; | 4216 | ;; |
4218 | 4217 | ||