owncloud / core

:cloud: ownCloud web server core (Files, DAV, etc.)
https://owncloud.com
GNU Affero General Public License v3.0
8.38k stars 2.05k forks source link

copy a folder to a destination that is an existing file makes the content of the destination folder not be readable every 10th time #39633

Open individual-it opened 2 years ago

individual-it commented 2 years ago

Steps to reproduce

  1. create user
  2. create folder
  3. create a file in the folder
  4. create an other file in the root
  5. copy the folder to the file
  6. GET the content of the file from inside of the destination folder (what was the file before) in a loop
USER=uu2
curl -u$USER:$USER -XMKCOL http://localhost/owncloud-core/remote.php/dav/files/$USER/folder
curl -u$USER:$USER -XPUT http://localhost/owncloud-core/remote.php/dav/files/$USER/folder/file.txt -d"123"
curl -u$USER:$USER -XPUT http://localhost/owncloud-core/remote.php/dav/files/$USER/copy.txt -d"123"
curl -u$USER:$USER -XCOPY http://localhost/owncloud-core/remote.php/dav/files/$USER/folder -H"Destination: http://localhost/owncloud-core/remote.php/dav/files/$USER/copy.txt"
while true; do curl -u $USER:$USER http://localhost/owncloud-core/remote.php/dav/files/$USER/copy.txt/file.txt; done

Expected behaviour

content can be retrieved every time

Actual behaviour

after 6 successful ready the server replies with 503 error after that every 10th requests fails

Server configuration

Operating system: Ubuntu 21.10 Web server: apache Database: mysql PHP version: 7.2 ownCloud version: (see ownCloud admin page) 10.9.0 Updated from an older ownCloud or fresh install: fresh Where did you install ownCloud from: git The content of config/config.php:

{
    "system": {
        "instanceid": "ocuv4s8d5xsv",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost"
        ],
        "datadirectory": "\/home\/artur\/www\/owncloud-core\/data",
        "overwrite.cli.url": "http:\/\/localhost\/owncloud-core",
        "dbtype": "mysql",
        "version": "10.9.0.3",
        "logtimezone": "UTC",
        "theme": "",
        "loglevel": 0,
        "maintenance": false,
        "default_language": "en",
        "singleuser": false,
        "ldapIgnoreNamingRules": false,
        "sharing.federation.allowHttpFallback": true,
        "files_external_allow_create_new_local": "true",
        "enable_previews": false,
        "dbname": "owncloud_20211231",
        "dbhost": "localhost",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "trusted_proxies": {
            "1": "10.4.1.248",
            "2": "127.0.0.1"
        },
        "htaccess.RewriteBase": "\/owncloud-core\/",
        "apps_paths": [
            {
                "path": "\/home\/artur\/www\/owncloud-core\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/home\/artur\/www\/owncloud-core\/apps-external",
                "url": "\/apps-external",
                "writable": true
            }
        ],
        "cors.allowed-domains": [
            "http:\/\/localhost:9100",
            "http:\/\/localhost\/owncloud-web"
        ],
        "installed": true,
        "dav.enable.tech_preview": true,
        "license-key": "***REMOVED SENSITIVE VALUE***",
        "web.rewriteLinks": "true",
        "csrf.disabled": "true",
        "allow_user_to_change_mail_address": "",
        "mail_smtpport": "1025",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "share_folder": "Shares",
        "log_type": "owncloud",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "grace_period.demo_key.show_popup": false
    }
}

List of activated apps:

