Ticket #1873: 1873_2.patch

File 1873_2.patch, 2.3 kB (added by wwalc, 8 months ago)
  • editor/filemanager/connectors/py/config.py

     
    6565# Allowed Resource Types 
    6666ConfigAllowedTypes = ['File', 'Image', 'Flash', 'Media'] 
    6767 
     68# After file is uploaded, sometimes it is required to change its permissions 
     69# so that it was possible to access it at the later time. 
     70# If possible, it is recommended to set more restrictive permissions, like 0755. 
     71# Set to 0 to disable this feature. 
     72# Note: not needed on Windows-based servers. 
     73ChmodOnUpload = 0755 
     74 
     75# See comments above. 
     76# Used when creating folders that does not exist. 
     77ChmodOnFolderCreate = 0755 
     78 
    6879# Do not touch this 3 lines, see "Configuration settings for each Resource Type" 
    6980AllowedExtensions = {}; DeniedExtensions = {}; 
    7081FileTypesPath = {}; FileTypesAbsolutePath = {}; 
  • editor/filemanager/connectors/py/fckcommands.py

     
    111111                "Purpose: physically creates a folder on the server" 
    112112                # No need to check if the parent exists, just create all hierachy 
    113113                oldumask = os.umask(0) 
    114                 os.makedirs(folderPath,mode=0755) 
     114                try: 
     115                        permissions = Config.ChmodOnFolderCreate 
     116                except AttributeError: #ChmodOnFolderCreate undefined 
     117                        permissions = 0755 
     118                os.makedirs(folderPath,mode=permissions) 
    115119                os.umask( oldumask ) 
    116120 
    117121class UploadFileCommandMixin (object): 
     
    168172                                                fout.close() 
    169173 
    170174                                                if os.path.exists ( newFilePath ): 
    171                                                         oldumask = os.umask(0) 
    172                                                         os.chmod( newFilePath, 0755 ) 
    173                                                         os.umask( oldumask ) 
     175                                                        doChmod = False 
     176                                                        try: 
     177                                                                doChmod = Config.ChmodOnUpload 
     178                                                                permissions = Config.ChmodOnUpload 
     179                                                        except AttributeError: #ChmodOnUpload undefined 
     180                                                                doChmod = True 
     181                                                                permissions = 0755 
     182                                                        if ( doChmod ): 
     183                                                                oldumask = os.umask(0) 
     184                                                                os.chmod( newFilePath, permissions ) 
     185                                                                os.umask( oldumask ) 
    174186 
    175187                                                newFileUrl = self.webUserFilesFolder + currentFolder + newFileName 
    176188