1
0
Fork 0
mirror of https://repo.or.cz/socat.git synced 2025-07-10 06:06:33 +00:00

On bad parameter number print syntax; struct single pointers are now mostly called sfd

This commit is contained in:
Gerhard Rieger 2023-07-13 09:06:35 +02:00
parent 5eebca3a5b
commit 50b199dcd9
42 changed files with 1354 additions and 1163 deletions

View file

@ -32,42 +32,44 @@ int allow_severity=10, deny_severity=10;
/* returns 0 if option was found and could be applied
returns 1 if option was not found
returns -1 if option was found but failed */
int xio_retropt_tcpwrap(xiosingle_t *xfd, struct opt *opts) {
int xio_retropt_tcpwrap(
struct single *sfd,
struct opt *opts) {
bool dolibwrap = false;
dolibwrap =
retropt_string(opts, OPT_TCPWRAPPERS,
&xfd->para.socket.ip.libwrapname) >= 0 || dolibwrap;
&sfd->para.socket.ip.libwrapname) >= 0 || dolibwrap;
dolibwrap =
retropt_string(opts, OPT_TCPWRAP_ETC,
&xfd->para.socket.ip.tcpwrap_etc) >= 0 || dolibwrap;
&sfd->para.socket.ip.tcpwrap_etc) >= 0 || dolibwrap;
#if defined(HAVE_HOSTS_ALLOW_TABLE)
dolibwrap =
retropt_string(opts, OPT_TCPWRAP_HOSTS_ALLOW_TABLE,
&xfd->para.socket.ip.hosts_allow_table) >= 0 || dolibwrap;
&sfd->para.socket.ip.hosts_allow_table) >= 0 || dolibwrap;
#endif
#if defined(HAVE_HOSTS_DENY_TABLE)
dolibwrap =
retropt_string(opts, OPT_TCPWRAP_HOSTS_DENY_TABLE,
&xfd->para.socket.ip.hosts_deny_table) >= 0 || dolibwrap;
&sfd->para.socket.ip.hosts_deny_table) >= 0 || dolibwrap;
#endif
if (dolibwrap) {
xfd->para.socket.ip.dolibwrap = true;
if (xfd->para.socket.ip.libwrapname == NULL) {
xfd->para.socket.ip.libwrapname = (char *)diag_get_string('p');
sfd->para.socket.ip.dolibwrap = true;
if (sfd->para.socket.ip.libwrapname == NULL) {
sfd->para.socket.ip.libwrapname = (char *)diag_get_string('p');
}
#if defined(HAVE_HOSTS_ALLOW_TABLE) || defined(HAVE_HOSTS_DENY_TABLE)
if (xfd->para.socket.ip.tcpwrap_etc) {
if (xfd->para.socket.ip.hosts_allow_table == NULL) {
xfd->para.socket.ip.hosts_allow_table =
Malloc(strlen(xfd->para.socket.ip.tcpwrap_etc)+1+11+1);
sprintf(xfd->para.socket.ip.hosts_allow_table, "%s/hosts.allow",
xfd->para.socket.ip.tcpwrap_etc);
if (sfd->para.socket.ip.tcpwrap_etc) {
if (sfd->para.socket.ip.hosts_allow_table == NULL) {
sfd->para.socket.ip.hosts_allow_table =
Malloc(strlen(sfd->para.socket.ip.tcpwrap_etc)+1+11+1);
sprintf(sfd->para.socket.ip.hosts_allow_table, "%s/hosts.allow",
sfd->para.socket.ip.tcpwrap_etc);
}
if (xfd->para.socket.ip.hosts_deny_table == NULL) {
xfd->para.socket.ip.hosts_deny_table =
Malloc(strlen(xfd->para.socket.ip.tcpwrap_etc)+1+10+1);
sprintf(xfd->para.socket.ip.hosts_deny_table, "%s/hosts.deny",
xfd->para.socket.ip.tcpwrap_etc);
if (sfd->para.socket.ip.hosts_deny_table == NULL) {
sfd->para.socket.ip.hosts_deny_table =
Malloc(strlen(sfd->para.socket.ip.tcpwrap_etc)+1+10+1);
sprintf(sfd->para.socket.ip.hosts_deny_table, "%s/hosts.deny",
sfd->para.socket.ip.tcpwrap_etc);
}
}
#endif /* defined(HAVE_HOSTS_ALLOW_TABLE) || defined(HAVE_HOSTS_DENY_TABLE) */
@ -79,8 +81,10 @@ int xio_retropt_tcpwrap(xiosingle_t *xfd, struct opt *opts) {
/* returns -1 if forbidden, 0 if no tcpwrap check, or 1 if explicitely allowed
*/
int xio_tcpwrap_check(xiosingle_t *xfd, union sockaddr_union *us,
union sockaddr_union *them) {
int xio_tcpwrap_check(
struct single *sfd,
union sockaddr_union *us,
union sockaddr_union *them) {
char *save_hosts_allow_table, *save_hosts_deny_table;
struct request_info ri;
#if WITH_IP6
@ -90,25 +94,25 @@ int xio_tcpwrap_check(xiosingle_t *xfd, union sockaddr_union *us,
#endif
int allow;
if (!xfd->para.socket.ip.dolibwrap) {
if (!sfd->para.socket.ip.dolibwrap) {
return 0;
}
if (us == NULL || them == NULL) { return -1; }
#if defined(HAVE_HOSTS_ALLOW_TABLE)
save_hosts_allow_table = hosts_allow_table;
if (xfd->para.socket.ip.hosts_allow_table) {
if (sfd->para.socket.ip.hosts_allow_table) {
Debug1("hosts_allow_table = \"%s\"",
xfd->para.socket.ip.hosts_allow_table);
hosts_allow_table = xfd->para.socket.ip.hosts_allow_table;
sfd->para.socket.ip.hosts_allow_table);
hosts_allow_table = sfd->para.socket.ip.hosts_allow_table;
}
#endif /* defined(HAVE_HOSTS_ALLOW_TABLE) */
#if defined(HAVE_HOSTS_DENY_TABLE)
save_hosts_deny_table = hosts_deny_table;
if (xfd->para.socket.ip.hosts_deny_table) {
if (sfd->para.socket.ip.hosts_deny_table) {
Debug1("hosts_deny_table = \"%s\"",
xfd->para.socket.ip.hosts_deny_table);
hosts_deny_table = xfd->para.socket.ip.hosts_deny_table;
sfd->para.socket.ip.hosts_deny_table);
hosts_deny_table = sfd->para.socket.ip.hosts_deny_table;
}
#endif /* defined(HAVE_HOSTS_DENY_TABLE) */
@ -132,14 +136,14 @@ int xio_tcpwrap_check(xiosingle_t *xfd, union sockaddr_union *us,
Warn1("inet_ntop(): %s", strerror(errno));
}
Debug7("request_init(%p, RQ_FILE, %d, RQ_CLIENT_SIN, {%s:%u}, RQ_SERVER_SIN, {%s:%u}, RQ_DAEMON, \"%s\", 0",
&ri, xfd->fd, clientaddr,
&ri, sfd->fd, clientaddr,
ntohs(((struct sockaddr_in *)them)->sin_port),
serveraddr, ntohs(us->ip4.sin_port),
xfd->para.socket.ip.libwrapname?xfd->para.socket.ip.libwrapname:(char *)diag_get_string('p'));
request_init(&ri, RQ_FILE, xfd->fd,
sfd->para.socket.ip.libwrapname?sfd->para.socket.ip.libwrapname:(char *)diag_get_string('p'));
request_init(&ri, RQ_FILE, sfd->fd,
RQ_CLIENT_SIN, them,
RQ_SERVER_SIN, &us->soa,
RQ_DAEMON, xfd->para.socket.ip.libwrapname?xfd->para.socket.ip.libwrapname:(char *)diag_get_string('p'), 0);
RQ_DAEMON, sfd->para.socket.ip.libwrapname?sfd->para.socket.ip.libwrapname:(char *)diag_get_string('p'), 0);
Debug("request_init() ->");
Debug1("sock_methods(%p)", &ri);