Subject: User Directory CHROOT and ls

From: Kevin Billings <[email-masked]>
Date: Mon, 18 Aug 1997 00:08:09 -0500

I have wu-ftp2.4 beta 14 setup on solaris 2.4 for our users so when they
login they are chroot to /export/home, but i get the following message:

200 PORT command successful.
LIST 
425 Can't create data socket (0.0.0.0,20): Bad file number.
DoDirList returned 0
rList returned 0

The list commands does not work. i have setup all directory per the
FAQ's

Thanks

Kevin Billings
Augusta.Net, Inc.

---

From: Mike Hedlund <[email-masked]>
Date: Sun, 17 Aug 1997 22:17:12 -0700 (PDT)

If you chroot() you need to have a "/dev/tcp and /dev/zero".. so make
/export/home/dev and stick tcp and zero in it. and if i recall, on solaris
2.4 you also need a "/etc/netconfig" altho i could be mistaken.. 

-mike

---

From: Carlos Canau <[email-masked]>
Date: Mon, 18 Aug 1997 10:10:55 +0100 (WET DST)

> 2.4 you also need a "/etc/netconfig" altho i could be mistaken.. 

	Oh boy... this  is the standard response  all over again.  The
list archives is full with this answer...  :'(

	Two or three weeks ago  I've  posted a similar question  about
2.4.13. I've followed  the  FAQ, Sun anonymous  FTP man  page with the
setup  script, played with ~ftp/devices, and  several  other crazy (?)
things that came on my mind.

	The problem is not  only  with "dir" or  "ls". The  problem is
