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

Chained removal of directories when permission is denied #1041

Closed
norbusan opened this issue Aug 28, 2020 · 12 comments · Fixed by #1045
Closed

Chained removal of directories when permission is denied #1041

norbusan opened this issue Aug 28, 2020 · 12 comments · Fixed by #1045
Labels
Bug Something isn't working Fixed Unable to reproduce

Comments

@norbusan
Copy link
Collaborator

Hi Alex,

on Debian I got the following wishlist bug report: https://bugs.debian.org/969138

Not sure whether this is possible, but I thought I mention it.

Best

I do not know whether this is default for all or most OneDrive for Business
setups, but in my OneDrive in Office 365, I cannot delete a directory if
it contains other directories or files from the web interface.
As a result I can delete such directory with a Windows desktop client,
but I cannot delete it with onedrive for linux. I get the following error:

ERROR: OneDrive returned an error with the following message:
  Error Message: HTTP request returned status code 401 (FORBIDDEN)
  Error Reason:  Access denied. You do not have permission to perform this action or access this resource.

As a workaround, I can delete the contents of the directory first
and proceed with deleting the directory itself. It would be nice, if
onedrive client could chain those requests automatically. Alternatively,
it could provide a similar warning as the web interface does:

"You have to delete all the items in this
folder before you can delete the folder."

From forum discussions, I guess that it is has something to do with
retention policies, but it makes no sense to me because I can
easily delete the entire folders along with their contents in
OneDrive Windows client.
@abraunegg
Copy link
Owner

@norbusan
Curious - as this issue should have been fixed via #955 - fixing bug #338

Curious case indeed. Request the user to provide a verbose debug log.

@norbusan
Copy link
Collaborator Author

Indeed indeed. I have already told the OP to join here ...

@RomanRiabenko
Copy link

I am using the version packaged in Debian sid on my personal laptop with OneDrive for Business in Office365. Here is my setup:

$ onedrive --version
onedrive v2.4.4-1

$ uname -a
Linux debian-laptop 5.7.0-3-amd64 #1 SMP Debian 5.7.17-1 (2020-08-23) x86_64 GNU/Linux

$ curl --version
curl 7.72.0 (x86_64-pc-linux-gnu) libcurl/7.72.0 OpenSSL/1.1.1g zlib/1.2.11 brotli/1.0.7 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.3.0) libssh2/1.8.0 nghttp2/1.41.0 librtmp/2.3
Release-Date: 2020-08-19
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets

$ onedrive --display-config
onedrive version                       = v2.4.4-1
Config path                            = /home/roman/.config/onedrive
Config file found in config path       = false
Config option 'check_nosync'           = false
Config option 'sync_dir'               = /home/roman/OneDrive
Config option 'skip_dir'               = 
Config option 'skip_file'              = ~*|.~*|*.tmp
Config option 'skip_dotfiles'          = false
Config option 'skip_symlinks'          = false
Config option 'monitor_interval'       = 300
Config option 'min_notify_changes'     = 5
Config option 'log_dir'                = /var/log/onedrive/
Config option 'classify_as_big_delete' = 1000
Config option 'sync_root_files'        = false
Selective sync 'sync_list' configured  = false
Business Shared Folders configured     = true
business_shared_folders contents:

A log when there is nothing to sync:

