Downloads fail if Downloads folder is a symlink to SD card

Bug #1549433 reported by Josué
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
webbrowser-app (Ubuntu)
Confirmed
Low
Unassigned

Bug Description

Hi.
My home folders (Documents, Downloads, Pictures and Videos) are symlinks from a folders with the same name from SD-Card in order to save internal storage.
I made those symlinks with "ln -s -r" through a terminal.

When I try to download a file, directly or just selecting option "open with" it fails.
If I try to download, for example a PDF file and try to open with document viewer, document viewer will say: the files doesn't exists.
If I try to download the file directly it will complete the downlad but the result will be the same.

In the log I can find that:
Failed moving file from "/home/phablet/.local/share/ubuntu-download-manager/webbrowser-app/Downloads/example.pdf" to "/home/phablet/Downloads/example.pdf

http://paste.ubuntu.com/14848556/

Bq E4.5 ubuntu edition.

Revision history for this message
Olivier Tilloy (osomon) wrote :

I’m suspecting apparmor denies write access to the resolved target of the symlink. Would need confirmation from someone in the security team.
Not sure what the plans are for supporting writing to the SD card.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

To confirm if it is apparmor, use 'grep DEN /var/log/syslog' after you see the error. I suspect it is apparmor because it will necessarily resolve symlinks. I suggest you update /etc/apparmor.d/local/usr.bin.webbrowser-app to add the necessary access, then do: sudo apparmor_parser -r /etc/apparmor.d/usr.bin.webbrowser-app

Note: modifying /etc/apparmor.d/local/usr.bin.webbrowser-app instead of /etc/apparmor.d/usr.bin.webbrowser-app means you you want be asked to merge your changes on upgrades.

Revision history for this message
Josué (j2g2rp) wrote :

Hi.
I was very busy last days.
I checked what you was suggesting:
Attached is the return of typing in terminal sudo grep DEN /var/log/syslog

I also typed in terminal "sudo apparmor_parser -r /etc/apparmor.d/usr.bin.webbrowser-app" but the result looks the same. I tryed to restart the device, now its looped -.- lets flash.

Revision history for this message
Olivier Tilloy (osomon) wrote :

@Josué: did you mean to attach the output? It looks like you didn’t. Did you actually modify /etc/apparmor.d/local/usr.bin.webbrowser-app before running the apparmor_parser command?

Revision history for this message
Josué (j2g2rp) wrote :

sorry, finally i couldn't to attach the output since the system was broken. I'll try to do it again next days, maybe i did something wrong ;)

Revision history for this message
Olivier Tilloy (osomon) wrote :

Ok. I’m marking the bug incomplete for now, while we wait for your input. Thanks!

Changed in webbrowser-app (Ubuntu):
status: New → Incomplete
Revision history for this message
Josué (j2g2rp) wrote :

Its strange but today I cant find the file syslog. Before flashing the device I'm sure it was there.
How can I update the file "/etc/apparmor.d/local/usr.bin.webbrowser-app"?

Revision history for this message
Olivier Tilloy (osomon) wrote :

I just realized that because of bug #1559995, modifications to /etc/apparmor.d/local/usr.bin.webbrowser-app won’t be taken into account.

Instead, you can try the following:

 - on your device, close the browser app
 - in the terminal app, enter the following command:
        sudo apparmor_parser -R /etc/apparmor.d/usr.bin.webbrowser-app
 - open the browser app, try to download a file, and let us know if it works
   - if it doesn’t then the problem lies elsewhere
   - if it does, close the browser app and enter the following command in the terminal app:
        sudo apparmor_parser /etc/apparmor.d/usr.bin.webbrowser-app
     then open the browser app, try to download a file, and it should fail

Please let us know how this goes.

Revision history for this message
Josué (j2g2rp) wrote :

Executing "sudo apparmor_parser -R /etc/apparmor.d/usr.bin.webbrowser-app" I could download one file. It was copied correctly in Downloads folder (log : http://paste.ubuntu.com/15468050/) but since it all other downloads are failing. (downloading always at 0%) Log:

*****
Loading module: 'libubuntu_application_api_touch_mirclient.so.3.0.0'
file:///usr/lib/arm-linux-gnueabihf/qt5/qml/Ubuntu/Components/1.3/TextField.qml:926: Error: Cannot assign to non-existent property "activeFocusOnPress"
file:///usr/lib/arm-linux-gnueabihf/qt5/qml/Ubuntu/Components/1.3/TextField.qml:902: Error: Cannot assign to non-existent property "activeFocusOnPress"
qml: Loaded 5 UA override(s) from file:///usr/lib/arm-linux-gnueabihf/qt5/qml/Ubuntu/Web/ua-overrides-mobile.js
[0321/225711:ERROR:layer_tree_host_impl.cc(2181)] Forcing zero-copy tile initialization as worker context is missing
[0321/225714:ERROR:layer_tree_host_impl.cc(2181)] Forcing zero-copy tile initialization as worker context is missing
Invalid tab index: -1
ShaderEffect: Property 'source' is not assigned a valid texture provider (QQuickItem*).
[0321/225717:ERROR:layer_tree_host_impl.cc(2181)] Forcing zero-copy tile initialization as worker context is missing
qml: caller DEPRECATED
file:///usr/lib/arm-linux-gnueabihf/qt5/qml/Ubuntu/Content/ContentPeerPicker13.qml:194: TypeError: Cannot read property 'peers' of null
file:///usr/lib/arm-linux-gnueabihf/qt5/qml/Ubuntu/Content/ContentPeerPicker13.qml:194: TypeError: Cannot read property 'peers' of null
****
the samething happens restarting the webbrowser.
Restarting the device:
Can download the file but it will say that the download fail.
paste.ubuntu.com/15468192
using again "sudo apparmor_parser -R /etc/apparmor.d/usr.bin.webbrowser-app": same result, i just can download correctly one file even restarting the webbrowser.

Then, closing webbrowser and executing: "sudo apparmor_parser /etc/apparmor.d/usr.bin.webbrowser-app"
looks like i cant download even a single file like you said.

Revision history for this message
Olivier Tilloy (osomon) wrote :

The issue with subsequent downloads stuck at 0% is probably a different one, and should be investigated separately. Can you reproduce it if you simply remove the symlink (so that the Downloads folder is an actual folder in your home directory)? If so, please file a separate bug report at https://bugs.launchpad.net/ubuntu/+source/webbrowser-app/+filebug.

Otherwise, this confirms my initial suspicion that apparmor prevents transparently following symlinks. Not really sure what can/should be done about this. Jamie, do you have suggestions? Is this a use case we can support with the current state of things?

Changed in webbrowser-app (Ubuntu):
status: Incomplete → Confirmed
summary: - download to symlink
+ Downloads fail if Downloads folder is a symlink to SD card
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

AppArmor won't follow symlinks by design cause that would allow people to escape policy.

Olivier Tilloy (osomon)
Changed in webbrowser-app (Ubuntu):
importance: Undecided → Low
Revision history for this message
Josué (j2g2rp) wrote :

I tryed to do that today.
Deleting the symlink to Downloads and making a new folder named "Downloads"
The issue of 0% cant be reproduced with or without tipping that comand so i think that is related with the comand.

Revision history for this message
Olivier Tilloy (osomon) wrote :

Thanks for the confirmation Josué.
That leaves us with the issue that the Downloads folder can’t be on the SD card (or anywhere else, really). This is an apparmor feature, so at this point I’m not really sure what can be done about it. The bug remains valid, but without a solution for now.

Revision history for this message
Josué (j2g2rp) wrote :

OK! thanks to @everyone for the info and the support ;)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.