Skip to content
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

OS X Instancepath related bug: no NUL terminator #104

Closed
gh0st42 opened this issue May 7, 2016 · 5 comments
Closed

OS X Instancepath related bug: no NUL terminator #104

gh0st42 opened this issue May 7, 2016 · 5 comments

Comments

@gh0st42
Copy link

gh0st42 commented May 7, 2016

Cannot use SERVALINSTANCE_PATH on OSX at the moment. Compiled prefixpath seems to work.

$ export SERVALINSTANCE_PATH=/tmp/servalinstancepath
$ rm -r /tmp/servalinstancepath/
16-05-07 14:54:10 +0200
INFO: Serval DNA version: START-3478-g8e223b5
WARN: conf.c:64:reload()  config file /tmp/servalinstancepath/serval.conf does not exist -- using all defaults
WARN: No network interfaces configured (empty 'interfaces' config option)
instancepath:/tmp/servalinstancepath
pidfile:/tmp/servalinstancepath/servald.pid
pid:10335
http_port:4111
mdp_inet_port:0

$ bin/servald-darwin id self
INFO: Local date/time: 2016-05-07 14:54:35 +0200
INFO: Serval DNA version: START-3478-g8e223b5
WARN: conf.c:64:reload()  config file /tmp/servalinstancepath/serval.conf does not exist -- using all defaults
1
sid
ERROR:mdp_client.c:349:overlay_mdp_recv()  reply did not come from server: AF_UNIX:"/tmp/servalinstancepath/mdp.socket\xff" (addrlen=36, no nul terminator)

ERROR:network_cli.c:380:app_id_self()    MDP Server error #1: 'Timeout waiting for reply to MDP packet (packet was successfully sent).'
ERROR:network_cli.c:384:app_id_self()  Failed to get local address list

$ uname -a
Darwin jupiter 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64

Funny thing is, without SERVALINSTANCE_PATH set it all works.

$ unset SERVALINSTANCE_PATH
$ echo $SERVALINSTANCE_PATH

$ bin/servald-darwin start
INFO: Local date/time: 2016-05-07 14:57:54 +0200
INFO: Serval DNA version: START-3478-g8e223b5
WARN: conf.c:64:reload()  config file /Users/gh0st/serval-conf/etc/serval/serval.conf does not exist -- using all defaults
WARN: No network interfaces configured (empty 'interfaces' config option)
pidfile:/Users/gh0st/serval-conf/var/run/serval/servald.pid
pid:10361
http_port:4112
mdp_inet_port:0

$ bin/servald-darwin id self
INFO: Local date/time: 2016-05-07 14:58:01 +0200
INFO: Serval DNA version: START-3478-g8e223b5
WARN: conf.c:64:reload()  config file /Users/gh0st/serval-conf/etc/serval/serval.conf does not exist -- using all defaults
1
sid
C25D7DB5F074A880467CFEF57A80E300432D19F8EBAB8C785C4F5696DD81C15F
@lakeman
Copy link
Member

lakeman commented May 7, 2016

Can you turn on debug.io and paste the log?

Hang on, this looks a bit off
https://github.com/servalproject/serval-dna/blob/development/socket.c#L290;

Should that be;
...
.msg_namelen = sizeof(struct socket_address),
...
bzero(&address->addr, sizeof(struct socket_address));

?

On Sat, May 7, 2016 at 10:33 PM, gh0st42 notifications@github.com wrote:

Cannot use SERVALINSTANCE_PATH on OSX at the moment. Compiled prefixpath
seems to work.

$ export SERVALINSTANCE_PATH=/tmp/servalinstancepath
$ rm -r /tmp/servalinstancepath/
16-05-07 14:54:10 +0200
INFO: Serval DNA version: START-3478-g8e223b5
WARN: conf.c:64:reload() config file /tmp/servalinstancepath/serval.conf does not exist -- using all defaults
WARN: No network interfaces configured (empty 'interfaces' config option)
instancepath:/tmp/servalinstancepath
pidfile:/tmp/servalinstancepath/servald.pid
pid:10335
http_port:4111
mdp_inet_port:0

$ bin/servald-darwin id self
INFO: Local date/time: 2016-05-07 14:54:35 +0200
INFO: Serval DNA version: START-3478-g8e223b5
WARN: conf.c:64:reload() config file /tmp/servalinstancepath/serval.conf does not exist -- using all defaults
1
sid
ERROR:mdp_client.c:349:overlay_mdp_recv() reply did not come from server: AF_UNIX:"/tmp/servalinstancepath/mdp.socket\xff" (addrlen=36, no nul terminator)

ERROR:network_cli.c:380:app_id_self() MDP Server error #1: 'Timeout waiting for reply to MDP packet (packet was successfully sent).'
ERROR:network_cli.c:384:app_id_self() Failed to get local address list

$ uname -a
Darwin jupiter 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64

Funny thing is, without SERVALINSTANCE_PATH set it all works.

$ unset SERVALINSTANCE_PATH
$ echo $SERVALINSTANCE_PATH

$ bin/servald-darwin start
INFO: Local date/time: 2016-05-07 14:57:54 +0200
INFO: Serval DNA version: START-3478-g8e223b5
WARN: conf.c:64:reload() config file /Users/gh0st/serval-conf/etc/serval/serval.conf does not exist -- using all defaults
WARN: No network interfaces configured (empty 'interfaces' config option)
pidfile:/Users/gh0st/serval-conf/var/run/serval/servald.pid
pid:10361
http_port:4112
mdp_inet_port:0

$ bin/servald-darwin id self
INFO: Local date/time: 2016-05-07 14:58:01 +0200
INFO: Serval DNA version: START-3478-g8e223b5
WARN: conf.c:64:reload() config file /Users/gh0st/serval-conf/etc/serval/serval.conf does not exist -- using all defaults
1
sid
C25D7DB5F074A880467CFEF57A80E300432D19F8EBAB8C785C4F5696DD81C15F


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#104

@gh0st42
Copy link
Author

gh0st42 commented May 7, 2016

Here ist the output of debug.io=true
serval-20160507160000.txt

@gh0st42
Copy link
Author

gh0st42 commented May 7, 2016

Changing these lines in socket.c didn't fix the problem..

@lakeman
Copy link
Member

lakeman commented May 7, 2016

Well, that was a bit of a guess, (and so's this...)

The problem might be here;

addr->addrlen=sizeof addr->local.sun_family + strlen(addr->local.sun_path) + 1;

It seems that OSX has a different definition for struct sockaddr_un;
http://idletechnology.blogspot.com.au/2011/12/unix-domain-sockets-on-osx.html

So we'll need to be more careful to measure the used bytes in the structure.
There apparently should by a SUN_LEN macro we can use like;

addr->addrlen=SUN_LEN(&addr->local);

And here;

unicast_addr.addrlen=sizeof unicast_addr.local.sun_family + strlen(unicast_addr.local.sun_path) + 1;

On Sun, May 8, 2016 at 12:37 AM, gh0st42 notifications@github.com wrote:

Changing these lines in socket.c didn't fix the problem..


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#104 (comment)

@gh0st42
Copy link
Author

gh0st42 commented May 8, 2016

Hm, after playing around a bit today I'm not able to reproduce the bug at the moment. Still, using SUN_LEN macro seems the right way to get the length in a platform independent way. At least on OSX it seams to work without breaking anything else.

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

2 participants