• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

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