Skip to content

luci-app-lxc: add permission to set lxc options#8531

Merged
systemcrash merged 1 commit intoopenwrt:masterfrom
mdevolde:luci-app-lxc-uci-set
Apr 9, 2026
Merged

luci-app-lxc: add permission to set lxc options#8531
systemcrash merged 1 commit intoopenwrt:masterfrom
mdevolde:luci-app-lxc-uci-set

Conversation

@mdevolde
Copy link
Copy Markdown
Contributor

@mdevolde mdevolde commented Apr 6, 2026

  • This PR is not from my main or master branch 💩, but a separate branch ✅
  • Each commit has a valid ✒️ Signed-off-by: <my@email.address> row (via git commit --signoff)
  • Each commit and PR title has a valid 📝 <package name>: title first line subject for packages
  • Incremented 🆙 any PKG_VERSION in the Makefile
  • Tested on: aarch64, OpenWrt 25.12.2, Opera One(version : 129.0.5823.44) ✅
  • Mention: @systemcrash
  • Screenshot of changes:

Actual behavior:
image

New behavior (working set/save):
image

  • Description:

Add set permission in acl.d file for luci-app-lxc to allow users to set lxc options in luci-app-lxc.
To perform my tests, I considered a user with these permissions in /etc/config/rpcd:

config login
        option username 'lxc'
        option password '$p$lxc'
        list read 'unauthenticated'
        list read 'luci-base'
        list read 'luci-app-lxc'
        list write 'luci-app-lxc'

Actually, users with these permissions are able to create containers and perform actions on them, but are not able to edit the basic settings. That's the purpose of this PR.

Add set permission in acl.d file for luci-app-lxc
to allow users to set lxc options in luci-app-lxc.
(considering that user has write permission for
this app)

Signed-off-by: mdevolde <martin.devolder2@gmail.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

Warning

Some formality checks failed.

Consider (re)reading submissions guidelines.

Failed checks

Issues marked with an ❌ are failing checks.

Commit 9220734

  • 🔶 Author name must be either a real name 'firstname lastname' or a nickname/alias/handle
    Actual: mdevolde seems to be a nickname or an alias
    Expected: a real name 'firstname lastname'
  • 🔶 Commit(ter) name must be either a real name 'firstname lastname' or a nickname/alias/handle
    Actual: mdevolde seems to be a nickname or an alias
    Expected: a real name 'firstname lastname'

For more details, see the full job log.

Something broken? Consider providing feedback.

@systemcrash
Copy link
Copy Markdown
Contributor

Am I right in thinking that the uci set command is now globally accessible via this app/user combo (e.g. uci set any-app any-property is possible)?

@mdevolde
Copy link
Copy Markdown
Contributor Author

mdevolde commented Apr 7, 2026

I made the set query with the sysauth_https of a non-admin user that hasn't access to this app (I received à 200):
image

I made the apply query with the same sysauth_https as above, and with a CSRF token that I just genereted for this user (I reveiced a 204):
image

But, as we can see, the changes aren't really applied (Free Space Treshold should be 200000):
image

So, it seems that a user just has uci access to the apps specified in the uci section (here, "uci": [ "lxc" ]), but it would be interesting to be sure about the exact behavior.

@mdevolde
Copy link
Copy Markdown
Contributor Author

mdevolde commented Apr 7, 2026

@systemcrash the curious thing is the 2xx responses, and not 4xx responses. I will check in the code to be 100% confident. If you know exactly how it works, I'm interested !

@mdevolde
Copy link
Copy Markdown
Contributor Author

mdevolde commented Apr 7, 2026

I forgot to precise but the other user trying to edit the lxc params has these permissions:

        list read 'unauthenticated'
        list read 'luci-base'
        list read 'luci-app-wol'
        list write 'luci-app-wol'

And this is the luci-app-wol acls:

{
	"luci-app-wol": {
		"description": "Grant access to wake-on-lan executables",
		"read": {
			"ubus": {
				"luci.wol": [ "stat" ],
				"luci-rpc": [ "getHostHints", "getNetworkDevices" ]
			},
			"uci": [ "luci-wol" ]
		},
		"write": {
			"ubus": {
				"luci.wol": [ "exec" ],
				"uci": [ "add", "set", "delete", "order" ]
			},
			"uci": [ "luci-wol" ]
		}
	}
}

So, he has uci set perm, but we don't wan't him to perform uci set on our lxc app

@mdevolde
Copy link
Copy Markdown
Contributor Author

mdevolde commented Apr 7, 2026

Ok I figured it out.

Response to uci set with the right auth token:

HTTP/1.1 200 OK
Connection: Keep-Alive
Keep-Alive: timeout=20
Content-Type: application/json
Content-Length: 39

[{"jsonrpc":"2.0","id":7,"result":[0]}]

Response to uci set with the wrong auth token:

HTTP/1.1 200 OK
Connection: Keep-Alive
Keep-Alive: timeout=20
Content-Type: application/json
Content-Length: 39

[{"jsonrpc":"2.0","id":7,"result":[6]}]

Diff:

HTTP/1.1 200 OK
Connection: Keep-Alive
Keep-Alive: timeout=20
Content-Type: application/json
Content-Length: 39

- [{"jsonrpc":"2.0","id":7,"result":[0]}]
+ [{"jsonrpc":"2.0","id":7,"result":[6]}]

The difference is the result code.
0 is 200 OK:

6 is 403 Permission denied:

403, 'Permission denied',

So, a user with this permission can't perform uci set to any app.

@mdevolde
Copy link
Copy Markdown
Contributor Author

mdevolde commented Apr 9, 2026

@systemcrash do you need any other information/test about these permissions?

@systemcrash
Copy link
Copy Markdown
Contributor

I guess there's no other reasonable way around this.

@systemcrash systemcrash merged commit 8420a72 into openwrt:master Apr 9, 2026
6 checks passed
@mdevolde mdevolde deleted the luci-app-lxc-uci-set branch April 9, 2026 16:51
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

Successfully merging this pull request may close these issues.

2 participants