Forum

Thread tagged as: Question, Problem

File Permissions in Resources Folder

I'm having an issue where we are uploading files via the assets functionality but the permissions on the files are getting changed in the upload process. Is there any way of disabling that?

Ultimatly as we are using Active Directory (LDAP) logins people have to keep providing their login credentials to download files and it is frustrating our staff - sometimes it is an impossible task.

Diagnostic Report

Perch Runway: 2.8.31
Production mode: Development (10)
Installed apps: content (2.8.31), assets (2.8.31), categories (2.8.31), collection_1 (2.8.31), perch_events (1.9.2), perch_blog (4.6), perch_gallery_extended (2.8.6), collection_2 (2.8.31), perch_members (1.4.2)
DB driver: PDO
DB tables: perch2_backup_plans (0), perch2_backup_resources (0), perch2_backup_runs (0), perch2_blog_authors (11), perch2_blog_comments (0), perch2_blog_index (24290), perch2_blog_posts (684), perch2_blog_posts_to_tags (24), perch2_blog_sections (0), perch2_blog_tags (14), perch2_categories (31), perch2_category_counts (7), perch2_category_sets (3), perch2_collection_index (9417), perch2_collection_items (474), perch2_collection_revisions (119), perch2_collections (2), perch2_content_index (732), perch2_content_items (221), perch2_content_regions (8), perch2_events (61), perch2_events_categories (4), perch2_events_to_categories (60), perch2_gallery_albums (12), perch2_gallery_albums_to_tags (43), perch2_gallery_image_versions (8852), perch2_gallery_images (825), perch2_gallery_images_to_tags (3127), perch2_gallery_smart_albums (15), perch2_gallery_tags (972), perch2_members (372), perch2_members_forms (0), perch2_members_member_tags (0), perch2_members_sessions (5597), perch2_members_tags (0), perch2_navigation (0), perch2_navigation_pages (0), perch2_page_routes (24), perch2_page_templates (34), perch2_pages (23), perch2_resource_log (3053), perch2_resource_tags (45), perch2_resources (2040), perch2_resources_to_tags (94), perch2_settings (51), perch2_user_passwords (0), perch2_user_privileges (45), perch2_user_role_privileges (98), perch2_user_roles (10), perch2_users (19)
Users: 19
App runtimes:
<?php
    $apps_list = array(
        'content', 
        'categories',
        'perch_blog',
        'perch_members',
        'perch_gallery_extended',
        'perch_forms',
        'perch_events',
    );
