Page 1 of 1

Some attached files with owner and group - nobody

Posted: Wed Apr 15, 2015 11:41 pm
by Jenny
I have 777 and hesk user for attachments directory, but I recieve attaches with rights "nobody", and I can't download it.. Only when I make 777 again and set group and permissions recursively I can get them. How can I solve it?

Re: Some attached files with owner and group - nobody

Posted: Thu Apr 16, 2015 8:07 am
by Klemen
This all boils down to how your server is setup. Your PHP probably runs under user "Nobody" hence all the files it generates are under user "Nobody".

To fix the issue your server would need to be configured to run PHP under your account username (for example using SuPHP).

Re: Some attached files with owner and group - nobody

Posted: Thu Apr 16, 2015 1:45 pm
by Jenny
Thank you!
But my hoster told that I have to configure the script with umask, which "making" this files :(

Re: Some attached files with owner and group - nobody

Posted: Thu Apr 16, 2015 4:54 pm
by Klemen
Wait, you mean you can't download files when you click from within the "View ticket" page, or when you try downloading directly over FTP?

Do you have email piping/pop3 fetching enabled?

Re: Some attached files with owner and group - nobody

Posted: Fri Apr 17, 2015 3:47 am
by Jenny
Klemen wrote:Wait, you mean you can't download files when you click from within the "View ticket" page
yes
or when you try downloading directly over FTP?
this too
Do you have email piping/pop3 fetching enabled?
piping enabled

Re: Some attached files with owner and group - nobody

Posted: Fri Apr 17, 2015 2:50 pm
by Klemen
Then this is definitely permissions problem because the PHP pipe is running under a different user.

You can try setting chmod and see if that helps:
1. open file inc/attachments.inc.php
2. inside find

Code: Select all

$info = array
3. just ABOVE that add

Code: Select all

@chmod(dirname(dirname(__FILE__)).'/'.$hesk_settings['attach_dir'].'/'.$file_name, 0644);
3. save, upload and test to see if it works on new tickets

Not sure if your host allows it, but you could also try to change the owner instead in step 2 above:

Code: Select all

@chown(dirname(dirname(__FILE__)).'/'.$hesk_settings['attach_dir'].'/'.$file_name, USER);
(replace USER with the username PHP runs under, either as "username" or numerical value (again check with your host to confirm under what user your scripts execute via browser, not pipe).

Re: Some attached files with owner and group - nobody

Posted: Wed Apr 22, 2015 9:43 pm
by Jenny
Thank you!

The problem was that MTA Postfix making pipe commands from "nobody" by default. I made in default_privs real user and it works correct now.

Another problem that all files still have 0600. This is not a big problem, but
@chmod(dirname(dirname(__FILE__)).'/'.$hesk_settings['attach_dir'].'/'.$file_name, 0644);
this did not solve the problem((

Re: Some attached files with owner and group - nobody

Posted: Thu Apr 23, 2015 6:27 pm
by Jenny
help me please :roll:

Re: Some attached files with owner and group - nobody

Posted: Fri Apr 24, 2015 6:29 pm
by Klemen
If the chmod doesn't work then it's either disabled in PHP or user running PHP doesn't have permissions to modify it?

Re: Some attached files with owner and group - nobody

Posted: Mon Apr 27, 2015 11:58 am
by Jenny
Klemen wrote:If the chmod doesn't work then it's either disabled in PHP or user running PHP doesn't have permissions to modify it?
I made a test file with this code:

Code: Select all

$text = "Test text";
$fp = fopen("file.txt", "w");
fwrite($fp, $text);
fclose($fp);
I got file created with 0644

I don't know why

Code: Select all

@chmod(dirname(dirname(__FILE__)).'/'.$hesk_settings['attach_dir'].'/'.$file_name, 0644);
not working :(

Re: Some attached files with owner and group - nobody

Posted: Mon Apr 27, 2015 1:04 pm
by Klemen
Because on your server piped script is running under a different username than the script you open via browser.