71 lines
1.8 KiB
Diff
71 lines
1.8 KiB
Diff
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);
|
|
vsf_sysutil_make_session_leader();
|
|
+ vsf_sysutil_reopen_standard_fds();
|
|
}
|
|
if (tunable_listen)
|
|
{
|
|
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)
|
|
}
|
|
|
|
void
|
|
+vsf_sysutil_reopen_standard_fds(void)
|
|
+{
|
|
+ /* This reopens STDIN, STDOUT and STDERR to /dev/null */
|
|
+
|
|
+ int fd;
|
|
+
|
|
+ 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;
|
|
+ }
|
|
+
|
|
+ if ( fd > 2 )
|
|
+ {
|
|
+ (void) close(fd);
|
|
+ }
|
|
+
|
|
+ return;
|
|
+
|
|
+error:
|
|
+ die("reopening standard file descriptors to /dev/null failed");
|
|
+}
|
|
+
|
|
+void
|
|
vsf_sysutil_tzset(void)
|
|
{
|
|
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
|
|
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,
|