[zeromq-dev] IPC REQ/REP socket unavailable to other users?
Stewart Douglas
sdouglas at snowgold.com
Wed Aug 11 21:12:42 CEST 2010
Have just done a quick test and had no issues connecting to an anonymous
UDS created by an another user.
The code I'm talking about sets up the socket for a connect or bind as
shown below having first called socket in the normal way.
struct sockaddr_un address;
bzero(&address, sizeof(address));
address.sun_family = AF_UNIX;
strncpy(address.sun_path, localSocketName.c_str(),
sizeof(address.sun_path));
int length = sizeof(address.sun_family) + strlen(address.sun_path);
// make sure we use an abstract name for the socket
address.sun_path[0] = 0;
if (::connect(theSocketFD, (struct sockaddr *)&address, length))
Presumably this could be changed in ipc.cpp, but not sure of the
implications for decoding the addresses passed in etc. And how
applicable this trick is across non Linux platforms. My copy of Stevens
is silent on the matter, or I am too tired to find the correct page.
Also I think length could be calculated simply from sizeof(address).
int zmq::resolve_local_path (sockaddr_storage *addr_, socklen_t
*addr_len_, const char *path_)
Hope this is some help
Stew
On 11/08/10 17:23, Pieter Hintjens wrote:
> On Wed, Aug 11, 2010 at 6:22 PM, Stewart Douglas<sdouglas at snowgold.com> wrote:
>
>
>> Nope can use them between different processes for sure, not talking about socket pair but socket then bind or connect. Pass in a sockaddr_un to connect or bind and make sure the first char of address.sun_path is 0 - best to do this after the strncpy of course ;-> Can dig out example code when I get home - but need to check that it does avoid the permissions issue. Also may be Linux specific
>>
> That'd be great...!
>
> -Pieter
>
>
>
--
Stewart Douglas
sdouglas at snowgold.com
http://www.snowgold.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20100811/e4bb4e30/attachment.htm>
More information about the zeromq-dev
mailing list