Scheduled tasks for perch_blog: delete_spam_comments (1440 mins)
Scheduled tasks for perch_events: update_category_counts (60 mins)
Editor plug-ins: markitup
H1: 9daca48f2e400867cd4c6b01953c4d12
L1: 20d0668e70f29399daa6cb8340dfc5b2
F1: 2edba60ed1f613d6dd804feb202456a2
headerColour: #ffffff
content_singlePageEdit: 1
helpURL:
siteURL: /
hideBranding: 0
content_collapseList: 1
lang: en-gb
update_2.7.6: done
latest_version: 2.8.15
on_sale_version: 2.8.34
update_2.7.8: done
perch_blog_update: 5.0
headerScheme: light
perch_blog_slug_format: %Y-%m-%d-{postTitle}
perch_blog_akismet_key:
perch_blog_max_spam_days: 0
dashboard: 1
hide_pwd_reset: 0
content_hideNonEditableRegions: 0
content_frontend_edit: 0
perch_blog_comment_notify: 0
perch_gallery_update: 2.8.5
perch_gallery_bucket_mode: single
perch_gallery_bucket: default
perch_members_login_page: /members/login.php?r={returnURL}
perch_gallery_basicUpload: 0
update_2.7.10: done
logoPath: /login/resources/1425049619_CPI_Logo.png
update_2.8: done
update_runway_2.8.7: done
perch_blog_post_url: /feed/post/{postSlug}
update_runway_2.8.8: done
perch_gallery_extended_update: 2.8.5
update_runway_2.8.13: done
update_runway_2.8.17: done
perch_events_detail_url: /event/{eventSlug}
perch_gallery_extended_bucket_mode: single
perch_gallery_extended_bucket: default
perch_gallery_extended_basicUpload: 0
perch_events_update: 1.8
update_runway_2.8.31: done
perch_members_update: 1.4
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_SITEPATH: /Users/danlee/Sites/Work/bell
PERCH_DB_USERNAME: marketing
PERCH_DB_SERVER: localhost
PERCH_DB_DATABASE: bell_live
PERCH_DB_PREFIX: perch2_
PERCH_TZ: Europe/London
PERCH_EMAIL_FROM: dan.lee@uk-cpi.com
PERCH_EMAIL_FROM_NAME: Dan Lee
PERCH_LOGINPATH: /login
PERCH_PATH: C:\inetpub\wwwroot\login
PERCH_CORE: C:\inetpub\wwwroot\login\core
PERCH_RESFILEPATH: C:\inetpub\wwwroot\login\resources
PERCH_RESPATH: /login/resources
PERCH_HTML5: 1
PERCH_PRODUCTION_MODE: 10
PERCH_YOUTUBE_API_KEY: AIzaSyDmHVMlNX7MHnm8PdE8Fl_k6DQZ_PBs0dM
PERCH_AD_ACCOUNT_SUFFIX: @uk-cpi.com
PERCH_AD_DOMAIN_CONTROLLERS: cpi03-dc01.uk-cpi.com
PERCH_AD_BASE_DN: OU=sites,OU=CPI,dc=uk-cpi,dc=com
PERCH_AD_ADMIN_USERNAME: intranet.ldap
PERCH_AD_ADMIN_PASSWORD: nMBmY9HxujNY5Bqf
PERCH_RUNWAY: 1
PERCH_ERROR_MODE: DIE
PERCH_DATE_LONG: %d %B %Y
PERCH_DATE_SHORT: %d %b %Y
PERCH_TIME_SHORT: %H:%M
PERCH_TIME_LONG: %H:%M:%S
PERCH_RUNWAY_ROUTED:
PERCH_STRONG_PASSWORDS:
PERCH_DEBUG:
PERCH_PREVIEW_ARG: preview
PERCH_TEMPLATE_PATH: C:\inetpub\wwwroot\login\templates
PERCH_DEFAULT_DOC: index.php
PERCH_DEFAULT_EXT: .php
PERCH_RWD:
PERCH_HTML_ENTITIES:
PERCH_SSL:
PERCH_STRIPSLASHES:
PERCH_PROGRESSIVE_FLUSH: 1
PERCH_PARANOID:
PERCH_FORCE_SECURE_COOKIES:
PERCH_PASSWORD_MIN_LENGTH: 6
PERCH_MAX_FAILED_LOGINS: 10
PERCH_AUTH_LOCKOUT_DURATION: 1 HOUR
PERCH_VERIFY_UPLOADS:
PERCH_AUTH_PLUGIN:
PERCH_DB_CHARSET: utf8
PERCH_DB_PORT:
PERCH_DB_SOCKET:
PERCH_SESSION_TIMEOUT_MINS: 20
HOSTING SETTINGS

