Skip to content

Commit 7f0f12c

Browse files
committed
Change socket owner to network user
1 parent 3fb8fe5 commit 7f0f12c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

hapt/files/hapt.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
class FFI:
2121
libc = ffi.open('libc.so.6')
2222

23+
lchown = libc.func('i', 'lchown', 'sII')
24+
2325
IN_CREATE = 0x00000100
2426
IN_DELETE = 0x00000200
2527

@@ -79,6 +81,9 @@ def connect_hostapd_socket(interface):
7981
local_address = '/var/run/hapt-%s-%d' % (interface, time.time() % 86400)
8082
sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
8183
sock.bind(encode_socket_address(local_address))
84+
# Make our local socket owned by the `network` group, so that hostapd (running as non-root) is allowed to send messages to it
85+
# See: https://github.com/openwrt/openwrt/blob/master/package/network/services/hostapd/patches/610-hostapd_cli_ujail_permission.patch
86+
FFI.lchown(local_address, 101, 101)
8287
sock.connect(encode_socket_address(remote_address))
8388
sock.send('ATTACH')
8489
response = sock.recv(1024)

0 commit comments

Comments
 (0)