From owner-freebsd-bugs@FreeBSD.ORG Fri Feb 5 07:40:03 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D6B52106568F for ; Fri, 5 Feb 2010 07:40:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id AFDDD8FC1B for ; Fri, 5 Feb 2010 07:40:03 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id o157e3E1050160 for ; Fri, 5 Feb 2010 07:40:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id o157e3Yq050159; Fri, 5 Feb 2010 07:40:03 GMT (envelope-from gnats) Date: Fri, 5 Feb 2010 07:40:03 GMT Message-Id: <201002050740.o157e3Yq050159@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Eugene Grosbein Cc: Subject: Re: bin/143570: [patch] stock ftpd does not handle "filesize" limit right X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Eugene Grosbein List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Feb 2010 07:40:03 -0000 The following reply was made to PR bin/143570; it has been noted by GNATS. From: Eugene Grosbein To: bug-followup@freebsd.org Cc: Subject: Re: bin/143570: [patch] stock ftpd does not handle "filesize" limit right Date: Fri, 5 Feb 2010 14:05:41 +0700 Here is better looking edition of the patch above: fixed spelling error in a comment, change for dologout() fuction corrected. --- libexec/ftpd/ftpd.c.orig 2010-02-05 11:19:23.000000000 +0700 +++ libexec/ftpd/ftpd.c 2010-02-05 13:57:43.000000000 +0700 @@ -428,6 +428,10 @@ } } + /* handle filesize limit gracefully */ + sa.sa_handler = SIG_IGN; + (void)sigaction(SIGXFSZ, &sa, NULL); + if (daemon_mode) { int *ctl_sock, fd, maxfd = -1, nfds, i; fd_set defreadfds, readfds; @@ -1183,14 +1187,16 @@ #endif (void) seteuid(0); - if (logged_in && dowtmp) - ftpd_logwtmp(ttyline, "", NULL); - pw = NULL; #ifdef LOGIN_CAP setusercontext(NULL, getpwuid(0), 0, LOGIN_SETPRIORITY|LOGIN_SETRESOURCES|LOGIN_SETUMASK| LOGIN_SETMAC); #endif + + if (logged_in && dowtmp) + ftpd_logwtmp(ttyline, "", NULL); + pw = NULL; + #ifdef USE_PAM if (pamh) { if ((e = pam_setcred(pamh, PAM_DELETE_CRED)) != PAM_SUCCESS) @@ -1463,7 +1469,7 @@ } setusercontext(lc, pw, 0, LOGIN_SETLOGIN|LOGIN_SETGROUP|LOGIN_SETPRIORITY| - LOGIN_SETRESOURCES|LOGIN_SETUMASK|LOGIN_SETMAC); + LOGIN_SETUMASK|LOGIN_SETMAC); #else setlogin(pw->pw_name); (void) initgroups(pw->pw_name, pw->pw_gid); @@ -1485,6 +1491,10 @@ (struct sockaddr *)&his_addr); logged_in = 1; +#ifdef LOGIN_CAP + setusercontext(lc, pw, 0, LOGIN_SETRESOURCES); +#endif + if (guest && stats && statfd < 0) #ifdef VIRTUAL_HOSTING statfd = open(thishost->statfile, O_WRONLY|O_APPEND); @@ -2745,6 +2755,11 @@ if (logged_in && dowtmp) { (void) seteuid(0); +#ifdef LOGIN_CAP + setusercontext(NULL, getpwuid(0), 0, + LOGIN_SETPRIORITY|LOGIN_SETRESOURCES|LOGIN_SETUMASK| + LOGIN_SETMAC); +#endif ftpd_logwtmp(ttyline, "", NULL); } /* beware of flushing buffers after a SIGPIPE */