Date: Sat, 30 Dec 1995 19:46:49 -0700 (MST) From: Ade Barkah <mbarkah@hemi.com> To: hackers@freebsd.org Cc: questions@freebsd.org Subject: Answer to /bin/ls and ftp (should be documented) Message-ID: <199512310246.TAA13020@hemi.com>
next in thread | raw e-mail | index | archive | help
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: <http://hemi.com/> --------------------------------------------------------------------
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199512310246.TAA13020>