also with  "get" and "put"  (everything that tries to open "/dev/tcp",
that is  the bind() function fails).  Probably  I'm missing some basic
thing, but anyway:

	Is  there any success story    with anonymous FTP (chroot  and
/dev/* on the chroot'd tree) on Solaris 2.x on ***SPARC*** ?

	best regards,
	</canau

-- 
Carlos Canau

---

From: [email-masked] (Winfried Magerl)
Date: Mon, 18 Aug 1997 11:38:21 +0200 (MDT)

> /dev/* on the chroot'd tree) on Solaris 2.x on ***SPARC*** ?

Yes ;-)

first to do:

man ftpd

Is this command realy so hard ?
On most systems (or better to say: on every system I know) you will find
a description how to set up the chroot for anonymous-ftp.
(and on some systems this description realy works ;-)

On solaris-2.5.1 you will find a shell-script to generate the chroot
for anonymous-ftp (yes, it's very complicate to set up the chroot
for solaris since you need a lot of shared libraries for ls).

And to be more specific for the devices here is the part of the shell-script
which creates the devices:
-----------------------------------
     # make device nodes. ticotsord and udp are necessary for
     # 'ls' to resolve NIS names.

     for device in zero tcp udp ticotsord
     do
        line=`ls -lL /dev/${device} | sed -e 's/,//'`
        major=`echo $line | awk '{print $5}'`
        minor=`echo $line | awk '{print $6}'`
        rm -f ${ftphome}/dev/${device}
        mknod ${ftphome}/dev/${device} c ${major} ${minor}
     done

     chmod 666 ${ftphome}/dev/*
-----------------------------------

best regards

	winfried

-- 
Winfried Magerl - Internet Administration
Siemens Business Services, 81739 Munich, Germany
Internet-Mail: [email-masked]

---

From: Carlos Canau <[email-masked]>
Date: Mon, 18 Aug 1997 11:36:26 +0100 (WET DST)

>> /dev/* on the chroot'd tree) on Solaris 2.x on ***SPARC*** ?

	Ufff... .... errr... I bet it isn't 2.5.1 :)...

> Is this command realy so hard ?

	Yes, it is!... I have to type 'm', then 'a', then 'n'!... then
I have to figure out what topic that I want to know about!...

	Thanks for  your  reply...  :) I'll just  quote  a line bit my
message:

>>> setup script, played  with  ~ftp/devices, and several other  crazy
>>> (?) things that came on my mind.

> for solaris since you need a lot of shared libraries for ls).

	I've played  with dynamic linked  and static ls. ls works fine
in "chroot ~ftp  /bin/ls". The problem  is on /dev/tcp and bind() (and
/dev/zero).

> which creates the devices:

	Here... look at my "dev" on the chroot'd tree:

total 16
  17088    1 dr-xr-xr-x   2 root     other         512 Aug 18 11:14 .
  11392   15 dr-xr-xr-x 832 root     other       15360 Aug  6 12:18 ..
  17089    0 crw-rw-rw-   1 root     other     11,  42 Aug 17 12:54 tcp
  17092    0 crw-rw-rw-   1 root     other    105,   1 Aug  5 19:17 ticotsord
  17093    0 crw-rw-rw-   1 root     other     11,  41 Aug  4 16:38 udp
  17090    0 crw-rw-rw-   1 root     other     13,  12 Aug  4 16:38 zero

	Show me yours :))),

	I even put "straddr.so" (from netconfig) on ~ftp/usr/lib ...

	Some truss output:

------> truss -f chroot ~ftp /bin/ls.dynamic
2082:   execve("/usr/local/bin/chroot", 0xEFFFFC4C, 0xEFFFFC5C)  argc = 3
2082:   open("/dev/zero", O_RDONLY)                     = 3
2082:   mmap(0x00000000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xEF7C0000
2082:   open("/usr/lib/libsec.so.1", O_RDONLY)          = 4
2082:   fstat(4, 0xEFFFF904)                            = 0
2082:   mmap(0x00000000, 4096, PROT_READ|PROT_EXEC, MAP_SHARED, 4, 0) = 0xEF7B0000
2082:   mmap(0x00000000, 77824, PROT_READ|PROT_EXEC, MAP_PRIVATE, 4, 0) = 0xEF790000
2082:   munmap(0xEF792000, 61440)                       = 0
2082:   mmap(0xEF7A1000, 4734, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 4, 4096) = 0xEF7A1000
2082:   close(4)                                        = 0
2082:   open("/usr/lib/libc.so.1", O_RDONLY)            = 4
2082:   fstat(4, 0xEFFFF904)                            = 0
2082:   mmap(0xEF7B0000, 4096, PROT_READ|PROT_EXEC, MAP_SHARED|MAP_FIXED, 4, 0) = 0xEF7B0000
2082:   mmap(0x00000000, 618496, PROT_READ|PROT_EXEC, MAP_PRIVATE, 4, 0) = 0xEF6C0000
2082:   munmap(0xEF73F000, 61440)                       = 0
2082:   mmap(0xEF74E000, 27968, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 4, 516096) = 0xEF74E000
2082:   mmap(0xEF755000, 8080, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xEF755000
2082:   close(4)                                        = 0
2082:   open("/usr/lib/libdl.so.1", O_RDONLY)           = 4
2082:   fstat(4, 0xEFFFF904)                            = 0
2082:   mmap(0xEF7B0000, 4096, PROT_READ|PROT_EXEC, MAP_SHARED|MAP_FIXED, 4, 0) = 0xEF7B0000
2082:   close(4)                                        = 0
2082:   open("/usr/platform/SUNW,SPARCstation-4/lib/libc_psr.so.1", O_RDONLY) Err#2 ENOENT
2082:   close(3)                                        = 0
2082:   brk(0x00025020)                                 = 0
2082:   brk(0x00027020)                                 = 0
2082:   chroot("/home/ftp")                = 0
2082:   execve("/bin/ls.dynamic", 0xEFFFFC5C, 0xEFFFFC64)  argc = 1
2082:   open("/dev/zero", O_RDONLY)                     Err#6 ENXIO
2082:   open("/dev/zero", O_RDONLY)                     Err#6 ENXIO
2082:   open("/dev/zero", O_RDONLY)                     Err#6 ENXIO
2082:   open("/dev/zero", O_RDONLY)                     Err#6 ENXIO
2082:   open("/dev/zero", O_RDONLY)                     Err#6 ENXIO
2082:   open("/dev/zero", O_RDONLY)                     Err#6 ENXIO

	... [ad nauseum]

2082:   open("/dev/zero", O_RDONLY)                     Err#6 ENXIO
2082:   open("/dev/zero", O_RDONLY)                     Err#6 ENXIO
2082:       Incurred fault #6, FLTBOUNDS  %pc = 0xEF7E6D8C
2082:         siginfo: SIGSEGV SEGV_MAPERR addr=0xEF7FFFE0
2082:       Received signal #11, SIGSEGV [default]
2082:         siginfo: SIGSEGV SEGV_MAPERR addr=0xEF7FFFE0
2082:           *** process killed ***

---------> truss -f chroot ~ftp /bin/ls.static -lisa /dev
2115:   execve("/usr/local/bin/chroot", 0xEFFFFC34, 0xEFFFFC4C)  argc = 5
2115:   open("/dev/zero", O_RDONLY)                     = 3
2115:   mmap(0x00000000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xEF7C0000
2115:   open("/usr/lib/libsec.so.1", O_RDONLY)          = 4
2115:   fstat(4, 0xEFFFF8EC)                            = 0
2115:   mmap(0x00000000, 4096, PROT_READ|PROT_EXEC, MAP_SHARED, 4, 0) = 0xEF7B0000
2115:   mmap(0x00000000, 77824, PROT_READ|PROT_EXEC, MAP_PRIVATE, 4, 0) = 0xEF790000
2115:   munmap(0xEF792000, 61440)                       = 0
2115:   mmap(0xEF7A1000, 4734, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 4, 4096) = 0xEF7A1000
2115:   close(4)                                        = 0
2115:   open("/usr/lib/libc.so.1", O_RDONLY)            = 4
2115:   fstat(4, 0xEFFFF8EC)                            = 0
2115:   mmap(0xEF7B0000, 4096, PROT_READ|PROT_EXEC, MAP_SHARED|MAP_FIXED, 4, 0) = 0xEF7B0000
2115:   mmap(0x00000000, 618496, PROT_READ|PROT_EXEC, MAP_PRIVATE, 4, 0) = 0xEF6C0000
2115:   munmap(0xEF73F000, 61440)                       = 0
2115:   mmap(0xEF74E000, 27968, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 4, 516096) = 0xEF74E000
2115:   mmap(0xEF755000, 8080, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xEF755000
2115:   close(4)                                        = 0
2115:   open("/usr/lib/libdl.so.1", O_RDONLY)           = 4
2115:   fstat(4, 0xEFFFF8EC)                            = 0
2115:   mmap(0xEF7B0000, 4096, PROT_READ|PROT_EXEC, MAP_SHARED|MAP_FIXED, 4, 0) = 0xEF7B0000
2115:   close(4)                                        = 0
2115:   open("/usr/platform/SUNW,SPARCstation-4/lib/libc_psr.so.1", O_RDONLY) Err#2 ENOENT
2115:   close(3)                                        = 0
2115:   brk(0x00025020)                                 = 0
2115:   brk(0x00027020)                                 = 0
2115:   chroot("/home/ftp")                = 0
2115:   execve("/bin/ls.static", 0xEFFFFC44, 0xEFFFFC54)  argc = 3
2115:   brk(0x0005DAF8)                                 = 0
2115:   brk(0x0005FAF8)                                 = 0
2115:   time()                                          = 871900063
2115:   ioctl(1, TCGETA, 0xEFFFFB5C)                    Err#22 EINVAL
2115:   ioctl(1, TIOCGWINSZ, 0xEFFFFBE0)                Err#22 EINVAL
2115:   brk(0x0005FAF8)                                 = 0
2115:   brk(0x00063AF8)                                 = 0
2115:   lstat("/dev", 0x0005E514)                       = 0
2115:   open("/dev", O_RDONLY|O_NDELAY)                 = 3
2115:   fcntl(3, F_SETFD, 0x00000001)                   = 0
2115:   fstat(3, 0xEFFFFAE8)                            = 0
2115:   getdents(3, 0x00062218, 1048)                   = 96
2115:   lstat("/dev/.", 0x0005E514)                     = 0
2115:   lstat("/dev/..", 0x0005E5B0)                    = 0
2115:   lstat("/dev/tcp", 0x0005E64C)                   = 0
2115:   lstat("/dev/zero", 0x0005E6E8)                  = 0
2115:   lstat("/dev/ticotsord", 0x0005E784)             = 0
2115:   lstat("/dev/udp", 0x0005E820)                   = 0
2115:   getdents(3, 0x00062218, 1048)                   = 0
2115:   close(3)                                        = 0
2115:   ioctl(1, TCGETA, 0xEFFFF9B4)                    Err#22 EINVAL
2115:   fstat(1, 0xEFFFFA28)                            = 0
2115:   brk(0x00063AF8)                                 = 0
2115:   brk(0x00065AF8)                                 = 0
2115:   open("/etc/nsswitch.conf", O_RDONLY)            = 3
2115:   fstat(3, 0xEFFFF628)                            = 0
2115:   brk(0x00065AF8)                                 = 0
2115:   brk(0x00067AF8)                                 = 0
2115:   ioctl(3, TCGETA, 0xEFFFF5B4)                    Err#25 ENOTTY
2115:   read(3, " #\n #   / e t c / n s s".., 8192)     = 690
2115:   read(3, 0x00064304, 8192)                       = 0
2115:   lseek(3, 0, SEEK_CUR)                           = 690
2115:   close(3)                                        = 0
2115:   open("/usr/share/lib/zoneinfo/WET", O_RDONLY)   = 3
2115:   read(3, "\0\0\0\0\0\0\0\0\0\0\0\0".., 8192)     = 680
2115:   close(3)                                        = 0
total 16
  17088    1 dr-xr-xr-x   2 0        1             512 Aug 18 11:14 .
  11392   15 dr-xr-xr-x 832 0        1           15360 Aug  6 12:18 ..
  17089    0 crw-rw-rw-   1 0        1         11,  42 Aug 17 12:54 tcp
  17092    0 crw-rw-rw-   1 0        1        105,   1 Aug  5 19:17 ticotsord
  17093    0 crw-rw-rw-   1 0        1         11,  41 Aug  4 16:38 udp
  17090    0 crw-rw-rw-   1 0        1         13,  12 Aug  4 16:38 zero
2115:   write(1, " t o t a l   1 6\n     1".., 445)     = 445
2115:   close(1)                                        = 0
2115:   lseek(0, 0, SEEK_CUR)                           = 1558908
2115:   _exit(0)

	:'(
	</canau

P.S.: I hope that I am not annoying anyone with my truss outputs :/. If
so, please accept my appologies.

---

From: Carlos Canau <[email-masked]>
Date: Mon, 18 Aug 1997 14:40:57 +0100 (WET DST)

> 	Ufff... .... errr... I bet it isn't 2.5.1 :)...

	This is sad... :(((. It was on the FAQ...  (the Solaris 2 FAQ,
I mean). Here's the quote:

-------------------------------------------------------------------------
*3.9) How can I set up anonymous FTP?

    If you need help, ftp the file "ftp.anon" from
    ftp://ftp.math.fsu.edu/pub/solaris/ftp.anon.

    ftpd(1M) is nearly complete when it comes to setting
    up anonymous ftp.  It only leaves out /etc/nsswitch.conf. [S2.3]

    Additionally, you must make sure that the filesystem ~ftp resides
    on is not mounted with the nosuid option.  This is because the nosuid 
    option also disables the kernel honoring device files which are 
    required in the chroot environment for ~ftp.

    For security reasons, it is important that no files under ~ftp are
    owned by ftp.  If they are, anonymous users can modify them.

    In Solaris 2.5 and later, you will need to copy /usr/lib/libmp.so.1
    as well as provide a /dev/ticlts (for wu-ftpd).

------------------------------------------------------------------------

	ftp.anon is the script that Winfried mentioned on his message;
	My  problem was  with   the filesystem being mounted  "nosuid"
which looked like a *good* option to a filesystem with a anonymous ftp
dir on... bah!;
	About /dev/ticlts  I don't think it  is needed.  It is working
without it and  the man  page for  tictls mentions that  "ticlts is  a
datagram-mode   transport provider"  so    I guess   it  isn't  really
necessary.

	I think this bit about the nosuid should go to the wu-ftpd FAQ
:).

	O.K....    I'm running wu-ftpd 2.4.14    on Solaris 2.5.1 on a
SPARC. It works.

	My thanks to everyone that send me mail about this problem.
	regards,
	</canau