From 6bc6b5dcd13e57b8ea73849f8b88a1b738f3f084 Mon Sep 17 00:00:00 2001 From: Archie Date: Mon, 3 Nov 2014 23:23:15 -0800 Subject: [PATCH] Simplifying hasPermissions Simplifying the permissions check. I've tested this with a couple permission sets and user sets. --- php/modules/misc.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/php/modules/misc.php b/php/modules/misc.php index 8a2d8c8..4b1bf94 100755 --- a/php/modules/misc.php +++ b/php/modules/misc.php @@ -121,13 +121,14 @@ function get_hashed_password($password) { } -function hasPermissions($path, $permissions = '0777') { +function hasPermissions($path) { - /* assume that if running with the same uid as the owner of the directory it's ok */ - $stat = @stat($path); - if ($stat && ($stat['uid'] == getmyuid())) return true; - if (substr(sprintf('%o', @fileperms($path)), -4)!=$permissions) return false; - else return true; + # Using built-in php function + if (is_writeable($path)) { + return true; + } + + return false; }