View Issue Details

IDProjectCategoryView StatusLast Update
0005092OXID eShop (all versions)2.8. Servicepublic2022-02-01 14:39
ReporterAndreHerrmann Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
Status confirmedResolutionopen 
Product Version4.6.5 revision 49955 
Summary0005092: Making problems in checkServerPermissions() visible
DescriptionDue oxsysrequirements is not allowed to be overloaded, I would like to request to implement my patch beneath.

It's about a problem I periodically come in touch with. The red light is not very meaningfull if you have the task to debug this and help page only shows the base paths to be checked.

Wouldn't it be nicer if the user directly sees the pathes the shop is complaining about?
Additional InformationHere's my quick patch suggest, which I recently used to be able to find the bad path which made modstat light red:


    /**
     * Checks if permissions on servers are correctly setup
     *
     * @param string $sPath check path [optional]
     * @param int $iMinPerm min permission level, default 777 [optional]
     *
     * @return int
     */
    public function checkServerPermissions( $sPath = null, $iMinPerm = 777 )
    {
        $sVerPrefix = '';

        clearstatcache();
        $sPath = $sPath ? $sPath : getShopBasePath();

        // special config file check
        $sFullPath = $sPath . "config.inc.php";
        if ( !is_readable( $sFullPath ) ||
             ( isAdmin() && is_writable( $sFullPath ) ) ||
             ( !isAdmin() && !is_writable( $sFullPath ) )
           ) {
            return 0;
        }

        $sTmp = "$sPath/tmp$sVerPrefix/";
        if (class_exists('oxConfig')) {
            $sCfgTmp = $this->getConfig()->getConfigParam('sCompileDir');
            if (strpos($sCfgTmp, '<sCompileDir_') === false) {
                $sTmp = $sCfgTmp;
            }
        }

        $aPathsToCheck = array(
                            $sPath."out/pictures{$sVerPrefix}/promo/",
                            $sPath."out/pictures{$sVerPrefix}/media/",
                            $sPath."out/pictures{$sVerPrefix}/master/",
                            $sPath."out/pictures{$sVerPrefix}/generated/",
                            $sPath."log/",
                            $sTmp
                            );

        $aFcErrorMessages = array();
        $iModStat = 2;
        $sPathToCheck = reset( $aPathsToCheck );
        while ( $sPathToCheck ) {
            // missing file/folder?
            if ( !file_exists( $sPathToCheck ) ) {
                $iModStat = 0;
                $aFcErrorMessages[] = "Missing file/folder $sPathToCheck";
            }

            if ( is_dir( $sPathToCheck ) ) {
                // adding subfolders
                $aSubF = glob( $sPathToCheck."*", GLOB_ONLYDIR );
                if (is_array($aSubF)) {
                    foreach ( $aSubF as $sNewFolder ) {
                        $aPathsToCheck[] = $sNewFolder . "/";
                    }
                }
            }

            // testing if file permissions >= $iMinPerm
            //if ( ( (int) substr( decoct( fileperms( $sFullPath ) ), 2 ) ) < $iMinPerm ) {
            if ( !is_readable( $sPathToCheck ) || !is_writable( $sPathToCheck ) ) {
                $sFcType = "";
                if ( !is_readable( $sPathToCheck ) ) {
                    $sFcType .= "read";
                }
                if ( !is_writable( $sPathToCheck ) ) {
                    if ( $sFcType != '' ) {
                        $sFcType .= " and";
                    }
                    $sFcType .= " write";
                }
                $aFcErrorMessages[] = "$sPathToCheck has no $sFcType permissions";
                $iModStat = 0;
            }

            $sPathToCheck = next( $aPathsToCheck );
        }

        if ( count( $aFcErrorMessages ) > 0 ) {
            $sFcErrorMessages = implode( "
", $aFcErrorMessages );
            oxUtilsView::getInstance()->addErrorToDisplay( oxNew( 'oxException', "File-Access-Errors:
".$sFcErrorMessages ) );
        }

        return $iModStat;
    }
TagsNo tags attached.
Attached Files
ShouldBeStd.png (103,463 bytes)   
ShouldBeStd.png (103,463 bytes)   
ThemeNot defined
BrowserAll
PHP VersionNot defined
Database VersionNot defined

Activities

FibreFoX

2013-04-30 14:46

reporter   ~0008651

Output should be limited on first view, if a lot of folders have wrong permissions, it would be too scary on the first impression. Maybe a details-popup would be nice aside from the red flag.

svetlana

2014-03-28 10:04

reporter   ~0009741

waiting for the PO decision.