From owner-freebsd-questions Sat Dec 30 18:47:17 1995 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id SAA01266 for questions-outgoing; Sat, 30 Dec 1995 18:47:17 -0800 (PST) Received: from hemi.com (hemi.com [204.132.158.10]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id SAA01260 Sat, 30 Dec 1995 18:47:13 -0800 (PST) Received: (from mbarkah@localhost) by hemi.com (8.6.11/8.6.9) id TAA13020; Sat, 30 Dec 1995 19:46:49 -0700 From: Ade Barkah Message-Id: <199512310246.TAA13020@hemi.com> Subject: Answer to /bin/ls and ftp (should be documented) To: hackers@freebsd.org Date: Sat, 30 Dec 1995 19:46:49 -0700 (MST) Cc: questions@freebsd.org X-Mailer: ELM [version 2.4 PL24] Content-Type: text Sender: owner-questions@freebsd.org Precedence: bulk Someone just asked why ftp doesn't list proper usernames when an anonymous user issues 'ls'. Unfortunately I deleted the email before deciding to answer question. =) I hope whoever asked it is reading this mail (I think it was posted to -hackers, but maybe it was to -questions, so forgive me for cross posting.) Under 4.4BSD, /bin/ls caches directory entries using the pwcache(3) package, which in turn uses getpwent() and friends to find the entry in the password database. The implication being, /bin/ls never looks in /etc/passwd, so even if you have created a dummy /etc/passwd under ~ftp, `ls' still cannot resolve the user name. The solution would be to make a password database using the pwd_mkdb command. The steps are as follows: 1. Make a dummy master.passwd, either by copying your real /etc/master.passwd to a temporary directory then deleting all but the necessary entries, or by creating it by hand. Remember that the master.passwd format is more complete than the /etc/passwd format. A sample entry is as follows: ftp:*:999:1002::0:0:Ftp Account:/usr20/f/ftp:/usr/local/etc/ftpd 2. Now compile your dummy master.passwd file into the password databases. In a directory other than /etc, use: pwd_mkdb -d . master.passwd This command will make two database files, pwd.db and spwd.db. Erase the spwd.db file, especially if your dummy master.passwd file contained real passwords. 3. Copy the new pwd.db file into ~ftp/etc, and make it only readable to everyone (chmod a=r pwd.db.) You should have two files in ~ftp/etc directory: pwd.db, and group. The passwd file is not necessary. Here's an example of how the ~ftp/etc directory might look: -r--r--r-- 1 root ftp 15 Dec 18 10:38 group -r--r--r-- 1 root ftp 40960 Dec 18 19:14 pwd.db 4. Make sure you copy /bin/ls into ~ftp/bin, and make it only executable by everyone (chmod a=x ls). And you're all set. This information should be documented somewhere, but I haven't seen it anywhere. Perhaps it is in the FAQ now. Regards, -Ade Barkah -------------------------------------------------------------------- Inet: mbarkah@hemi.com - HEMISPHERE ONLINE - www: --------------------------------------------------------------------