RainLoop / rainloop-webmail

Simple, modern & fast web-based email client
http://rainloop.net
MIT License
4.11k stars 891 forks source link

[202] Data folder permisions error #262

Closed MrKeiKun closed 10 years ago

MrKeiKun commented 10 years ago

Information: Im using rainloop from github src, I installed once before on another server. Worked fine same procedures. Now im running centos7.

I already ran

cd /var/www/rainloop
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

still not working

[root@neko www]# pwd
/var/www
[root@neko www]# ls -lha
total 28K
drwxr-xr-x.  7 root root 4.0K Jul 31 07:12 .
drwxr-xr-x. 21 root root 4.0K Jul 29 12:42 ..
drwxr-xr-x.  2 root root 4.0K Jul 23 10:48 cgi-bin
drwxr-xr-x.  2 root root 4.0K Jun  9 22:32 html
drwxr-xr-x. 10 root root 4.0K Jul 31 07:12 rainloop
total 92K
drwxr-xr-x. 10 root root 4.0K Jul 31 07:12 .
drwxr-xr-x.  7 root root 4.0K Jul 31 07:12 ..
drwxr-xr-x.  4 root root 4.0K Jul 31 07:12 build
drwxrwxrwx.  2 root root 4.0K Jul 31 07:18 data
drwxr-xr-x. 12 root root 4.0K Jul 31 07:12 dev
drwxr-xr-x.  8 root root 4.0K Jul 31 07:12 .git
-rw-r--r--.  1 root root  126 Jul 31 07:12 .gitignore
-rw-r--r--.  1 root root  19K Jul 31 07:12 gulpfile.js
-rw-r--r--.  1 root root  214 Jul 31 07:12 _include.php
-rw-r--r--.  1 root root  428 Jul 31 07:12 index.php
-rw-r--r--.  1 root root 1.2K Jul 31 07:12 .jshintrc
-rw-r--r--.  1 root root 1.5K Jul 31 07:12 LICENSE
-rw-r--r--.  1 root root   69 Jul 31 07:12 _MULTIPLY
-rw-r--r--.  1 root root 1.2K Jul 31 07:12 package.json
drwxr-xr-x. 20 root root 4.0K Jul 31 07:12 plugins
drwxrwxrwx.  3 root root 4.0K Jul 31 07:12 rainloop
-rw-r--r--.  1 root root  791 Jul 31 07:12 README.md
drwxr-xr-x.  4 root root 4.0K Jul 31 07:12 tests
drwxr-xr-x. 32 root root 4.0K Jul 31 07:12 vendors
RainLoop commented 10 years ago

755 and 644 works with apache/nginx user only. If you want to use root owner fo files, you shoud set 775 and 664.

cd /var/www/rainloop
find . -type d -exec chmod 775 {} \;
find . -type f -exec chmod 664 {} \;
MrKeiKun commented 10 years ago

@RainLoop

still not working have you guys even tested this over centos 6.x and 7? cause default all files and folders located @ /var/www/ are all owned by root generated by apache(from base) of centOS

RainLoop commented 10 years ago

Please, run this code in RainLoop Webmail root folder.

check.php

<?php

define('APP_DATA_FOLDER_PATH', './data/');

$sCheckName = 'delete_if_you_see_it_after_install';
$sCheckFolder = APP_DATA_FOLDER_PATH.$sCheckName;
$sCheckFilePath = APP_DATA_FOLDER_PATH.$sCheckName.'/'.$sCheckName.'.file';

@unlink($sCheckFilePath);
@rmdir($sCheckFolder);

$aResult = array();
if (is_dir(APP_DATA_FOLDER_PATH))
{
    $aResult = array(
        '1) is_dir='.(@is_dir(APP_DATA_FOLDER_PATH) ? '1' : '0'),
        '2) is_readable='.(@is_readable(APP_DATA_FOLDER_PATH) ? '1' : '0'),
        '3) is_writable='.(@is_writable(APP_DATA_FOLDER_PATH) ? '1' : '0'),
        '4) mkdir='.(@mkdir($sCheckFolder, 0755) ? '1' : '0'),
        '5) file_put_contents='.(false !== @file_put_contents($sCheckFilePath, time()) ? '1' : '0'),
        '6) unlink='.(false !== @unlink($sCheckFilePath) ? '1' : '0'),
        '7) rmdir='.(false !== @rmdir($sCheckFolder) ? '1' : '0')
    );
}
else
{
    $aResult[] = 'is_dir=0';
}

echo implode("</br>\r\n", $aResult);
?>
MrKeiKun commented 10 years ago

@RainLoop

1) is_dir=1
2) is_readable=1
3) is_writable=0
4) mkdir=0
5) file_put_contents=0
6) unlink=0
7) rmdir=0
RainLoop commented 10 years ago

Your data folder is not writable from PHP code. Try to set correct chown for data folder (your webserver user - apache, www-data or nginx)

MrKeiKun commented 10 years ago

@RainLoop

I already 777 everything still not working

can you give me a code that will write something inside data? cause i don't think data isn't writeable

RainLoop commented 10 years ago

I already gave you the code. He tried to write files in the data folder.

MrKeiKun commented 10 years ago

@RainLoop

so 1-7 should be is equal to 1 that is just over /data/ right?

RainLoop commented 10 years ago

Yes

RainLoop commented 10 years ago

Is this issue still relevant?

MrKeiKun commented 10 years ago

Selinux issue~ @RainLoop Documentation should tell to disable Selinux~

RainLoop commented 10 years ago

Ok, thanks!

JeffDuf commented 9 years ago

