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

download files from luci ( use LuCI as file share ) #846

Closed
mirjafarabedi opened this issue Nov 12, 2016 · 8 comments
Closed

download files from luci ( use LuCI as file share ) #846

mirjafarabedi opened this issue Nov 12, 2016 · 8 comments

Comments

@mirjafarabedi
Copy link

I've uploaded some files in my OpenWrt root , /etc , /tmp directories.
I want user to be able to download uploaded files from from the above directories .
How can i give a download URL to user , to download that files ?

@hnyman
Copy link
Contributor

hnyman commented Nov 12, 2016

You should not give them access to /etc and root directories, as then they can also see your settings and other private stuff.

By default LuCI allows read access to stuff under /www directory
You should place the public stuff there.

Note that you can utilise symlinks, as explained here:
https://forum.openwrt.org/viewtopic.php?pid=298615#p298615

Just create a symlink to the directory you want to share under /www like this:

# ln -s /path/to/shared/folder /www/sharename

And you can access it like this: http://192.168.1.1/sharename

@hnyman hnyman changed the title download files from luci download files from luci ( use LuCI as file share ) Nov 12, 2016
@mirjafarabedi
Copy link
Author

I know this security risk (download from /etc and ...) . But in my app i monitor some sensor information and save them in /tmp folder.(in memory). and then i want access user download this exported info after authenticating with his username and password.Is this not possible ? (Thanks in advance for your response)

@mirjafarabedi
Copy link
Author

Unfortunately your answer doesn't work for me

@hnyman
Copy link
Contributor

hnyman commented Nov 12, 2016

Works for me, but naturally only from LAN. If you want it to work from wan, you need to adjust firewall etc.

Below is example of outputting tail of kernel log to file /www/test/test.txt and then how it is visible in the browser:

root@lede:~# cd /www
root@lede:/www# mkdir test
root@lede:/www# cd test/
root@lede:/www# dmesg | tail > test.txt
root@lede:/www/test# cat /www/test/test.txt
[67087.447386] [<c021f9bc>] (handle_IPI) from [<c0209474>] (gic_handle_irq+0x90/0xbc)
[67087.454677] [<c0209474>] (gic_handle_irq) from [<c020a594>] (__irq_svc+0x54/0x70)
[67087.462130] Exception stack(0xdd471f80 to 0xdd471fc8)
...

capture1

capture2

EDIT:
And I tested also the "symlink" approach. I linked the Luci statistics dir to be /www/rrd and it shows ok in browser:

root@lede:/www# ln -s /tmp/rrd/lede/ /www/rrd

captur2e

@mirjafarabedi
Copy link
Author

Thanks to answer.
But i have an other problem.
In LuCI web app in the system-backup/flash firmware mene user can download a backup of /etc folder . As below :
capture

How can i implement a functionality like this to allow user download files from /etc folder ?

@hnyman
Copy link
Contributor

hnyman commented Nov 12, 2016

In LuCI web app in the system-backup/flash firmware mene user can download a backup of /etc folder

LuCI doesn't actual make a copy of /etc. It only launches a sysupgrade script that collects files from /etc (also also from other places if necessary) and creates an archive of those to /tmp (I think) and then sends that to the browser. Source code for the LuCI side functionality is here, in case you want to write something similar for your needs: https://github.com/openwrt/luci/blob/master/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua#L302

The sysupgrade script is coming from base-files: https://github.com/openwrt/openwrt/blob/master/package/base-files/files/sbin/sysupgrade

The easy approach for you is to use the /www like I showed, and just make sure that you have script that copies the files there as needed. If you want more complex access to other parts of the file system, feel free to start coding along the lines I showed here.

@mirjafarabedi
Copy link
Author

Thank you for your good answers . I will test your suggested solutions and I will announce the results.
Thanks again :))

@mirjafarabedi
Copy link
Author

I created a directory in my /etc folder . and then i linked it to /www/test (ln -s /etc/test1 /www/test)
and it works for me .
Thank you very much :)

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

No branches or pull requests

2 participants