Code Monkey home page Code Monkey logo

Comments (14)

timdodge avatar timdodge commented on May 30, 2024 1

I'm not an expert on socket "files", but the permission on the control sockets are:

root@wap:~# ls -la /var/run/hostapd/wlan0
srwxrwx--- 1 network network 0 Apr 11 12:25 /var/run/hostapd/wlan0

When running as the root user, wifi-presence can't access them. I've tried catting the socket as root and just get a "No such device or address" error back. I guess that as a minimum, the wifi-presence user needs to be in the network group.

from wifi-presence.

jmccrohan avatar jmccrohan commented on May 30, 2024 1

Thanks, LGTM.

Open a PR against openwrt-packages and ping me to merge.

from wifi-presence.

McGiverGim avatar McGiverGim commented on May 30, 2024

I've the same problem. Could you explain how can I do it?

from wifi-presence.

timdodge avatar timdodge commented on May 30, 2024

Edit /etc/init.d/wifi-presence
Add to start_service():

procd_set_param user network
procd_set_param group network

from wifi-presence.

McGiverGim avatar McGiverGim commented on May 30, 2024

I added the two parameters. I don't have the error anymore, but I think I have something bad configured. I can't see anything at the MQTT server. I will look again to the configuration.
Thanks for the help!
@awilliams could you add this two parameters to the OpenWrt package?

from wifi-presence.

awilliams avatar awilliams commented on May 30, 2024

I've only seen processes run as root on OpenWrt unless explicitly set otherwise. For this reason, I've had no permissions issues. Is wifi-presence being run as root for you and you still see the permissions issues with the control sockets?

Instead of hardcoding network, I'd like to make the user/group configurable (similar to kcptun for example). Would that solve the issue you're experiencing?

from wifi-presence.

McGiverGim avatar McGiverGim commented on May 30, 2024

I can't say too much, I don't have too much experience with Linux or Openwrt. I only installed the package with opkg and I experienced the issue until I added the lines commented by @timdodge.

from wifi-presence.

jmccrohan avatar jmccrohan commented on May 30, 2024

@awilliams I encountered this issue also, and was resolved using the changes suggested by @timdodge. Feel free to ping me if you want to make these changes directly in OpenWrt.

from wifi-presence.

awilliams avatar awilliams commented on May 30, 2024

I've created a PR that I think will address this issue: PR #6.

Please try it out if you're able to. After updating the /etc/init.d/wifi-presence script, add the following to /etc/config/wifi-presence to run the process as network / network:

         option runAsUser 'network'
         option runAsGroup 'network'

If the PR looks good, I'll make the same change in the openwrt/packages repo.

I'm guessing you're using seccomp or something similar, and triggering this case in hostapd's init script, causing it to run as network / network.

from wifi-presence.

jmccrohan avatar jmccrohan commented on May 30, 2024

@awilliams can you share a bit more detail on your OpenWrt builds? Are you running an old build/snapshot, or a target where seccomp is unavailable? Given that seccomp is enabled by default on most (all?) targets, I think that the user/group options should be uncommented in the config file.
ad2b6bd#diff-5000e54b7b529e6c12b270a4c9335886f97c9b4065dda3d789740f4e7a042aa5R52-R53

from wifi-presence.

awilliams avatar awilliams commented on May 30, 2024

@jmccrohan Thanks for letting me know that seccomp is enabled by default. I'm using a custom build of OpenWrt for my routers, so wasn't aware.

What do you think about the following idea? Modify the changes in #6 to auto-detect the proper user if runAsUser/runAsGroup aren't explicitly defined. In other words, instead of defaulting to root, do something like stat the /var/run/hostapd/wlan0 sockets and run wifi-presence as the owner of that file.

from wifi-presence.

jmccrohan avatar jmccrohan commented on May 30, 2024

@awilliams Up to you how you implement it. A simple comment might in the config file re root/network users might suffice and is easier to maintain. Key is to get this fixed and merged into OpenWrt so that new users don't get bitten by this issue. :-)

from wifi-presence.

awilliams avatar awilliams commented on May 30, 2024

I think the recent change in #6 will work fine.

It allows setting a user/group in /etc/config/wifi-presence. If no specific values are set, then the init script will look at the owner of the sockets in /var/run/hostapd and use that user as the user/group to start wifi-presence. I'd expect this to work for almost all users without them having to touch their configs.

If you're able @jmccrohan, please review. Once merged in this repo, I'll make the same change to openwrt/packages.

from wifi-presence.

awilliams avatar awilliams commented on May 30, 2024

Fixed by openwrt/packages#18573

from wifi-presence.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.