Enabled:
  - activity:
    - Version: 2.6.1
    - Path: /home/artur/www/owncloud-core/apps/activity
  - comments:
    - Version: 0.3.0
    - Path: /home/artur/www/owncloud-core/apps/comments
  - dav:
    - Version: 0.7.0
    - Path: /home/artur/www/owncloud-core/apps/dav
  - diagnostics:
    - Version: 0.1.4
    - Path: /home/artur/www/owncloud-core/apps/diagnostics
  - federatedfilesharing:
    - Version: 0.5.0
    - Path: /home/artur/www/owncloud-core/apps/federatedfilesharing
  - federation:
    - Version: 0.1.0
    - Path: /home/artur/www/owncloud-core/apps/federation
  - files:
    - Version: 1.5.2
    - Path: /home/artur/www/owncloud-core/apps/files
  - files_external:
    - Version: 0.8.0
    - Path: /home/artur/www/owncloud-core/apps/files_external
  - files_mediaviewer:
    - Version: 1.0.5
    - Path: /home/artur/www/owncloud-core/apps-external/files_mediaviewer
  - files_sharing:
    - Version: 0.14.0
    - Path: /home/artur/www/owncloud-core/apps/files_sharing
  - files_texteditor:
    - Version: 2.3.0
    - Path: /home/artur/www/owncloud-core/apps/files_texteditor
  - files_trashbin:
    - Version: 0.9.1
    - Path: /home/artur/www/owncloud-core/apps/files_trashbin
  - files_versions:
    - Version: 1.3.0
    - Path: /home/artur/www/owncloud-core/apps/files_versions
  - gallery:
    - Version: 16.1.2
    - Path: /home/artur/www/owncloud-core/apps-external/gallery
  - market:
    - Version: 0.6.1
    - Path: /home/artur/www/owncloud-core/apps/market
  - provisioning_api:
    - Version: 0.5.0
    - Path: /home/artur/www/owncloud-core/apps/provisioning_api
  - systemtags:
    - Version: 0.3.0
    - Path: /home/artur/www/owncloud-core/apps/systemtags
  - testing:
    - Version: 0.1.0
    - Path: /home/artur/www/owncloud-core/apps/testing
  - updatenotification:
    - Version: 0.2.1
    - Path: /home/artur/www/owncloud-core/apps/updatenotification
Disabled:
  - brute_force_protection:
    - Path: /home/artur/www/owncloud-core/apps/brute_force_protection
  - contacts:
    - Path: /home/artur/www/owncloud-core/apps/contacts
  - customgroups:
    - Path: /home/artur/www/owncloud-core/apps/customgroups
  - encryption:
    - Path: /home/artur/www/owncloud-core/apps/encryption
  - files_primary_s3:
    - Path: /home/artur/www/owncloud-core/apps/files_primary_s3
  - guests:
    - Path: /home/artur/www/owncloud-core/apps/guests
  - more-fun-theme:
    - Path: /home/artur/www/owncloud-core/apps/more-fun-theme
  - multidirtest:
    - Path: /home/artur/www/owncloud-core/apps/multidirtest
  - notes:
    - Path: /home/artur/www/owncloud-core/apps/notes
  - notifications:
    - Path: /home/artur/www/owncloud-core/apps/notifications
  - oauth2:
    - Path: /home/artur/www/owncloud-core/apps-external/oauth2
  - password_policy:
    - Path: /home/artur/www/owncloud-core/apps/password_policy
  - ransomware_protection:
    - Path: /home/artur/www/owncloud-core/apps/ransomware_protection
  - search_elastic:
    - Path: /home/artur/www/owncloud-core/apps/search_elastic
  - security:
    - Path: /home/artur/www/owncloud-core/apps/security
  - theme-example:
    - Path: /home/artur/www/owncloud-core/apps/theme-example
  - twofactor_totp:
    - Path: /home/artur/www/owncloud-core/apps/twofactor_totp
  - user_ldap:
    - Path: /home/artur/www/owncloud-core/apps/user_ldap
  - user_management:
    - Path: /home/artur/www/owncloud-core/apps/user_management
  - windows_network_drive:
    - Path: /home/artur/www/owncloud-core/apps-external/windows_network_drive

Are you using external storage, if yes which one: local/smb/sftp/... no Are you using encryption: yes/no no Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/... no, but with LDAP it seems to happen more often see more debugging in https://github.com/owncloud/user_ldap/issues/702

Logs

Web server error log

