Implementing Direct Download of logfile in LuCI on OpenWrt

Hello,

I am trying to add a button to LuCI in OpenWrt for direct downloading of logs and implement its functionality. I found some reference material in flash.js and other questions on the forum. However, I am encountering an issue where I receive the message “Access to path denied by ACL” and it does not work.

This is the code I am working with, located in
*/www/luci-static/resources/view/system/flash.js*:

...
o = ss.option(form.Button, 'dl_download', _('Download log')); o.inputstyle = 'action important'; o.inputtitle = _('Download log...'); o.onclick = L.bind(this.handleDownloadLogConfirm, this);

...

handleDownloadLogConfirm: function (ev) {
var form = E('form', {
'method': 'post',
'action': L.env.cgi_base + '/cgi-download',
'enctype': 'application/x-www-form-urlencoded'
}, [
E('input', { 'type': 'hidden', 'name': 'sessionid', 'value': rpc.getSessionID() }),
E('input', { 'type': 'hidden', 'name': 'path', 'value': '/logs/router_log.gz' }),
E('input', { 'type': 'hidden', 'name': 'filename', 'value': 'router_log.gz' })
]);
ev.target.parentNode.appendChild(form);
form.submit();
form.parentNode.removeChild(form);
},
...

*I'm not sure what "dl_download" refers to; in the case of backup, it's "dl_backup", so I wrote this code based on that assumption.

The file exists in the path. (/logs/router_log.gz)
I wondered if the path was the problem, so I also granted permission to the path.
I also tested it by putting the file in the tmp folder, but it still doesn't work.
It says “Access to path denied by ACL”.

Please teach me how to download files from luci.
Waiting for help. :scream:

This ain't a full path. /logs aren't under root. Your are missing /var/logs or /tmp/var/logs depending on where you have found the file.

1 Like

Thank you for your answer.
/logs/router_log.gz
This route is one I created myself.
I created a script to save the daily edited log separately to this path.
And there's a file to download in this path

It's been solved very simply.
There was no problem with the code.
After modifying the luci-mod-system.json during the test, I logged out after fully refreshing and checked it, and the download went well. ㅜㅜ
This problem has been solved :rofl:

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.