Re: [Openvpn-devel] Opened file descriptors in script calls

2003-02-12 Thread Aaron Sethman
On Mon, 10 Feb 2003, Christoph Pfisterer wrote: > >fcntl(fd, F_SETFD, FD_CLOEXEC); > > Ideally, one would do this for each file descriptor as it is opened. > Yeah I hadn't thought about that, James already added this to the CVS tree. Aaron

Re: [Openvpn-devel] Opened file descriptors in script calls

2003-02-11 Thread Aaron Sethman
On Tue, 11 Feb 2003, James Yonan wrote: > /* Set a file descriptor to not be passed across execs */ > void > set_cloexec (int fd) > { > if (fcntl (fd, F_SETFD, FD_CLOEXEC) < 0) > msg (M_ERR, "Set file descriptor to FD_CLOEXEC failed"); > } > > Just set the FD_CLOEXEC flag on the fd and it won

Re: [Openvpn-devel] Opened file descriptors in script calls

2003-02-11 Thread James Yonan
Aaron Sethman said: > On Mon, 10 Feb 2003, Alberto Gonzalez Iniesta wrote: > > > > > Hi, > > > > Again, I'm no C hacker, but I think this should be better: > > > > for(x = 3; x < 100; x++) > > > > Since the first 3 fds (stdin, stdout and stderr) should be kept open. > > > Wasn't sure if stdin, s

Re: [Openvpn-devel] Opened file descriptors in script calls

2003-02-10 Thread Aaron Sethman
On Mon, 10 Feb 2003, Alberto Gonzalez Iniesta wrote: > > Hi, > > Again, I'm no C hacker, but I think this should be better: > > for(x = 3; x < 100; x++) > > Since the first 3 fds (stdin, stdout and stderr) should be kept open. > Wasn't sure if stdin, stdout and stderr needed to be left open or not

Re: [Openvpn-devel] Opened file descriptors in script calls

2003-02-10 Thread Wolfgang Ocker
On Mon, 2003-02-10 at 02:01, Aaron Sethman wrote: > Here is a simple little replacement for system() that does close file > descriptors. The main issue with it is though, it ends up picking an > arbitrary number of fds to close. I picked closing 0 to 99. You can use getdtablesize() to determine

Re: [Openvpn-devel] Opened file descriptors in script calls

2003-02-10 Thread Alberto Gonzalez Iniesta
On Sun, Feb 09, 2003 at 08:01:12PM -0500, Aaron Sethman wrote: > > Here is a simple little replacement for system() that does close file > descriptors. The main issue with it is though, it ends up picking an > arbitrary number of fds to close. I picked closing 0 to 99. > > Aaron > > > int s_s

Re: [Openvpn-devel] Opened file descriptors in script calls

2003-02-10 Thread Christoph Pfisterer
Aaron Sethman wrote: Here is a simple little replacement for system() that does close file descriptors. The main issue with it is though, it ends up picking an arbitrary number of fds to close. I picked closing 0 to 99. I don't think this is necessary. Every file descriptor has a "close on

Re: [Openvpn-devel] Opened file descriptors in script calls

2003-02-09 Thread Aaron Sethman
Here is a simple little replacement for system() that does close file descriptors. The main issue with it is though, it ends up picking an arbitrary number of fds to close. I picked closing 0 to 99. Aaron int s_system(const char *string) { pid_t pid; int x; pid = fork()

Re: [Openvpn-devel] Opened file descriptors in script calls

2003-02-07 Thread James Yonan
Alberto, Yes, I agree. The child process that executes a script doesn't need those file descriptors, so they can be closed. Since openvpn uses the system() function to run scripts, and because the system() function doesn't close any file descriptors on its own, it would be necessary to write an

[Openvpn-devel] Opened file descriptors in script calls

2003-02-06 Thread Alberto Gonzalez Iniesta
Hi, I got another bug report on Debian's openvpn package. It states that openvpn's file descriptors are kept open while scripts are called. It claims they should be closed. My C knowledge is far from make a patch for this one :) And maybe you don't agree with this (James?). You can see the report