diff mbox

Add new user mode option -ignore-environment

Message ID 1279225717-7309-1-git-send-email-weil@mail.berlios.de
State New
Headers show

Commit Message

Stefan Weil July 15, 2010, 8:28 p.m. UTC
An empty environment is sometimes useful in user mode.
The new option provides it for linux-user and bsd-user
(darwin-user still has no environment related options).

The patch also adds the documentation for other
environment related options.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 bsd-user/main.c   |    6 ++++++
 linux-user/main.c |    6 ++++++
 qemu-doc.texi     |   14 ++++++++++++++
 3 files changed, 26 insertions(+), 0 deletions(-)

Comments

Markus Armbruster July 16, 2010, 7:04 a.m. UTC | #1
Stefan Weil <weil@mail.berlios.de> writes:

> An empty environment is sometimes useful in user mode.
> The new option provides it for linux-user and bsd-user
> (darwin-user still has no environment related options).

Stupid question: why is /usr/bin/env insufficient?

[...]
Stefan Weil July 16, 2010, 1:09 p.m. UTC | #2
Am 16.07.2010 09:04, schrieb Markus Armbruster:
> Stefan Weil<weil@mail.berlios.de>  writes:
>
>    
>> An empty environment is sometimes useful in user mode.
>> The new option provides it for linux-user and bsd-user
>> (darwin-user still has no environment related options).
>>      
> Stupid question: why is /usr/bin/env insufficient?
>
> [...]
>
>    

In most cases it is sufficient (but not always available - Windows...).
The options -U and -E are also redundant and can be replaced by
/usr/bin/env.

But -U and -E exist, so completing the set of environment related
options seems to be logical. The name of the new option was
inspired by /usr/bin/env!

And finally, there is a use case where /usr/bin/env is a bad choice:
just look for "getenv" and you will find one in linux-user/main.c.
Removing the environment via /usr/bin/env will also remove
environment variables which are read by qemu's runtime code.
Stefan Weil Aug. 1, 2010, 11:48 a.m. UTC | #3
Am 16.07.2010 15:09, schrieb Stefan Weil:
> Am 16.07.2010 09:04, schrieb Markus Armbruster:
>> Stefan Weil<weil@mail.berlios.de>  writes:
>>
>>> An empty environment is sometimes useful in user mode.
>>> The new option provides it for linux-user and bsd-user
>>> (darwin-user still has no environment related options).
>> Stupid question: why is /usr/bin/env insufficient?
>>
>> [...]
>>
>
> In most cases it is sufficient (but not always available - Windows...).
> The options -U and -E are also redundant and can be replaced by
> /usr/bin/env.
>
> But -U and -E exist, so completing the set of environment related
> options seems to be logical. The name of the new option was
> inspired by /usr/bin/env!
>
> And finally, there is a use case where /usr/bin/env is a bad choice:
> just look for "getenv" and you will find one in linux-user/main.c.
> Removing the environment via /usr/bin/env will also remove
> environment variables which are read by qemu's runtime code.


Is there any more feedback on this patch?
Or can it be commited to git master?
Stefan Weil Aug. 11, 2010, 8:45 a.m. UTC | #4
Am 01.08.2010 13:48, schrieb Stefan Weil:
> Am 16.07.2010 15:09, schrieb Stefan Weil:
>> Am 16.07.2010 09:04, schrieb Markus Armbruster:
>>> Stefan Weil<weil@mail.berlios.de>  writes:
>>>
>>>> An empty environment is sometimes useful in user mode.
>>>> The new option provides it for linux-user and bsd-user
>>>> (darwin-user still has no environment related options).
>>> Stupid question: why is /usr/bin/env insufficient?
>>>
>>> [...]
>>>
>>
>> In most cases it is sufficient (but not always available - Windows...).
>> The options -U and -E are also redundant and can be replaced by
>> /usr/bin/env.
>>
>> But -U and -E exist, so completing the set of environment related
>> options seems to be logical. The name of the new option was
>> inspired by /usr/bin/env!
>>
>> And finally, there is a use case where /usr/bin/env is a bad choice:
>> just look for "getenv" and you will find one in linux-user/main.c.
>> Removing the environment via /usr/bin/env will also remove
>> environment variables which are read by qemu's runtime code.
>
>
> Is there any more feedback on this patch?
> Or can it be commited to git master?


Ping? The patch is still missing.

