From 16fde6798bc170cbfd6827f81216df61c0fc8483 Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 15 Jun 2016 17:28:42 +0100 Subject: [PATCH] Allow write access to all files if a user has effective root permissions on linux --- modules/juce_core/native/juce_posix_SharedCode.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/juce_core/native/juce_posix_SharedCode.h b/modules/juce_core/native/juce_posix_SharedCode.h index 111b5818b8..033e4378b6 100644 --- a/modules/juce_core/native/juce_posix_SharedCode.h +++ b/modules/juce_core/native/juce_posix_SharedCode.h @@ -332,11 +332,21 @@ uint64 File::getFileIdentifier() const return juce_stat (fullPath, info) ? (uint64) info.st_ino : 0; } +static bool hasEffectiveRootFilePermissions() +{ + #if JUCE_LINUX + return (geteuid() == 0); + #else + return false; + #endif +} + //============================================================================== bool File::hasWriteAccess() const { if (exists()) - return access (fullPath.toUTF8(), W_OK) == 0; + return (hasEffectiveRootFilePermissions() + || access (fullPath.toUTF8(), W_OK) == 0); if ((! isDirectory()) && fullPath.containsChar (separator)) return getParentDirectory().hasWriteAccess();