i had the same problem. 777 worked.

boycce commented 9 years ago

Same had to change chmod to 777

galch99 commented 9 years ago

@RainLoop 1) is_dir=1 2) is_readable=1 3) is_writable=1 4) mkdir=1 5) file_put_contents=0 6) unlink=0 7) rmdir=1

every thing 777. but not working :(

rjapeer commented 8 years ago

Took me a little while to figure out, but the solution is to have SE Linux allow writing data folder by httpd: You need to change the label on '/your/installation/folder/data'. In my case this is done by the following two commands (as root user):

[root@machine rainloop]# cd /var/www/html/rainloop
[root@machine rainloop]# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/rainloop/data'
[root@machine rainloop]# restorecon -v '/var/www/html/rainloop/data'

Note that the complete path to the rainloop data folder must be specified. You can check the setting using ls -Z:

[root@machine rainloop]# ls -Z
drwxr-xr-x. apache apache system_u:object_r:httpd_sys_rw_content_t:s0 data
-rw-r--r--. apache apache system_u:object_r:httpd_sys_content_t:s0 index.php
drwxr-xr-x. apache apache system_u:object_r:httpd_sys_content_t:s0 rainloop

And with the check.php script from a previous comment the output should be:

1) is_dir=1
2) is_readable=1
3) is_writable=1
4) mkdir=1
5) file_put_contents=1
6) unlink=1
7) rmdir=1
saikatharryc commented 8 years ago

[202] Data folder permissions error [is_writable]. i have SSH console. how do i make this run?

aestheticsdata commented 8 years ago

following the doc has worked for me :

http://www.rainloop.net/docs/permissions/

maybe it was the missing : chown -R www-data:www-data .

saikatharryc commented 8 years ago

not worked.

lutfiarfianto commented 8 years ago

i have

1) is_dir=1 2) is_readable=1 3) is_writable=1 4) mkdir=1 5) file_put_contents=0 6) unlink=0 7) rmdir=1

chmod = 0777

but i dont have ssh access

what should i do?

mpatron commented 8 years ago

You should try

setsebool httpd_unified true
setsebool httpd_can_network_connect true
yum install policycoreutils-python
cd /var/www/html/rainloop
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/rainloop/data'
restorecon -v '/var/www/html/rainloop/data'
systemctl restart httpd

It is working for me on my centos7+rainloop.

parsibox commented 7 years ago

you should desable selinux and reboot your os

MoacirSchmidt commented 7 years ago

For Windows + IIS you have to give proper permissions to IUSR also

Alirezaies commented 7 years ago

I had the same problem with SELinux off and correct permissions (644 for files and 755 for directories). I needed to change php-fpm user to the same user as web server (e.g. nginx, www-data, ...)

here is what I changed in /etc/php-fpm.d/www.conf in CentOS 7:

listen.owner = nobody
listen.group = nobody
user = nginx
group = nginx

and then sudo systemctl restart php-fpm solved the problem

mojili commented 7 years ago

I had the same problem with SELinux. first setenforce 0 and then try if everything is ok, then enable SELinux setenforce 1 and try to find the targets witch SELinux denies them . Tail -f /var/log/audit/audit.log | grep deny then with semanage or other tools set the proper permission.

shaahinhs commented 7 years ago

hi , i had the same problem ;

1) is_dir= 2) is_readable=1 3) is_writable=1 4) mkdir=1 5) file_put_contents=1 6) unlink=1 7) rmdir=1 Selinux disable

but : [202] Data folder permisions error

os: centos 5.11 / apache 2.2.31

mpatron commented 6 years ago

shaahinhs , you should follow https://github.com/pierre-alain-b/rainloop-nextcloud/issues/7

Mardiie commented 5 years ago

Might be a dumb addition, but make sure the rainloop folder is owned by www-data.

eanon commented 5 years ago

Hello, Just my two cents on a topic that, I guess, still raises issues in a lot of minds all year long (not only about Rainloop). For me, what is said on http://www.rainloop.net/docs/permissions/ is not enough since it takes some assumptions (eg. www-data user) with no strong way to figure-out what to do if your system is not perfectly as described...

So, here is my proposition: 1) cd root-directory-where-rainloop-installed (should contain 2 directories: 'rainloop' and 'data') 2) ps aux | grep name-of-your-webserver (e.g. nginx) => In 1st column you see user running web server (for nginx, consider worker only) 3) chown -R webserver_user_found_above:webserver_user_found_above rainloop 4) ps aux | grep php => In 1st column you see user running PHP code 5) chown -R php_user_found_above:php_user_found_above data 6) chmod all directories recursively to 755 (through SSH or using FTP client like FileZilla) 7) chmod all files recursively to 644 (through SSH or using FTP client like FileZilla) 8) Test all is OK with PHP script provided by Rainloop in comment #50786471 above 9) As double-check, go to Rainloop Admin panel and do a change, then logout/login to see if kept.

For example, here an exotic context: in a VPS I just installed yesterday, the user about Nginx was "emps" (related to Webuzo, a control panel from which I installed Nginx) and the one running PHP-FPM was "admin" (this being confirmed looking in the php-fpm.conf managed by Webuzo again). So, my two concerned users were "emps:emps" and "admin:admin".

But, please, never go the devil way giving ownership to root or superuser with dangerous chmod like 777.

Hoping it may help...

chrboesch commented 4 years ago

For those who use nginx and php-fpm: As of PHP 7.4 php-fpm protects the system by mounting /usr, /boot, and /etc directories read-only. For it to work, the directory /usr/share/webapps/ must be moved to /www/, for example.