Re: Can't undate running process binary in Solaris?



Frank Cusack wrote On 07/05/07 16:41,:
On Thu, 05 Jul 2007 13:34:23 -0700 Frank Cusack <fcusack@xxxxxxxxxxx> wrote:

On Thu, 05 Jul 2007 03:40:12 -0700 Boltar <boltar2003@xxxxxxxxxxx> wrote:

I'm trying to get a running process to update its own binary but for
some reason under Solaris it doesn't work , the binary remains
unchanged even though no errors are returned from any function. Does
anyone know why this might happen? My test code is below:

...

mptr = (char *)mmap(
NULL,fs.st_size,PROT_READ | PROT_WRITE,MAP_PRIVATE,fd,

^^^^^^^^^^^


Actually, even when you fix that i don't think you'll be able to
update in-place. You will probably get ETXTBUSY or whatever the
error is, if not at mmap() time, than maybe you'll get SEGV or
a bus error when you actually write to memory.

If a program's text is busy (I mean, if a program is running),
Solaris will not let you, e.g., do something like "echo > program".

Or do I have it backwards and it's Linux that doesn't allow this?

Solaris allows the update (I tried it).

I'm not sure what Boltar's goal in self-modifying the
executable is, though. He mentioned this thread in another
having to do with license-enforcement schemes, but I don't
see any way to use self-modification for enforcement (it's
too easy to protect the file against being written, or to
restore an unmodified backup copy). Boltar, what are you
trying to accomplish? Maybe there's an easier way ...

--
Eric.Sosman@xxxxxxx
.



Relevant Pages

  • Re: Cant undate running process binary in Solaris?
    ... some reason under Solaris it doesn't work, ... a bus error when you actually write to memory. ... If a program's text is busy, ... Solaris will not let you, e.g., do something like "echo> program". ...
    (comp.unix.programmer)
  • Re: Cant undate running process binary in Solaris?
    ... Solaris will not let you, e.g., do something like "echo> program". ... I'm not sure what Boltar's goal in self-modifying the ... Well I could just use a hidden file or shared memory but they're much ...
    (comp.unix.programmer)
  • Re: which file system to use
    ... Sun servers are incredibly ... I'd be right with you up to the last solaris 10 release. ... Packaging is my only reason to choose a linux over solaris these days. ... matter is that bugs exist in software. ...
    (Ubuntu)
  • Re: route command baffles me.
    ... | on solaris, ... i set my default route ... for some reason things never go so smoothly ... If there is no cable connected to the interface, ...
    (comp.os.linux.networking)
  • Re: "Torn between two OS" - Solaris vs Linux
    ... >> That sounds like a good reason to migrate to Linux rather than Solaris. ... partitions -- it's a standard partitioning structure which is commonly ...
    (comp.unix.solaris)