127.0.0.1 - uu2 [31/Dec/2021:16:27:09 +0545] "GET /owncloud-core/remote.php/dav/files/uu2/copy.txt/file.txt HTTP/1.1" 200 1285 "-" "curl/7.74.0"
127.0.0.1 - uu2 [31/Dec/2021:16:27:09 +0545] "GET /owncloud-core/remote.php/dav/files/uu2/copy.txt/file.txt HTTP/1.1" 200 1277 "-" "curl/7.74.0"
127.0.0.1 - uu2 [31/Dec/2021:16:27:09 +0545] "GET /owncloud-core/remote.php/dav/files/uu2/copy.txt/file.txt HTTP/1.1" 200 1281 "-" "curl/7.74.0"
127.0.0.1 - uu2 [31/Dec/2021:16:27:09 +0545] "GET /owncloud-core/remote.php/dav/files/uu2/copy.txt/file.txt HTTP/1.1" 200 1285 "-" "curl/7.74.0"
127.0.0.1 - uu2 [31/Dec/2021:16:27:09 +0545] "GET /owncloud-core/remote.php/dav/files/uu2/copy.txt/file.txt HTTP/1.1" 200 1291 "-" "curl/7.74.0"
127.0.0.1 - uu2 [31/Dec/2021:16:27:09 +0545] "GET /owncloud-core/remote.php/dav/files/uu2/copy.txt/file.txt HTTP/1.1" 200 1283 "-" "curl/7.74.0"
127.0.0.1 - uu2 [31/Dec/2021:16:27:09 +0545] "GET /owncloud-core/remote.php/dav/files/uu2/copy.txt/file.txt HTTP/1.1" 200 1275 "-" "curl/7.74.0"
127.0.0.1 - uu2 [31/Dec/2021:16:27:09 +0545] "GET /owncloud-core/remote.php/dav/files/uu2/copy.txt/file.txt HTTP/1.1" 200 1281 "-" "curl/7.74.0"
127.0.0.1 - uu2 [31/Dec/2021:16:27:09 +0545] "GET /owncloud-core/remote.php/dav/files/uu2/copy.txt/file.txt HTTP/1.1" 503 1242 "-" "curl/7.74.0"
127.0.0.1 - uu2 [31/Dec/2021:16:27:10 +0545] "GET /owncloud-core/remote.php/dav/files/uu2/copy.txt/file.txt HTTP/1.1" 200 1285 "-" "curl/7.74.0"

ownCloud log (data/owncloud.log)

{"reqId":"FaMRRLEP49ZBvbcF1EdE","level":4,"time":"2021-12-31T10:42:10+00:00","remoteAddr":"127.0.0.1","user":"uu2","app":"webdav","method":"GET","url":"\/owncloud-core\/remote.php\/dav\/files\/uu2\/copy.txt\/file.txt","message":"Exception: HTTP\/1.1 503 Could not open file: {\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\ServiceUnavailable\",\"Message\":\"Could not open file\",\"Code\":0,\"Trace\":\"#0 \\\/home\\\/artur\\\/www\\\/owncloud-core\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(85): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\File->get()\\n#1 \\\/home\\\/artur\\\/www\\\/owncloud-core\\\/lib\\\/composer\\\/sabre\\\/event\\\/lib\\\/WildcardEmitterTrait.php(89): Sabre\\\\DAV\\\\CorePlugin->httpGet()\\n#2 \\\/home\\\/artur\\\/www\\\/owncloud-core\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(472): Sabre\\\\DAV\\\\Server->emit()\\n#3 \\\/home\\\/artur\\\/www\\\/owncloud-core\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(253): Sabre\\\\DAV\\\\Server->invokeMethod()\\n#4 \\\/home\\\/artur\\\/www\\\/owncloud-core\\\/apps\\\/dav\\\/lib\\\/Server.php(345): Sabre\\\\DAV\\\\Server->start()\\n#5 \\\/home\\\/artur\\\/www\\\/owncloud-core\\\/apps\\\/dav\\\/appinfo\\\/v2\\\/remote.php(31): OCA\\\\DAV\\\\Server->exec()\\n#6 \\\/home\\\/artur\\\/www\\\/owncloud-core\\\/remote.php(165): require_once('\\\/home\\\/artur\\\/www...')\\n#7 {main}\",\"File\":\"\\\/home\\\/artur\\\/www\\\/owncloud-core\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/File.php\",\"Line\":404}"}
individual-it commented 2 years ago

my debugging shows that the code really arrives in https://github.com/owncloud/core/blob/e60f5f03dcf0f23cba622d4343579e3d3f2ee970/lib/private/Files/Storage/Local.php#L298 and fopen gets all the right data but returns false I can see the data on disk and can read it from there