summaryrefslogtreecommitdiff
path: root/debian/patches/fix_chown.patch
blob: 31b82e2573f099b28a534824cedde5fcf8b8f2af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Description: Fix chown in cache
 Ensure files in cache belong to www-data. phpBB tries to set them to
 the same owner than common.php, that belongs to root under Debian, and
 then set them world writable because it can’t change the owner (nor
 group) to root.
Author: David Prévot <taffit@debian.org>
Bug-Debian: http://bugs.debian.org/711172
Forwarded: not-needed
Last-Update: 2013-09-28
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -725,16 +725,16 @@
 		{
 			global $phpbb_root_path, $phpEx;
 
-			// Determine owner/group of common.php file and the filename we want to change here
-			$common_php_owner = @fileowner($phpbb_root_path . 'common.' . $phpEx);
-			$common_php_group = @filegroup($phpbb_root_path . 'common.' . $phpEx);
+			// Determine owner/group of the filename we want to change here
+			$common_php_owner = (function_exists('posix_getpwnam')) ? @posix_getpwnam('www-data') : false;
+			$common_php_group = (function_exists('posix_getgrnam')) ? @posix_getgrnam('www-data') : false;
 
 			// And the owner and the groups PHP is running under.
 			$php_uid = (function_exists('posix_getuid')) ? @posix_getuid() : false;
 			$php_gids = (function_exists('posix_getgroups')) ? @posix_getgroups() : false;
 
 			// If we are unable to get owner/group, then do not try to set them by guessing
-			if (!$php_uid || empty($php_gids) || !$common_php_owner || !$common_php_group)
+			if (!$php_uid || empty($php_gids) || empty($common_php_owner) || empty($common_php_group))
 			{
 				$_chmod_info['process'] = false;
 			}
@@ -742,8 +742,8 @@
 			{
 				$_chmod_info = array(
 					'process'		=> true,
-					'common_owner'	=> $common_php_owner,
-					'common_group'	=> $common_php_group,
+					'common_owner'	=> $common_php_owner[uid],
+					'common_group'	=> $common_php_group[gid],
 					'php_uid'		=> $php_uid,
 					'php_gids'		=> $php_gids,
 				);