• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Issue FileManager and ServerFileManager permission issue

sfsdg

New Pleskian
I'm need to copy subdomain files to new domain folder, i have a custom extension. This extension using pm_ServerFileManager class's copyFile method. But files are copying with root user? If I use pm_FileManager extension return Permission error like "filemng failed: filemng: stat failed: Permission denied. System error 13: Permission denied"

Here is my code;

PHP:
protected function _run()
    {
        $from = $this->_params["from"];
        $to = $this->_params["to"];
        $defaultDbUsername = $this->_params["defaultDbUsername"];
        $defaultDbPassword = $this->_params["defaultDbPassword"];

        $domain = new \pm_Domain();

        $fromDomain =  $domain->getByDomainId($from);
        $toDomain =  $domain->getByDomainId($to);
  
        $fromDomainDocumentRoot = $fromDomain->getDocumentRoot();
        $toDomainDocumentRoot = $toDomain->getDocumentRoot();

        $fileManager = new \pm_FileManager($to);

        //Yükleme yapılacak site klsörünü temizleme
        $toFilePath = $fileManager->scanDir($toDomainDocumentRoot, true);
        foreach ($toFilePath as $value) {
            $fileManager->removeFile($toDomainDocumentRoot . "/" . $value);
        }

        //Wordpress yükleme
        $fromFilePath = $fileManager->scanDir($fromDomainDocumentRoot, true);
        foreach ($fromFilePath as $value) {
            $fileManager->copyFile($fromDomainDocumentRoot . "/" . $value, $toDomainDocumentRoot);
            //$fileManager->chmod($fromDomainDocumentRoot . "/" . $value, "755");
        }

        $toFileContents = $fileManager->fileGetContents($toDomainDocumentRoot . "/wp-config.php");

        $domainName = $domain->getName();

        $toFileContents = preg_replace('/define\(\'DB_NAME\', \'(.*?)\'\);/', "define('DB_NAME', '$domainName');", $toFileContents);
        $toFileContents = preg_replace('/define\(\'DB_USER\', \'(.*?)\'\);/', "define('DB_USER', '$defaultDbUsername');", $toFileContents);
        $toFileContents = preg_replace('/define\(\'DB_PASSWORD\', \'(.*?)\'\);/', "define('DB_PASSWORD', '$defaultDbPassword');", $toFileContents);

        $fileManager->filePutContents($toDomainDocumentRoot . "/wp-config.php", $toFileContents);


        return [
            'status' => true,
        ];
    }

This return like that result
Code:
<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.8.0">
  <extension>
    <call>
      <result>
        <status>error</status>
        <errcode>1002</errcode>
        <errtext>filemng failed: filemng: stat failed: Permission denied

System error 13: Permission denied</errtext>
      </result>
    </call>
  </extension>
</packet>

If I use pm_ServerFileManager class code works perfectly but files are copy with root user;
roo_problem.png


Edit:
I'm researching already for this post. And everybody says like "this is not possible". But wp-toolkit and "Plesk Web Clone" doing this, how?
 
Last edited:
If customers are custom (not Administrator) and different or same I can copy files between domains. This is local, if I go to real server on the I can't do this.
 
Back
Top