n42n / n3n

Peer to Peer VPN
https://n3n.dev
86 stars 9 forks source link

Add patch for OpenWrt #48

Closed small-5 closed 3 months ago

small-5 commented 3 months ago

OpenWrt should use /var/run/n3n instead of /run/n3n. The libcap is not required.

hamishcoleman commented 3 months ago

Have you experienced errors with the use of "/run"? Can you link to an OpenWRT policy document that says not to use it?

I see that "/run" is a symlink to "/var/run", and thus it has no problem with staying unpatched. This would be the only OpenWRT-specific patch in the source code, so it should be avoided if at all possible. If not possible to avoid, we are the upstream, so we also should avoid carrying a patch file and just have an ifdef in the actual source code (as that is more resilient to changes)

small-5 commented 3 months ago

Yes, an error will be reported if /run is used. OpenWrt does not have a /run directory, only /var/run (actually /tmp/run) If don't use a patch, can only add a flag to determine whether it is OpenWrt.

hamishcoleman commented 3 months ago

My openwrt systems all have a "/run" as a symlink to "/var/run", so I dont see any problem. Have openwrt changed they way they work recently? Can you link to this change?

small-5 commented 3 months ago

image The OpenWrt code does not symlink "/run" to "/var/run", only $(LN) /tmp/run $(1)/var/run

https://github.com/openwrt/openwrt/blob/e6fec638d2791547c45c9a5267be07a722e03cd9/package/base-files/files/etc/init.d/boot#L27 https://github.com/openwrt/openwrt/blob/e6fec638d2791547c45c9a5267be07a722e03cd9/package/base-files/Makefile#L223

small-5 commented 3 months ago

In my impression, OpenWrt projects all use /var/run or /tmp/run image

hamishcoleman commented 3 months ago

Equally, I can show you an openwrt system that has a symlink from /run to /var/run - which now appears to be a vendor patch.

Probably a better patch would be to plumb up the (currently unused) configure --runstatedir option to default to "/run" (as all modern linux systems use and expect) and allow the openwrt build to specify a --runstatedir=/var/run

small-5 commented 3 months ago

Your OpenWrt should used a third-party patch, so there is a /run directory. For me, using configure --runstatedir or patch can achieve the same effect.

hamishcoleman commented 3 months ago

Managing a patch file is more unreliable, harder to edit and more hidden from view. Their use is valuable when the upstream cannot fix or change things. Since this is the upstream project, we can fix the problem at the source by adding a configure feature

small-5 commented 3 months ago

Then let me modify the code and add runstatedir to test it.

hamishcoleman commented 3 months ago

Just so you know, you can just reuse the same pull request, and push different patches into it - which has the advantage that the context, old patch history and conversation is not lost