Skip to content

Add a uci config file for matter and run matter as root - #51

Open
fvb-mind wants to merge 1 commit into
project-chip:mainfrom
fvb-mind:dev/matter-managed-nim
Open

Add a uci config file for matter and run matter as root#51
fvb-mind wants to merge 1 commit into
project-chip:mainfrom
fvb-mind:dev/matter-managed-nim

Conversation

@fvb-mind

@fvb-mind fvb-mind commented Jul 9, 2026

Copy link
Copy Markdown
  • Add a matter uci config file with one config variable (wifi_iface)
  • Matter could not access ubus --> running as root for now

Note: This PR also includes the change of #50 since we need it and it hasn't been merged yet

* Add a matter uci config file with one config variable (wifi_iface)
* Matter could not access ubus --> running as root for now

Signed-off-by: Frederik Van Bogaert <frederik.vanbogaert@mind.be>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Frederik Van Bogaert seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request adds rpcd as a dependency, installs a new UCI configuration file, and comments out the user and group parameters in the init script, causing the daemon to run as root. The review feedback highlights a security regression where the daemon runs as root instead of the unprivileged matter user; it is recommended to restore the unprivileged user and update the ACL permissions instead. Additionally, it is suggested to rename the matter_uci.defaults file to avoid confusion, as it is installed as a configuration file rather than a first-boot defaults script.

Comment on lines +27 to +28
#procd_set_param user matter
#procd_set_param group matter

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

security-high high

Running the daemon as root instead of the unprivileged matter user is a significant security regression. The reason the daemon could not access ubus is likely because the matter user lacks the necessary permissions in service/matter-netman/files/matter_acl.json to access the uci ubus object (provided by rpcd, which was added as a dependency in this PR) or other required ubus objects.

Instead of running as root, we should keep the daemon running as the matter user and update service/matter-netman/files/matter_acl.json to grant the necessary ubus permissions. For example, to allow reading UCI configurations, you can add the uci object with the get method to the ACL file:

	"access": {
		"otbr": {
			"methods": ["*"]
		},
		"uci": {
			"methods": ["get"]
		}
	}
Suggested change
#procd_set_param user matter
#procd_set_param group matter
procd_set_param user matter
procd_set_param group matter

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think instead of running as root you should be able to just add the relevant objects to service/matter-netman/files/matter_acl.json to give the matter user access.

$(INSTALL_DATA) ./files/bootstrap.sh $(1)/usr/share/matter/
$(INSTALL_DATA) ./files/matter_acl.json $(1)/usr/share/acl.d
$(INSTALL_BIN) ./files/matter.init $(1)/etc/init.d/matter
$(INSTALL_DATA) ./files/matter_uci.defaults $(1)/etc/config/matter

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The source file is named matter_uci.defaults, but it is installed directly as a UCI configuration file to /etc/config/matter. In OpenWrt, .defaults files typically refer to uci-defaults scripts (which are shell scripts executed on first boot). To avoid confusion, the source file should be renamed to matter.config or simply matter in the repository.

	$(INSTALL_DATA) ./files/matter.config $(1)/etc/config/matter

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think calling it matter.defaults is fine, have a look at otbr-agent.defaults for an example. They need to be installed into /etc/uci-defaults/; I think what you're doing here will overwrite the config file on a package upgrade.

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.

3 participants