Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local storage is no longer getting cleaned up when user is deleted with occ user:delete #28791

Closed
metheos opened this issue Sep 10, 2021 · 8 comments · Fixed by #30889
Closed

Comments

@metheos
Copy link

metheos commented Sep 10, 2021

My local storage is no longer getting cleaned up since PR 26792
I manually put the removed lines from /lib/private/User/User.php back into my instance since I had a bunch of users to delete yesterday and didn't want to manually clear the storage and _storages and _filecache tables for all of them.

Steps to reproduce

  1. add a user
  2. log in as new user to create home folder
  3. delete user with occ user:delete

Expected behaviour

local storage for the user should be deleted and relevant entries in _storages and _filecache tables should be cleared

Actual behaviour

user storage and database entries are not cleared

Server configuration

Nextcloud 22.1.1
Ubuntu 20.04.2
Apache 2.4.41
PHP 7.4.3

Signing status:

Signing status
No errors have been found.

List of activated apps:

App list
  - accessibility: 1.7.0
  - activity: 2.15.0
  - admin_audit: 1.11.0
  - bruteforcesettings: 2.2.0
  - cloud_federation_api: 1.4.0
  - comments: 1.11.0
  - contactsinteraction: 1.2.0
  - dav: 1.18.0
  - deck: 1.5.2
  - documentserver_community: 0.1.11
  - external: 3.9.0
  - extract: 1.3.2
  - federatedfilesharing: 1.11.0
  - files: 1.16.0
  - files_antivirus: 3.2.1
  - files_automatedtagging: 1.12.0
  - files_downloadactivity: 1.11.1
  - files_pdfviewer: 2.3.0
  - files_retention: 1.11.1
  - files_rightclick: 1.1.0
  - files_sharing: 1.13.2
  - files_trashbin: 1.11.0
  - files_versions: 1.14.0
  - files_videoplayer: 1.11.0
  - groupfolders: 10.0.0
  - guests: 2.0.2
  - impersonate: 1.9.0
  - libresign: 2.4.5
  - logreader: 2.7.0
  - lookup_server_connector: 1.9.0
  - metadata: 0.14.0
  - nextcloud_announcements: 1.11.0
  - notes: 4.1.1
  - notifications: 2.10.1
  - oauth2: 1.9.0
  - onlyoffice: 7.1.2
  - password_policy: 1.12.0
  - photos: 1.4.0
  - privacy: 1.6.0
  - provisioning_api: 1.11.0
  - ransomware_protection: 1.11.0
  - recommendations: 1.1.0
  - serverinfo: 1.12.0
  - settings: 1.3.0
  - sharebymail: 1.11.0
  - support: 1.5.0
  - survey_client: 1.10.0
  - suspicious_login: 4.0.0
  - systemtags: 1.11.0
  - theming: 1.12.0
  - twofactor_backupcodes: 1.10.1
  - updatenotification: 1.11.0
  - user_ldap: 1.11.0
  - user_status: 1.1.1
  - viewer: 1.6.0
  - weather_status: 1.1.0
  - workflowengine: 2.3.1
Disabled:
  - calendar
  - circles
  - contacts
  - dashboard
  - encryption
  - federation
  - files_external
  - files_frommail
  - firstrunwizard
  - mail
  - text

Nextcloud configuration:

Config report
{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "***REMOVED SENSITIVE VALUE***",
            "***REMOVED SENSITIVE VALUE***"
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "forwarded_for_headers": [
            "HTTP_X_FORWARDED_FOR"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "overwrite.cli.url": "***REMOVED SENSITIVE VALUE***",
        "overwriteprotocol": "https",
        "dbtype": "mysql",
        "version": "22.1.1.2",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "ldapIgnoreNamingRules": false,
        "ldapProviderFactory": "\\OCA\\User_LDAP\\LDAPProviderFactory",
        "memcache.local": "\\OC\\Memcache\\Redis",
        "filelocking.enabled": "true",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0,
            "timeout": 0,
            "dbindex": 0
        },
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_smtpauthtype": "LOGIN",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "25",
        "maintenance": false,
        "loglevel": 2,
        "log_type": "owncloud",
        "logfile": "\/var\/log\/nextcloud.log",
        "theme": "",
        "updater.release.channel": "stable",
        "encryption.legacy_format_support": false,
        "encryption.key_storage_migrated": false,
        "trashbin_retention_obligation": "30, 35",
        "preview_max_x": 400,
        "preview_max_y": 400,
        "preview_max_scale_factor": 1.5,
        "default_phone_region": "US"
    }
}