$ onedrive --synchronize --verbose
Using 'user' Config Dir: /home/roman/.config/onedrive
Using 'system' Config Dir: /etc/onedrive
No user or system config file found, using application defaults
Initializing the OneDrive API ...
Configuring Global Azure AD Endpoints
Opening the item database ...
All operations will be performed in: /home/roman/OneDrive
Application version: v2.4.4-1
Account Type: business
Default Drive ID: b!vekxjFzA4kGrYv0V4uesVqJQmDnXbw9Bgib4Wh-fdaww4SgAVQrWQ6JPNYW97ghq
Default Root ID: 01YLXYNGF6Y2GOVW7725BZO354PWSELRRZ
Remaining Free Space: 899799887896
Fetching details for OneDrive Root
OneDrive Root exists in the database
Initializing the Synchronization Engine ...
Syncing changes from OneDrive ...
Applying changes of Path ID: 01YLXYNGF6Y2GOVW7725BZO354PWSELRRZ
Updated Remaining Free Space: 899799887896
Uploading differences of ~/OneDrive
Processing .
The directory has not changed
Processing Attachments
The directory has not changed
Processing Microsoft Teams Chat Files
The directory has not changed
Processing Microsoft Teams Chat Files/виды санкций.docx
The file has not changed
Processing Microsoft Teams Chat Files/Тендерна юристи в новій редакції від 29.05.20.docx
The file has not changed
Processing Файли чату Microsoft Teams
The directory has not changed
Processing Файли чату Microsoft Teams/Знімок з 2020-07-30 14-36-01.png
The file has not changed
Processing Файли чату Microsoft Teams/Договір_ з правками.docx
The file has not changed
Uploading new items of ~/OneDrive
Applying changes of Path ID: 01YLXYNGF6Y2GOVW7725BZO354PWSELRRZ
Updated Remaining Free Space: 899799887896

After I added a directory and a text file in it:

$ onedrive --synchronize --verbose
Using 'user' Config Dir: /home/roman/.config/onedrive
Using 'system' Config Dir: /etc/onedrive
No user or system config file found, using application defaults
Initializing the OneDrive API ...
Configuring Global Azure AD Endpoints
Opening the item database ...
All operations will be performed in: /home/roman/OneDrive
Application version: v2.4.4-1
Account Type: business
Default Drive ID: b!vekxjFzA4kGrYv0V4uesVqJQmDnXbw9Bgib4Wh-fdaww4SgAVQrWQ6JPNYW97ghq
Default Root ID: 01YLXYNGF6Y2GOVW7725BZO354PWSELRRZ
Remaining Free Space: 899799887896
Fetching details for OneDrive Root
OneDrive Root exists in the database
Initializing the Synchronization Engine ...
Syncing changes from OneDrive ...
Applying changes of Path ID: 01YLXYNGF6Y2GOVW7725BZO354PWSELRRZ
Updated Remaining Free Space: 899799887896
Uploading differences of ~/OneDrive
Processing .
The directory has not changed
Processing Attachments
The directory has not changed
Processing Microsoft Teams Chat Files
The directory has not changed
Processing Microsoft Teams Chat Files/виды санкций.docx
The file has not changed
Processing Microsoft Teams Chat Files/Тендерна юристи в новій редакції від 29.05.20.docx
The file has not changed
Processing Файли чату Microsoft Teams
The directory has not changed
Processing Файли чату Microsoft Teams/Знімок з 2020-07-30 14-36-01.png
The file has not changed
Processing Файли чату Microsoft Teams/Договір_ з правками.docx
The file has not changed
Uploading new items of ~/OneDrive
OneDrive Client requested to create remote path: ./Test
The requested directory to create was not found on OneDrive - creating remote directory: ./Test
Successfully created the remote directory ./Test on OneDrive
Uploading new file ./Test/TestFile.txt ... 
Uploading 100% |oooooooooooooooooooooooooooooooooooooooo| DONE IN 00:00:01                                                                                                                                         
done.
Remaining free space on OneDrive: 899799887875
Applying changes of Path ID: 01YLXYNGF6Y2GOVW7725BZO354PWSELRRZ
Updated Remaining Free Space: 899799887062
Number of items from OneDrive to process: 3

After I removed the directory:

