Hi,
I'm running scim-bridge-0.4.15.
In FreeBSD, scim-bridge creates the socket with incomplete path name, i.e. the socket is created with following path name:
/tmp/scim-bridge-0.3.0.socket-1001@localhost:0.
instead of:
/tmp/scim-bridge-0.3.0.socket-1001@localhost:0.0
Yes, no zero character at the end.
I truss-ed it and noticed that there is an issue with the path-name length.
--- an excerpt from: truss $(which scim-bridge) ---
socket(PF_LOCAL,SOCK_STREAM,0) = 3 (0x3)
connect(3,{ AF_UNIX "/tmp/scim-bridge-0.3.0.socket-1001@localhost:0.0" },49) ERR#2 'No such file or directory'
close(3) = 0 (0x0)
unlink("/tmp/scim-bridge-0.3.0.socket-1001@localhost:0.0") ERR#2 'No such file or directory'
socket(PF_LOCAL,SOCK_STREAM,0) = 3 (0x3)
fcntl(3,F_GETFL,) = 2 (0x2)
fcntl(3,F_SETFL,O_NONBLOCK|0x2) = 0 (0x0)
bind(3,{ AF_UNIX "/tmp/scim-bridge-0.3.0.socket-1001@localhost:0.0" },49) = 0 (0x0)
listen(0x3,0x40,0x31,0x8080808080808080,0x101010101010101,0x8080808080808080) = 0 (0x0)
--- an excerpt from: truss $(which scim-bridge) ---
The attached diff file fixes the issue for me.
Patch fixes the issue.
do you have UNIX_PATH_MAX constant available in freebsd?
according to "man unix" in my linux (gentoo), sun_path is of size UNIX_PATH_MAX
Before hardcoding that magic number, I tried to look for a CONSTANT NAME, but unfortunately found none.
I'm running Arch GNU/Linux, and I can confirm that I see 'UNIX_PATH_MAX' mentioned in unix(7). But I can't seem to find its in the "sys/socket.h" or "sys/un.h" mention.
----8<-----8<-----
chateau.d.if!abbe:~ % printf "#include <sys/socket.h>\n#include <sys/un.h>" |gcc -E - |fgrep -i UNIX_PATH |wc -l
0
chateau.d.if!abbe:~ % grep -R UNIX_PATH_MAX /usr/include/
/usr/include/linux/un.h:#define UNIX_PATH_MAX 108
/usr/include/linux/un.h: char sun_path[UNIX_PATH_MAX]; /* pathname */
/usr/include/valgrind/vki/vki-linux.h:#define VKI_UNIX_PATH_MAX 108
/usr/include/valgrind/vki/vki-linux.h: char sun_path[VKI_UNIX_PATH_MAX]; /* pathname */
---->8----->8-----
Following is the corresponding declaration in "sys/un.h":
----8<-----8<-----
/* Structure describing the address of an AF_LOCAL (aka AF_UNIX) socket. */
struct sockaddr_un
{
__SOCKADDR_COMMON (sun_);
char sun_path[108]; /* Path name. */
};
---->8----->8-----
FreeBSD manpage[1] about unix(7) is clear in this case.
References:
[1] - http://www.freebsd.org/cgi/man.cgi?query=unix&apropos=0&sektion=4&manpath=FreeBSD+8.1-RELEASE&format=html
HTH
looks like it's better to call sizeof on sun_path then as the UNIX_PATH_MAX
reading the man page of freebsd you referenced, it seems strncpy should only copy UNIX_PATH_MAX-1 characters (sun_path string should have a null character in it)
Merged in r353, thanks!