MyBB Community Forums

Full Version: [F] Avatar wrong CHMod
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi, when i upload a Avatar, he get only CHMOD 600

So the Upload works, but the Avatar get the wrong rights.
The avatar upload function uses the apache user/usergroup instead of the user/usergroup of the domain where the Forum is running, that's why the files become chmod 600.

EDIT: OK, i checked this with my own server configuration, and everything with the user/usergroup works fine.
ah, and how can i fix that?

Because on other Forum Systems oder CMS i havent this problem, the Forum is on my server, same as the domain, you can check it @ replay-gaming.eu if ypu want to test it

Its a empty Forum, atm its more for testing

thx for yout help
OK, i found the problem

Open /inc/function_upload.php

Goto Line 558:

@my_chmod($path."/".$filename, 0664);

and change to

@my_chmod($path."/".$filename, 0644);

After this, all avatar that are uploaded have chmod 644.
Thank you for your bug report.

This bug has been fixed in our internal code repository. Please note that the problem will not be fixed here until these forums are updated.
Why aren't you using the my_chmod function?

//Custom chmod function to fix problems with hosts who's server configurations screw up umasks
// (quoted from mybb_1400\Upload\inc\functions.php line #5244)
@my_chmod($path."/".$filename, 0644);

As far as I can see mybb use the chmod functionality only twice:
mybb_1400\Upload\inc\functions_image.php line #123 - @my_chmod($path."/".$filename, 0666);
mybb_1400\Upload\inc\functions_upload.php line #558 - @my_chmod($path."/".$filename, 0664);

and in both by the my_chmod function and not directly chmod.
The my_chmod function seems not to work for all apache/php configurations, because the uploaded files had chmod 600 and not 664. But the chmod function works perfect on my configuration.
Some users in the german community reported that this fix isn't working. The problem is that the function my_chmod() always returns false.

Here's a little testscript:
<?php
function my_chmod($mode)
{
	if(substr($mode, 0, 1) != '0' || strlen($mode) !== 4)
	{
		echo "Failure!";
	}
	else
	{
		echo "Success";
	}
}

my_chmod(0644);
?>
It outputs "Failure". The problem is that substr() and strlen() only work with strings. If you set the argument inside quotation marks it returns "Success":
my_chmod("0644");
Double fixed.

@Chris might be the reason why it didn't work on your other work script

Try this michael

function my_chmod($file, $mode)
{
	if(substr((string)$mode, 0, 1) != '0' || strlen((string)$mode) !== 4)
	{
		return false;
	}
	$old_umask = umask(0);
	$result = chmod($file, $mode);
	umask($old_umask);
	return $result;
}
It's not working. I also inserted the line
$mode = (string)$mode;
at the beginning of the my_chmod function before and it didn't work.
Pages: 1 2