$ onedrive --synchronize --verbose
Using 'user' Config Dir: /home/roman/.config/onedrive
Using 'system' Config Dir: /etc/onedrive
No user or system config file found, using application defaults
Initializing the OneDrive API ...
Configuring Global Azure AD Endpoints
Opening the item database ...
All operations will be performed in: /home/roman/OneDrive
Application version: v2.4.4-1
Account Type: business
Default Drive ID: b!vekxjFzA4kGrYv0V4uesVqJQmDnXbw9Bgib4Wh-fdaww4SgAVQrWQ6JPNYW97ghq
Default Root ID: 01YLXYNGF6Y2GOVW7725BZO354PWSELRRZ
Remaining Free Space: 899799887062
Fetching details for OneDrive Root
OneDrive Root exists in the database
Initializing the Synchronization Engine ...
Syncing changes from OneDrive ...
Applying changes of Path ID: 01YLXYNGF6Y2GOVW7725BZO354PWSELRRZ
Updated Remaining Free Space: 899799887062
Uploading differences of ~/OneDrive
Processing .
The directory has not changed
Processing Attachments
The directory has not changed
Processing Microsoft Teams Chat Files
The directory has not changed
Processing Microsoft Teams Chat Files/виды санкций.docx
The file has not changed
Processing Microsoft Teams Chat Files/Тендерна юристи в новій редакції від 29.05.20.docx
The file has not changed
Processing Файли чату Microsoft Teams
The directory has not changed
Processing Файли чату Microsoft Teams/Знімок з 2020-07-30 14-36-01.png
The file has not changed
Processing Файли чату Microsoft Teams/Договір_ з правками.docx
The file has not changed
Processing Test
The directory has been deleted locally
Deleting item from OneDrive: Test

ERROR: OneDrive returned an error with the following message:
  Error Message: HTTP request returned status code 401 (FORBIDDEN)
  Error Reason:  Access denied. You do not have permission to perform this action or access this resource.
Uploading new items of ~/OneDrive
Applying changes of Path ID: 01YLXYNGF6Y2GOVW7725BZO354PWSELRRZ
Updated Remaining Free Space: 899799887062

@abraunegg
Copy link
Owner

@RomanRiabenko
In accordance with the support process requirements, please provide a debug log for support using the following process: https://github.com/abraunegg/onedrive/wiki/Generate-debug-log-for-support

abraunegg added a commit that referenced this issue Aug 28, 2020
* Add debugging around item deletion
@abraunegg
Copy link
Owner

@RomanRiabenko
Thanks for the debug log, however whilst it shows that the deletion failing, there is nothing in the current debug log file that indicates there is an issue.

In attempting to replicate this issue with 'master' I am also unable to do so:

upload directory and file:

Using 'user' Config Dir: /home/alex/.config/onedrive-business/
Using 'system' Config Dir: 
Configuration file successfully loaded
Initializing the OneDrive API ...
Configuring Global Azure AD Endpoints
Opening the item database ...
All operations will be performed in: /home/alex/OneDriveBusiness
Application version: v2.4.5-7-gbc1ce11
Account Type: business
Default Drive ID: b!bO8V7s9SSk6r7mWHpIjURotN33W1W2tEv3OXV_oFIdQimEdOHR-1So7CqeT1MfHA
Default Root ID: 01WIXGO5V6Y2GOVW7725BZO354PWSELRRZ
Remaining Free Space: 1086154686130
Fetching details for OneDrive Root
OneDrive Root exists in the database
Initializing the Synchronization Engine ...
Syncing changes from OneDrive ...
Applying changes of Path ID: 01WIXGO5V6Y2GOVW7725BZO354PWSELRRZ
Updated Remaining Free Space: 1086154686130
Uploading differences of ~/OneDriveBusiness
Processing .
The directory has not changed
Uploading new items of ~/OneDriveBusiness
OneDrive Client requested to create remote path: ./Test
The requested directory to create was not found on OneDrive - creating remote directory: ./Test
Successfully created the remote directory ./Test on OneDrive
Uploading new file ./Test/TestFile.txt ... 
Uploading 100% |oooooooooooooooooooooooooooooooooooooooo| DONE IN 00:00:00                                                                                                                    
done.
Remaining free space on OneDrive: 1086154686110
Applying changes of Path ID: 01WIXGO5V6Y2GOVW7725BZO354PWSELRRZ
Updated Remaining Free Space: 1086154685274
Number of items from OneDrive to process: 3

