Studio-42 / elFinder

📁 Open-source file manager for web, written in JavaScript using jQuery and jQuery UI
https://studio-42.github.io/elFinder/
Other
4.64k stars 1.41k forks source link

Chmod function always disabled #3080

Closed zengenuity closed 4 years ago

zengenuity commented 4 years ago

I can't figure out why the chmod button is always disabled for me. I have enabled the button, but when I select a file, it's always greyed-out, as shown here.

Screen Shot 2019-12-31 at 1 11 42 PM

I have enabled the chmod command in my connector config by adding:

'allowChmodReadOnly' => TRUE,
'statOwner'     => TRUE,

That makes the button show up, but it's always disabled. The statOwner function is working, and I have the permission shown in Get Info.

Screen Shot 2019-12-31 at 1 16 41 PM

I must be missing a step. Any ideas?

zengenuity commented 4 years ago

I should have mentioned this is on LocalFileSystem driver.

nao-pon commented 4 years ago

@zengenuity Is the execution account of php (Web server) UID 2000? chmod can only be a file whose owner is php (Web server).

zengenuity commented 4 years ago

Thanks for your help with this.

Yes, UID 2000 is a user account "dev". Some debugging output from the command line:

Dev is UID 2000:

dev@studentdru1:~/data$ id
uid=2000(dev) gid=2000(dev) groups=2000(dev)

Dev owns the file and has write access.

dev@studentdru1:~/data$ ls -l
total 0
-rw-r--r--    1 dev      dev              0 Dec 31 18:01 NewFile.php

PHP is running as mod-php on Apache. Apache is running as user dev:

dev@studentdru1:~/data$ ps ax
PID   USER     TIME  COMMAND
...
 1935 dev       0:00 /usr/sbin/httpd -d /var/www -f /etc/apache2/httpd.conf -k start
 1936 dev       0:00 /usr/sbin/httpd -d /var/www -f /etc/apache2/httpd.conf -k start

The file NewFile.php was actually created using elFinder, and it was created owned by dev, so that matches with the web server user.

Dev user can run chmod on the command line, and it works:

dev@studentdru1:~/data$ ls -l
total 0
-rw-r--r--    1 dev      dev              0 Dec 31 18:01 NewFile.php
dev@studentdru1:~/data$ chmod 755 NewFile.php
dev@studentdru1:~/data$ ls -l
total 0
-rwxr-xr-x    1 dev      dev              0 Dec 31 18:01 NewFile.php
dev@studentdru1:~/data$

Anything else I should check?

nao-pon commented 4 years ago

elFinder use posix_getuid() to get PHP uid. What is result next test code on your web server?


<?php
var_dump(posix_getuid());
zengenuity commented 4 years ago

Ugh. Sorry. php-posix module was not installed.

I thought it was because --enable-posix=shared was on the configure command info in phpinfo(). But, apparently on Alpine Linux, you also need to have php7-posix package installed. After I install, it works.

Thanks again for your help debugging this.