Files
Gary Dotzler 17a3a87f6e procd: assign conventional /dev/net/tun permissions
Set /dev/net/tun to mode 0666, matching the TUN/TAP permissions
documented by docs.kernel.org[1] and the default udev policy used by
other Linux systems[2].

This avoids forcing otherwise unprivileged processes to retain elevated
privileges solely to open the device node.

Interface creation and attachment remain subject to the kernel's usual
capability and ownership checks.

[1] https://docs.kernel.org/networking/tuntap.html#configuration
[2] https://github.com/systemd/systemd/blob/be1e78ec49f8c84c634d9e58dae834b27ea28436/rules.d/50-udev-default.rules.in#L111

Signed-off-by: Gary Dotzler <geldot@protonmail.com>
Link: https://github.com/openwrt/openwrt/pull/25464
Signed-off-by: Nick Hainke <vincent@systemli.org>
2026-10-11 09:57:57 +02:00

86 lines
1.8 KiB
JSON

[
[ "case", "ACTION", {
"add": [
[ "if",
[ "and",
[ "has", "MAJOR" ],
[ "has", "MINOR" ]
],
[
[ "if",
[ "eq", "DEVNAME", "null" ],
[
[ "makedev", "/dev/%DEVNAME%", "0666" ],
[ "exec", "/bin/ln", "-s", "/proc/self/fd", "/dev/fd" ],
[ "exec", "/bin/ln", "-s", "/proc/self/fd/0", "/dev/stdin" ],
[ "exec", "/bin/ln", "-s", "/proc/self/fd/1", "/dev/stdout" ],
[ "exec", "/bin/ln", "-s", "/proc/self/fd/2", "/dev/stderr" ],
[ "return" ]
]
],
[ "if",
[ "eq", "DEVNAME",
[ "full", "ptmx", "zero", "tty", "net", "net/tun", "random", "urandom" ]
],
[
[ "makedev", "/dev/%DEVNAME%", "0666" ],
[ "return" ]
]
],
[ "include", "/etc/hotplug.json.d/*.json" ],
[ "if",
[ "regex", "DEVNAME", "^tty" ],
[ "makedev", "/dev/%DEVNAME%", "0660", "dialout" ]
],
[ "if",
[ "has", "DEVNAME" ],
[ "makedev", "/dev/%DEVNAME%", "0600" ]
]
]
],
[ "if",
[ "has", "FIRMWARE" ],
[
[ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ],
[ "load-firmware", "/lib/firmware" ],
[ "return" ]
]
],
[ "if",
[ "regex", "DEVNAME", "^ttyGS" ],
[ "start-console", "%DEVNAME%" ]
]
],
"remove" : [
[ "if",
[ "and",
[ "has", "DEVNAME" ],
[ "has", "MAJOR" ],
[ "has", "MINOR" ]
],
[ "rm", "/dev/%DEVNAME%" ]
]
]
} ],
[ "if",
[ "and",
[ "has", "BUTTON" ],
[ "eq", "SUBSYSTEM", "button" ]
],
[ "button", "/etc/rc.button/%BUTTON%" ]
],
[ "if",
[ "and",
[ "eq", "SUBSYSTEM", "usb-serial" ],
[ "regex", "DEVNAME",
[ "^ttyUSB", "^ttyACM" ]
]
],
[ "exec", "/sbin/hotplug-call", "tty" ],
[ "if",
[ "isdir", "/etc/hotplug.d/%SUBSYSTEM%" ],
[ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ]
]
]
]