Friday 15 February 2013

Linux C - implementing the ability that a program can update itself -


I am writing a program in the Linux environment (Debian-Leny) and want to update the program to update I am available (program updates are notified when new updates are available). I see in a way that the program can update itself.

What I am thinking is that the main program opens a new program to handle updates. Updater program will get updated source information about changes in source code (access to source) and changes to source code, such as:

  edit1: line 20, remove column 5 to 20 Give; Edit2: Line25, Delete Column 4-7, then "if (x> 3) {" column 4 Edit 3: Line 26, enter a new line and enter "x ++";   

Then kill the main process, compile the source code again, and then replace the new binary with the old one.

Or is there a way to implement better (simpler) and standard way a program can update itself?

I use the program to control a system with Linux embedded boards, therefore, I do not want the source code accessible to any other person (if the system is hacked or something else ). If using the source code is the best way to update a program, how do you suggest saving the source code? If you suggest encrypting the source code, can I use the function (Linux C) program to encrypt and decrypt source files?

If your target system is Debian, then you should update the Debian Packaging System. Package your compiled application in the .deb package, distribute it to the APT archive, which is included in your system's sources.list , and only for a regular update check For Cron use APT with the .deb package may contain a post-installation script that restarts your application.

You can run a apt-proxy caching proxy on your "gateway" nodes on which the Internet is used, and other nodes are used by their apt as source.

In this case it is probably not appropriate to distribute the source code, because then you should include a full compiler toolchain on your target system.

No comments:

Post a Comment