开发者

How to make binary which downloads its newer copy?(limitied conditions)

开发者 https://www.devze.com 2023-04-05 23:27 出处:网络
Would like to ask for advice. there is a need for binary to have a mechanism for self update. Lets imagine binary rolls on host A and updates-server is server B.

Would like to ask for advice. there is a need for binary to have a mechanism for self update. Lets imagine binary rolls on host A and updates-server is server B.

Lobster method is to fork bash script with wget/ftp/ncftp/etc getter wich will downlo开发者_JAVA技巧ad and replace. But ehm...there is no such tools on A and they will not be installed.

In short I can't use any external software tools(external to running binary).I can just hardcode mechanism in running binary.

As binary image runs it can load binary(and md5 file) simply via tcp sockets in tmp file,then do md5 compare and if everything ok then replace binary and restart itself. Its easy to do, but I have some strange feeling...dunno.

Mb someone can share and advice?:)Thank you in advance.

Conditions: binary is written in pure c. freebsd is binary rolling side and update-serve is centos. So java/python/c++/any is available at server side but not on free. Y, tobe honest its is possbile install some tools on client side and openfirewall for ftp, but want to avoid and hardcode :)

ADDED: must be noted that the enviroment between A and B is secured..eghm...as we think, in any way security and access problem and spoofing/sniffing out of our world there :) its just local update implementation mechanism for some binary which nowdays we update from center within expect scripts via ssh.


You will have to reimplement a whole host of functionality if you want to do so. My easiest suggestion would be to link to libcurl, hardcode the download path into your executable and write the image of your executable back to $ARGV[0]. However, you should definitely rethink your distribution concept, most distributions do some form of package management, and using it is the easiest alternative for all parties involved.


First of all check if you can modify a binary when a process is executing it, some system does not allow it.

You say you can not use external tool so probbly you can not create another "updater program" which will do the chenge instead of your binary. Probalby you can download such program (from where you want to downlaod your update), execute it (exec, replaces current process with the new one) that executed process will download and upded your main one, and then exec to it.

0

精彩评论

暂无评论...
验证码 换一张
取 消