From 2bc705b9efc0ffdca9b092105d17e7ff1aff39ea Mon Sep 17 00:00:00 2001 From: sminnee Date: Thu, 20 Nov 2008 22:48:03 +0000 Subject: [PATCH] Improved help text that the installer provides when file permissions aren't met. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/phpinstaller/branches/2.3@66328 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- install.php | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/install.php b/install.php index 3ae45cd..0b9387b 100644 --- a/install.php +++ b/install.php @@ -374,23 +374,37 @@ class InstallRequirements { if(!is_writeable($filename)) { if(function_exists('posix_getgroups')) { - $user = posix_getpwuid(posix_geteuid()); - $groups = posix_getgroups(); - foreach($groups as $group) { - $groupInfo = posix_getgrgid($group); - $groupList[] = $groupInfo['name']; + $userID = posix_geteuid(); + $user = posix_getpwuid($userID); + + $currentOwnerID = fileowner($filename); + $currentOwner = posix_getpwuid($currentOwnerID); + + $testDetails[2] .= "User '$user[name]' needs to be able to write to this file:\n$filename\n\nThe file is currently owned by '$currentOwner[name]'. "; + + if($user['name'] == $currentOwner['name']) { + $testDetails[2] .= "We recommend that you make the file writeable."; + } else { + + $groups = posix_getgroups(); + foreach($groups as $group) { + $groupInfo = posix_getgrgid($group); + if(in_array($currentOwner['name'], $groupInfo['members'])) $groupList[] = $groupInfo['name']; + } + if($groupList) { + $testDetails[2] .= " We recommend that you make the file group-writeable and change the group to one of these groups:\n - ". implode("\n - ", $groupList) + . "\n\nFor example:\nchmod g+w $filename\nchgrp " . $groupList[0] . " $filename"; + } else { + $testDetails[2] .= " There is no user-group that contains both the web-server user and the owner of this file. Change the ownership of the file, create a new group, or temporarily make the file writeable by everyone during the install process."; + } } - $groupList = "'" . implode("', '", $groupList) . "'"; } - - $testDetails[2] .= "User '$user[name]' needs to be able to write to this file:\n$filename"; + + } else { + $testDetails[2] .= "The webserver user needs to be able to write to this file:\n$filename"; + } + $this->error($testDetails); } - /* - } else { - $testDetails[2] .= "Unable to detect whether I can write to files. Please ensure $filename is writable."; - $this->warning($testDetails); - } - */ } function requireTempFolder($testDetails) {