Force login
before any other code can execute
ftpsess : user pass cmdseq
user : USER SP username CRLF
pass : PASS SP password CRLF
cmdseq : cmd | cmdseq cmd
cmd : CWD SP pathname CRLF
| ...
Tangled code is messy
ftpd
into two programs:setuid()
and chroot()
smaller
: 125 lines for login handles.ftpd is supposed to be on port 20, but only root can bind low-numbered port can we give up root privilege after login?
setUID
program that binds an open socket to port 20.fork/exec()
invoke the program above.