• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved pm_ApiCli::ch_mode only on files?

lippoliv

Basic Pleskian
Hi there,
any way to realize a pm_ApiCli::ch_mode-Call only for files?

PHP:
    pm_ApiCli::callSbin(
        'ch_mode',
        [
            $permissions,
            '-R',
            '$(find ' . $path . ' -type f)',
        ]
    );

Doesnt work

Error: Execution ch_mode has failed with exit code 1, stdout: , stderr: ch_mode: $(find /var/www/vhosts/test.de/httpdocs/test -type f): No such file or directory

I also played around with FileManager to checkout if I could build a recursive function on my own to start at a given Directory and scan down recusively for only files and do an FileManager->chmod (little dirty) but there is also no way to decide whether the given path is an dir or an file...
 
Hello,

I would recommend to implement a small shell script in sbin directory of your extension and run it using pm_ApiCli::callSbin passing necessary permissions and path. It will be more flexible.

The other case if you want to make chmod under vhost owner privileges. In this case you use something similar to:
Code:
$domain = pm_Domain::getByName('example.com');
$fileManager = new pm_FileManager($domain->getId());
$user = $domain->getSysUserLogin();
$path = $fileManager->getFilePath('path/inside/vhost/');

pm_ApiCli::callSbin('filemng', [$user, 'exec', $path, 'chmod', '-R', '644', '.']);
 
Hello vlikhtanskiy,
thanks for your reply.

Can you please provide any additional Information for your first idea? I looked around and did not find usefull informations about where to place the file (plib/hooks/sbin/... should it be, in other parts I read it has to be in /psa/admin/bin/modules/my-module/...) and how to call it?
I tryed to place a script in plib/hooks/sbin and called pm_ApiCli::callSbin('my-util'... and also pm_ApiCli::callSbin('my-util.sh'... but none worked: "Util not found".

As of I really just work in vhosts, I extend the Filemanager, I tryed already something like your second Approach and run into two Problems: As users act differently, I maybe have no domainId / Domain (Login, Open FileManager, Navigate to some path...). And on the other Hand I don't just want to set recursive permissions, I want to set seperate permissions for files and for Folders. So the simple "chmod -R 644 ." will not work as of it sets for both.
 
@vlikhtanskiy Thanks for your additional Information. Really nice it worked.

First test was confusing. I did all like the "ext-syslog-watch" but the command wasn't found. I stopped for some seconds and got the idea to "install" the Extension. That seems to be the key. Maybe also my auto-upload was not configured correct (new mapping has to be added). But after an install it worked pretty good :)

Now I can finish and submit that Extension. Thanks again.
 
@vlikhtanskiy weird Story: Today I did some finalizations to get the Extension ready for submit. I also did one Change on the Shell file. Now I get an error: "Error: Execution change_permissions_recursive has failed with exit code 126, stdout: , stderr: bash: /opt/psa/admin/bin/modules/permissions-recursive/change_permissions_recursive: Permission denied" when running the command.

I rolled back my Change, but the error still occures!?
 
I suggest to send the extension archive to certification team for detailed investigations.
 
Last edited:
Error: Execution change_permissions_recursive has failed with exit code 126, stdout: , stderr: bash: /opt/psa/admin/bin/modules/permissions-recursive/change_permissions_recursive: Permission denied

I have the same error with my extension, is there already a way to fix this problem?
 
Back
Top