Manipulating Environment Variables of an Already running process
Manipulating Environment Variables of an Already running process
am 12.10.2010 22:05:42 von Hatem Nassrat
Is it possible to, manipulate an environment variables of an already
running process (using a current linux distro, and not a self hacked
kernel)?
A usecase, changing the PS1 environement var of an already running
bash process from another bash process.
Any ideas?
--
Hatem Nassrat
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Manipulating Environment Variables of an Already running process
am 13.10.2010 23:01:21 von Michal Nazarewicz
2010/10/12 Hatem Nassrat :
> Is it possible to, manipulate an environment variables of an already
> running process (using a current linux distro, and not a self hacked
> kernel)?
>
> A usecase, changing the PS1 environement var of an already running
> bash process from another bash process.
No. And even if it were possible you have no guarantees that the other
process will reread the environment variables.
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Manipulating Environment Variables of an Already running process
am 13.10.2010 23:23:30 von Hatem Nassrat
2010/10/13 MichaÅ Nazarewicz
> 2010/10/12 Hatem Nassrat :
> > A usecase, changing the PS1 environement var of an already running
> > bash process from another bash process.
>
> No. And even if it were possible you have no guarantees that the othe=
r
> process will reread the environment variables.
Well the use case I gave is one where the env var gets reread for each
new prompt.
Direct memory manipulation seems to be the only way I can think of,
but I do not think this is possible in userland. I was thinking maybe
there is a hidden sys call that might make this possible, like a very
hacky and unstable IPC :), yeah there is no sane reason for such a
feature but it would be cool to know if its at all possible.
--
Hatem Nassrat
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie"=
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Manipulating Environment Variables of an Already running process
am 13.10.2010 23:29:05 von Michal Nazarewicz
W dniu 13 października 2010 23:23 użytkownik Hatem Nassrat
napisaÅ:
> 2010/10/13 MichaÅ Nazarewicz
>> 2010/10/12 Hatem Nassrat :
>> > A usecase, changing the PS1 environement var of an already running
>> > bash process from another bash process.
>>
>> No. And even if it were possible you have no guarantees that the oth=
er
>> process will reread the environment variables.
>
> Well the use case I gave is one where the env var gets reread for eac=
h
> new prompt.
I wouldn't bet on it without looking at bash's code. Bash could just
copy PS1 to some
internal structures and read it rather than environment variable.
> Direct memory manipulation seems to be the only way I can think of,
> but I do not think this is possible in userland. I was thinking maybe
> there is a hidden sys call that might make this possible, like a very
> hacky and unstable IPC :), yeah there is no sane reason for such a
> feature but it would be cool to know if its at all possible.
No such thing. Process's memory is its own (unless process wants to sha=
re it).
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie"=
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Manipulating Environment Variables of an Already running process
am 14.10.2010 00:40:45 von Joel Fernandes
You could probably do it with ptrace(2) with request =3D PTRACE_POKEDAT=
A
thanks,
Joel
On Tue, Oct 12, 2010 at 3:05 PM, Hatem Nassrat wro=
te:
> Is it possible to, manipulate an environment variables of an already
> running process (using a current linux distro, and not a self hacked
> kernel)?
>
> A usecase, changing the PS1 environement var of an already running
> bash process from another bash process.
>
> Any ideas?
>
> --
> Hatem Nassrat
> --
> To unsubscribe from this list: send the line "unsubscribe linux-newbi=
e" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at =A0http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.linux-learn.org/faqs
>
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie"=
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Manipulating Environment Variables of an Already running process
am 14.10.2010 03:21:56 von Hatem Nassrat
On Wed, Oct 13, 2010 at 7:40 PM, Joel Fernandes wrote:
> You could probably do it with ptrace(2) with request = PTRACE_POKEDATA
I think thats it! I have been playing around with gdb thanks to this
hint. I have attached to a running bash terminal and trying to mess
with it, not getting very far but I think this is how it can be done
:)
--
Hatem Nassrat
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs