bol-van / zapret

DPI bypass multi platform
5.84k stars 512 forks source link

Do not setgroups() on FreeBSD #257

Open kiryanov opened 1 month ago

kiryanov commented 1 month ago

setgroups() call will fail with EPERM on FreeBSD. It renders --user and --uid options useless.

bol-van commented 3 weeks ago

It doesn't reproduce on my system What is your BSD version ? May be you run tpws not as root ? If so then --user and --uid options are not available for obvious reasons. They will cause error

kiryanov commented 3 weeks ago

14.1. I run it from root as a daemon, it drops privileges with no issues, but a call to setgroups fails. PS: setgroups invocation differs between linux and freebsd, in particular freebsd needs a primary group to be specified twice in the list of groups, maybe that’s the issue. I can do some more testing in a week or two.

bol-van commented 3 weeks ago

the only call to setgroups is setgroups(0,NULL); it's intended to drop all supplimentary groups

kiryanov commented 1 week ago

So I have conducted quite some testing and I definitely could not make it work with setgroups() on FreeBSD 14.1 even using the FreeBSD semantics and passing the primary gid as the first member of the groups array. Maybe instead of removing the call just make the error non-fatal? Most of the code I have looked at just prints a warning if setgroups() call fails.

bol-van commented 1 week ago

may be you share your test code ? i cant reproduce what you talk about