Writing gpio without being root or CP_ADMIN

Hi!

I wonder if there is any way to write to /sys/class without privileged or CP_ADMIN capability?
I don’t want my container to have the full power just for a simple gpio access.

I know that i always can mount /dev/mem and write directly to the gpio registers but that’s definitly not the way i want to go (portability, …), ever.

Thanks!

Hello,
You can try adding an udev rule on the host os: https://github.com/balena-os/meta-balena#udevrules
This rule would chown the gpio files to a numeric uid and gid like here https://stackoverflow.com/questions/30938991/access-gpio-sys-class-gpio-as-non-root .
Then in your Dockerfile, create a user with the gid used in the udev rule.
I don’t know if it would work but I see no other way.