Authorize FTP commands and data connections by the rules in force

An FTP control connection authorizes each OPEN or USER and each data
connection while it lasts, which may be across a reload: these go
through clientauth() too, as a client of the newest service on its
listener after a reload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vladimir DubrovinandClaude Opus 5.5 committed 2026-10-15 00:49:53 +03:00
1 parent ae27a5cf90
commit dfee08ded4
2 files changed
+4 -4

No files matched your search

+2 -2
View File
@@ -203,13 +203,13 @@ SOCKET ftpdata(struct clientparam *param){
*SAPORT(&param->sinsl) = 0;
i = param->operation;
param->operation = FTP_DATA;
if((param->res = (*param->srv->authfunc)(param))) {
if((param->res = clientauth(param))) {
if(param->remsock != INVALID_SOCKET) {
param->srv->so._closesocket(param->sostate, param->remsock);
param->remsock = INVALID_SOCKET;
}
memset(&param->sinsl, 0, sizeof(param->sinsl));
if((param->res = (*param->srv->authfunc)(param))) {
if((param->res = clientauth(param))) {
param->remsock = rem;
return INVALID_SOCKET;
}
+2 -2
View File
@@ -54,7 +54,7 @@ void * ftpprchild(struct clientparam* param) {
param->srv->so._closesocket(param->sostate, param->remsock);
param->remsock = INVALID_SOCKET;
}
if((res = (*param->srv->authfunc)(param))) {RETURN(res);}
if((res = clientauth(param))) {RETURN(res);}
param->ctrlsocksrv = param->remsock;
if(socksend(param, param->ctrlsock, (unsigned char *)"220 Ready\r\n", 11, param->srv->timeouts[STRING_S])!=11) {RETURN (801);}
status = 1;
@@ -62,7 +62,7 @@ void * ftpprchild(struct clientparam* param) {
else if (!strncasecmp((char *)buf, "USER ", 5)){
if(parseconnusername((char *)buf +5, param, 0, 21)){RETURN(804);}
if(!status){
if((res = (*param->srv->authfunc)(param))) {RETURN(res);}
if((res = clientauth(param))) {RETURN(res);}
param->ctrlsocksrv = param->remsock;
}
if(socksend(param, param->ctrlsock, (unsigned char *)"331 ok\r\n", 8, param->srv->timeouts[STRING_S])!=8) {RETURN (807);}