lists.barton.de
Anmelden
Registrieren
Anmelden
Registrieren
Diese Liste verwalten
×
Tastenkürzel
Thread-Ansicht
j
: Nächste ungelesene Nachricht
k
: Vorherige ungelesene Nachricht
j a
: Zu allen Threads wechseln
j l
: Zur Listenübersicht springen
2024
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2023
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2022
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2021
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2020
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2019
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2018
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2017
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2016
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2015
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2014
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2013
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2012
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2011
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2010
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2009
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2008
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2007
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2006
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Februar
Januar
2005
Dezember
November
Oktober
September
August
Juli
Juni
Mai
April
März
Listenübersicht
Herunterladen
ngIRCd GIT Updates
Juli 2010
----- 2024 -----
Dezember 2024
November 2024
Oktober 2024
September 2024
August 2024
Juli 2024
Juni 2024
Mai 2024
April 2024
März 2024
Februar 2024
Januar 2024
----- 2023 -----
Dezember 2023
November 2023
Oktober 2023
September 2023
August 2023
Juli 2023
Juni 2023
Mai 2023
April 2023
März 2023
Februar 2023
Januar 2023
----- 2022 -----
Dezember 2022
November 2022
Oktober 2022
September 2022
August 2022
Juli 2022
Juni 2022
Mai 2022
April 2022
März 2022
Februar 2022
Januar 2022
----- 2021 -----
Dezember 2021
November 2021
Oktober 2021
September 2021
August 2021
Juli 2021
Juni 2021
Mai 2021
April 2021
März 2021
Februar 2021
Januar 2021
----- 2020 -----
Dezember 2020
November 2020
Oktober 2020
September 2020
August 2020
Juli 2020
Juni 2020
Mai 2020
April 2020
März 2020
Februar 2020
Januar 2020
----- 2019 -----
Dezember 2019
November 2019
Oktober 2019
September 2019
August 2019
Juli 2019
Juni 2019
Mai 2019
April 2019
März 2019
Februar 2019
Januar 2019
----- 2018 -----
Dezember 2018
November 2018
Oktober 2018
September 2018
August 2018
Juli 2018
Juni 2018
Mai 2018
April 2018
März 2018
Februar 2018
Januar 2018
----- 2017 -----
Dezember 2017
November 2017
Oktober 2017
September 2017
August 2017
Juli 2017
Juni 2017
Mai 2017
April 2017
März 2017
Februar 2017
Januar 2017
----- 2016 -----
Dezember 2016
November 2016
Oktober 2016
September 2016
August 2016
Juli 2016
Juni 2016
Mai 2016
April 2016
März 2016
Februar 2016
Januar 2016
----- 2015 -----
Dezember 2015
November 2015
Oktober 2015
September 2015
August 2015
Juli 2015
Juni 2015
Mai 2015
April 2015
März 2015
Februar 2015
Januar 2015
----- 2014 -----
Dezember 2014
November 2014
Oktober 2014
September 2014
August 2014
Juli 2014
Juni 2014
Mai 2014
April 2014
März 2014
Februar 2014
Januar 2014
----- 2013 -----
Dezember 2013
November 2013
Oktober 2013
September 2013
August 2013
Juli 2013
Juni 2013
Mai 2013
April 2013
März 2013
Februar 2013
Januar 2013
----- 2012 -----
Dezember 2012
November 2012
Oktober 2012
September 2012
August 2012
Juli 2012
Juni 2012
Mai 2012
April 2012
März 2012
Februar 2012
Januar 2012
----- 2011 -----
Dezember 2011
November 2011
Oktober 2011
September 2011
August 2011
Juli 2011
Juni 2011
Mai 2011
April 2011
März 2011
Februar 2011
Januar 2011
----- 2010 -----
Dezember 2010
November 2010
Oktober 2010
September 2010
August 2010
Juli 2010
Juni 2010
Mai 2010
April 2010
März 2010
Februar 2010
Januar 2010
----- 2009 -----
Dezember 2009
November 2009
Oktober 2009
September 2009
August 2009
Juli 2009
Juni 2009
Mai 2009
April 2009
März 2009
Februar 2009
Januar 2009
----- 2008 -----
Dezember 2008
November 2008
Oktober 2008
September 2008
August 2008
Juli 2008
Juni 2008
Mai 2008
April 2008
März 2008
Februar 2008
Januar 2008
----- 2007 -----
Dezember 2007
November 2007
Oktober 2007
September 2007
August 2007
Juli 2007
Juni 2007
Mai 2007
April 2007
März 2007
Februar 2007
Januar 2007
----- 2006 -----
Dezember 2006
November 2006
Oktober 2006
September 2006
August 2006
Juli 2006
Juni 2006
Mai 2006
April 2006
März 2006
Februar 2006
Januar 2006
----- 2005 -----
Dezember 2005
November 2005
Oktober 2005
September 2005
August 2005
Juli 2005
Juni 2005
Mai 2005
April 2005
März 2005
ngircd-commits@lists.barton.de
2 Teilnehmer
36 Diskussionen
Einen n
N
euen Thread beginnen
Alexander Barton : New functions Client_[Set]OrigUser() to get/ set user specified by peer
by alex@arthur.barton.de
14 Jul '10
14 Jul '10
Module: ngircd.git Branch: master Commit: 1995af0ed62a4bbf544e0b5d9e0613fc912c9e3b URL:
http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=1995af0e…
Author: Alexander Barton <alex(a)barton.de> Date: Sun Jul 11 17:03:43 2010 +0200 New functions Client_[Set]OrigUser() to get/set user specified by peer The Client_SetOrigUser() function is used to store the peer-provided user name (see USER command) in its original form, not changed by IDENT results, for example. --- src/ngircd/client.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- src/ngircd/client.h | 7 +++++++ src/ngircd/irc-login.c | 3 +++ 3 files changed, 57 insertions(+), 1 deletions(-) diff --git a/src/ngircd/client.c b/src/ngircd/client.c index e6dbf15..44123ea 100644 --- a/src/ngircd/client.c +++ b/src/ngircd/client.c @@ -200,8 +200,10 @@ Init_New_Client(CONN_ID Idx, CLIENT *Introducer, CLIENT *TopServer, client->type = Type; if (ID) Client_SetID(client, ID); - if (User) + if (User) { Client_SetUser(client, User, Idented); + Client_SetOrigUser(client, User); + } if (Hostname) Client_SetHostname(client, Hostname); if (Info) @@ -352,6 +354,25 @@ Client_SetUser( CLIENT *Client, const char *User, bool Idented ) } /* Client_SetUser */ +/** + * Set "original" user name of a client. + * This function saves the "original" user name, the user name specified by + * the peer using the USER command, into the CLIENT structure. This user + * name may be used for authentication, for example. + * @param Client The client. + * @param User User name to set. + */ +GLOBAL void +Client_SetOrigUser(CLIENT *Client, const char *User) { + assert(Client != NULL); + assert(User != NULL); + +#ifdef PAM & IDENTAUTH + strlcpy(Client->orig_user, User, sizeof(Client->orig_user)); +#endif +} /* Client_SetOrigUser */ + + GLOBAL void Client_SetInfo( CLIENT *Client, const char *Info ) { @@ -601,6 +622,31 @@ Client_User( CLIENT *Client ) } /* Client_User */ +#ifdef PAM + +/** + * Get the "original" user name as supplied by the USER command. + * The user name as given by the client is used for authentication instead + * of the one detected using IDENT requests. + * @param Client The client. + * @return Original user name. + */ +GLOBAL char * +Client_OrigUser(CLIENT *Client) { +#ifndef IDENTAUTH + char *user = Client->user; + + if (user[0] == '~') + user++; + return user; +#else + return Client->orig_user; +#endif +} /* Client_OrigUser */ + +#endif + + GLOBAL char * Client_Hostname( CLIENT *Client ) { diff --git a/src/ngircd/client.h b/src/ngircd/client.h index 90fd6f2..352ddf3 100644 --- a/src/ngircd/client.h +++ b/src/ngircd/client.h @@ -43,6 +43,9 @@ typedef struct _CLIENT char pwd[CLIENT_PASS_LEN]; /* password received of the client */ char host[CLIENT_HOST_LEN]; /* hostname of the client */ char user[CLIENT_USER_LEN]; /* user name ("login") */ +#ifdef PAM & IDENTAUTH + char orig_user[CLIENT_USER_LEN];/* user name supplied by USER command */ +#endif char info[CLIENT_INFO_LEN]; /* long user name (user) / info text (server) */ char modes[CLIENT_MODE_LEN]; /* client modes */ int hops, token, mytoken; /* "hops" and "Token" (see SERVER command) */ @@ -92,6 +95,9 @@ GLOBAL char *Client_ID PARAMS(( CLIENT *Client )); GLOBAL char *Client_Mask PARAMS(( CLIENT *Client )); GLOBAL char *Client_Info PARAMS(( CLIENT *Client )); GLOBAL char *Client_User PARAMS(( CLIENT *Client )); +#ifdef PAM +GLOBAL char *Client_OrigUser PARAMS(( CLIENT *Client )); +#endif GLOBAL char *Client_Hostname PARAMS(( CLIENT *Client )); GLOBAL char *Client_Password PARAMS(( CLIENT *Client )); GLOBAL char *Client_Modes PARAMS(( CLIENT *Client )); @@ -111,6 +117,7 @@ GLOBAL bool Client_HasMode PARAMS(( CLIENT *Client, char Mode )); GLOBAL void Client_SetHostname PARAMS(( CLIENT *Client, const char *Hostname )); GLOBAL void Client_SetID PARAMS(( CLIENT *Client, const char *Nick )); GLOBAL void Client_SetUser PARAMS(( CLIENT *Client, const char *User, bool Idented )); +GLOBAL void Client_SetOrigUser PARAMS(( CLIENT *Client, const char *User )); GLOBAL void Client_SetInfo PARAMS(( CLIENT *Client, const char *Info )); GLOBAL void Client_SetPassword PARAMS(( CLIENT *Client, const char *Pwd )); GLOBAL void Client_SetType PARAMS(( CLIENT *Client, int Type )); diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c index 5a52d3c..906b669 100644 --- a/src/ngircd/irc-login.c +++ b/src/ngircd/irc-login.c @@ -401,6 +401,7 @@ IRC_USER(CLIENT * Client, REQUEST * Req) #else Client_SetUser(Client, Req->argv[0], false); #endif + Client_SetOrigUser(Client, Req->argv[0]); /* "Real name" or user info text: Don't set it to the empty * string, the original ircd can't deal with such "real names" @@ -433,6 +434,7 @@ IRC_USER(CLIENT * Client, REQUEST * Req) Req->prefix); Client_SetUser(c, Req->argv[0], true); + Client_SetOrigUser(c, Req->argv[0]); Client_SetHostname(c, Req->argv[1]); Client_SetInfo(c, Req->argv[3]); @@ -575,6 +577,7 @@ IRC_WEBIRC(CLIENT *Client, REQUEST *Req) Client_Conn(Client), Req->argv[1], Req->argv[2], Req->argv[3]); Client_SetUser(Client, Req->argv[1], true); + Client_SetOrigUser(Client, Req->argv[1]); Client_SetHostname(Client, Req->argv[2]); return CONNECTED; } /* IRC_WEBIRC */
1
0
0
0
Alexander Barton : Detect PAM libraries
by alex@arthur.barton.de
14 Jul '10
14 Jul '10
Module: ngircd.git Branch: master Commit: 761b2284b953de0d5c2f847e55e3fbc030243178 URL:
http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=761b2284…
Author: Alexander Barton <alex(a)barton.de> Date: Sun Jul 11 17:01:45 2010 +0200 Detect PAM libraries --- INSTALL | 6 ++++++ configure.in | 34 +++++++++++++++++++++++++++++++++- src/ngircd/conf.c | 8 ++++++++ src/ngircd/ngircd.c | 14 +++++--------- 4 files changed, 52 insertions(+), 10 deletions(-) diff --git a/INSTALL b/INSTALL index 60e7b5e..f84ee3f 100644 --- a/INSTALL +++ b/INSTALL @@ -184,6 +184,12 @@ standard locations. to the daemon, for example by using "/etc/hosts.{allow|deny}". The "libwrap" is required for this option. +* PAM: + --with-pam[=<path>] + + Enable support for PAM, the Pluggable Authentication Modules library. + See doc/PAM.txt for details. + IV. Useful make-targets ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/configure.in b/configure.in index 57883ed..79ab22a 100644 --- a/configure.in +++ b/configure.in @@ -33,6 +33,7 @@ AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used]) AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled]) AH_TEMPLATE([ZEROCONF], [Define if support for Zeroconf should be included]) AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests]) +AH_TEMPLATE([PAM], [Define if PAM should be used]) AH_TEMPLATE([HAVE_sockaddr_in_len], [Define if sockaddr_in.sin_len exists]) AH_TEMPLATE([TARGET_OS], [Target operating system name]) @@ -479,6 +480,33 @@ if test "$x_identauth_on" = "yes"; then AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!])) fi +# compile in PAM support? + +x_pam_on=no +AC_ARG_WITH(pam, + [ --with-pam enable user authentication using PAM], + [ if test "$withval" != "no"; then + if test "$withval" != "yes"; then + CFLAGS="-I$withval/include $CFLAGS" + CPPFLAGS="-I$withval/include $CPPFLAGS" + LDFLAGS="-L$withval/lib $LDFLAGS" + fi + AC_CHECK_LIB(pam, pam_authenticate) + AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes, + AC_MSG_ERROR([Can't enable PAM support!]) + ) + fi + ] +) +if test "$x_pam_on" = "yes"; then + AC_DEFINE(PAM, 1) + AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes) + if test "$pam_ok" != "yes"; then + AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes, + AC_MSG_ERROR([required C header missing!])) + fi +fi + # compile in IRC+ protocol support? x_ircplus_on=yes @@ -657,10 +685,14 @@ echo $ECHO_N " I/O backend: $ECHO_C" echo $ECHO_N " IPv6 protocol: $ECHO_C" echo $ECHO_N "$x_ipv6_on $ECHO_C" - echo $ECHO_N " SSL support: $ECHO_C" echo "$x_ssl_lib" +echo $ECHO_N " PAM support: $ECHO_C" +test "$x_pam_on" = "yes" \ + && echo "yes" \ + || echo "no" + echo # -eof- diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index 33a607b..f78eaee 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -291,7 +291,9 @@ Conf_Test( void ) puts( "[GLOBAL]" ); printf(" Name = %s\n", Conf_ServerName); printf(" Info = %s\n", Conf_ServerInfo); +#ifndef PAM printf(" Password = %s\n", Conf_ServerPwd); +#endif printf(" WebircPassword = %s\n", Conf_WebircPwd); printf(" AdminInfo1 = %s\n", Conf_ServerAdmin1); printf(" AdminInfo2 = %s\n", Conf_ServerAdmin2); @@ -1401,6 +1403,12 @@ Validate_Config(bool Configtest, bool Rehash) "No administrative information configured but required by RFC!"); } +#ifdef PAM + if (Conf_ServerPwd[0]) + Config_Error(LOG_ERR, + "This server uses PAM, \"Password\" will be ignored!"); +#endif + #ifdef DEBUG servers = servers_once = 0; for (i = 0; i < MAX_SERVERS; i++) { diff --git a/src/ngircd/ngircd.c b/src/ngircd/ngircd.c index 0319d83..ec42b23 100644 --- a/src/ngircd/ngircd.c +++ b/src/ngircd/ngircd.c @@ -360,7 +360,6 @@ Fill_Version( void ) #ifdef ZLIB if( NGIRCd_VersionAddition[0] ) strlcat( NGIRCd_VersionAddition, "+", sizeof NGIRCd_VersionAddition ); - strlcat( NGIRCd_VersionAddition, "ZLIB", sizeof NGIRCd_VersionAddition ); #endif #ifdef SSL_SUPPORT @@ -370,49 +369,46 @@ Fill_Version( void ) #ifdef TCPWRAP if( NGIRCd_VersionAddition[0] ) strlcat( NGIRCd_VersionAddition, "+", sizeof NGIRCd_VersionAddition ); - strlcat( NGIRCd_VersionAddition, "TCPWRAP", sizeof NGIRCd_VersionAddition ); #endif #ifdef ZEROCONF if( NGIRCd_VersionAddition[0] ) strlcat( NGIRCd_VersionAddition, "+", sizeof NGIRCd_VersionAddition ); - strlcat( NGIRCd_VersionAddition, "ZEROCONF", sizeof NGIRCd_VersionAddition ); #endif #ifdef IDENTAUTH if( NGIRCd_VersionAddition[0] ) strlcat( NGIRCd_VersionAddition, "+", sizeof NGIRCd_VersionAddition ); - strlcat( NGIRCd_VersionAddition, "IDENT", sizeof NGIRCd_VersionAddition ); #endif +#ifdef PAM + if (NGIRCd_VersionAddition[0]) + strlcat(NGIRCd_VersionAddition, "+", sizeof NGIRCd_VersionAddition); + strlcat(NGIRCd_VersionAddition, "PAM", sizeof NGIRCd_VersionAddition); +#endif #ifdef DEBUG if( NGIRCd_VersionAddition[0] ) strlcat( NGIRCd_VersionAddition, "+", sizeof NGIRCd_VersionAddition ); - strlcat( NGIRCd_VersionAddition, "DEBUG", sizeof NGIRCd_VersionAddition ); #endif #ifdef SNIFFER if( NGIRCd_VersionAddition[0] ) strlcat( NGIRCd_VersionAddition, "+", sizeof NGIRCd_VersionAddition ); - strlcat( NGIRCd_VersionAddition, "SNIFFER", sizeof NGIRCd_VersionAddition ); #endif #ifdef STRICT_RFC if( NGIRCd_VersionAddition[0] ) strlcat( NGIRCd_VersionAddition, "+", sizeof NGIRCd_VersionAddition ); - strlcat( NGIRCd_VersionAddition, "RFC", sizeof NGIRCd_VersionAddition ); #endif #ifdef IRCPLUS if( NGIRCd_VersionAddition[0] ) strlcat( NGIRCd_VersionAddition, "+", sizeof NGIRCd_VersionAddition ); - strlcat( NGIRCd_VersionAddition, "IRCPLUS", sizeof NGIRCd_VersionAddition ); #endif #ifdef WANT_IPV6 if (NGIRCd_VersionAddition[0]) strlcat(NGIRCd_VersionAddition, "+", sizeof(NGIRCd_VersionAddition)); - strlcat(NGIRCd_VersionAddition, "IPv6", sizeof(NGIRCd_VersionAddition)); #endif if( NGIRCd_VersionAddition[0] )
1
0
0
0
Alexander Barton : Refactor Resolve_Read() into generic Proc_Read() function
by alex@arthur.barton.de
14 Jul '10
14 Jul '10
Module: ngircd.git Branch: master Commit: 79be1c477e167892b12b77dcef1d298d9d017d3c URL:
http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=79be1c47…
Author: Alexander Barton <alex(a)barton.de> Date: Sun Jul 11 16:58:30 2010 +0200 Refactor Resolve_Read() into generic Proc_Read() function --- src/ngircd/conn.c | 4 ++-- src/ngircd/proc.c | 27 +++++++++++++++++++++++++++ src/ngircd/proc.h | 2 ++ src/ngircd/resolve.c | 28 ---------------------------- src/ngircd/resolve.h | 1 - 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index f4efff1..f059d91 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -1952,7 +1952,7 @@ cb_Connect_to_Server(int fd, UNUSED short events) } /* Read result from pipe */ - len = Resolve_Read(&Conf_Server[i].res_stat, dest_addrs, sizeof(dest_addrs)); + len = Proc_Read(&Conf_Server[i].res_stat, dest_addrs, sizeof(dest_addrs)); if (len == 0) return; @@ -2005,7 +2005,7 @@ cb_Read_Resolver_Result( int r_fd, UNUSED short events ) } /* Read result from pipe */ - len = Resolve_Read(&My_Connections[i].proc_stat, readbuf, sizeof readbuf -1); + len = Proc_Read(&My_Connections[i].proc_stat, readbuf, sizeof readbuf -1); if (len == 0) return; diff --git a/src/ngircd/proc.c b/src/ngircd/proc.c index 3eb3d80..f543883 100644 --- a/src/ngircd/proc.c +++ b/src/ngircd/proc.c @@ -116,4 +116,31 @@ Proc_GenericSignalHandler(int Signal) } } +/** + * Read bytes from a pipe of a forked child process. + */ +GLOBAL size_t +Proc_Read(PROC_STAT *proc, void *buffer, size_t buflen) +{ + ssize_t bytes_read = 0; + + assert(buffer != NULL); + assert(buflen > 0); + + bytes_read = read(proc->pipe_fd, buffer, buflen); + if (bytes_read < 0) { + if (errno == EAGAIN) + return 0; + Log(LOG_CRIT, "Can't read from child process %ld: %s", + proc->pid, strerror(errno)); + bytes_read = 0; + } +#if DEBUG + else if (bytes_read == 0) + LogDebug("Can't read from child process %ld: EOF", proc->pid); +#endif + Proc_Kill(proc); + return (size_t)bytes_read; +} + /* -eof- */ diff --git a/src/ngircd/proc.h b/src/ngircd/proc.h index a7bff4f..40a2c29 100644 --- a/src/ngircd/proc.h +++ b/src/ngircd/proc.h @@ -32,6 +32,8 @@ GLOBAL void Proc_Kill PARAMS((PROC_STAT *proc)); GLOBAL void Proc_GenericSignalHandler PARAMS((int Signal)); +GLOBAL size_t Proc_Read PARAMS((PROC_STAT *proc, void *buffer, size_t buflen)); + #endif /* -eof- */ diff --git a/src/ngircd/resolve.c b/src/ngircd/resolve.c index 26ad103..d121b0a 100644 --- a/src/ngircd/resolve.c +++ b/src/ngircd/resolve.c @@ -462,32 +462,4 @@ Do_ResolveName( const char *Host, int w_fd ) } /* Do_ResolveName */ -/** - * Read result of resolver sub-process from pipe - */ -GLOBAL size_t -Resolve_Read( PROC_STAT *s, void* readbuf, size_t buflen) -{ - ssize_t bytes_read; - - assert(buflen > 0); - - /* Read result from pipe */ - bytes_read = read(Proc_GetPipeFd(s), readbuf, buflen); - if (bytes_read < 0) { - if (errno == EAGAIN) - return 0; - - Log( LOG_CRIT, "Resolver: Can't read result: %s!", strerror(errno)); - bytes_read = 0; - } -#ifdef DEBUG - else if (bytes_read == 0) - Log( LOG_DEBUG, "Resolver: Can't read result: EOF"); -#endif - Proc_Kill(s); - return (size_t)bytes_read; -} - - /* -eof- */ diff --git a/src/ngircd/resolve.h b/src/ngircd/resolve.h index 9759a2c..044ceec 100644 --- a/src/ngircd/resolve.h +++ b/src/ngircd/resolve.h @@ -18,7 +18,6 @@ GLOBAL bool Resolve_Addr PARAMS((PROC_STAT * s, const ng_ipaddr_t * Addr, int identsock, void (*cbfunc) (int, short))); GLOBAL bool Resolve_Name PARAMS((PROC_STAT * s, const char *Host, void (*cbfunc) (int, short))); -GLOBAL size_t Resolve_Read PARAMS((PROC_STAT * s, void *buf, size_t buflen)); #endif
1
0
0
0
Alexander Barton : Make Proc_Kill() more fault-tolerant
by alex@arthur.barton.de
14 Jul '10
14 Jul '10
Module: ngircd.git Branch: master Commit: 7b5e2fe38e7af696155e687924462c4b9fe951bc URL:
http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=7b5e2fe3…
Author: Alexander Barton <alex(a)barton.de> Date: Sun Jul 11 16:54:44 2010 +0200 Make Proc_Kill() more fault-tolerant --- src/ngircd/proc.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ngircd/proc.c b/src/ngircd/proc.c index 75c1aaf..3eb3d80 100644 --- a/src/ngircd/proc.c +++ b/src/ngircd/proc.c @@ -93,10 +93,11 @@ GLOBAL void Proc_Kill(PROC_STAT *proc) { assert(proc != NULL); - assert(proc->pipe_fd >= 0); - io_close(proc->pipe_fd); - kill(proc->pid, SIGTERM); + if (proc->pipe_fd > 0) + io_close(proc->pipe_fd); + if (proc->pid > 0) + kill(proc->pid, SIGTERM); Proc_InitStruct(proc); }
1
0
0
0
Alexander Barton : New function Conn_GetProcStat()
by alex@arthur.barton.de
14 Jul '10
14 Jul '10
Module: ngircd.git Branch: master Commit: bf8b64630443b2bd3fe2a298f860ea0d492df649 URL:
http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=bf8b6463…
Author: Alexander Barton <alex(a)barton.de> Date: Sun Jul 11 15:15:23 2010 +0200 New function Conn_GetProcStat() Get PROC_STAT sub-process structure of a given connection. --- src/ngircd/conn.c | 17 ++++++++++++++++- src/ngircd/conn.h | 3 ++- src/ngircd/resolve.c | 1 - 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index 9da618f..f4efff1 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -68,7 +68,6 @@ #include "log.h" #include "ng_ipaddr.h" #include "parse.h" -#include "proc.h" #include "resolve.h" #include "tool.h" @@ -2099,6 +2098,22 @@ Conn_GetClient( CONN_ID Idx ) return c ? c->client : NULL; } +/** + * Get PROC_STAT sub-process structure of a connection. + * @param Idx Connection index number + * @return PROC_STAT structure + */ +GLOBAL PROC_STAT * +Conn_GetProcStat(CONN_ID Idx) +{ + CONNECTION *c; + + assert(Idx >= 0); + c = array_get(&My_ConnArray, sizeof (CONNECTION), (size_t)Idx); + assert(c != NULL); + return &c->proc_stat; +} /* Conn_GetProcStat */ + /** * Get CONN_ID from file descriptor associated to a subprocess structure. diff --git a/src/ngircd/conn.h b/src/ngircd/conn.h index e9b470b..a63fcbb 100644 --- a/src/ngircd/conn.h +++ b/src/ngircd/conn.h @@ -44,11 +44,11 @@ typedef long CONN_ID; #include "client.h" +#include "proc.h" #ifdef CONN_MODULE #include "defines.h" -#include "proc.h" #include "array.h" #include "tool.h" #include "ng_ipaddr.h" @@ -115,6 +115,7 @@ GLOBAL void Conn_SyncServerStruct PARAMS(( void )); GLOBAL CONN_ID Conn_GetFromProc PARAMS((int fd)); GLOBAL CLIENT* Conn_GetClient PARAMS((CONN_ID i)); +GLOBAL PROC_STAT* Conn_GetProcStat PARAMS((CONN_ID i)); #ifdef SSL_SUPPORT GLOBAL bool Conn_GetCipherInfo PARAMS((CONN_ID Idx, char *buf, size_t len)); GLOBAL bool Conn_UsesSSL PARAMS((CONN_ID Idx)); diff --git a/src/ngircd/resolve.c b/src/ngircd/resolve.c index f8c39cf..26ad103 100644 --- a/src/ngircd/resolve.c +++ b/src/ngircd/resolve.c @@ -35,7 +35,6 @@ #include "defines.h" #include "log.h" #include "ng_ipaddr.h" -#include "proc.h" #include "exp.h" #include "resolve.h"
1
0
0
0
Alexander Barton : Code cleanup: don' t reset penalty time on DNS resolver result
by alex@arthur.barton.de
14 Jul '10
14 Jul '10
Module: ngircd.git Branch: master Commit: e4ffcd00bdbe6d66d419e2f364a0d2dd317202b5 URL:
http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=e4ffcd00…
Author: Alexander Barton <alex(a)barton.de> Date: Sun Jul 11 15:12:17 2010 +0200 Code cleanup: don't reset penalty time on DNS resolver result See commit d4632a727fbee6: it's not necessary any more! --- src/ngircd/conn.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index 4df1e9e..9da618f 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -2049,8 +2049,6 @@ cb_Read_Resolver_Result( int r_fd, UNUSED short events ) #ifdef DEBUG else Log( LOG_DEBUG, "Resolver: discarding result for already registered connection %d.", i ); #endif - /* Reset penalty time */ - Conn_ResetPenalty( i ); } /* cb_Read_Resolver_Result */
1
0
0
0
Alexander Barton : New function Proc_GenericSignalHandler()
by alex@arthur.barton.de
14 Jul '10
14 Jul '10
Module: ngircd.git Branch: master Commit: 4cc4c29e380b24a0f53d99f702d6678f71a31ff3 URL:
http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=4cc4c29e…
Author: Alexander Barton <alex(a)barton.de> Date: Thu Jul 1 00:39:35 2010 +0200 New function Proc_GenericSignalHandler() --- src/ngircd/proc.c | 16 ++++++++++++++++ src/ngircd/proc.h | 2 ++ src/ngircd/resolve.c | 18 +----------------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/ngircd/proc.c b/src/ngircd/proc.c index 5f3cade..75c1aaf 100644 --- a/src/ngircd/proc.c +++ b/src/ngircd/proc.c @@ -18,6 +18,7 @@ #include <errno.h> #include <signal.h> #include <string.h> +#include <stdlib.h> #include <unistd.h> #include "log.h" @@ -99,4 +100,19 @@ Proc_Kill(PROC_STAT *proc) Proc_InitStruct(proc); } +/** + * Generic signal handler for forked child processes. + */ +GLOBAL void +Proc_GenericSignalHandler(int Signal) +{ + switch(Signal) { + case SIGTERM: +#ifdef DEBUG + Log_Subprocess(LOG_DEBUG, "Child got TERM signal, exiting."); +#endif + exit(1); + } +} + /* -eof- */ diff --git a/src/ngircd/proc.h b/src/ngircd/proc.h index c342e1d..a7bff4f 100644 --- a/src/ngircd/proc.h +++ b/src/ngircd/proc.h @@ -30,6 +30,8 @@ GLOBAL pid_t Proc_Fork PARAMS((PROC_STAT *proc, int *pipefds, GLOBAL void Proc_Kill PARAMS((PROC_STAT *proc)); +GLOBAL void Proc_GenericSignalHandler PARAMS((int Signal)); + #endif /* -eof- */ diff --git a/src/ngircd/resolve.c b/src/ngircd/resolve.c index e5ac9ec..f8c39cf 100644 --- a/src/ngircd/resolve.c +++ b/src/ngircd/resolve.c @@ -109,28 +109,12 @@ Resolve_Name( PROC_STAT *s, const char *Host, void (*cbfunc)(int, short)) /** - * Signal handler for the forked resolver subprocess. - */ -static void -Signal_Handler(int Signal) -{ - switch(Signal) { - case SIGTERM: -#ifdef DEBUG - Log_Subprocess(LOG_DEBUG, "Resolver: Got TERM signal, exiting."); -#endif - exit(1); - } -} - - -/** * Initialize forked resolver subprocess. */ static void Init_Subprocess(void) { - signal(SIGTERM, Signal_Handler); + signal(SIGTERM, Proc_GenericSignalHandler); Log_Init_Subprocess("Resolver"); }
1
0
0
0
Alexander Barton : Rename Log_[{Init|Exit}_]Resolver to Log_[{Init|Exit}_] Subprocess
by alex@arthur.barton.de
14 Jul '10
14 Jul '10
Module: ngircd.git Branch: master Commit: 0db9a31e50598db6c01d67ea72e2970256e0558b URL:
http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=0db9a31e…
Author: Alexander Barton <alex(a)barton.de> Date: Thu Jul 1 00:34:56 2010 +0200 Rename Log_[{Init|Exit}_]Resolver to Log_[{Init|Exit}_]Subprocess Rename Log_Init_Resolver, Log_Exit_Resolver, and Log_Resolver to Log_Init_Subprocess, Log_Exit_Subprocess, and Log_Subprocess and make it more generic thereby. --- src/ngircd/log.c | 39 ++++++++++++++++++++------------------- src/ngircd/log.h | 6 +++--- src/ngircd/resolve.c | 50 ++++++++++++++++++++++++++++---------------------- 3 files changed, 51 insertions(+), 44 deletions(-) diff --git a/src/ngircd/log.c b/src/ngircd/log.c index f81c308..c8dbdd3 100644 --- a/src/ngircd/log.c +++ b/src/ngircd/log.c @@ -264,64 +264,65 @@ va_dcl GLOBAL void -Log_Init_Resolver( void ) +Log_Init_Subprocess(char *Name) { #ifdef SYSLOG openlog( PACKAGE_NAME, LOG_CONS|LOG_PID, LOG_LOCAL5 ); #endif #ifdef DEBUG - Log_Resolver(LOG_DEBUG, "Resolver sub-process starting, PID %ld.", (long)getpid()); + Log_Subprocess(LOG_DEBUG, "%s sub-process starting, PID %ld.", + Name, (long)getpid()); #endif -} /* Log_Init_Resolver */ +} GLOBAL void -Log_Exit_Resolver( void ) +Log_Exit_Subprocess(char *Name) { #ifdef DEBUG - Log_Resolver(LOG_DEBUG, "Resolver sub-process %ld done.", (long)getpid()); + Log_Subprocess(LOG_DEBUG, "%s sub-process %ld done.", + Name, (long)getpid()); #endif #ifdef SYSLOG closelog( ); #endif -} /* Log_Exit_Resolver */ +} #ifdef PROTOTYPES GLOBAL void -Log_Resolver( const int Level, const char *Format, ... ) +Log_Subprocess(const int Level, const char *Format, ...) #else GLOBAL void -Log_Resolver( Level, Format, va_alist ) +Log_Subprocess(Level, Format, va_alist) const int Level; const char *Format; va_dcl #endif { - /* Eintrag des Resolver in Logfile(s) schreiben */ - char msg[MAX_LOG_MSG_LEN]; va_list ap; - assert( Format != NULL ); + assert(Format != NULL); #ifdef DEBUG - if(( Level == LOG_DEBUG ) && ( ! NGIRCd_Debug )) return; + if ((Level == LOG_DEBUG) && (!NGIRCd_Debug)) + return; #else - if( Level == LOG_DEBUG ) return; + if (Level == LOG_DEBUG) + return; #endif - /* String mit variablen Argumenten zusammenbauen ... */ #ifdef PROTOTYPES - va_start( ap, Format ); + va_start(ap, Format); #else - va_start( ap ); + va_start(ap); #endif - vsnprintf( msg, MAX_LOG_MSG_LEN, Format, ap ); - va_end( ap ); + vsnprintf(msg, MAX_LOG_MSG_LEN, Format, ap); + va_end(ap); Log_Message(Level, msg); -} /* Log_Resolver */ +} /** diff --git a/src/ngircd/log.h b/src/ngircd/log.h index e7e6b61..9fdb8a2 100644 --- a/src/ngircd/log.h +++ b/src/ngircd/log.h @@ -46,10 +46,10 @@ GLOBAL void LogDebug PARAMS(( const char *Format, ... )); static inline void LogDebug PARAMS(( UNUSED const char *Format, ... )){/* Do nothing. The compiler should optimize this out, please ;-) */} #endif -GLOBAL void Log_Init_Resolver PARAMS(( void )); -GLOBAL void Log_Exit_Resolver PARAMS(( void )); +GLOBAL void Log_Init_Subprocess PARAMS((char *Name)); +GLOBAL void Log_Exit_Subprocess PARAMS((char *Name)); -GLOBAL void Log_Resolver PARAMS(( const int Level, const char *Format, ... )); +GLOBAL void Log_Subprocess PARAMS((const int Level, const char *Format, ...)); #ifdef DEBUG GLOBAL void Log_InitErrorfile PARAMS(( void )); diff --git a/src/ngircd/resolve.c b/src/ngircd/resolve.c index 295a559..e5ac9ec 100644 --- a/src/ngircd/resolve.c +++ b/src/ngircd/resolve.c @@ -72,7 +72,7 @@ Resolve_Addr(PROC_STAT * s, const ng_ipaddr_t *Addr, int identsock, /* Sub process */ Init_Subprocess(); Do_ResolveAddr( Addr, identsock, pipefd[1]); - Log_Exit_Resolver( ); + Log_Exit_Subprocess("Resolver"); exit(0); } return false; @@ -101,7 +101,7 @@ Resolve_Name( PROC_STAT *s, const char *Host, void (*cbfunc)(int, short)) /* Sub process */ Init_Subprocess(); Do_ResolveName(Host, pipefd[1]); - Log_Exit_Resolver( ); + Log_Exit_Subprocess("Resolver"); exit(0); } return false; @@ -117,7 +117,7 @@ Signal_Handler(int Signal) switch(Signal) { case SIGTERM: #ifdef DEBUG - Log_Resolver(LOG_DEBUG, "Resolver: Got TERM signal, exiting."); + Log_Subprocess(LOG_DEBUG, "Resolver: Got TERM signal, exiting."); #endif exit(1); } @@ -131,7 +131,7 @@ static void Init_Subprocess(void) { signal(SIGTERM, Signal_Handler); - Log_Init_Resolver(); + Log_Init_Subprocess("Resolver"); } @@ -168,17 +168,20 @@ Do_IdentQuery(int identsock, array *resolved_addr) return; #ifdef DEBUG - Log_Resolver(LOG_DEBUG, "Doing IDENT lookup on socket %d ...", identsock); + Log_Subprocess(LOG_DEBUG, "Doing IDENT lookup on socket %d ...", + identsock); #endif res = ident_id( identsock, 10 ); #ifdef DEBUG - Log_Resolver(LOG_DEBUG, "Ok, IDENT lookup on socket %d done: \"%s\"", - identsock, res ? res : "(NULL)" ); + Log_Subprocess(LOG_DEBUG, "Ok, IDENT lookup on socket %d done: \"%s\"", + identsock, res ? res : "(NULL)"); #endif if (!res) /* no result */ return; if (!array_cats(resolved_addr, res)) - Log_Resolver(LOG_WARNING, "Resolver: Cannot copy IDENT result: %s!", strerror(errno)); + Log_Subprocess(LOG_WARNING, + "Resolver: Cannot copy IDENT result: %s!", + strerror(errno)); free(res); #else @@ -240,7 +243,7 @@ ReverseLookup(const ng_ipaddr_t *IpAddr, char *resbuf, size_t reslen) assert(reslen >= NG_INET_ADDRSTRLEN); ng_ipaddr_tostr_r(IpAddr, tmp_ip_str); - Log_Resolver(LOG_WARNING, "%s: Can't resolve address \"%s\": %s", + Log_Subprocess(LOG_WARNING, "%s: Can't resolve address \"%s\": %s", funcname, tmp_ip_str, errmsg); strlcpy(resbuf, tmp_ip_str, reslen); return false; @@ -288,10 +291,10 @@ ForwardLookup(const char *hostname, array *IpAddr) switch (res) { case 0: break; case EAI_SYSTEM: - Log_Resolver(LOG_WARNING, "Can't resolve \"%s\": %s", hostname, strerror(errno)); + Log_Subprocess(LOG_WARNING, "Can't resolve \"%s\": %s", hostname, strerror(errno)); return false; default: - Log_Resolver(LOG_WARNING, "Can't resolve \"%s\": %s", hostname, gai_strerror(res)); + Log_Subprocess(LOG_WARNING, "Can't resolve \"%s\": %s", hostname, gai_strerror(res)); return false; } @@ -314,9 +317,10 @@ ForwardLookup(const char *hostname, array *IpAddr) if (!h) { #ifdef h_errno - Log_Resolver(LOG_WARNING, "Can't resolve \"%s\": %s", hostname, Get_Error(h_errno)); + Log_Subprocess(LOG_WARNING, "Can't resolve \"%s\": %s", + hostname, Get_Error(h_errno)); #else - Log_Resolver(LOG_WARNING, "Can't resolve \"%s\"", hostname); + Log_Subprocess(LOG_WARNING, "Can't resolve \"%s\"", hostname); #endif return false; } @@ -352,7 +356,7 @@ Addr_in_list(const array *resolved_addr, const ng_ipaddr_t *Addr) tmpAddrs = array_start(resolved_addr); while (len > 0) { - Log_Resolver(LOG_WARNING, "Address mismatch: %s != %s", + Log_Subprocess(LOG_WARNING, "Address mismatch: %s != %s", tmp_ip_str, ng_ipaddr_tostr(tmpAddrs)); tmpAddrs++; len--; @@ -365,14 +369,14 @@ Addr_in_list(const array *resolved_addr, const ng_ipaddr_t *Addr) static void Log_Forgery_NoIP(const char *ip, const char *host) { - Log_Resolver(LOG_WARNING, "Possible forgery: %s resolved to %s " + Log_Subprocess(LOG_WARNING, "Possible forgery: %s resolved to %s " "(which has no ip address)", ip, host); } static void Log_Forgery_WrongIP(const char *ip, const char *host) { - Log_Resolver(LOG_WARNING,"Possible forgery: %s resolved to %s " + Log_Subprocess(LOG_WARNING,"Possible forgery: %s resolved to %s " "(which points to different address)", ip, host); } @@ -386,7 +390,7 @@ ArrayWrite(int fd, const array *a) assert(data); if( (size_t)write(fd, data, len) != len ) - Log_Resolver( LOG_CRIT, "Resolver: Can't write to parent: %s!", + Log_Subprocess( LOG_CRIT, "Resolver: Can't write to parent: %s!", strerror(errno)); } @@ -404,7 +408,7 @@ Do_ResolveAddr(const ng_ipaddr_t *Addr, int identsock, int w_fd) array_init(&resolved_addr); ng_ipaddr_tostr_r(Addr, tmp_ip_str); #ifdef DEBUG - Log_Resolver(LOG_DEBUG, "Now resolving %s ...", tmp_ip_str); + Log_Subprocess(LOG_DEBUG, "Now resolving %s ...", tmp_ip_str); #endif if (!ReverseLookup(Addr, hostname, sizeof(hostname))) goto dns_done; @@ -419,13 +423,15 @@ Do_ResolveAddr(const ng_ipaddr_t *Addr, int identsock, int w_fd) strlcpy(hostname, tmp_ip_str, sizeof(hostname)); } #ifdef DEBUG - Log_Resolver(LOG_DEBUG, "Ok, translated %s to \"%s\".", tmp_ip_str, hostname); + Log_Subprocess(LOG_DEBUG, "Ok, translated %s to \"%s\".", tmp_ip_str, hostname); #endif dns_done: len = strlen(hostname); hostname[len] = '\n'; if (!array_copyb(&resolved_addr, hostname, ++len)) { - Log_Resolver(LOG_CRIT, "Resolver: Can't copy resolved name: %s!", strerror(errno)); + Log_Subprocess(LOG_CRIT, + "Resolver: Can't copy resolved name: %s!", + strerror(errno)); array_free(&resolved_addr); return; } @@ -448,7 +454,7 @@ Do_ResolveName( const char *Host, int w_fd ) ng_ipaddr_t *addr; size_t len; #endif - Log_Resolver(LOG_DEBUG, "Now resolving \"%s\" ...", Host); + Log_Subprocess(LOG_DEBUG, "Now resolving \"%s\" ...", Host); array_init(&IpAddrs); /* Resolve hostname */ @@ -462,7 +468,7 @@ Do_ResolveName( const char *Host, int w_fd ) addr = array_start(&IpAddrs); assert(addr); for (; len > 0; --len,addr++) { - Log_Resolver(LOG_DEBUG, "translated \"%s\" to %s.", + Log_Subprocess(LOG_DEBUG, "translated \"%s\" to %s.", Host, ng_ipaddr_tostr(addr)); } #endif
1
0
0
0
Alexander Barton : Don't #include client.h when conn.h/conn-func. h is already included
by alex@arthur.barton.de
14 Jul '10
14 Jul '10
Module: ngircd.git Branch: master Commit: 5462c6c50fd01fd516e29a42ee0b15c946c11d27 URL:
http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=5462c6c5…
Author: Alexander Barton <alex(a)barton.de> Date: Wed Jun 30 23:49:52 2010 +0200 Don't #include client.h when conn.h/conn-func.h is already included conn.h and cinn-func.h both already #include client.h, so it is not needed to do it twice. --- src/ngircd/channel.c | 1 - src/ngircd/conf.c | 1 - src/ngircd/irc-channel.c | 1 - src/ngircd/irc-info.c | 1 - src/ngircd/irc-login.c | 1 - src/ngircd/irc-mode.c | 1 - src/ngircd/irc-op.c | 1 - src/ngircd/irc-oper.c | 1 - src/ngircd/irc-server.c | 1 - src/ngircd/irc-write.c | 1 - src/ngircd/irc.c | 1 - src/ngircd/lists.c | 1 - src/ngircd/log.c | 1 - src/ngircd/ngircd.c | 1 - src/ngircd/numeric.c | 1 - src/ngircd/op.c | 1 - src/ngircd/parse.c | 1 - 17 files changed, 0 insertions(+), 17 deletions(-) diff --git a/src/ngircd/channel.c b/src/ngircd/channel.c index 0fa38de..175f23b 100644 --- a/src/ngircd/channel.c +++ b/src/ngircd/channel.c @@ -27,7 +27,6 @@ #include "defines.h" #include "conn-func.h" -#include "client.h" #include "exp.h" #include "channel.h" diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index 43b07b7..33a607b 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -39,7 +39,6 @@ #include "array.h" #include "ngircd.h" #include "conn.h" -#include "client.h" #include "channel.h" #include "defines.h" #include "log.h" diff --git a/src/ngircd/irc-channel.c b/src/ngircd/irc-channel.c index 138a94a..3bf02c6 100644 --- a/src/ngircd/irc-channel.c +++ b/src/ngircd/irc-channel.c @@ -22,7 +22,6 @@ #include "defines.h" #include "conn.h" -#include "client.h" #include "channel.h" #include "conn-func.h" #include "lists.h" diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c index 806ab27..0a50e9f 100644 --- a/src/ngircd/irc-info.c +++ b/src/ngircd/irc-info.c @@ -25,7 +25,6 @@ #include "ngircd.h" #include "conn-func.h" #include "conn-zip.h" -#include "client.h" #include "channel.h" #include "conf.h" #include "defines.h" diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c index cd1899c..5a52d3c 100644 --- a/src/ngircd/irc-login.c +++ b/src/ngircd/irc-login.c @@ -24,7 +24,6 @@ #include "ngircd.h" #include "conn-func.h" #include "conf.h" -#include "client.h" #include "channel.h" #include "log.h" #include "messages.h" diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c index 9a0f397..80a6003 100644 --- a/src/ngircd/irc-mode.c +++ b/src/ngircd/irc-mode.c @@ -22,7 +22,6 @@ #include "defines.h" #include "conn.h" -#include "client.h" #include "channel.h" #include "irc-write.h" #include "lists.h" diff --git a/src/ngircd/irc-op.c b/src/ngircd/irc-op.c index 6cd0104..e4d6f3b 100644 --- a/src/ngircd/irc-op.c +++ b/src/ngircd/irc-op.c @@ -21,7 +21,6 @@ #include "defines.h" #include "conn.h" -#include "client.h" #include "channel.h" #include "irc-write.h" #include "lists.h" diff --git a/src/ngircd/irc-oper.c b/src/ngircd/irc-oper.c index 900c860..a927b19 100644 --- a/src/ngircd/irc-oper.c +++ b/src/ngircd/irc-oper.c @@ -23,7 +23,6 @@ #include "ngircd.h" #include "conn-func.h" #include "conf.h" -#include "client.h" #include "channel.h" #include "irc-write.h" #include "log.h" diff --git a/src/ngircd/irc-server.c b/src/ngircd/irc-server.c index 987513b..e7ff726 100644 --- a/src/ngircd/irc-server.c +++ b/src/ngircd/irc-server.c @@ -26,7 +26,6 @@ #include "conn-func.h" #include "conn-zip.h" #include "conf.h" -#include "client.h" #include "channel.h" #include "irc-write.h" #include "lists.h" diff --git a/src/ngircd/irc-write.c b/src/ngircd/irc-write.c index afefefb..dd592f0 100644 --- a/src/ngircd/irc-write.c +++ b/src/ngircd/irc-write.c @@ -26,7 +26,6 @@ #include "defines.h" #include "conn-func.h" -#include "client.h" #include "channel.h" #include "exp.h" diff --git a/src/ngircd/irc.c b/src/ngircd/irc.c index f913d8d..a1d073c 100644 --- a/src/ngircd/irc.c +++ b/src/ngircd/irc.c @@ -24,7 +24,6 @@ static char UNUSED id[] = "$Id: irc.c,v 1.132 2008/01/15 22:28:14 fw Exp $"; #include "ngircd.h" #include "conn-func.h" #include "conf.h" -#include "client.h" #include "channel.h" #include "defines.h" #include "irc-write.h" diff --git a/src/ngircd/lists.c b/src/ngircd/lists.c index 94069d4..363c62d 100644 --- a/src/ngircd/lists.c +++ b/src/ngircd/lists.c @@ -19,7 +19,6 @@ #include "defines.h" #include "conn.h" -#include "client.h" #include "channel.h" #include "log.h" #include "match.h" diff --git a/src/ngircd/log.c b/src/ngircd/log.c index 439ca41..f81c308 100644 --- a/src/ngircd/log.c +++ b/src/ngircd/log.c @@ -34,7 +34,6 @@ #include "ngircd.h" #include "defines.h" #include "conn.h" -#include "client.h" #include "channel.h" #include "irc-write.h" diff --git a/src/ngircd/ngircd.c b/src/ngircd/ngircd.c index 8b2e4a8..0319d83 100644 --- a/src/ngircd/ngircd.c +++ b/src/ngircd/ngircd.c @@ -41,7 +41,6 @@ #include "defines.h" #include "conn.h" #include "conf-ssl.h" -#include "client.h" #include "channel.h" #include "conf.h" #include "lists.h" diff --git a/src/ngircd/numeric.c b/src/ngircd/numeric.c index b0a7798..0dcfe75 100644 --- a/src/ngircd/numeric.c +++ b/src/ngircd/numeric.c @@ -24,7 +24,6 @@ #include "conf.h" #include "conn.h" #include "conn-func.h" -#include "client.h" #include "channel.h" #include "irc-write.h" #include "lists.h" diff --git a/src/ngircd/op.c b/src/ngircd/op.c index 031bc28..c70be6e 100644 --- a/src/ngircd/op.c +++ b/src/ngircd/op.c @@ -19,7 +19,6 @@ #include <string.h> #include "conn.h" -#include "client.h" #include "channel.h" #include "conf.h" #include "log.h" diff --git a/src/ngircd/parse.c b/src/ngircd/parse.c index 3710d70..95c49a5 100644 --- a/src/ngircd/parse.c +++ b/src/ngircd/parse.c @@ -26,7 +26,6 @@ #include "ngircd.h" #include "defines.h" #include "conn-func.h" -#include "client.h" #include "channel.h" #include "log.h" #include "messages.h"
1
0
0
0
Alexander Barton : New function Conn_GetFromProc() to get CONN_ID of a subprocess
by alex@arthur.barton.de
14 Jul '10
14 Jul '10
Module: ngircd.git Branch: master Commit: 3d49fa5bffac43f2fcf535c8b1aedae732d1f9f5 URL:
http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=3d49fa5b…
Author: Alexander Barton <alex(a)barton.de> Date: Tue Jun 29 23:38:39 2010 +0200 New function Conn_GetFromProc() to get CONN_ID of a subprocess Get CONN_ID from file descriptor associated to a subprocess structure. --- src/ngircd/conn.c | 32 +++++++++++++++++++++++--------- src/ngircd/conn.h | 1 + 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index 0d82d53..4df1e9e 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -1986,7 +1986,7 @@ cb_Read_Resolver_Result( int r_fd, UNUSED short events ) * IDENT user name.*/ CLIENT *c; - int i; + CONN_ID i; size_t len; char *identptr; #ifdef IDENTAUTH @@ -1996,14 +1996,8 @@ cb_Read_Resolver_Result( int r_fd, UNUSED short events ) #endif LogDebug("Resolver: Got callback on fd %d, events %d", r_fd, events ); - - /* Search associated connection ... */ - for( i = 0; i < Pool_Size; i++ ) { - if(( My_Connections[i].sock != NONE ) - && (Proc_GetPipeFd(&My_Connections[i].proc_stat) == r_fd)) - break; - } - if( i >= Pool_Size ) { + i = Conn_GetFromProc(r_fd); + if (i == NONE) { /* Ops, none found? Probably the connection has already * been closed!? We'll ignore that ... */ io_close( r_fd ); @@ -2108,6 +2102,26 @@ Conn_GetClient( CONN_ID Idx ) } +/** + * Get CONN_ID from file descriptor associated to a subprocess structure. + * @param fd File descriptor + * @return CONN_ID or NONE (-1) + */ +GLOBAL CONN_ID +Conn_GetFromProc(int fd) +{ + int i; + + assert(fd > 0); + for (i = 0; i < Pool_Size; i++) { + if ((My_Connections[i].sock != NONE) + && (Proc_GetPipeFd(&My_Connections[i].proc_stat) == fd)) + return i; + } + return NONE; +} /* Conn_GetFromProc */ + + #ifdef SSL_SUPPORT /** diff --git a/src/ngircd/conn.h b/src/ngircd/conn.h index 7665bb3..e9b470b 100644 --- a/src/ngircd/conn.h +++ b/src/ngircd/conn.h @@ -113,6 +113,7 @@ GLOBAL void Conn_Close PARAMS(( CONN_ID Idx, const char *LogMsg, const char *Fwd GLOBAL void Conn_SyncServerStruct PARAMS(( void )); +GLOBAL CONN_ID Conn_GetFromProc PARAMS((int fd)); GLOBAL CLIENT* Conn_GetClient PARAMS((CONN_ID i)); #ifdef SSL_SUPPORT GLOBAL bool Conn_GetCipherInfo PARAMS((CONN_ID Idx, char *buf, size_t len));
1
0
0
0
← Neuer
1
2
3
4
Älter →
Springe zur Seite:
1
2
3
4
Ergebnisse pro Seite:
10
25
50
100
200