PHP: 5.6.0
Zend: 2.6.0
OS: WINNT
SAPI: cgi-fcgi
Safe mode: not detected
MySQL client: mysqlnd 5.0.11-dev - 20120503 - $Id: f373ea5dd5538761406a8022a4b8a374418b240e $
MySQL server: 5.5.42
Free disk space: 110.27 GB
Extensions: Core, bcmath, calendar, ctype, date, ereg, filter, ftp, hash, iconv, json, mcrypt, SPL, odbc, pcre, Reflection, session, standard, mysqlnd, tokenizer, zip, zlib, libxml, dom, PDO, openssl, SimpleXML, wddx, xml, xmlreader, xmlwriter, cgi-fcgi, mysql, mysqli, mbstring, gd, gettext, curl, exif, xmlrpc, Phar, soap, pdo_mysql, pdo_sqlite, imap, tidy, pdo_sqlsrv, sqlsrv, ldap, mhash
GD: Yes
ImageMagick: No
PHP max upload size: 30M
PHP max form post size: 40M
PHP memory limit: 128M
Total max uploadable file size: 30M
Resource folder writeable: Yes
Session timeout: 24 minutes
Native JSON: Yes
Filter functions: Yes
Transliteration functions: No
PROCESSOR_ARCHITEW6432: AMD64
_FCGI_X_PIPE_: \\.\pipe\IISFCGI-a00b0207-99ba-46b3-9b99-874d5c1d41c2
PHP_FCGI_MAX_REQUESTS: 10000
PHPRC: C:\Program Files (x86)\PHP\v5.6
ALLUSERSPROFILE: C:\ProgramData
APPDATA: C:\Windows\system32\config\systemprofile\AppData\Roaming
APP_POOL_CONFIG: C:\inetpub\temp\apppools\DefaultAppPool\DefaultAppPool.config
APP_POOL_ID: DefaultAppPool
CommonProgramFiles: C:\Program Files (x86)\Common Files
CommonProgramFiles(x86): C:\Program Files (x86)\Common Files
CommonProgramW6432: C:\Program Files\Common Files
COMPUTERNAME: CPI01-IS02
ComSpec: C:\Windows\system32\cmd.exe
FP_NO_HOST_CHECK: NO
LOCALAPPDATA: C:\Windows\system32\config\systemprofile\AppData\Local
NUMBER_OF_PROCESSORS: 1
OS: Windows_NT
Path: C:\Program Files (x86)\PHP\v5.6;C:\Program Files\Internet Explorer;;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\MySQL\MySQL Server 5.5\bin;
PATHEXT: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE: x86
PROCESSOR_IDENTIFIER: Intel64 Family 6 Model 62 Stepping 4, GenuineIntel
PROCESSOR_LEVEL: 6
PROCESSOR_REVISION: 3e04
ProgramData: C:\ProgramData
ProgramFiles: C:\Program Files (x86)
ProgramFiles(x86): C:\Program Files (x86)
ProgramW6432: C:\Program Files
PSModulePath: C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC: C:\Users\Public
SystemDrive: C:
SystemRoot: C:\Windows
TEMP: C:\Windows\TEMP
TMP: C:\Windows\TEMP
USERDOMAIN: UK-CPI
USERNAME: CPI01-IS02$
USERPROFILE: C:\Windows\system32\config\systemprofile
windir: C:\Windows
ORIG_PATH_INFO: /login/core/settings/diagnostics/index.php
URL: /login/core/settings/diagnostics/index.php
SERVER_SOFTWARE: Microsoft-IIS/8.5
SERVER_PROTOCOL: HTTP/1.1
SERVER_PORT: 80
SERVER_NAME: intranet.uk-cpi.com
SCRIPT_NAME: /login/core/settings/diagnostics/index.php
SCRIPT_FILENAME: C:\inetpub\wwwroot\login\core\settings\diagnostics\index.php
REQUEST_URI: /login/core/settings/diagnostics/?extended
REQUEST_METHOD: GET
REMOTE_USER: UK-CPI\dan.lee
REMOTE_PORT: 55548
REMOTE_HOST: 10.24.10.86
REMOTE_ADDR: 10.24.10.86
QUERY_STRING: extended
PATH_TRANSLATED: C:\inetpub\wwwroot\login\core\settings\diagnostics\index.php
LOGON_USER: UK-CPI\dan.lee
LOCAL_ADDR: 172.26.86.36
INSTANCE_META_PATH: /LM/W3SVC/1
INSTANCE_NAME: DEFAULT WEB SITE
INSTANCE_ID: 1
HTTPS: off
GATEWAY_INTERFACE: CGI/1.1
DOCUMENT_ROOT: C:\inetpub\wwwroot
AUTH_USER: UK-CPI\dan.lee
AUTH_TYPE: NTLM
APPL_PHYSICAL_PATH: C:\inetpub\wwwroot\
APPL_MD_PATH: /LM/W3SVC/1/ROOT
WEBSOCKET_VERSION: 13
IIS_UrlRewriteModule: 7.1.0871.0
HTTP_UPGRADE_INSECURE_REQUESTS: 1
HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
HTTP_REFERER: https://intranet.uk-cpi.com/login/core/settings/diagnostics/
HTTP_HOST: intranet.uk-cpi.com
HTTP_COOKIE: __utma=136563892.1720010777.1463495111.1488290595.1488293969.354; __utmc=136563892; __utmz=136563892.1488273410.352.26.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); _ga=GA1.2.1720010777.1463495111; cmsa=1; p_m=8612613a93513ce9344a3515743d8e0c7ec11266; _pk_id.1.906d=47ce3de69007d90c.1463478350.299.1488366699.1488365593.; _pk_ses.1.906d=*; PHPSESSID=pbdds07akestg2s7luvb1qfoi0
HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.8
HTTP_ACCEPT_ENCODING: gzip, deflate, sdch
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_CONNECTION: keep-alive
FCGI_ROLE: RESPONDER
PHP_SELF: /login/core/settings/diagnostics/index.php
REQUEST_TIME_FLOAT: 1488367340.4077
REQUEST_TIME: 1488367340
Dan Lee

