void pass (const char *passwd) { if (cred.logged_in || askpasswd == 0) { reply (503, "Login with USER first."); return; } askpasswd = 0; if (!cred.guest) /* "ftp" is the only account allowed no password. */ { /* Try to authenticate the user. Failed if != 0. */ if (auth_pass (passwd, &cred) != 0) { /* Any particular reasons. */ if (cred.message) { reply (530, "%s", cred.message); free (cred.message); cred.message = NULL; } else reply (530, "Login incorrect."); if (logging) syslog (LOG_NOTICE, "FTP LOGIN FAILED FROM %s, %s", cred.remotehost, curname); if (login_attempts++ >= 5) { syslog (LOG_NOTICE, "repeated login failures from %s", cred.remotehost); exit (0); } return; } } cred.logged_in = 1; /* Everything seems to be allright. */ complete_login (&cred); login_attempts = 0; /* This time successful. */ }
void nntp(void) { char buf[4096]; int len; while (TRUE) { IsDoing("Waiting"); len = get_nntp(buf, sizeof(buf) -1); if (len < 0) return; if (len == 0) continue; if (strcasestr(buf, (char *)"AUTHINFO PASS") == NULL) { Syslog('n', "< \"%s\"", printable(buf, 0)); } else { Syslog('n', "< \"AUTHINFO PASS ********\""); } if (! check_free()) { send_nntp("400 server closed"); return; } /* * Process received command */ if (strncasecmp(buf, "QUIT", 4) == 0) { send_nntp("205 Goodbye\r\n"); return; } else if (strncasecmp(buf, "AUTHINFO USER", 13) == 0) { auth_user(buf); } else if (strncasecmp(buf, "AUTHINFO PASS", 13) == 0) { auth_pass(buf); } else if (strncasecmp(buf, "ARTICLE", 7) == 0) { if (check_auth(buf)) command_abhs(buf); } else if (strncasecmp(buf, "BODY", 4) == 0) { if (check_auth(buf)) command_abhs(buf); } else if (strncasecmp(buf, "LIST", 4) == 0) { if (check_auth(buf)) command_list(buf); } else if (strncasecmp(buf, "GROUP", 5) == 0) { if (check_auth(buf)) command_group(buf); } else if (strncasecmp(buf, "HEAD", 4) == 0) { if (check_auth(buf)) command_abhs(buf); } else if (strncasecmp(buf, "POST", 4) == 0) { if (check_auth(buf)) command_post(buf); } else if (strncasecmp(buf, "IHAVE", 5) == 0) { send_nntp("435 Article not wanted - do not send it"); } else if (strncasecmp(buf, "NEWGROUPS", 9) == 0) { send_nntp("235 Warning: NEWGROUPS not implemented, returning empty list"); send_nntp("."); } else if (strncasecmp(buf, "NEWNEWS", 7) == 0) { send_nntp("230 Warning: NEWNEWS not implemented, returning empty list"); send_nntp("."); } else if (strncasecmp(buf, "SLAVE", 5) == 0) { send_nntp("202 Slave status noted"); } else if (strncasecmp(buf, "STAT", 4) == 0) { if (check_auth(buf)) command_abhs(buf); } else if (strncasecmp(buf, "MODE READER", 11) == 0) { if (check_auth(buf)) { if (authorized) send_nntp("200 Server ready, posting allowed"); else send_nntp("201 Server ready, no posting allowed"); } } else if (strncasecmp(buf, "XOVER", 5) == 0) { if (check_auth(buf)) command_xover(buf); } else if (strncasecmp(buf, "HELP", 4) == 0) { send_nntp("100 Help text follows"); send_nntp("Recognized commands:"); send_nntp(""); send_nntp("ARTICLE"); send_nntp("AUTHINFO"); send_nntp("BODY"); send_nntp("GROUP"); send_nntp("HEAD"); send_nntp("IHAVE (not implemented, messages are always rejected)"); send_nntp("LIST"); send_nntp("NEWGROUPS (not implemented, always returns an empty list)"); send_nntp("NEWNEWS (not implemented, always returns an empty list)"); send_nntp("POST"); send_nntp("QUIT"); send_nntp("SLAVE (has no effect)"); send_nntp("STAT"); send_nntp("XOVER"); send_nntp(""); send_nntp("FTNNNTP supports most of RFC-977 and also has support for AUTHINFO and"); send_nntp("limited XOVER support (RFC-2980)"); send_nntp("."); } else { send_nntp("500 Unknown command"); } } }