Some attached files with owner and group - nobody

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
Jenny
Posts: 18
Joined: Thu Mar 26, 2015 7:52 am

Some attached files with owner and group - nobody

Post 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?
Klemen
Site Admin
Posts: 10147
Joined: Fri Feb 11, 2005 4:04 pm

Re: Some attached files with owner and group - nobody

Post 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).
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Jenny
Posts: 18
Joined: Thu Mar 26, 2015 7:52 am

Re: Some attached files with owner and group - nobody

Post by Jenny »

Thank you!
But my hoster told that I have to configure the script with umask, which "making" this files :(
Klemen
Site Admin
Posts: 10147
Joined: Fri Feb 11, 2005 4:04 pm

Re: Some attached files with owner and group - nobody

Post 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?
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Jenny
Posts: 18
Joined: Thu Mar 26, 2015 7:52 am

Re: Some attached files with owner and group - nobody

Post 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
Klemen
Site Admin
Posts: 10147
Joined: Fri Feb 11, 2005 4:04 pm

Re: Some attached files with owner and group - nobody

Post 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).
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Jenny
Posts: 18
Joined: Thu Mar 26, 2015 7:52 am

Re: Some attached files with owner and group - nobody

Post 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((
Jenny
Posts: 18
Joined: Thu Mar 26, 2015 7:52 am

Re: Some attached files with owner and group - nobody

Post by Jenny »

help me please :roll:
Klemen
Site Admin
Posts: 10147
Joined: Fri Feb 11, 2005 4:04 pm

Re: Some attached files with owner and group - nobody

Post 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?
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Jenny
Posts: 18
Joined: Thu Mar 26, 2015 7:52 am

Re: Some attached files with owner and group - nobody

Post 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 :(
Klemen
Site Admin
Posts: 10147
Joined: Fri Feb 11, 2005 4:04 pm

Re: Some attached files with owner and group - nobody

Post by Klemen »

Because on your server piped script is running under a different username than the script you open via browser.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Post Reply