Dan Lee 1 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You probably need to talk to your host about that.

Dan Lee

Dan Lee 1 points

What about...

    define('PERCH_CHMOD_FILES', '765');

Would that not be the solution?

Duncan Revell

Duncan Revell 78 points
Registered Developer

Chmod doesn't work on Windows?

Dan Lee

Dan Lee 1 points

Good point - I'm on IIS 7

I'm guessing there isn't an equivalent for the config file in perch?

Duncan Revell

Duncan Revell 78 points
Registered Developer

As Drew says, it's a Windows permissions thing. I'm sure on Windows, PHP runs as Local System. If users are having trouble getting files from that folder, change Windows permissions on the folder itself or change the authentication method on the web server.

Might have to modify the core to run the windows attrib command

\core\lib\PerchUtil.class.php

    public static function set_file_permissions($filename)
    {
        if (defined('PERCH_CHMOD_FILES'))
            @chmod($filename, PERCH_CHMOD_FILES);
    }

EDIT: See

https://stackoverflow.com/a/37962006

https://www.howyoudo.info/index.php/how-to-fix-windows-server-upload-file-inherit-permissions-error/

Dan Lee

Dan Lee 1 points

Thanks for you help guys. This seems to solve the problem:

Solution:

Updated \core\lib\PerchUtil.class.php so that files inherit permissions from its new location. This is an update to the core perch files - so you would need to be aware of any updates to the file.

public static function set_file_permissions($filename)
{
// inherit permissions from its new location
exec( 'icacls "'.$filename.'" /q /c /reset' );

if (defined('PERCH_CHMOD_FILES'))
@chmod($filename, PERCH_CHMOD_FILES);
}
Drew McLellan

Drew McLellan 2638 points
Perch Support

You also need to be aware that you no longer qualify for support if you modify core files.

Dan Lee

Dan Lee 1 points

Is that on a per licence basis?

Drew McLellan

Drew McLellan 2638 points
Perch Support

By editing the software you're in breach of the license agreement. Out of fairness to customers who follow the license agreement, we don't divert resources to those who break it. Especially when we then have no idea what we're trying to support because the software has been changed.

Dan Lee

Dan Lee 1 points

Ok, thanks Drew. In that case, I'll revert the implementation of this and ask our IT team to fix the permissions in ISS rather than breach the agreement.