diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-03-28 03:51:50 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-04-16 22:03:08 -0400 |
commit | cbfb8e703ed9c7e31848ebf959ac7a4cf27b4a64 (patch) | |
tree | 63c352b5287e9f57ed91b2950d4fec9d5cf1c864 /src/common/compat.c | |
parent | 3802e32c7d94c599546069d8246636b0d3a4ad10 (diff) | |
download | tor-cbfb8e703ed9c7e31848ebf959ac7a4cf27b4a64.tar.gz tor-cbfb8e703ed9c7e31848ebf959ac7a4cf27b4a64.zip |
Add 'rename' to the sandboxed syscalls
(If we don't restrict rename, there's not much point in restricting
open, since an attacker could always use rename to make us open
whatever they want.)
Diffstat (limited to 'src/common/compat.c')
-rw-r--r-- | src/common/compat.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index 04c9d59235..5c18535285 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -175,6 +175,14 @@ tor_fopen_cloexec(const char *path, const char *mode) return result; } +/** As rename(), but work correctly with the sandbox. */ +int +tor_rename(const char *path_old, const char *path_new) +{ + return rename(sandbox_intern_string(path_old), + sandbox_intern_string(path_new)); +} + #if defined(HAVE_SYS_MMAN_H) || defined(RUNNING_DOXYGEN) /** Try to create a memory mapping for <b>filename</b> and return it. On * failure, return NULL. Sets errno properly, using ERANGE to mean @@ -799,7 +807,7 @@ int replace_file(const char *from, const char *to) { #ifndef _WIN32 - return rename(from,to); + return tor_rename(from, to); #else switch (file_status(to)) { @@ -814,7 +822,7 @@ replace_file(const char *from, const char *to) errno = EISDIR; return -1; } - return rename(from,to); + return tor_rename(from,to); #endif } |