mirror of
git://slackware.nl/current.git
synced 2024-12-29 10:25:00 +01:00
d31c50870d
Thu Jun 30 20:26:57 UTC 2016 Slackware 14.2 x86_64 stable is released! The long development cycle (the Linux community has lately been living in "interesting times", as they say) is finally behind us, and we're proud to announce the release of Slackware 14.2. The new release brings many updates and modern tools, has switched from udev to eudev (no systemd), and adds well over a hundred new packages to the system. Thanks to the team, the upstream developers, the dedicated Slackware community, and everyone else who pitched in to help make this release a reality. The ISOs are off to be replicated, a 6 CD-ROM 32-bit set and a dual-sided 32-bit/64-bit x86/x86_64 DVD. Please consider supporting the Slackware project by picking up a copy from store.slackware.com. We're taking pre-orders now, and offer a discount if you sign up for a subscription. Have fun! :-)
101 lines
3.1 KiB
Diff
101 lines
3.1 KiB
Diff
From 6dee7eadd1b7352ec503ea04fa1639d4a93f370b Mon Sep 17 00:00:00 2001
|
|
From: Nils Philippsen <nils@redhat.com>
|
|
Date: Thu, 16 Aug 2012 11:18:31 +0200
|
|
Subject: [PATCH] patch: close-fds
|
|
|
|
Squashed commit of the following:
|
|
|
|
commit 4fdedd3a8b66fb42b2d4dde62df28c78571c1c5d
|
|
Author: Nils Philippsen <nils@redhat.com>
|
|
Date: Fri Nov 19 12:15:58 2010 +0100
|
|
|
|
don't leak file descriptors to help browser process (#455450)
|
|
---
|
|
src/xsane.c | 43 +++++++++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 43 insertions(+)
|
|
|
|
diff --git a/src/xsane.c b/src/xsane.c
|
|
index 775610e..1c5d61d 100644
|
|
--- a/src/xsane.c
|
|
+++ b/src/xsane.c
|
|
@@ -48,6 +48,8 @@
|
|
|
|
#include <sys/wait.h>
|
|
|
|
+#include <stdarg.h>
|
|
+
|
|
/* ---------------------------------------------------------------------------------------------------------------------- */
|
|
|
|
struct option long_options[] =
|
|
@@ -3684,6 +3686,41 @@ static void xsane_show_gpl(GtkWidget *widget, gpointer data)
|
|
|
|
/* ---------------------------------------------------------------------------------------------------------------------- */
|
|
|
|
+static void xsane_close_fds_for_exec(signed int first_fd_to_leave_open, ...)
|
|
+{
|
|
+ int open_max;
|
|
+ signed int i;
|
|
+
|
|
+ va_list ap;
|
|
+ unsigned char *close_fds;
|
|
+
|
|
+ open_max = (int) sysconf (_SC_OPEN_MAX);
|
|
+
|
|
+ close_fds = malloc (open_max);
|
|
+
|
|
+ memset (close_fds, 1, open_max);
|
|
+
|
|
+ va_start (ap, first_fd_to_leave_open);
|
|
+
|
|
+ for (i = first_fd_to_leave_open; i >= 0; i = va_arg (ap, signed int)) {
|
|
+ if (i < open_max)
|
|
+ close_fds[i] = 0;
|
|
+ }
|
|
+
|
|
+ va_end (ap);
|
|
+
|
|
+ DBG(DBG_info, "closing unneeded file descriptors\n");
|
|
+
|
|
+ for (i = 0; i < open_max; i++) {
|
|
+ if (close_fds[i])
|
|
+ close (i);
|
|
+ }
|
|
+
|
|
+ free (close_fds);
|
|
+}
|
|
+
|
|
+/* ---------------------------------------------------------------------------------------------------------------------- */
|
|
+
|
|
static void xsane_show_doc_via_nsr(GtkWidget *widget, gpointer data) /* show via netscape remote */
|
|
{
|
|
char *name = (char *) data;
|
|
@@ -3736,6 +3773,8 @@ static void xsane_show_doc_via_nsr(GtkWidget *widget, gpointer data) /* show via
|
|
ipc_file = fdopen(xsane.ipc_pipefd[1], "w");
|
|
}
|
|
|
|
+ xsane_close_fds_for_exec (1, 2, xsane.ipc_pipefd[1], -1);
|
|
+
|
|
DBG(DBG_info, "trying to change user id for new subprocess:\n");
|
|
DBG(DBG_info, "old effective uid = %d\n", (int) geteuid());
|
|
setuid(getuid());
|
|
@@ -3778,6 +3817,8 @@ static void xsane_show_doc_via_nsr(GtkWidget *widget, gpointer data) /* show via
|
|
ipc_file = fdopen(xsane.ipc_pipefd[1], "w");
|
|
}
|
|
|
|
+ xsane_close_fds_for_exec (1, 2, xsane.ipc_pipefd[1], -1);
|
|
+
|
|
DBG(DBG_info, "trying to change user id for new subprocess:\n");
|
|
DBG(DBG_info, "old effective uid = %d\n", (int) geteuid());
|
|
setuid(getuid());
|
|
@@ -3899,6 +3940,8 @@ static void xsane_show_doc(GtkWidget *widget, gpointer data)
|
|
ipc_file = fdopen(xsane.ipc_pipefd[1], "w");
|
|
}
|
|
|
|
+ xsane_close_fds_for_exec (1, 2, xsane.ipc_pipefd[1], -1);
|
|
+
|
|
DBG(DBG_info, "trying to change user id for new subprocess:\n");
|
|
DBG(DBG_info, "old effective uid = %d\n", (int) geteuid());
|
|
setuid(getuid());
|
|
--
|
|
1.7.11.4
|
|
|