mirror of
https://github.com/osmarks/ngircd.git
synced 2025-08-29 08:52:20 +00:00
Do IDENT requests even when DNS lookups are disabled
Without this patch, disabling DNS in the configuration disabled IDENT lookups as well (for no good reason). This patch allows enabling/disabling DNS lookups and IDENT requests completely separately and enhances the messages sent to the client when "NoticeBeforeRegistration" is enabled, too. Thanks for reporting this, Miniontoby! Closes #291.
This commit is contained in:
parent
499ca9ce6f
commit
00dc9d2845
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* ngIRCd -- The Next Generation IRC Daemon
|
* ngIRCd -- The Next Generation IRC Daemon
|
||||||
* Copyright (c)2001-2019 Alexander Barton (alex@barton.de) and Contributors.
|
* Copyright (c)2001-2024 Alexander Barton (alex@barton.de) and Contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -1485,10 +1485,6 @@ Conn_StartLogin(CONN_ID Idx)
|
|||||||
|
|
||||||
assert(Idx >= 0);
|
assert(Idx >= 0);
|
||||||
|
|
||||||
/* Nothing to do if DNS (and resolver subprocess) is disabled */
|
|
||||||
if (!Conf_DNS)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#ifdef IDENTAUTH
|
#ifdef IDENTAUTH
|
||||||
/* Should we make an IDENT request? */
|
/* Should we make an IDENT request? */
|
||||||
if (Conf_Ident)
|
if (Conf_Ident)
|
||||||
@ -1498,13 +1494,21 @@ Conn_StartLogin(CONN_ID Idx)
|
|||||||
if (Conf_NoticeBeforeRegistration) {
|
if (Conf_NoticeBeforeRegistration) {
|
||||||
/* Send "NOTICE *" messages to the client */
|
/* Send "NOTICE *" messages to the client */
|
||||||
#ifdef IDENTAUTH
|
#ifdef IDENTAUTH
|
||||||
if (Conf_Ident)
|
if (Conf_Ident) {
|
||||||
(void)Conn_WriteStr(Idx,
|
if (Conf_DNS)
|
||||||
"NOTICE * :*** Looking up your hostname and checking ident");
|
(void)Conn_WriteStr(Idx,
|
||||||
else
|
"NOTICE * :*** Looking up your hostname and checking ident");
|
||||||
|
else
|
||||||
|
(void)Conn_WriteStr(Idx,
|
||||||
|
"NOTICE * :*** Checking ident");
|
||||||
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
if(Conf_DNS)
|
||||||
(void)Conn_WriteStr(Idx,
|
(void)Conn_WriteStr(Idx,
|
||||||
"NOTICE * :*** Looking up your hostname");
|
"NOTICE * :*** Looking up your hostname");
|
||||||
|
else
|
||||||
|
(void)Conn_WriteStr(Idx,
|
||||||
|
"NOTICE * :*** Processing your connection");
|
||||||
/* Send buffered data to the client, but break on errors
|
/* Send buffered data to the client, but break on errors
|
||||||
* because Handle_Write() would have closed the connection
|
* because Handle_Write() would have closed the connection
|
||||||
* again in this case! */
|
* again in this case! */
|
||||||
@ -1512,8 +1516,9 @@ Conn_StartLogin(CONN_ID Idx)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Resolve_Addr(&My_Connections[Idx].proc_stat, &My_Connections[Idx].addr,
|
Resolve_Addr_Ident(&My_Connections[Idx].proc_stat,
|
||||||
ident_sock, cb_Read_Resolver_Result);
|
&My_Connections[Idx].addr,
|
||||||
|
ident_sock, cb_Read_Resolver_Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2298,13 +2303,16 @@ cb_Read_Resolver_Result( int r_fd, UNUSED short events )
|
|||||||
* the resolver results, so we don't have to worry to override settings
|
* the resolver results, so we don't have to worry to override settings
|
||||||
* from these commands here. */
|
* from these commands here. */
|
||||||
if(Client_Type(c) == CLIENT_UNKNOWN) {
|
if(Client_Type(c) == CLIENT_UNKNOWN) {
|
||||||
strlcpy(My_Connections[i].host, readbuf,
|
if (readbuf[0]) {
|
||||||
sizeof(My_Connections[i].host));
|
/* We got a hostname */
|
||||||
Client_SetHostname(c, readbuf);
|
strlcpy(My_Connections[i].host, readbuf,
|
||||||
if (Conf_NoticeBeforeRegistration)
|
sizeof(My_Connections[i].host));
|
||||||
(void)Conn_WriteStr(i,
|
Client_SetHostname(c, readbuf);
|
||||||
|
if (Conf_NoticeBeforeRegistration)
|
||||||
|
(void)Conn_WriteStr(i,
|
||||||
"NOTICE * :*** Found your hostname: %s",
|
"NOTICE * :*** Found your hostname: %s",
|
||||||
My_Connections[i].host);
|
My_Connections[i].host);
|
||||||
|
}
|
||||||
#ifdef IDENTAUTH
|
#ifdef IDENTAUTH
|
||||||
++identptr;
|
++identptr;
|
||||||
if (*identptr) {
|
if (*identptr) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* ngIRCd -- The Next Generation IRC Daemon
|
* ngIRCd -- The Next Generation IRC Daemon
|
||||||
* Copyright (c)2001-2014 Alexander Barton (alex@barton.de) and Contributors.
|
* Copyright (c)2001-2024 Alexander Barton (alex@barton.de) and Contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#include "resolve.h"
|
#include "resolve.h"
|
||||||
|
|
||||||
static void Do_ResolveAddr PARAMS(( const ng_ipaddr_t *Addr, int Sock, int w_fd ));
|
static void Do_ResolveAddr_Ident PARAMS(( const ng_ipaddr_t *Addr, int Sock, int w_fd ));
|
||||||
static void Do_ResolveName PARAMS(( const char *Host, int w_fd ));
|
static void Do_ResolveName PARAMS(( const char *Host, int w_fd ));
|
||||||
|
|
||||||
#ifdef WANT_IPV6
|
#ifdef WANT_IPV6
|
||||||
@ -52,11 +52,11 @@ extern bool Conf_ConnectIPv6;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve IP (asynchronous!).
|
* Resolve IP address and do IDENT lookup asynchronously.
|
||||||
*/
|
*/
|
||||||
GLOBAL bool
|
GLOBAL bool
|
||||||
Resolve_Addr(PROC_STAT * s, const ng_ipaddr_t *Addr, int identsock,
|
Resolve_Addr_Ident(PROC_STAT * s, const ng_ipaddr_t *Addr, int identsock,
|
||||||
void (*cbfunc) (int, short))
|
void (*cbfunc) (int, short))
|
||||||
{
|
{
|
||||||
int pipefd[2];
|
int pipefd[2];
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
@ -71,7 +71,7 @@ Resolve_Addr(PROC_STAT * s, const ng_ipaddr_t *Addr, int identsock,
|
|||||||
/* Sub process */
|
/* Sub process */
|
||||||
Log_Init_Subprocess("Resolver");
|
Log_Init_Subprocess("Resolver");
|
||||||
Conn_CloseAllSockets(identsock);
|
Conn_CloseAllSockets(identsock);
|
||||||
Do_ResolveAddr(Addr, identsock, pipefd[1]);
|
Do_ResolveAddr_Ident(Addr, identsock, pipefd[1]);
|
||||||
Log_Exit_Subprocess("Resolver");
|
Log_Exit_Subprocess("Resolver");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@ -356,7 +356,7 @@ ArrayWrite(int fd, const array *a)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Do_ResolveAddr(const ng_ipaddr_t *Addr, int identsock, int w_fd)
|
Do_ResolveAddr_Ident(const ng_ipaddr_t *Addr, int identsock, int w_fd)
|
||||||
{
|
{
|
||||||
/* Resolver sub-process: resolve IP address and write result into
|
/* Resolver sub-process: resolve IP address and write result into
|
||||||
* pipe to parent. */
|
* pipe to parent. */
|
||||||
@ -365,8 +365,15 @@ Do_ResolveAddr(const ng_ipaddr_t *Addr, int identsock, int w_fd)
|
|||||||
size_t len;
|
size_t len;
|
||||||
array resolved_addr;
|
array resolved_addr;
|
||||||
|
|
||||||
|
hostname[0] = '\0';
|
||||||
array_init(&resolved_addr);
|
array_init(&resolved_addr);
|
||||||
ng_ipaddr_tostr_r(Addr, tmp_ip_str);
|
ng_ipaddr_tostr_r(Addr, tmp_ip_str);
|
||||||
|
|
||||||
|
/* Skip DNS lookup when DNS is disabled; just return an empty ("") host
|
||||||
|
* name but still issue an IDENT query, if supported and enabled. */
|
||||||
|
if (!Conf_DNS)
|
||||||
|
goto dns_done;
|
||||||
|
|
||||||
Log_Subprocess(LOG_DEBUG, "Now resolving %s ...", tmp_ip_str);
|
Log_Subprocess(LOG_DEBUG, "Now resolving %s ...", tmp_ip_str);
|
||||||
if (!ReverseLookup(Addr, hostname, sizeof(hostname)))
|
if (!ReverseLookup(Addr, hostname, sizeof(hostname)))
|
||||||
goto dns_done;
|
goto dns_done;
|
||||||
@ -397,7 +404,7 @@ Do_ResolveAddr(const ng_ipaddr_t *Addr, int identsock, int w_fd)
|
|||||||
ArrayWrite(w_fd, &resolved_addr);
|
ArrayWrite(w_fd, &resolved_addr);
|
||||||
|
|
||||||
array_free(&resolved_addr);
|
array_free(&resolved_addr);
|
||||||
} /* Do_ResolveAddr */
|
} /* Do_ResolveAddr_Ident */
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* ngIRCd -- The Next Generation IRC Daemon
|
* ngIRCd -- The Next Generation IRC Daemon
|
||||||
* Copyright (c)2001-2010 by Alexander Barton (alex@barton.de)
|
* Copyright (c)2001-2024 Alexander Barton (alex@barton.de) and Contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -17,7 +17,7 @@
|
|||||||
* Asynchronous resolver (header)
|
* Asynchronous resolver (header)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL bool Resolve_Addr PARAMS((PROC_STAT * s, const ng_ipaddr_t * Addr,
|
GLOBAL bool Resolve_Addr_Ident PARAMS((PROC_STAT * s, const ng_ipaddr_t * Addr,
|
||||||
int identsock, void (*cbfunc) (int, short)));
|
int identsock, void (*cbfunc) (int, short)));
|
||||||
GLOBAL bool Resolve_Name PARAMS((PROC_STAT * s, const char *Host,
|
GLOBAL bool Resolve_Name PARAMS((PROC_STAT * s, const char *Host,
|
||||||
void (*cbfunc) (int, short)));
|
void (*cbfunc) (int, short)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user