Regards,
Stefan
Stefan Weil Sept. 9, 2010, 5:30 p.m. UTC | #5
Am 16.07.2010 09:04, schrieb Markus Armbruster:
> Stefan Weil<weil@mail.berlios.de>  writes:
>
>    
>> An empty environment is sometimes useful in user mode.
>> The new option provides it for linux-user and bsd-user
>> (darwin-user still has no environment related options).
>>      
> Stupid question: why is /usr/bin/env insufficient?
>
> [...]
>    

Hi Markus,

was your question answered (and can Antony commit this change to QEMU 
master)?

Regards
Stefan
Anthony Liguori Sept. 9, 2010, 5:34 p.m. UTC | #6
On 09/09/2010 12:30 PM, Stefan Weil wrote:
> Am 16.07.2010 09:04, schrieb Markus Armbruster:
>> Stefan Weil<weil@mail.berlios.de>  writes:
>>
>>> An empty environment is sometimes useful in user mode.
>>> The new option provides it for linux-user and bsd-user
>>> (darwin-user still has no environment related options).
>> Stupid question: why is /usr/bin/env insufficient?
>>
>> [...]
>
> Hi Markus,
>
> was your question answered (and can Antony commit this change to QEMU 
> master)?

Riku is the linux-user maintainer so it really ought to go through his tree.

Regards,

Anthony Liguori

> Regards
> Stefan
>
>
Markus Armbruster Sept. 10, 2010, 8:26 a.m. UTC | #7
Stefan Weil <weil@mail.berlios.de> writes:

> Am 16.07.2010 09:04, schrieb Markus Armbruster:
>> Stefan Weil<weil@mail.berlios.de>  writes:
>>
>>    
>>> An empty environment is sometimes useful in user mode.
>>> The new option provides it for linux-user and bsd-user
>>> (darwin-user still has no environment related options).
>>>      
>> Stupid question: why is /usr/bin/env insufficient?
>>
>> [...]
>>    
>
> Hi Markus,
>
> was your question answered (and can Antony commit this change to QEMU
> master)?

I don't mind.
diff mbox

Patch

diff --git a/bsd-user/main.c b/bsd-user/main.c
index aff9f13..6b12f8b 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -795,6 +795,12 @@  int main(int argc, char **argv)
             r = argv[optind++];
             if (envlist_setenv(envlist, r) != 0)
                 usage();
+        } else if (!strcmp(r, "ignore-environment")) {
+            envlist_free(envlist);
+            if ((envlist = envlist_create()) == NULL) {
+                (void) fprintf(stderr, "Unable to allocate envlist\n");
+                exit(1);
+            }
         } else if (!strcmp(r, "U")) {
             r = argv[optind++];
             if (envlist_unsetenv(envlist, r) != 0)
diff --git a/linux-user/main.c b/linux-user/main.c
index 403c8d3..bf60922 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2759,6 +2759,12 @@  int main(int argc, char **argv, char **envp)
             r = argv[optind++];
             if (envlist_setenv(envlist, r) != 0)
                 usage();
+        } else if (!strcmp(r, "ignore-environment")) {
+            envlist_free(envlist);
+            if ((envlist = envlist_create()) == NULL) {
+                (void) fprintf(stderr, "Unable to allocate envlist\n");
+                exit(1);
+            }
         } else if (!strcmp(r, "U")) {
             r = argv[optind++];
             if (envlist_unsetenv(envlist, r) != 0)
diff --git a/qemu-doc.texi b/qemu-doc.texi
index e67bf44..ec7820e 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -2136,6 +2136,13 @@  Set the x86 elf interpreter prefix (default=/usr/local/qemu-i386)
 Set the x86 stack size in bytes (default=524288)
 @item -cpu model
 Select CPU model (-cpu ? for list and additional feature selection)
+@item -ignore-environment
+Start with an empty environment. Without this option,
+the inital environment is a copy of the caller's environment.
+@item -E @var{var}=@var{value}
+Set environment @var{var} to @var{value}.
+@item -U @var{var}
+Remove @var{var} from the environment.
 @item -B offset
 Offset guest address by the specified number of bytes.  This is useful when
 the address region required by guest applications is reserved on the host.
@@ -2359,6 +2366,13 @@  Print the help
 Set the library root path (default=/)
 @item -s size
 Set the stack size in bytes (default=524288)
+@item -ignore-environment
+Start with an empty environment. Without this option,
+the inital environment is a copy of the caller's environment.
+@item -E @var{var}=@var{value}
+Set environment @var{var} to @var{value}.
+@item -U @var{var}
+Remove @var{var} from the environment.
 @item -bsd type
 Set the type of the emulated BSD Operating system. Valid values are
 FreeBSD, NetBSD and OpenBSD (default).