Are you using external storage, if yes which one: No

Are you using encryption: no

Are you using an external user-backend, if yes which one: ldap and local users

Logs

Web server error log

Web server error log
No error log entries during example procedure

Nextcloud log (data/nextcloud.log)

Nextcloud log
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"files_antivirus","method":"","url":"--","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"extract","method":"","url":"--","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"files_sharing","method":"","url":"--","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"metadata","method":"","url":"--","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"suspicious_login","method":"","url":"--","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":1,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for OCP\\IUser::preDelete: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":1,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for OCP\\IUser::changeUser: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"dav","method":"","url":"--","message":"Activity generated for a changed card in addressbook 1","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":1,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for \\OCA\\DAV\\CardDAV\\CardDavBackend::updateCard: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"onlyoffice","method":"","url":"--","message":"deleteAllVersions dummytest ","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":1,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for OCP\\IUser::preDelete: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":1,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for OCP\\IUser::changeUser: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":1,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for OCP\\IUser::postDelete: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"dav","method":"","url":"--","message":"Activity generated for a deleted card in addressbook 1","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":1,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for \\OCA\\DAV\\CardDAV\\CardDavBackend::deleteCard: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"dav","method":"","url":"--","message":"Activity generated for deleted calendar 160","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"dav","method":"","url":"--","message":"Reminders of calendar 160 cleaned up","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"dav","method":"","url":"--","message":"Default calendar needs no update because the deleted calendar is no the user's default one","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"dav","method":"","url":"--","message":"Activity generated for deleted addressbook 158","userAgent":"--","version":"22.1.1.2"}
@metheos metheos added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Sep 10, 2021
@kesselb
Copy link
Contributor

kesselb commented Sep 12, 2021

On my local test setup the user files are removed (from db and filesystem) also with local storage. When the user delete process fails you should see a error message in the user manager and also exceptions are logged.

@metheos
Copy link
Author

metheos commented Sep 12, 2021

I was deleting from the server using occ user:delete, nothing indicated a problem. I also had logging set to debug and no exceptions were logged in Apache or nextcloud during the delete.

@metheos
Copy link
Author

metheos commented Sep 12, 2021

On my local test setup the user files are removed (from db and filesystem) also with local storage. When the user delete process fails you should see a error message in the user manager and also exceptions are logged.

I just changed my user.php file to the normal one and confirmed that deleting a user from the web gui does remove their data correctly, but doing so with occ user:delete does not. Maybe the proper events aren't fired when deleting a user from the command?

You can't delete ldap remnants from the web gui, so I'm keeping my changes for now.

@metheos metheos changed the title local storage is no longer getting cleaned up when user is deleted local storage is no longer getting cleaned up when user is deleted with occ user:delete Sep 13, 2021
@szaimen szaimen added 1. to develop Accepted and waiting to be taken care of feature: occ feature: users and groups and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Sep 15, 2021
@come-nc
Copy link
Contributor

come-nc commented Jan 25, 2022

The problem is that the Listener classes are connected in OC\Core\Application constructor which is never run when running occ user:delete command.
This may have other side effects as well.

@metheos
Copy link
Author

metheos commented Jan 25, 2022

The problem is that the Listener classes are connected in OC\Core\Application constructor which is never run when running occ user:delete command. This may have other side effects as well.

I figured it would be something like that. I guess not many people are syncing ldap users? or not cleaning them up anyway.
My workaround hack of putting the lines back in to /lib/private/User/User.php is no longer working in 22.2.3. So I'm back to manually deleting the files and database entries when I do ldap user cleanup.

@come-nc
Copy link
Contributor

come-nc commented Jan 27, 2022

It is not limited to LDAP users in my experience, I have it with local users as well.

@come-nc come-nc linked a pull request Jan 27, 2022 that will close this issue
@come-nc
Copy link
Contributor

come-nc commented Feb 1, 2022

A workaround for this problem is to use the ocs API instead of the user:delete command:

curl -H "OCS-APIRequest: true" -X DELETE http://admin:[email protected]/ocs/v1.php/cloud/users/bob

@metheos
Copy link
Author

metheos commented Feb 1, 2022

A workaround for this problem is to use the ocs API instead of the user:delete command:

curl -H "OCS-APIRequest: true" -X DELETE http://admin:[email protected]/ocs/v1.php/cloud/users/bob

Thanks for this. I'm using it now to do my monthly cleanup of ldap-remnants and it's working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants