- fixed daemonize_plus patch

- fixed test in initscript [ -z "CONFS" ]
This commit is contained in:
Jiri Skala 2009-05-21 05:53:01 +00:00
parent 5e7840e43e
commit 1a7313fc35
3 changed files with 61 additions and 17 deletions

View File

@ -1,6 +1,6 @@
diff -up vsftpd-2.1.1/standalone.c.daemonize_plus vsftpd-2.1.1/standalone.c 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.daemonize_plus 2009-05-10 22:11:24.000000000 +0200
+++ vsftpd-2.1.1/standalone.c 2009-05-04 16:18:30.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; @@ -26,6 +26,8 @@ static unsigned int s_ipaddr_size;
static void handle_sigchld(void* duff); 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 void prepare_child(int sockfd);
static unsigned int handle_ip_count(void* p_raw_addr); static unsigned int handle_ip_count(void* p_raw_addr);
static void drop_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) if (forkret > 0)
{ {
/* Parent, just exit */ /* Parent, just exit */
- vsf_sysutil_exit(0); - vsf_sysutil_exit(0);
+ vsf_sysutil_sigaction(kVSFSysUtilSigALRM, handle_sigalrm);
+ vsf_sysutil_sigaction(kVSFSysUtilSigUSR1, handle_sigusr1);
+
+ vsf_sysutil_set_alarm(3); + vsf_sysutil_set_alarm(3);
+ vsf_sysutil_pause(); + vsf_sysutil_pause();
+ +
+ vsf_sysutil_exit(1); + 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 */ /* Son, close standard FDs to avoid SSH hang-on-exit */
vsf_sysutil_reopen_standard_fds(); 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"); 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 else
{ {
@@ -127,6 +139,10 @@ vsf_standalone_main(void) @@ -127,6 +145,10 @@ vsf_standalone_main(void)
{ {
die("could not bind listening IPv6 socket"); 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(0);
vsf_sysutil_close(1); 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); 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) hash_ip(unsigned int buckets, void* p_key)
{ {
diff -up vsftpd-2.1.1/sysutil.c.daemonize_plus vsftpd-2.1.1/sysutil.c 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.daemonize_plus 2009-05-10 22:11:24.000000000 +0200
+++ vsftpd-2.1.1/sysutil.c 2009-05-04 16:18:30.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 @@ -201,6 +201,9 @@ vsf_sysutil_translate_sig(const enum EVS
case kVSFSysUtilSigHUP: case kVSFSysUtilSigHUP:
realsig = SIGHUP; realsig = SIGHUP;
@ -94,16 +104,46 @@ diff -up vsftpd-2.1.1/sysutil.c.daemonize_plus vsftpd-2.1.1/sysutil.c
int int
vsf_sysutil_fork(void) 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"); die("setrlimit NOFILE");
} }
} }
+ +
+static struct sigaction sigalr, sigusr1;
+
+void +void
+vsf_sysutil_sigaction(const enum EVSFSysUtilSignal sig, void (*p_handlefunc)(int)) +vsf_sysutil_sigaction(const enum EVSFSysUtilSignal sig, void (*p_handlefunc)(int))
+{ +{
+ int realsig = vsf_sysutil_translate_sig(sig); + 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 +int
@ -119,8 +159,8 @@ diff -up vsftpd-2.1.1/sysutil.c.daemonize_plus vsftpd-2.1.1/sysutil.c
+ return pause(); + return pause();
+} +}
diff -up vsftpd-2.1.1/sysutil.h.daemonize_plus vsftpd-2.1.1/sysutil.h 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.daemonize_plus 2009-05-10 22:11:24.000000000 +0200
+++ vsftpd-2.1.1/sysutil.h 2009-05-04 16:23:47.000000000 +0200 +++ vsftpd-2.1.1/sysutil.h 2009-05-10 22:11:24.000000000 +0200
@@ -29,7 +29,8 @@ enum EVSFSysUtilSignal @@ -29,7 +29,8 @@ enum EVSFSysUtilSignal
kVSFSysUtilSigCHLD, kVSFSysUtilSigCHLD,
kVSFSysUtilSigPIPE, kVSFSysUtilSigPIPE,

View File

@ -37,7 +37,7 @@ start() {
if [ -d /etc/vsftpd ] ; then if [ -d /etc/vsftpd ] ; then
CONFS=`ls /etc/vsftpd/*.conf 2>/dev/null` CONFS=`ls /etc/vsftpd/*.conf 2>/dev/null`
[ -z $CONFS ] && exit 6 [ -z "$CONFS" ] && exit 6
for i in $CONFS; do for i in $CONFS; do
site=`basename $i .conf` site=`basename $i .conf`
echo -n $"Starting $prog for $site: " echo -n $"Starting $prog for $site: "

View File

@ -3,7 +3,7 @@
Name: vsftpd Name: vsftpd
Version: 2.1.1 Version: 2.1.1
Release: 0.2.%{pretag}%{?dist} Release: 0.3.%{pretag}%{?dist}
Summary: Very Secure Ftp Daemon Summary: Very Secure Ftp Daemon
Group: System Environment/Daemons Group: System Environment/Daemons
@ -139,6 +139,10 @@ fi
%changelog %changelog
* Thu May 21 2009 Jiri Skala <jskala@redhat.com> - 2.1.1-0.3
- fixed daemonize_plus patch
- fixed test in initscript [ -z "CONFS" ]
* Mon May 04 2009 Jiri Skala <jskala@redhat.com> - 2.1.1-0.2 * Mon May 04 2009 Jiri Skala <jskala@redhat.com> - 2.1.1-0.2
- fixes daemonize patch - fixes daemonize patch