Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ const callSystemValidateFirmwareImage = rpc.declare({
expect: { '': { valid: false, forceable: true } }
});

const callGetBoardJSON = rpc.declare({
object: 'luci-rpc',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the PR description sync described in the last comment did not land — as of 208df8f the body still reads "Introduce a small factoryLanIP() helper backed by the existing luci.getBoardJSON rpc method" (it is a module-scoped string, and the object is luci-rpc per this line) and "Behaviour for stock upstream builds is unchanged (board.json still contains '192.168.1.1')", the premise the rewritten commit message correctly drops. Possibly an unsaved edit in the GitHub description box; worth re-applying so the body matches the commit message.


Generated by Claude Code

method: 'getBoardJSON',
expect: { '': {} }
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ACL grant. luci-rpc getBoardJSON is only granted by the luci-base-network-status group (luci-base.json:40), which the flash view does not depend on. The luci-mod-system-flash group's read.ubus section only lists file (luci-mod-system.json:181-183).`` This works for root (whose rpcd session is granted `*`) but silently fails with "Access denied" for any restricted user that has only the flash ACL — exactly the case this change is meant to fix. Please add `"luci-rpc": [ "getBoardJSON" ]` to `luci-mod-system-flash`'s `read.ubus`.


Generated by Claude Code


/* Cached factory-reset LAN IP, prefetched in load() so it can be passed
* synchronously to ui.awaitReconnect() before firstboot/sysupgrade wipe
* the device and rpcd disappears. */
let factoryLanIP = '192.168.1.1';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the PR description still describes the pre-force-push revision and now contradicts the commit message on two facts: it says the change introduces "a small factoryLanIP() helper backed by the existing luci.getBoardJSON rpc method" (it is a module-scoped string, and the object is luci-rpc), and it repeats "Behaviour for stock upstream builds is unchanged (board.json still contains '192.168.1.1')" — the premise the rewritten commit message correctly drops, since stock board.json has no network.lan.ipaddr key at all and the default now comes from this line. Worth syncing the body with the commit message so the merged description matches the code.


Generated by Claude Code


function findStorageSize(procmtd, procpart) {
let kernsize = 0, rootsize = 0, wholesize = 0;

Expand Down Expand Up @@ -71,7 +82,11 @@ return view.extend({
fs.trimmed('/proc/sys/kernel/hostname'),
fs.trimmed('/proc/mtd'),
fs.trimmed('/proc/partitions'),
fs.trimmed('/proc/mounts')
fs.trimmed('/proc/mounts'),
L.resolveDefault(callGetBoardJSON(), {}).then(bj => {
factoryLanIP = bj?.network?.lan?.ipaddr ?? '192.168.1.1';
return factoryLanIP;
})
];

return Promise.all(tasks);
Expand Down Expand Up @@ -101,7 +116,7 @@ return view.extend({
/* Currently the sysupgrade rpc call will not return, hence no promise handling */
fs.exec('/sbin/firstboot', [ '-r', '-y' ]);

ui.awaitReconnect('192.168.1.1', 'openwrt.lan');
ui.awaitReconnect(factoryLanIP, 'openwrt.lan');
},

handleRestore(ev) {
Expand Down Expand Up @@ -163,7 +178,7 @@ return view.extend({
E('p', { 'class': 'spinning' }, _('The system is rebooting now. If the restored configuration changed the current LAN IP address, you might need to reconnect manually.'))
]);

ui.awaitReconnect(window.location.host, '192.168.1.1', 'openwrt.lan');
ui.awaitReconnect(window.location.host, factoryLanIP, 'openwrt.lan');
}, this))
.catch(function(e) { ui.addNotification(null, E('p', e.message)) })
.finally(function() { btn.firstChild.data = _('Upload archive...') });
Expand Down Expand Up @@ -337,7 +352,7 @@ return view.extend({
if (opts['keep'][0].checked)
ui.awaitReconnect(window.location.host);
else
ui.awaitReconnect(window.location.host, '192.168.1.1', 'openwrt.lan');
ui.awaitReconnect(window.location.host, factoryLanIP, '192.168.1.1', 'openwrt.lan');
},

handleBackupList(ev) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@
"/sbin/sysupgrade --list-backup": [ "exec" ]
},
"ubus": {
"file": [ "exec", "read", "stat" ]
"file": [ "exec", "read", "stat" ],
"luci-rpc": [ "getBoardJSON" ]
}
},
"write": {
Expand Down
Loading