31 lines
1.0 KiB
Diff
31 lines
1.0 KiB
Diff
|
diff -up xsane-0.995/src/xsane.c.close-fds xsane-0.995/src/xsane.c
|
||
|
--- xsane-0.995/src/xsane.c.close-fds 2007-09-28 17:24:56.000000000 +0200
|
||
|
+++ xsane-0.995/src/xsane.c 2008-07-15 17:48:17.000000000 +0200
|
||
|
@@ -3681,6 +3681,8 @@ static void xsane_show_doc_via_nsr(GtkWi
|
||
|
char *arg[5];
|
||
|
struct stat st;
|
||
|
char netscape_lock_path[PATH_MAX];
|
||
|
+ int open_max;
|
||
|
+ int i;
|
||
|
|
||
|
DBG(DBG_proc, "xsane_show_doc_via_nsr(%s)\n", name);
|
||
|
|
||
|
@@ -3725,6 +3727,17 @@ static void xsane_show_doc_via_nsr(GtkWi
|
||
|
ipc_file = fdopen(xsane.ipc_pipefd[1], "w");
|
||
|
}
|
||
|
|
||
|
+ open_max = (int) sysconf (_SC_OPEN_MAX);
|
||
|
+
|
||
|
+ DBG(DBG_info, "closing unneeded file descriptors\n");
|
||
|
+
|
||
|
+ /* leave stdin, stdout, stderr alone */
|
||
|
+ for (i = 3; i < open_max; i++) {
|
||
|
+ /* xsane.ipc_pipefd[0] is closed by now */
|
||
|
+ if (i != xsane.ipc_pipefd[1])
|
||
|
+ close (i);
|
||
|
+ }
|
||
|
+
|
||
|
DBG(DBG_info, "trying to change user id for new subprocess:\n");
|
||
|
DBG(DBG_info, "old effective uid = %d\n", (int) geteuid());
|
||
|
setuid(getuid());
|