[comp.sys.sun] Anonymous FTP on SUN

tjcm@stl.stc.co.uk (11/21/89)

I am currently trying to set up an anonymous ftp service on a Sun 3/260
running SunOS 4.0.1. I am not entirely sure how to go about this, but we
do have other Non-Sun machines around the site which have been
successfully configured and I have based my initial attempt on those.

The set-up is as follows:

	Create an ftp user in /etc/passwd:

		ftp:*:5555:6:Anon. FTP:/usr/spool/ftp:

	Create a directory /usr/spool/ftp with two sub-directories ./bin and
	./etc.
	Place the binaries 'sh' and 'ls' in the ./bin directory.
	Place a 'passwd' file in the ./etc directory.
	The 'passwd file contains the following three users:

		root:*:0:1:Operator,SYSTEM:/:
		nobody:*:32767:32767:Mismatched NFS ID's:/:
		ftp:*:5555:6:Anon. FTP:/:


When I try to make an ftp connection from another machine I get the
following complaint when I use the 'ls' command within ftp:

mach1% ftp -n mach2
Connected to mach2
220 mach2 FTP server (SunOS 4.0) ready.
ftp> user ftp root
331 Guest login ok, send ident as password.
230 Guest login ok, access restrictions apply.
ftp> ls
200 PORT command successful.
150 ASCII data connection for /bin/ls (XXX.YYY.200.6,1513).
crt0: no /usr/lib/ld.so
226 ASCII Transfer complete.
25 bytes received in 0.06 seconds (.41 Kbytes/s)
ftp>

It would appear that the problem is that /bin/ls is a dynamically linked
executable. Other commands appear to work fine; I created a directory
/usr/spool/ftp/pub and place a few files in there which can all be
accessed using the 'get' command.

I tried placing a copy of 'ld.so' in /usr/spool/ftp/usr/lib/ld.so but ftp
complained with:
150 ASCII data connection for /bin/ls (XXX.YYY.200.6,1534).
crt0: no /dev/zero
226 ASCII Transfer complete.

My initial use for anon. ftp is to allow other machines to copy certain
files from my machine on a nightly basis; So any batch scripts which I
create will work fine.

Does anyone know what further steps I must take to allow users to log in
to ftp and browse through the files I am exporting using the 'ls' command.
Is their a version of 'ls' somewhere in the SunOS filesystem which is not
dynamically linked ?!

Any comments or suggestions would be appreciated.

Thanks,
Crawford Macnab      ( tjcm@stl.stc.co.uk +44-279-29531 Ext 2153 )

edwin@praxis.cs.ruu.nl (Edwin Kremer) (12/02/89)

Let me first make clear that I've only little experience with Sun's...

  > I tried placing a copy of 'ld.so' in /usr/spool/ftp/usr/lib/ld.so

Good point. "ld.so" is *indeed* needed in that directory.

  > 150 ASCII data connection for /bin/ls (XXX.YYY.200.6,1534).
  > crt0: no /dev/zero

You should create the special file /dev/zero below FTP's home directory
(remember that FTP does a chroot() to it's home directory) like this:

	% cd ~ftp
	% mkdir dev
	% mknod dev/zero c 3 12

  > Any comments or suggestions would be appreciated.

Well, this should do the trick. For more info check your manual page
FTPD(8c).

		Good luck,
					--[ Edwin ]--

Edwin Kremer, Department of Computer Science, University of Utrecht
Padualaan 14,  P.O. Box 80.089,  3508 TB  Utrecht,  The Netherlands
Phone : +31 - 30 - 534104     |     Telefax: +31 - 30 - 513791
E-Mail: edwin@cs.ruu.nl       |     UUCP to: ...!hp4nl!ruuinf!edwin

tran@xlnvax.excelan.com (Tony Tran) (12/03/89)

Crawford Macnab <tjcm@stl.stc.co.uk> in v8n204 asked:

>Does anyone know what further steps I must take to allow users to log in
>to ftp and browse through the files I am exporting using the 'ls' command.
>Is their a version of 'ls' somewhere in the SunOS filesystem which is not
>dynamically linked ?!

Basically, anonymous ftp chroots to ~ftp and uses the bin, etc directories
under the new root.  SunOS 4.x's "ls" was dynamically linked, which
requires ld.so in /usr/lib (~ftp/usr/lib/ld.so). This is to prevent
anonymous ftp's from being able to browse your entire filesystem.

There are 3 solutions to fix this problem:

1. If you have access to source, either Sun or 4.3 BSD, get the source for
"ls" and recompile it, being sure to link it with "-Bstatic".  The result
won't need the shared library and can be placed in ftp's bin directory.
{no dynamic linking}

2. Copy the /usr/lib/ld.so to ~ftp/usr/lib/ld.so This library alone will
NOT work. It also needs libc.so.1.[1|2|3] plus ~ftp/dev/zero for it to
work. {cd to ~ftp/dev and mknod zero c 3 12}

3. Copy the "ls" executable from a SUN OS 3.x machine and use that.

SUNOS 3.x doesn't have dynamic linking so you should not run into this
problem.

William LeFebvre also had a long article about anonymous FTP published in
The Sun Observer in the July issue.

Tony Tran
Novell San Jose
Internet: tran@na.excelan.COM 
UUCP: 	  {ames,sun,apple,amdahl}!excelan!tran