MCPcopy Create free account
hub / github.com/apache/httpd / proxy_ftp_command

Function proxy_ftp_command

modules/proxy/mod_proxy_ftp.c:811–850  ·  view source on GitHub ↗

* Generic "send FTP command to server" routine, using the control socket. * Returns the FTP returncode (3 digit code) * Allows for tracing the FTP protocol (in LogLevel debug) */

Source from the content-addressed store, hash-verified

809 * Allows for tracing the FTP protocol (in LogLevel debug)
810 */
811static int
812proxy_ftp_command(const char *cmd, request_rec *r, conn_rec *ftp_ctrl,
813 apr_bucket_brigade *bb, char **pmessage)
814{
815 char *crlf;
816 int rc;
817 char message[HUGE_STRING_LEN];
818
819 /* If cmd == NULL, we retrieve the next ftp response line */
820 if (cmd != NULL) {
821 conn_rec *c = r->connection;
822 APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_pool_create(cmd, strlen(cmd), r->pool, c->bucket_alloc));
823 APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_flush_create(c->bucket_alloc));
824 ap_pass_brigade(ftp_ctrl->output_filters, bb);
825
826 if (APLOGrtrace2(r)) {
827 /* strip off the CRLF for logging */
828 apr_cpystrn(message, cmd, sizeof(message));
829 if ((crlf = strchr(message, '\r')) != NULL ||
830 (crlf = strchr(message, '\n')) != NULL)
831 *crlf = '\0';
832 if (strncmp(message,"PASS ", 5) == 0)
833 strcpy(&message[5], "****");
834 ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r, ">%s", message);
835 }
836 }
837
838 rc = ftp_getrc_msg(ftp_ctrl, bb, message, sizeof(message));
839 if (rc == -1 || rc == 421)
840 strcpy(message,"<unable to read result>");
841 if ((crlf = strchr(message, '\r')) != NULL ||
842 (crlf = strchr(message, '\n')) != NULL)
843 *crlf = '\0';
844 ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r, "<%3.3u %s", rc, message);
845
846 if (pmessage != NULL)
847 *pmessage = apr_pstrdup(r->pool, message);
848
849 return rc;
850}
851
852/* Set ftp server to TYPE {A,I,E} before transfer of a directory or file */
853static int ftp_set_TYPE(char xfer_type, request_rec *r, conn_rec *ftp_ctrl,

Callers 3

ftp_set_TYPEFunction · 0.85
ftp_get_PWDFunction · 0.85
proxy_ftp_handlerFunction · 0.85

Calls 2

ap_pass_brigadeFunction · 0.85
ftp_getrc_msgFunction · 0.85

Tested by

no test coverage detected