2008-09-09 03:53:37 +00:00
|
|
|
diff -up vsftpd-2.0.6/standalone.c.fds vsftpd-2.0.6/standalone.c
|
|
|
|
--- vsftpd-2.0.6/standalone.c.fds 2008-09-08 23:29:23.000000000 -0400
|
|
|
|
+++ vsftpd-2.0.6/standalone.c 2008-09-08 23:30:16.000000000 -0400
|
|
|
|
@@ -57,6 +57,7 @@ vsf_standalone_main(void)
|
|
|
|
vsf_sysutil_close_failok(1);
|
|
|
|
vsf_sysutil_close_failok(2);
|
2005-08-04 09:09:49 +00:00
|
|
|
vsf_sysutil_make_session_leader();
|
|
|
|
+ vsf_sysutil_reopen_standard_fds();
|
|
|
|
}
|
|
|
|
if (tunable_listen)
|
|
|
|
{
|
2008-09-09 03:53:37 +00:00
|
|
|
diff -up vsftpd-2.0.6/sysutil.c.fds vsftpd-2.0.6/sysutil.c
|
|
|
|
--- vsftpd-2.0.6/sysutil.c.fds 2008-09-08 23:29:23.000000000 -0400
|
|
|
|
+++ vsftpd-2.0.6/sysutil.c 2008-09-08 23:32:26.000000000 -0400
|
|
|
|
@@ -2457,6 +2457,44 @@ vsf_sysutil_make_session_leader(void)
|
2005-08-04 09:09:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
+vsf_sysutil_reopen_standard_fds(void)
|
|
|
|
+{
|
|
|
|
+ /* This reopens STDIN, STDOUT and STDERR to /dev/null */
|
2008-09-09 03:53:37 +00:00
|
|
|
+
|
2005-08-04 09:09:49 +00:00
|
|
|
+ int fd;
|
2008-09-09 03:53:37 +00:00
|
|
|
+
|
2005-08-04 09:09:49 +00:00
|
|
|
+ if ( (fd = open("/dev/null", O_RDWR, 0)) == -1 )
|
|
|
|
+ {
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( dup2(fd, STDIN_FILENO) == -1 )
|
|
|
|
+ {
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( dup2(fd, STDOUT_FILENO) == -1 )
|
|
|
|
+ {
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( dup2(fd, STDERR_FILENO) == -1 )
|
|
|
|
+ {
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
2008-09-09 03:53:37 +00:00
|
|
|
+
|
2005-08-04 09:09:49 +00:00
|
|
|
+ if ( fd > 2 )
|
|
|
|
+ {
|
|
|
|
+ (void) close(fd);
|
|
|
|
+ }
|
2008-09-09 03:53:37 +00:00
|
|
|
+
|
2005-08-04 09:09:49 +00:00
|
|
|
+ return;
|
2008-09-09 03:53:37 +00:00
|
|
|
+
|
2005-08-04 09:09:49 +00:00
|
|
|
+error:
|
|
|
|
+ die("reopening standard file descriptors to /dev/null failed");
|
|
|
|
+}
|
2008-09-09 03:53:37 +00:00
|
|
|
+
|
2005-08-04 09:09:49 +00:00
|
|
|
+void
|
|
|
|
vsf_sysutil_tzset(void)
|
|
|
|
{
|
2008-09-09 03:53:37 +00:00
|
|
|
int retval;
|
|
|
|
diff -up vsftpd-2.0.6/sysutil.h.fds vsftpd-2.0.6/sysutil.h
|
|
|
|
--- vsftpd-2.0.6/sysutil.h.fds 2008-02-01 20:30:39.000000000 -0500
|
|
|
|
+++ vsftpd-2.0.6/sysutil.h 2008-09-08 23:29:24.000000000 -0400
|
|
|
|
@@ -293,6 +293,7 @@ unsigned char vsf_sysutil_get_random_byt
|
2005-08-04 09:09:49 +00:00
|
|
|
unsigned int vsf_sysutil_get_umask(void);
|
|
|
|
void vsf_sysutil_set_umask(unsigned int umask);
|
|
|
|
void vsf_sysutil_make_session_leader(void);
|
|
|
|
+void vsf_sysutil_reopen_standard_fds(void);
|
|
|
|
void vsf_sysutil_tzset(void);
|
|
|
|
const char* vsf_sysutil_get_current_date(void);
|
|
|
|
void vsf_sysutil_qsort(void* p_base, unsigned int num_elem,
|