Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Commits on Mar 20, 2015
  1. fdopen: only one connection to fd passing socket

    Set the backlog of the socket used for passing the fd from the
    privileged process to 0.
Commits on Mar 16, 2015
  1. solaris: fix opening of local socket

    Opening a socket using the open/2 interface would fail on Solaris because
    the socket type value for the socket used for fd passing was hardcoded.
Commits on Feb 19, 2015
  1. Remove integer lookups for family/type/proto

    Integer to atom conversion for socket(2) arguments are not used (and are
    not exported, except for family which was exported recently in commit
    A more reliable way of looking up system dependent constants is planned.
Commits on Feb 18, 2015
  1. Fix compilation on Solaris

    So errno is not thread local on Solaris and is set to 0 by default on
    error. Really Solaris?
    On Solaris, compile using POSIX mode which requires c99 mode which fixes
    errno, uses void* instead of c_addr_t* for iovec and various other errors.
    Add solaris constants for dgram, stream and raw which differ from other
    unix platforms. Make the send/recvmsg example work on Solaris.
    Platform dependent constants need to be fixed in the future. This could
    be done either by adding a lookup table to the NIF or writing a small
    program in C to generate an erlang module at compile time.
    Bump version to 0.6.1.
Commits on Feb 14, 2015
  1. Remove procket_msg module

  2. Add sendmsg/4,5 and recvmsg/4,5

    Some small fixes and interface changes to sendmsg/5 and recvmsg/4 based
    on the pull request by Andrew Thompson:
    * recvmsg: the msg_namelen field is value-result. Resize the source
      address binary to this length. Fixes einval on FreeBSD when passing
      in an overlong socket address as noted in the sendmsg/recvmsg echo
    * recvmsg: account for padding in cmsghdr structure when calculating the
      cmsg data length.
    * recvmsg: reverse the list of cmsg tuples so the order is the same as
      returned using the CMSG_NXTHDR() macro
    * recvmsg: if bufsize or ctrlsize are 0, set the iov_base or msg_name
      to NULL instead of a 0 byte binary
    * sendmsg: if buf or sa are empty binaries, set iov_base or msg_name to
    * cleanup: fix pasto in arg order, memory leaks, change recvmsg to return
      msg_flags as a signed int
    The following alterations were made to the interface:
    * recvmsg/5: add an extra argument to recvmsg to specify the size
      of sockaddr
      recvmsg() with a connected socket and a non-NULL msg_name field
      in the msghdr structure will return EISCONN.
      Allow the caller to specify the length of the sockaddr structure (for
      example, 128 bytes is the size of sockaddr_storage which is large enough
      to hold any socket address).
      Add recvmsg/4, a version of recvmsg for connected sockets that defaults
      to setting msg_name to NULL.
    * recvmsg/sendmsg: make the arg order consistent
      Change the order of arguments so the input and output values are in the
      same order and position, recvmsg and sendmsg provide the same order and
      the order reflects sendto()/recvfrom().
      The order for arguments and return values is:
      * buffer
      * flags
      * control data
      * socket address
    TODO: Solaris support
    Thanks @Vagabond!
Commits on Feb 5, 2015
  1. @Vagabond

    Fix sendmsg/recvmsg on FreeBSD/NetBSD/OpenBSD

    Vagabond authored
    Some padding/length issues needed to be fixed, but now the
    sendmsg/recvmsg echo test works on all 3 BSDs and on Linux.
  2. @Vagabond

    Make sendmsg and recvmsg actually usable

    Vagabond authored
    Instead of passing in a binary that is treated as the 'msghdr' struct,
    pass in data needed to construct an appropriate msghdr struct and also
    return useful result data, including the control data.
    Documentation and an example are also included.
Commits on Nov 17, 2014
  1. Use local file operations for slave nodes

    Opening a socket on a slave node using the procket setuid helper would
    fail, due to file operations being performed on the master:
        1> slave:start('bar', 'n', "-env ERL_LIBS /path/to/erlang").
        (n@foo)3> rpc:call('n@bar', procket, open, [58, [{protocol,tcp},{family,inet},{type,stream}]]).
    The failure happens because procket creates a temporary directory to
    store the unix socket used to pass the fd from the helper into the NIF.
    Because slave nodes defer file operations to the master, the temp
    directory would be created on the master but would be attempted to be
    used on the slave.
    The work around was to manually specify the location of the unix socket
    using the 'pipe' option:
        rpc:call('n@bar', procket, open, [58, [{pipe, "/tmp/procket.s"}, {protocol,tcp},{family,inet},{type,stream}]]).
    Fix by bypassing the file server using the prim_file module directly.
    Slave nodes now should work without any other setup:
        (n@foo)3> rpc:call('n@bar', procket, open, [58,
        (n@foo)4> rpc:call('n@bar', gen_tcp, listen, [0,
    Checking the remote mode, the socket is listening:
        bar$ sudo netstat -ptnl | grep 58
        tcp        0      0    * LISTEN      23902/beam.smp
    Thanks to xingang shi for reporting and debugging this problem!
Commits on Nov 16, 2014
  1. Attempt to run the setuid helper twice

    In many situations, the procket setuid helper may be permitted to bind
    the socket without any extra work:
        * beam could be running as root
        * the helper could be setuid or setgid
        * the process may have a capability set
        * the process may be permitted to access a device file or port
    Simplify the convoluted logic for launching the procket setuid helper
    by running the helper twice: without sudo and with sudo. If the caller
    wants to suppress this behaviour, the 'exec' option can be passed in to
        procket:open(23, [{exec, ""}]).
  2. Fix the echo example

    The behaviour of gen_tcp:listen/2 seems to have changed at some point:
    if a non-zero port is passed in, the inet driver attempts to bind this
    port, even if an 'fd' parameter exists in the options.
    Setting the port to 0 seems to force inet to use the fd option.
Commits on Nov 14, 2014
  1. Merge pull request #16 from arashbm/master

    adding empty applications parameter
  2. @arashbm
  3. @arashbm


    arashbm authored
Commits on Nov 12, 2014
  1. Support compilation on Solaris

Commits on Jul 23, 2014
  1. Remove hardcoded dependency on gcc

    Allow procket to compile using clang on FreeBSD.
Commits on Jun 4, 2014
  1. readme: update instuctions for sudo

    On CentOS, sudoers sets "requiretty" by default. Even if the procket
    helper is run as root, sudo will fail and procket will return
        # id
        uid=0(root) gid=0(root) groups=0(root)
        # erl -pa ebin
        1> {error,eperm} = procket:open(34, [{protocol,tcp}, {family,inet},
    Add instructions for disabling "requiretty" by program or by user.
    Thanks to @josemic and xingang shi!
Commits on Jan 29, 2014
  1. linux: fix compiling under a 32-bit VM/64-bit arch

    Fix build failure:
    rebar designates 32-bit VM on x864_64 as
    My guess is that a half-word emulator will be reported as
    "x86_64.*-32", so try to accomodate this case as well.
    Thanks @NAR!
Commits on Jan 27, 2014
  1. Display bad arguments in error

Commits on Jan 22, 2014
  1. procket: return badarg

Commits on Jan 21, 2014
  1. procket: throw -> error

Commits on Jan 17, 2014
Commits on Dec 22, 2013
  1. Add targets for dialyzer

Commits on Dec 19, 2013
  1. Allow atoms in io* funs

    Take integers or atoms in ioc, iow, iorw, to allow lookup of values
    based on platform.
    From dialyzer:
    bpf.erl:120: The call bpf:ior(66,'gseesent',4) will never return since it differs in the 2nd argument from the success typing arguments: (integer(),integer(),integer())
    bpf.erl:181: The call bpf:iow(66,'sseesent',4) will never return since it differs in the 2nd argument from the success typing arguments: (integer(),integer(),integer())
Commits on Dec 18, 2013
  1. Remove unnecessary case clause

    From dialyzer:
    procket.erl:204: The variable Error can never match since previous
    clauses completely covered the type {'ok',_}
    The code should be changed to return an error, rather than crashing but
    the code will currently crash in fdopen.
Commits on Dec 11, 2013
Commits on Dec 1, 2013
Commits on Nov 30, 2013
Commits on Nov 29, 2013
  1. Add a stub for unload

Commits on Nov 28, 2013
Commits on Nov 26, 2013
Commits on Nov 5, 2013
  1. @cybergrind
Something went wrong with that request. Please try again.