local deletion & re-run:

[alex@centos7full fix-issue-1041]$ ./onedrive --confdir '~/.config/onedrive-business/' --synchronize --verbose
Using 'user' Config Dir: /home/alex/.config/onedrive-business/
Using 'system' Config Dir: 
Configuration file successfully loaded
Initializing the OneDrive API ...
Configuring Global Azure AD Endpoints
Opening the item database ...
All operations will be performed in: /home/alex/OneDriveBusiness
Application version: v2.4.5-7-gbc1ce11
Account Type: business
Default Drive ID: b!bO8V7s9SSk6r7mWHpIjURotN33W1W2tEv3OXV_oFIdQimEdOHR-1So7CqeT1MfHA
Default Root ID: 01WIXGO5V6Y2GOVW7725BZO354PWSELRRZ
Remaining Free Space: 1086154685274
Fetching details for OneDrive Root
OneDrive Root exists in the database
Initializing the Synchronization Engine ...
Syncing changes from OneDrive ...
Applying changes of Path ID: 01WIXGO5V6Y2GOVW7725BZO354PWSELRRZ
Updated Remaining Free Space: 1086154685274
Uploading differences of ~/OneDriveBusiness
Processing .
The directory has not changed
Processing Test
The directory has been deleted locally
Deleting item from OneDrive: Test
Uploading new items of ~/OneDriveBusiness
Applying changes of Path ID: 01WIXGO5V6Y2GOVW7725BZO354PWSELRRZ
Updated Remaining Free Space: 1086154685274
Number of items from OneDrive to process: 3

As such, please can you utilise the following PR which will provide additional debug details at the exact area where this is failing for you and re-run the tests & provide a new verbose debug log when using the PR. This will assist in identifying what is potentially going wrong for you given that I am unable to reproduce this.

git clone https://github.com/abraunegg/onedrive.git
cd onedrive
git fetch origin pull/1045/head:pr1045
git checkout pr1045
./configure; make clean; make;

@norbusan
Copy link
Collaborator Author

This is indeed strange. I don't think the version makes s difference here, because the 2.4.5 patch is in Debian 2.4.4, this is where I tested it.

The other difference that comes to my mind is ldc2 versus dmd.

Roman, just to make sure, could you try with git master and compiling with dmd instead? Explanations on how to do this is given in the docs here.

Thanks

@RomanRiabenko
Copy link

Hello. I've checked dependancies, downloaded and installed dmd_2.093.1-0_amd64.deb, compiled precisely as instructed above, checked that --display-config output is the same, except for the version, which is v2.4.5-8-g681ad3d, and sent the new log.

@abraunegg
Copy link
Owner

@RomanRiabenko
Many thanks for the updated debug log. OK - all the the data for the delete query is correct. I have updated the PR code, please can you rebuild your PR version using the same PR steps as per above. When you are running this version, it should be onedrive v2.4.5-9-gd16f8db

Please can you perform your tests again and advise the results when using this updated PR.

@RomanRiabenko
Copy link

@abraunegg
I still get the warning, but the directory gets removed.

@abraunegg
Copy link
Owner

@RomanRiabenko
Please can you provide an updated debug log, as the new log you have sent does not show any error / warning or deletion.

@abraunegg
Copy link
Owner

@RomanRiabenko
Please can you rebuild your client with an updated PR - you should have onedrive v2.4.5-10-g01d0431 - if you can retest & provide an updated debug log so that it can be identified where the error message is still being generated from.

@abraunegg abraunegg changed the title Chained removal of directories when retention policy applies Chained removal of directories when permission is denied Aug 31, 2020
abraunegg added a commit that referenced this issue Sep 1, 2020
…h access denied (Issue #1041) (#1045)

* Handle removing child items on OneDrive when parent item responds with access denied due to parent folder permissions issue.
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something isn't working Fixed Unable to reproduce
Projects
None yet
3 participants