From 1a7313fc35d36ffa9f4d022b2e4bea316bb82d4c Mon Sep 17 00:00:00 2001 From: Jiri Skala Date: Thu, 21 May 2009 05:53:01 +0000 Subject: [PATCH] - fixed daemonize_plus patch - fixed test in initscript [ -z "CONFS" ] --- vsftpd-2.1.1-daemonize_plus.patch | 70 ++++++++++++++++++++++++------- vsftpd.init | 2 +- vsftpd.spec | 6 ++- 3 files changed, 61 insertions(+), 17 deletions(-) diff --git a/vsftpd-2.1.1-daemonize_plus.patch b/vsftpd-2.1.1-daemonize_plus.patch index 3cb05ae..99b3a57 100644 --- a/vsftpd-2.1.1-daemonize_plus.patch +++ b/vsftpd-2.1.1-daemonize_plus.patch @@ -1,6 +1,6 @@ diff -up vsftpd-2.1.1/standalone.c.daemonize_plus vsftpd-2.1.1/standalone.c ---- vsftpd-2.1.1/standalone.c.daemonize_plus 2009-05-04 16:18:30.000000000 +0200 -+++ vsftpd-2.1.1/standalone.c 2009-05-04 16:18:30.000000000 +0200 +--- vsftpd-2.1.1/standalone.c.daemonize_plus 2009-05-10 22:11:24.000000000 +0200 ++++ vsftpd-2.1.1/standalone.c 2009-05-10 22:11:24.000000000 +0200 @@ -26,6 +26,8 @@ static unsigned int s_ipaddr_size; static void handle_sigchld(void* duff); @@ -10,22 +10,32 @@ diff -up vsftpd-2.1.1/standalone.c.daemonize_plus vsftpd-2.1.1/standalone.c static void prepare_child(int sockfd); static unsigned int handle_ip_count(void* p_raw_addr); static void drop_ip_count(void* p_raw_addr); -@@ -50,7 +52,13 @@ vsf_standalone_main(void) +@@ -46,11 +48,23 @@ vsf_standalone_main(void) + } + if (tunable_background) + { ++ vsf_sysutil_sigaction(kVSFSysUtilSigALRM, handle_sigalrm); ++ vsf_sysutil_sigaction(kVSFSysUtilSigUSR1, handle_sigusr1); ++ + int forkret = vsf_sysutil_fork(); if (forkret > 0) { /* Parent, just exit */ - vsf_sysutil_exit(0); -+ vsf_sysutil_sigaction(kVSFSysUtilSigALRM, handle_sigalrm); -+ vsf_sysutil_sigaction(kVSFSysUtilSigUSR1, handle_sigusr1); -+ + vsf_sysutil_set_alarm(3); + vsf_sysutil_pause(); + + vsf_sysutil_exit(1); ++ } ++ else if (forkret == 0) ++ { ++ // Son, restore original signal handler ++ vsf_sysutil_sigaction(kVSFSysUtilSigALRM, 0L); ++ vsf_sysutil_sigaction(kVSFSysUtilSigUSR1, 0L); } /* Son, close standard FDs to avoid SSH hang-on-exit */ vsf_sysutil_reopen_standard_fds(); -@@ -98,6 +106,10 @@ vsf_standalone_main(void) +@@ -98,6 +112,10 @@ vsf_standalone_main(void) { die("could not bind listening IPv4 socket"); } @@ -36,7 +46,7 @@ diff -up vsftpd-2.1.1/standalone.c.daemonize_plus vsftpd-2.1.1/standalone.c } else { -@@ -127,6 +139,10 @@ vsf_standalone_main(void) +@@ -127,6 +145,10 @@ vsf_standalone_main(void) { die("could not bind listening IPv6 socket"); } @@ -47,7 +57,7 @@ diff -up vsftpd-2.1.1/standalone.c.daemonize_plus vsftpd-2.1.1/standalone.c } vsf_sysutil_close(0); vsf_sysutil_close(1); -@@ -252,6 +268,20 @@ handle_sighup(void* duff) +@@ -252,6 +274,20 @@ handle_sighup(void* duff) vsf_parseconf_load_file(0, 0); } @@ -69,8 +79,8 @@ diff -up vsftpd-2.1.1/standalone.c.daemonize_plus vsftpd-2.1.1/standalone.c hash_ip(unsigned int buckets, void* p_key) { diff -up vsftpd-2.1.1/sysutil.c.daemonize_plus vsftpd-2.1.1/sysutil.c ---- vsftpd-2.1.1/sysutil.c.daemonize_plus 2009-05-04 16:18:30.000000000 +0200 -+++ vsftpd-2.1.1/sysutil.c 2009-05-04 16:18:30.000000000 +0200 +--- vsftpd-2.1.1/sysutil.c.daemonize_plus 2009-05-10 22:11:24.000000000 +0200 ++++ vsftpd-2.1.1/sysutil.c 2009-05-10 22:11:59.000000000 +0200 @@ -201,6 +201,9 @@ vsf_sysutil_translate_sig(const enum EVS case kVSFSysUtilSigHUP: realsig = SIGHUP; @@ -94,16 +104,46 @@ diff -up vsftpd-2.1.1/sysutil.c.daemonize_plus vsftpd-2.1.1/sysutil.c int vsf_sysutil_fork(void) { -@@ -2786,3 +2795,23 @@ vsf_sysutil_set_no_fds() +@@ -2786,3 +2795,53 @@ vsf_sysutil_set_no_fds() die("setrlimit NOFILE"); } } + ++static struct sigaction sigalr, sigusr1; ++ +void +vsf_sysutil_sigaction(const enum EVSFSysUtilSignal sig, void (*p_handlefunc)(int)) +{ + int realsig = vsf_sysutil_translate_sig(sig); -+ vsf_sysutil_set_sighandler(realsig, p_handlefunc); ++ int retval; ++ struct sigaction sigact, *origsigact=NULL; ++ if (realsig==SIGALRM) ++ { ++ origsigact = &sigalr; ++ } ++ else if (realsig==SIGUSR1) ++ { ++ origsigact = &sigusr1; ++ } ++ vsf_sysutil_memclr(&sigact, sizeof(sigact)); ++ if (p_handlefunc != NULL) ++ { ++ sigact.sa_handler = p_handlefunc; ++ retval = sigfillset(&sigact.sa_mask); ++ if (retval != 0) ++ { ++ die("sigfillset"); ++ } ++ retval = sigaction(realsig, &sigact, origsigact); ++ } ++ else ++ { ++ retval = sigaction(realsig, origsigact, NULL); ++ } ++ if (retval != 0) ++ { ++ die("sigaction"); ++ } +} + +int @@ -119,8 +159,8 @@ diff -up vsftpd-2.1.1/sysutil.c.daemonize_plus vsftpd-2.1.1/sysutil.c + return pause(); +} diff -up vsftpd-2.1.1/sysutil.h.daemonize_plus vsftpd-2.1.1/sysutil.h ---- vsftpd-2.1.1/sysutil.h.daemonize_plus 2009-05-04 16:18:30.000000000 +0200 -+++ vsftpd-2.1.1/sysutil.h 2009-05-04 16:23:47.000000000 +0200 +--- vsftpd-2.1.1/sysutil.h.daemonize_plus 2009-05-10 22:11:24.000000000 +0200 ++++ vsftpd-2.1.1/sysutil.h 2009-05-10 22:11:24.000000000 +0200 @@ -29,7 +29,8 @@ enum EVSFSysUtilSignal kVSFSysUtilSigCHLD, kVSFSysUtilSigPIPE, diff --git a/vsftpd.init b/vsftpd.init index c9434b1..218b143 100755 --- a/vsftpd.init +++ b/vsftpd.init @@ -37,7 +37,7 @@ start() { if [ -d /etc/vsftpd ] ; then CONFS=`ls /etc/vsftpd/*.conf 2>/dev/null` - [ -z $CONFS ] && exit 6 + [ -z "$CONFS" ] && exit 6 for i in $CONFS; do site=`basename $i .conf` echo -n $"Starting $prog for $site: " diff --git a/vsftpd.spec b/vsftpd.spec index 19e3810..5f839f7 100644 --- a/vsftpd.spec +++ b/vsftpd.spec @@ -3,7 +3,7 @@ Name: vsftpd Version: 2.1.1 -Release: 0.2.%{pretag}%{?dist} +Release: 0.3.%{pretag}%{?dist} Summary: Very Secure Ftp Daemon Group: System Environment/Daemons @@ -139,6 +139,10 @@ fi %changelog +* Thu May 21 2009 Jiri Skala - 2.1.1-0.3 +- fixed daemonize_plus patch +- fixed test in initscript [ -z "CONFS" ] + * Mon May 04 2009 Jiri Skala - 2.1.1-0.2 - fixes daemonize patch