-#ifndef DEBUG
- if (fork())
- exit(0);
- for (s = 0; s < 10; s++)
- if (!logging || (s != 2))
- (void) close(s);
- (void) open("/", O_RDONLY);
- (void) dup2(0, 1);
- if (!logging)
- (void) dup2(0, 2);
- { int tt = open("/dev/tty", O_RDWR);
- if (tt > 0) {
- ioctl(tt, TIOCNOTTY, 0);
- close(tt);
- }
- }
-#endif
- while ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- perror("ftpd: socket");
- sleep(5);
- }
- if (options & SO_DEBUG)
- if (setsockopt(s, SOL_SOCKET, SO_DEBUG, 0, 0) < 0)
- perror("ftpd: setsockopt (SO_DEBUG)");
- if (setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, 0, 0) < 0)
- perror("ftpd: setsockopt (SO_KEEPALIVE)");
- while (bind(s, &ctrl_addr, sizeof (ctrl_addr), 0) < 0) {
- perror("ftpd: bind");
- sleep(5);
- }
- signal(SIGCHLD, reapchild);
- listen(s, 10);
+ signal(SIGPIPE, lostconn);
+ signal(SIGCHLD, SIG_IGN);
+ /* do telnet option negotiation here */
+ /*
+ * Set up default state
+ */
+ logged_in = 0;
+ data = -1;
+ type = TYPE_A;
+ form = FORM_N;
+ stru = STRU_F;
+ mode = MODE_S;
+ gethostname(hostname, sizeof (hostname));
+ reply(220, "%s FTP server (%s) ready.",
+ hostname, version);