aboutsummaryrefslogtreecommitdiffstats
path: root/vconsole.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2017-03-14 16:38:12 +0100
committerGerd Hoffmann <kraxel@redhat.com>2017-03-14 16:38:12 +0100
commitba8b9705d15936664a57cfef4772931a0f70ba93 (patch)
treee7d75ae4e82b532ba0d594d6e598dd7eaae2700a /vconsole.c
parent52ef709b258be2927c74e916ed936bc3749078a7 (diff)
downloadvconsole-ba8b9705d15936664a57cfef4772931a0f70ba93.tar.gz
close file handles before exec
Diffstat (limited to 'vconsole.c')
-rw-r--r--vconsole.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/vconsole.c b/vconsole.c
index db172d9..b150c96 100644
--- a/vconsole.c
+++ b/vconsole.c
@@ -300,6 +300,14 @@ static struct vconsole_domain *find_guest(struct vconsole_window *win)
return dom;
}
+static void prepare_exec(void)
+{
+ int i;
+
+ for (i = 3; i < 1024; i++)
+ close(i);
+}
+
static void run_virt_viewer(struct vconsole_domain *dom,
bool reconnect)
{
@@ -326,6 +334,7 @@ static void run_virt_viewer(struct vconsole_domain *dom,
return;
} else {
/* child */
+ prepare_exec();
execvp("virt-viewer", argv);
perror("execvp");
exit(1);
@@ -356,6 +365,7 @@ static void run_virsh_edit(struct vconsole_domain *dom)
return;
} else {
/* child */
+ prepare_exec();
execvp("xterm", argv);
perror("execvp");
exit(1);
@@ -485,6 +495,7 @@ static void menu_cb_manual(GtkAction *action, gpointer userdata)
return;
} else {
/* child */
+ prepare_exec();
execlp("xdg-open", "xdg-open", "man:vconsole(1)", NULL);
perror("execlp");
exit(1);