Commit Graph

10 Commits

Author SHA1 Message Date
Michael Santos
86bf475fbf Add convenience macros for stdio 2014-03-27 16:21:50 -04:00
Michael Santos
86ceca06b1 headers: mirror numbering of Unix stdio
Change the order of the message header types so that STDIN is 0, STDOUT
is 1 and STDERR is 3.
2014-03-27 14:50:51 -04:00
Michael Santos
d60a653689 Protocol changes for exec()
Since stdout is used for control and for data, add a new message type
(proxy) to distinguish them.

When a child calls exec():

* if the call is unsuccessful, the child writes a term to stdout which
  the parent proxies

* if the call is successful, no value is returned but the child will close
  the control socket on exec. The parent will "spoof" an "ok" response.

Allocate the message headers on the heap to make it easier to layer them.

If the child process has not exec'ed, use the packet length to avoid
having multiple writes coalesce into a single read.

Before checking if an fd is ready, ensure the fd is a positive value. On
freebsd, invalid fd's cause FD_ISSET() to segfault.
2014-03-23 08:20:26 -04:00
Michael Santos
0167a3a9df Correct headers for stderr 2014-03-21 10:40:44 -04:00
Michael Santos
82c527aa91 Use macros to generate header pattern matches 2014-03-18 17:28:33 -04:00
Michael Santos
fc7a27edda Rename ALCOVE_MSG_CAST -> ALCOVE_MSG_EVENT
Remove the unused function alcove_drv:event/1,2.
2014-03-15 11:23:18 -04:00
Michael Santos
fed8f44a68 Use standard names for standard I/O messages 2014-03-08 14:55:25 -05:00
Michael Santos
4036daca80 Support multiple processes
Modify the message format to include the PID. Tests pass but requires
much more work. The message format is now:

* erlang -> port: make a call

    2:ALCOVE_MSG_CALL
    2:call
    *:arg

* port -> erlang: call results

    2:ALCOVE_MSG_CALL
    *:arg

* erlang -> port: write to child's stdin

    2:ALCOVE_MSG_CHILDIN
    4:pid

* port -> erlang: write from child's stdout

    2:ALCOVE_MSG_CHILDOUT
    4:pid
    *:data

* port -> erlang: write from child's stderr

    2:ALCOVE_MSG_CHILDERR
    4:pid
    *:data
2014-03-07 16:36:08 -05:00
Michael Santos
8f40d16eb1 Add support for setrlimit(2)/getrlimit(2) 2014-03-02 10:31:50 -05:00
Michael Santos
a9245bae00 alcove: sandbox for erlang ports
alcove acts a proxy between the Erlang VM and a forked process. It can
enforce restrictions on the child process, such as dropping privileges,
setting resource limits and chroot'ing.

The goal is to support Linux namespaces, seccomp mode and cgroups so
the port process can run in an application container.

alcove should be portable though and a subset of the features should
work on any unix, possibly even supporting the sandboxing mechanisms on
other platforms.
2014-03-02 08:59:33 -05:00