Error if deleting a webdav user

Discussion in 'Developers' Forum' started by BenM, Nov 28, 2024.

  1. BenM

    BenM Member

    Running (Debian Bookworm) ISPConfig 3.2.12p1
    PHP Fatal error: Uncaught TypeError: fgets(): Argument #1 ($stream) must be of type resource, bool given in /usr/local/ispconfig/server/plugins-available/apache2_plugin.inc.php:2990

    I deleted the section, and the call to patchVhostWebdav, else the jobshandeling get stuc.

    /**
    * This function patches the vhost-file and adds all webdav - user.
    * This function is written, because the creation of the vhost - file is sophisticated and
    * i don't want to make it more "heavy" by also adding this code too...
    * @author Oliver Vogel
    * @param string $fileName The Name of the .vhost-File (path included)
    * @param string $webdavRoot The root of the webdav-folder
    */
    private function _patchVhostWebdav($fileName, $webdavRoot) {
    global $app;
    $in = fopen($fileName, 'r');
    $output = '';
    $inWebdavSection = false;
    /*
    * read line by line and search for the username and authname
    */
    while ($line = fgets($in)) {

    /*
    * is the "replace-comment" found...
    */
    if (trim($line) == '# WEBDAV BEGIN') {
    /*
    * The begin of the webdav - section is found, so ignore all lines til the end is found
    */
    $inWebdavSection = true;
    $output .= " # WEBDAV BEGIN\n";
    /*
    * add all the webdav-dirs to the webdav-section
    */
    $files = @scandir($webdavRoot);
    if(is_array($files)) {
    foreach($files as $file) {
    if (substr($file, strlen($file) - strlen('.htdigest')) == '.htdigest' && preg_match("/^[a-zA-Z0-9\-_\.]*$/", $file)) {
    /*
    * found a htdigest - file, so add it to webdav
    */
    $fn = substr($file, 0, strlen($file) - strlen('.htdigest'));
    $output .= "\n";
    // $output .= " Alias /" . $fn . ' ' . $webdavRoot . '/' . $fn . "\n";
    // $output .= " <Location /" . $fn . ">\n";
    $output .= " Alias /webdav/" . $fn . ' ' . $webdavRoot . '/' . $fn . "\n";
    $output .= " <Location /webdav/" . $fn . ">\n";
    $output .= " DAV On\n";
    $output .= ' BrowserMatch "MSIE" AuthDigestEnableQueryStringHack=On'."\n";
    $output .= " AuthType Digest\n";
    if($fn != '' && $fn != '/') {
    $output .= " AuthName \"" . $fn . "\"\n";
    } else {
    $output .= " AuthName \"Restricted Area\"\n";
    }
    $output .= " AuthUserFile " . $webdavRoot . '/' . $file . "\n";
    $output .= " Require valid-user \n";
    $output .= " Options +Indexes \n";
    $output .= " Order allow,deny \n";
    $output .= " Allow from all \n";
    $output .= " </Location> \n";
    }
    }
    }
    }
    /*
    * is the "replace-comment-end" found...
    */
    if (trim($line) == '# WEBDAV END') {
    /*
    * The end of the webdav - section is found, so stop ignoring
    */
    $inWebdavSection = false;
    }
    /*
    * Write the line to the output, if it is not in the section
    */
    if (!$inWebdavSection) {
    $output .= $line;
    }
    }
    fclose($in);
    /*
    * Now lets write the new file
    */
    $app->system->file_put_contents($fileName, $output);
    }
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Thanks, that's likely a PHP 8.x incompatibility. Most likely nobody noticed it yet as Webdav is basically not used anymore today. I'll add it ti the issue tracker.
     

Share This Page