Skip to content

mod_notionflux: fchmod of socket always fails on FreeBSD #350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jeffpc opened this issue Feb 4, 2023 · 6 comments
Open

mod_notionflux: fchmod of socket always fails on FreeBSD #350

jeffpc opened this issue Feb 4, 2023 · 6 comments

Comments

@jeffpc
Copy link
Contributor

jeffpc commented Feb 4, 2023

On FreeBSD, mod_notionflux fails on start (xmessage opens mentioning an invalid argument error) because of an invalid arg related to the listening socket. start_listening tries to fchmod the newly created socket but on FreeBSD this always fails. The manpage for fchmod says:

     [EINVAL]           The fd argument refers to a socket, not to a file.

The following (hacky) patch fixes the issue and mod_notionflux seems to start up fine.

diff --git a/mod_notionflux/mod_notionflux.c b/mod_notionflux/mod_notionflux.c
index 51949e07..e9176c7c 100644
--- a/mod_notionflux/mod_notionflux.c
+++ b/mod_notionflux/mod_notionflux.c
@@ -328,8 +328,10 @@ static bool start_listening()
     if(listenfd<0)
         goto errwarn;
 
+#ifndef __FreeBSD__
     if(fchmod(listenfd, S_IRUSR|S_IWUSR)<0)
         goto errwarn;
+#endif
 
     addr.sun_family=AF_UNIX;
 
@wilhelmy
Copy link
Collaborator

wilhelmy commented Feb 5, 2023

While this should be fine from a security standpoint since we're wrapping the socket into a secured temporary directory, it still feels suboptimal until now that it's coming back to me that FreeBSD doesn't support permissions on socket files no matter whether per chmod or fchmod.

@jeffpc
Copy link
Contributor Author

jeffpc commented Feb 5, 2023

This fchmod is weird - it happens right after socket() - so this fd is a completely new socket and isn't associated with a path yet and so it makes perfect sense that the fchmod would fail. Note that the chmod after we bind the socket (a few lines later) succeeds.

@nunotexbsd
Copy link

Hello @jeffpc

I've just committed notion port to FreeBSD tree:
https://cgit.freebsd.org/ports/commit/?id=b2dddd954285133eade5e1c9673ae9ad69e4bd17

Could you update your ports tree and do a quick run test?

Thanks

@jeffpc
Copy link
Contributor Author

jeffpc commented Mar 8, 2025 via email

@jeffpc
Copy link
Contributor Author

jeffpc commented Mar 12, 2025

I'll try to find a few minutes this weekend to give it a try.

Sorry for the delay. I successfully built the port. My quick test of it indicates that it works.

@nunotexbsd
Copy link

@jeffpc

Nice!
I'm trying to know the reason of some keys giving problems: #336 (comment)
Do you have similar errors?

Also, If you got any custom key bindings on .notion/cfg_notion.lua please sent it to my e-mail so I can further test.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants