tags:

views:

180

answers:

2

I need to distribute some Erlang code which is closed source to a client. I think the easiest way would be to simply give an Erlang shell command to pull the code from a remote host. The remote host will be an Erlang VM which does not shared the same secret cookie as the client. How can I do this?

For example, if I am in the Erlang shell, I would like something thats lets me do:

load_lib(mysql).
load_lib(postgres).

: and then Erlang would download and install the BEAM files, and would allow me to use the mysql: and postgres: Erlang modules from that point on

Update: 1) I have been suggested to use tarballs, so I guess the procedure in this case would be something like:

Find Erlang lib directory and CD to it
wget tarball to the current directory

Not as nice as gem install, but its the best that Erlang can do

+1  A: 

Couldn't you simply upload your code to some repository and provide access to the client? You could also provide a script to automatically load the new versions of the code without stopping the live system... Or am I missing something?

Roberto Aloi
+1  A: 

You can't really have this done between two untrusted Erlang node. That secret cookie is the only security measure existing between nodes. You will need to roll out your own protocol, even if it's just straight HTTP.

What you could do from that point on is either send a BEAM file over the network, or just send the binary data contained inside one. You can then load the module by calling code:load_file/1 for the BEAM, or code:load_binary/3for the binary data.

This all sounds relatively brittle to me though. A repository, as suggested by Roberto Aloi would likely be the best idea.

I GIVE TERRIBLE ADVICE
So it would bascially be impossible to implement something like gem:install on Erlang are you saying? Why is this more brittle than the tarball idea?
Zubair
I have no idea how gem:install works (never used it), but from the docs, a sure thing is that it doesn't connect two instances of a VM together directly with the VM's native distribution mechanism. It seems to go to a repository (probably with URLs and everything over a given protocol) to fetch files and dump them on your computer.This is mostly a reply to your VM-to-VM concept. Nothing would really stop you from just fetching files and putting them in a searchable path by any mean you want. Connecting two distant VMs that way (without a cookie) is just not the best plan to do this.
I GIVE TERRIBLE ADVICE
Also to add more, using code:load_binary/3 might allow you to fetch binary data from any resource and load it in the Erlang VM without saving any file. Once the VM is restarted/shut down, everything is gone. That can be an interesting option, but that's the one that sounded especially brittle to me.
I GIVE TERRIBLE ADVICE
This answer at least points me in the right direction!
Zubair