Bug 21494

Summary: ftpd can't handle /etc/chroot entries without a NL
Product: Base System Reporter: djhill <djhill>
Component: miscAssignee: Yar Tikhiy <yar>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description djhill 2000-09-23 06:56:38 UTC
>Number:         21494
>Category:       misc
>Synopsis:       ftpd doesn't count
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Sep 22 23:00:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     David Hill
>Release:        4.1
>Organization:
>Environment:
FreeBSD beast.hill.hom 4.1-STABLE FreeBSD 4.1-STABLE #5: Thu Sep 14 17:00:50 EDT 2000     root@beast.hill.hom:/usr/src/sys/compile/BEAST  i386
>Description:
When adding a user to /etc/ftpchroot without hitting enter at the end
(does not at \n), ftpd will fail to check the username.  Ok, maybe I
am being picky, but when I had to add only one username to
/etc/ftpchroot, and it wasn't working, I finally remembered to hit enter.
A patch is available below (could it hurt it add it?)
>How-To-Repeat:
add a user to /etc/ftpchroot without hitting enter at the end.
>Fix:
--- ftpd.c.orig Wed Sep 20 05:57:57 2000
+++ ftpd.c      Sat Sep 23 01:53:33 2000
@@ -977,7 +977,7 @@

        if ((fd = fopen(fname, "r")) != NULL) {
                while (!found && fgets(line, sizeof(line), fd) != NULL)
-                       if ((p = strchr(line, '\n')) != NULL) {
+                       if (((p = strchr(line, '\n')) != NULL) || (p = strchr(line, '\0')) != NULL) {
                                *p = '\0';
                                if (line[0] == '#')
                                        continue;

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Comment 1 djhill 2000-09-23 07:00:01 UTC
When adding a user to /etc/ftpchroot without hitting enter at the end
(does not at \n), ftpd will fail to check the username.  Ok, maybe I
am being picky, but when I had to add only one username to
/etc/ftpchroot, and it wasn't working, I finally remembered to hit enter.
A patch is available below (could it hurt it add it?)

Fix: 

if ((fd = fopen(fname, "r")) != NULL) {
                while (!found && fgets(line, sizeof(line), fd) != NULL)
-                       if ((p = strchr(line, '\n')) != NULL) {
+                       if (((p = strchr(line, '\n')) != NULL) || (p = strchr(line, '\0')) != NULL) {
                                *p = '\0';
                                if (line[0] == '#')
                                        continue;--wXTmFNHi4qkbkmTj3hg3qckcSwo9dWcKSBi6dGm3skTktKN5
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

--- ftpd.c.orig Wed Sep 20 05:57:57 2000
+++ ftpd.c      Sat Sep 23 01:53:33 2000
@@ -977,7 +977,7 @@
How-To-Repeat: add a user to /etc/ftpchroot without hitting enter at the end.
Comment 2 Mike Heffner freebsd_committer freebsd_triage 2001-06-29 04:23:02 UTC
Responsible Changed
From-To: freebsd-bugs->mikeh

I'll look at this.
Comment 3 Mike Heffner freebsd_committer freebsd_triage 2001-12-24 20:36:14 UTC
Responsible Changed
From-To: mikeh->yar

Yar has looked at this and made more progress than I have so far.
Comment 4 Yar Tikhiy freebsd_committer freebsd_triage 2002-07-12 16:52:20 UTC
State Changed
From-To: open->patched

CURRENT fixed, MFC pending.
Comment 5 Yar Tikhiy freebsd_committer freebsd_triage 2002-08-12 16:07:59 UTC
State Changed
From-To: patched->feedback

The bug is fixed in STABLE & CURRENT. 
Is the problem gone in your configuration?
Comment 6 Yar Tikhiy freebsd_committer freebsd_triage 2002-08-13 13:19:47 UTC
State Changed
From-To: feedback->closed

Originator's email is gone.