[IRC-Dev CVS] [CVS] Module ircd-ircdev: Change committed
Brought to you by:
zolty
From: Toni G. <zo...@us...> - 2003-11-02 00:47:48
|
CVSROOT : /cvsroot/irc-dev Module : ircd-ircdev Commit time: 2003-11-02 00:47:44 UTC Modified files: ChangeLog ChangeLog.es Makefile.in TODO.es configure configure.in include/client.h include/patchlevel.h include/res.h include/s_bsd.h include/s_conf.h ircd/.cvsignore ircd/Makefile.in ircd/client.c ircd/ircd.c ircd/ircd_lexer.l ircd/ircd_parser.y ircd/list.c ircd/m_connect.c ircd/m_oper.c ircd/s_auth.c ircd/s_bsd.c ircd/s_conf.c ircd/s_user.c libs/adns/README Added files: ircd/res_adns.c ircd/res_libresolv.c Removed files: ircd/res.c Log message: Author: zoltan <zo...@ir...> Log message: 2003-11-02 Toni Garcia <zo...@ir...> 1.0.alpha4 * Implementacion de Privilegios. * Cambios en la resolucion DNS. * Se incluye el source de la libreria adns. ---------------------- diff included ---------------------- Index: ircd-ircdev/ChangeLog diff -u ircd-ircdev/ChangeLog:1.4 ircd-ircdev/ChangeLog:1.5 --- ircd-ircdev/ChangeLog:1.4 Sat Nov 1 09:19:35 2003 +++ ircd-ircdev/ChangeLog Sat Nov 1 16:47:33 2003 @@ -1,10 +1,15 @@ # # ChangeLog for ircd-ircdev # -# $Id: ChangeLog,v 1.4 2003/11/01 17:19:35 zolty Exp $ +# $Id: ChangeLog,v 1.5 2003/11/02 00:47:33 zolty Exp $ # # Insert new changes at beginning of the change list. # +2003-11-02 Toni Garcia <zo...@ir...> 1.0.alpha4 + * Privilegies user feature. + * Changed DNS resolution. + * Incluyed adns library source. + 2003-11-01 Toni Garcia <zo...@ir...> 1.0.alpha3 * Implementation epoll() engine. * Upgrade to Undernet u2.10.11.05. Index: ircd-ircdev/ChangeLog.es diff -u ircd-ircdev/ChangeLog.es:1.4 ircd-ircdev/ChangeLog.es:1.5 --- ircd-ircdev/ChangeLog.es:1.4 Sat Nov 1 09:19:35 2003 +++ ircd-ircdev/ChangeLog.es Sat Nov 1 16:47:33 2003 @@ -1,10 +1,15 @@ # # Log de Cambios para ircd-ircdev # -# $Id: ChangeLog.es,v 1.4 2003/11/01 17:19:35 zolty Exp $ +# $Id: ChangeLog.es,v 1.5 2003/11/02 00:47:33 zolty Exp $ # # Insertar los nuevos cambios al principio de esta lista de cambios. # +2003-11-02 Toni Garcia <zo...@ir...> 1.0.alpha4 + * Implementacion de Privilegios. + * Cambios en la resolucion DNS. + * Se incluye el source de la libreria adns. + 2003-11-01 Toni Garcia <zo...@ir...> 1.0.alpha3 * Implementacion del engine de epoll(). * Actualizacion al u2.10.11.05 de Undernet. Index: ircd-ircdev/Makefile.in diff -u ircd-ircdev/Makefile.in:1.1.1.1 ircd-ircdev/Makefile.in:1.2 --- ircd-ircdev/Makefile.in:1.1.1.1 Mon Sep 8 03:34:25 2003 +++ ircd-ircdev/Makefile.in Sat Nov 1 16:47:33 2003 @@ -26,11 +26,12 @@ SHELL = @SHPROG@ RM = @RMPROG@ AWK = @AWK@ +adns_subdir = @ADNS_SUBDIR@ @SET_MAKE@ #### End of system configuration section. #### -SUBDIRS = doc ircd -IRCD_MAKEFILES = Makefile doc/Makefile ircd/Makefile +SUBDIRS = doc ${adns_subdir} ircd +IRCD_MAKEFILES = Makefile doc/Makefile libs/adns/Makefile ircd/Makefile all: build Index: ircd-ircdev/TODO.es diff -u ircd-ircdev/TODO.es:1.1 ircd-ircdev/TODO.es:1.2 --- ircd-ircdev/TODO.es:1.1 Sat Nov 1 09:19:35 2003 +++ ircd-ircdev/TODO.es Sat Nov 1 16:47:33 2003 @@ -1,12 +1,13 @@ # # TODO para ircd-ircdev # -# $Id: TODO.es,v 1.1 2003/11/01 17:19:35 zolty Exp $ +# $Id: TODO.es,v 1.2 2003/11/02 00:47:33 zolty Exp $ # # Insertar las nuevas entradas al principio de la lista TODO. # 1/Nov/2003 +Bug al conectar sale umode -Oo. +Enlazar la libreria de adns al ircd. Bug en el configure al elegir entre poll() y epoll() en linux que tienen fuentes pero no estan activados. - -Bug en las U-lines (uworld y jupes) +Bug en las U-lines (uworld y jupes). Index: ircd-ircdev/configure diff -u ircd-ircdev/configure:1.3 ircd-ircdev/configure:1.4 --- ircd-ircdev/configure:1.3 Sat Nov 1 09:19:35 2003 +++ ircd-ircdev/configure Sat Nov 1 16:47:33 2003 @@ -309,7 +309,7 @@ # include <unistd.h> #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP AWK SET_MAKE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S RMPROG SHPROG OSDEP_C ENGINE_C INSTALL_RULE SYMLINK IRCDMODE IRCDOWN IRCDGRP DPATH LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP AWK SET_MAKE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S RMPROG SHPROG OSDEP_C ENGINE_C RES_C ADNS_SUBDIR INSTALL_RULE SYMLINK IRCDMODE IRCDOWN IRCDGRP DPATH LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -7556,6 +7556,139 @@ ENGINE_C="engine_epoll.c $ENGINE_C" fi +#AC_MSG_CHECKING([whether to enable the adns resolver engine]) +#AC_ARG_ENABLE([adns], +#[ --disable-adns Disable adns resolver], +#[unet_cv_enable_adns=$enable_adns], +#[AC_CACHE_VAL(unet_cv_enable_adns, +#[unet_cv_enable_adns=yes])]) + +#AC_MSG_RESULT([$unet_cv_enable_adns]) + +#if test x"$unet_cv_enable_adns" != xno; then +# AC_DEFINE([USE_ADNS], , [Define to enable the adns resolver]) +# AC_CONFIG_SUBDIRS([libs/adns]) +# RES_C="res_adns.c" +# LIBS="../libs/adns/src/libadns.a $LIBS" +# ADNS_SUBDIR="libs/adns" +#else + RES_C="res_libresolv.c" + ADNS_SUBDIR="" + + echo "$as_me:$LINENO: checking for library containing res_mkquery" >&5 +echo $ECHO_N "checking for library containing res_mkquery... $ECHO_C" >&6 +if test "${ac_cv_search_res_mkquery+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +ac_cv_search_res_mkquery=no +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char res_mkquery (); +int +main () +{ +res_mkquery (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_res_mkquery="none required" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +if test "$ac_cv_search_res_mkquery" = no; then + for ac_lib in resolv; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char res_mkquery (); +int +main () +{ +res_mkquery (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_res_mkquery="-l$ac_lib" +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + done +fi +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_res_mkquery" >&5 +echo "${ECHO_T}$ac_cv_search_res_mkquery" >&6 +if test "$ac_cv_search_res_mkquery" != no; then + test "$ac_cv_search_res_mkquery" = "none required" || LIBS="$ac_cv_search_res_mkquery $LIBS" + +else + { { echo "$as_me:$LINENO: error: Unable to find library containing res_mkquery()" >&5 +echo "$as_me: error: Unable to find library containing res_mkquery()" >&2;} + { (exit 1); exit 1; }; } +fi + +#fi + + + echo "$as_me:$LINENO: checking what name to give the symlink" >&5 echo $ECHO_N "checking what name to give the symlink... $ECHO_C" >&6 @@ -8606,6 +8739,8 @@ s,@SHPROG@,$SHPROG,;t t s,@OSDEP_C@,$OSDEP_C,;t t s,@ENGINE_C@,$ENGINE_C,;t t +s,@RES_C@,$RES_C,;t t +s,@ADNS_SUBDIR@,$ADNS_SUBDIR,;t t s,@INSTALL_RULE@,$INSTALL_RULE,;t t s,@SYMLINK@,$SYMLINK,;t t s,@IRCDMODE@,$IRCDMODE,;t t @@ -9141,6 +9276,7 @@ echo " Debug: $unet_cv_enable_debug" echo " Profile: $unet_cv_enable_profile" echo " Pedantic: $unet_cv_enable_pedantic" +echo " ADNS: $unet_cv_enable_adns" echo " Owner/mode: $unet_cv_with_owner.$unet_cv_with_group ($unet_cv_with_mode)" echo " Chroot: $unet_cv_with_chroot" echo "" Index: ircd-ircdev/configure.in diff -u ircd-ircdev/configure.in:1.3 ircd-ircdev/configure.in:1.4 --- ircd-ircdev/configure.in:1.3 Sat Nov 1 09:19:35 2003 +++ ircd-ircdev/configure.in Sat Nov 1 16:47:33 2003 @@ -19,7 +19,7 @@ dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. dnl -dnl $Id: configure.in,v 1.3 2003/11/01 17:19:35 zolty Exp $ +dnl $Id: configure.in,v 1.4 2003/11/02 00:47:33 zolty Exp $ dnl Make sure we are in the correct directory (someone could have run dnl 'configure' with a wrong '--srcdir'). @@ -386,6 +386,34 @@ ENGINE_C="engine_epoll.c $ENGINE_C" fi +dnl --disable-adns check... +#AC_MSG_CHECKING([whether to enable the adns resolver engine]) +#AC_ARG_ENABLE([adns], +#[ --disable-adns Disable adns resolver], +#[unet_cv_enable_adns=$enable_adns], +#[AC_CACHE_VAL(unet_cv_enable_adns, +#[unet_cv_enable_adns=yes])]) + +#AC_MSG_RESULT([$unet_cv_enable_adns]) + +#if test x"$unet_cv_enable_adns" != xno; then +# AC_DEFINE([USE_ADNS], , [Define to enable the adns resolver]) +# AC_CONFIG_SUBDIRS([libs/adns]) +# RES_C="res_adns.c" +# LIBS="../libs/adns/src/libadns.a $LIBS" +# ADNS_SUBDIR="libs/adns" +#else + RES_C="res_libresolv.c" + ADNS_SUBDIR="" + + dnl Look for res_mkquery. Done after AC_LIBRARY_NET in case res_mkquery + dnl is in one of those libraries somewhere. + AC_SEARCH_LIBS(res_mkquery, resolv, , + [AC_MSG_ERROR([Unable to find library containing res_mkquery()])]) +#fi +AC_SUBST(RES_C) +AC_SUBST(ADNS_SUBDIR) + dnl --with-symlink lets us set the name of the symlink; defaults to "ircd" AC_MSG_CHECKING([what name to give the symlink]) AC_ARG_WITH([symlink], @@ -695,6 +723,7 @@ echo " Debug: $unet_cv_enable_debug" echo " Profile: $unet_cv_enable_profile" echo " Pedantic: $unet_cv_enable_pedantic" +echo " ADNS: $unet_cv_enable_adns" echo " Owner/mode: $unet_cv_with_owner.$unet_cv_with_group ($unet_cv_with_mode)" echo " Chroot: $unet_cv_with_chroot" echo "" Index: ircd-ircdev/include/client.h diff -u ircd-ircdev/include/client.h:1.1.1.1 ircd-ircdev/include/client.h:1.2 --- ircd-ircdev/include/client.h:1.1.1.1 Mon Sep 8 03:34:27 2003 +++ ircd-ircdev/include/client.h Sat Nov 1 16:47:33 2003 @@ -18,7 +18,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * - * $Id: client.h,v 1.1.1.1 2003/09/08 10:34:27 zolty Exp $ + * $Id: client.h,v 1.2 2003/11/02 00:47:33 zolty Exp $ */ #ifndef INCLUDED_client_h #define INCLUDED_client_h @@ -53,7 +53,6 @@ struct Server; struct User; struct Whowas; -struct DNSReply; struct hostent; struct Privs; struct AuthRequest; @@ -66,6 +65,22 @@ * source file, or in the source file itself (when only used in that file). */ +typedef unsigned long flagpage_t; + +#define FLAGSET_NBITS (8 * sizeof(flagpage_t)) +#define FLAGSET_INDEX(flag) (flag / FLAGSET_NBITS) +#define FLAGSET_MASK(flag) (1<<(flag % FLAGSET_NBITS)) + +#define DECLARE_FLAGSET(name,max) \ + struct name \ + { \ + unsigned long bits[((max + FLAGSET_NBITS - 1) / FLAGSET_NBITS)]; \ + }; + +#define FLAGSET_ISSET(set,flag) ((set).bits[FLAGSET_INDEX(flag)] & FLAGSET_MASK(flag)) +#define FLAGSET_SET(set, flag) (set).bits[FLAGSET_INDEX(flag)] |= FLAGSET_MASK(flag) +#define FLAGSET_CLEAR(set, flag) (set).bits[FLAGSET_INDEX(flag)] &= ~FLAGSET_MASK(flag) + enum Priv { PRIV_CHAN_LIMIT, /* no channel limit on oper */ PRIV_MODE_LCHAN, /* oper can mode local chans */ @@ -91,28 +106,15 @@ PRIV_BADCHAN, /* oper can BADCHAN */ PRIV_LOCAL_BADCHAN, /* oper can local BADCHAN */ PRIV_SEE_CHAN, /* oper can see in secret chans */ - PRIV_PROPAGATE, /* propagate oper status */ PRIV_DISPLAY, /* "Is an oper" displayed */ PRIV_SEE_OPERS, /* display hidden opers */ - PRIV_WIDE_GLINE, /* oper can set wider G-lines */ - PRIV_FORCE_OPMODE, /* oper can override a Q-line */ PRIV_FORCE_LOCAL_OPMODE,/* oper can override a local channel Q-line */ - PRIV_LAST_PRIV /* must be the same as the last priv */ }; -#define _PRIV_NBITS (8 * sizeof(unsigned long)) - -#define _PRIV_IDX(priv) ((priv) / _PRIV_NBITS) -#define _PRIV_BIT(priv) (1 << ((priv) % _PRIV_NBITS)) - -struct Privs { - unsigned long priv_mask[(PRIV_LAST_PRIV + _PRIV_NBITS - 1) / _PRIV_NBITS]; -}; - enum Flag { FLAG_PINGSENT, /* Unreplied ping sent */ FLAG_DEADSOCKET, /* Local socket is dead--Exiting soon */ @@ -136,6 +138,7 @@ FLAG_LOCOP, /* Local operator -- SRB */ FLAG_SERVNOTICE, /* server notices such as kill */ + FLAG_OPER, /* Operator */ FLAG_INVISIBLE, /* makes user invisible */ FLAG_WALLOP, /* send wallops to them */ @@ -145,15 +148,13 @@ FLAG_DEBUG, /* send global debug/anti-hack info */ FLAG_ACCOUNT, /* account name has been set */ FLAG_HIDDENHOST, /* user's host is hidden */ - - _FLAG_COUNT, + FLAG_LAST_FLAG, FLAG_LOCAL_UMODES = FLAG_LOCOP, /* First local mode flag */ FLAG_GLOBAL_UMODES = FLAG_OPER /* First global mode flag */ }; -struct Flags { - unsigned long flag_bits[((_FLAG_COUNT + _PRIV_NBITS - 1) / _PRIV_NBITS)]; -}; +DECLARE_FLAGSET(Privs, PRIV_LAST_PRIV); +DECLARE_FLAGSET(Flags, FLAG_LAST_FLAG); struct Connection { /* @@ -188,7 +189,7 @@ struct SLink* con_confs; /* Configuration record associated */ HandlerType con_handler; /* message index into command table for parsing */ - struct DNSReply* con_dns_reply; /* DNS reply used during client + struct hostent* con_dns_reply; /* DNS reply used during client registration */ struct ListingArgs* con_listing; unsigned int con_max_sendq; /* cached max send queue for client */ @@ -393,12 +394,9 @@ /* * flags macros. */ -#define FlagSet(fset, flag) ((fset)->flag_bits[_PRIV_IDX(flag)] |= \ - _PRIV_BIT(flag)) -#define FlagClr(fset, flag) ((fset)->flag_bits[_PRIV_IDX(flag)] &= \ - ~(_PRIV_BIT(flag))) -#define FlagHas(fset, flag) ((fset)->flag_bits[_PRIV_IDX(flag)] & \ - _PRIV_BIT(flag)) +#define FlagSet(fset, flag) FLAGSET_SET(*fset, flag) +#define FlagClr(fset, flag) FLAGSET_CLEAR(*fset, flag) +#define FlagHas(fset, flag) FLAGSET_ISSET(*fset, flag) #define SetFlag(cli, flag) FlagSet(&cli_flags(cli), flag) #define ClrFlag(cli, flag) FlagClr(&cli_flags(cli), flag) #define HasFlag(cli, flag) FlagHas(&cli_flags(cli), flag) @@ -428,9 +426,10 @@ #define IsService(x) HasFlag(x, FLAG_SERVICE) #define IsAccount(x) HasFlag(x, FLAG_ACCOUNT) #define IsHiddenHost(x) HasFlag(x, FLAG_HIDDENHOST) -#define HasHiddenHost(x) (IsAccount(x) && IsHiddenHost(x)) +#define IsPingSent(x) HasFlag(x, FLAG_PINGSENT) #define IsPrivileged(x) (IsAnOper(x) || IsServer(x)) +#define HasHiddenHost(x) (IsAccount(x) && IsHiddenHost(x)) #define SetAccess(x) SetFlag(x, FLAG_CHKACCESS) #define SetBurst(x) SetFlag(x, FLAG_BURST) @@ -451,6 +450,7 @@ #define SetService(x) SetFlag(x, FLAG_SERVICE) #define SetAccount(x) SetFlag(x, FLAG_ACCOUNT) #define SetHiddenHost(x) SetFlag(x, FLAG_HIDDENHOST) +#define SetPingSent(x) SetFlag(x, FLAG_PINGSENT) #define ClearAccess(x) ClrFlag(x, FLAG_CHKACCESS) #define ClearBurst(x) ClrFlag(x, FLAG_BURST) @@ -466,6 +466,7 @@ #define ClearWallops(x) ClrFlag(x, FLAG_WALLOP) #define ClearServNotice(x) ClrFlag(x, FLAG_SERVNOTICE) #define ClearHiddenHost(x) ClrFlag(x, FLAG_HIDDENHOST) +#define ClearPingSent(x) ClrFlag(x, FLAG_PINGSENT) /* free flags */ #define FREEFLAG_SOCKET 0x0001 /* socket needs to be freed */ @@ -510,12 +511,9 @@ #define SNO_OPER (SNO_CONNEXIT|SNO_OLDREALOP) #define SNO_NOISY (SNO_SERVKILL|SNO_UNAUTH) -#define PrivSet(pset, priv) ((pset)->priv_mask[_PRIV_IDX(priv)] |= \ - _PRIV_BIT(priv)) -#define PrivClr(pset, priv) ((pset)->priv_mask[_PRIV_IDX(priv)] &= \ - ~(_PRIV_BIT(priv))) -#define PrivHas(pset, priv) ((pset)->priv_mask[_PRIV_IDX(priv)] & \ - _PRIV_BIT(priv)) +#define PrivSet(fset, flag) FLAGSET_SET(*fset, flag) +#define PrivClr(fset, flag) FLAGSET_CLEAR(*fset, flag) +#define PrivHas(fset, flag) FLAGSET_ISSET(*fset, flag) #define GrantPriv(cli, priv) (PrivSet(&(cli_privs(cli)), priv)) #define RevokePriv(cli, priv) (PrivClr(&(cli_privs(cli)), priv)) @@ -532,7 +530,7 @@ extern void client_drop_sendq(struct Connection* con); extern void client_add_sendq(struct Connection* con, struct Connection** con_p); -extern void client_set_privs(struct Client* client); +extern void client_set_privs(struct Client* client, struct ConfItem *oper); extern int client_report_privs(struct Client* to, struct Client* client); #endif /* INCLUDED_client_h */ Index: ircd-ircdev/include/patchlevel.h diff -u ircd-ircdev/include/patchlevel.h:1.4 ircd-ircdev/include/patchlevel.h:1.5 --- ircd-ircdev/include/patchlevel.h:1.4 Sat Nov 1 09:19:35 2003 +++ ircd-ircdev/include/patchlevel.h Sat Nov 1 16:47:33 2003 @@ -15,10 +15,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: patchlevel.h,v 1.4 2003/11/01 17:19:35 zolty Exp $ + * $Id: patchlevel.h,v 1.5 2003/11/02 00:47:33 zolty Exp $ * */ -#define PATCHLEVEL ".alpha3" +#define PATCHLEVEL ".alpha4" #define RELEASE "1.0" Index: ircd-ircdev/include/res.h diff -u ircd-ircdev/include/res.h:1.1.1.1 ircd-ircdev/include/res.h:1.2 --- ircd-ircdev/include/res.h:1.1.1.1 Mon Sep 8 03:34:27 2003 +++ ircd-ircdev/include/res.h Sat Nov 1 16:47:33 2003 @@ -1,7 +1,7 @@ /* * irc2.7.2/ircd/res.h (C)opyright 1992 Darren Reed. * - * $Id: res.h,v 1.1.1.1 2003/09/08 10:34:27 zolty Exp $ + * $Id: res.h,v 1.2 2003/11/02 00:47:33 zolty Exp $ */ #ifndef INCLUDED_res_h #define INCLUDED_res_h @@ -14,26 +14,20 @@ struct Client; struct hostent; -struct DNSReply { - struct hostent* hp; /* hostent struct */ - int ref_count; /* reference count */ -}; - struct DNSQuery { void* vptr; /* pointer used by callback to identify request */ - void (*callback)(void* vptr, struct DNSReply* reply); /* callback to call */ + void (*callback)(void* vptr, struct hostent* reply); /* callback to call */ }; extern int ResolverFileDescriptor; /* GLOBAL - file descriptor (s_bsd.c) */ extern void get_res(void); -extern struct DNSReply* gethost_byname(const char* name, - const struct DNSQuery* req); -extern struct DNSReply* gethost_byaddr(const char* name, - const struct DNSQuery* req); +extern void gethost_byname(const char* name, const struct DNSQuery* req); +extern void gethost_byaddr(const char* name, const struct DNSQuery* req); extern int init_resolver(void); extern void restart_resolver(void); extern time_t timeout_resolver(time_t now); + /* * delete_resolver_queries - delete all outstanding queries for the * pointer arg, DO NOT call this from a resolver callback function the Index: ircd-ircdev/include/s_bsd.h diff -u ircd-ircdev/include/s_bsd.h:1.1.1.1 ircd-ircdev/include/s_bsd.h:1.2 --- ircd-ircdev/include/s_bsd.h:1.1.1.1 Mon Sep 8 03:34:27 2003 +++ ircd-ircdev/include/s_bsd.h Sat Nov 1 16:47:33 2003 @@ -1,7 +1,7 @@ /* * s_bsd.h * - * $Id: s_bsd.h,v 1.1.1.1 2003/09/08 10:34:27 zolty Exp $ + * $Id: s_bsd.h,v 1.2 2003/11/02 00:47:33 zolty Exp $ */ #ifndef INCLUDED_s_bsd_h #define INCLUDED_s_bsd_h @@ -17,7 +17,6 @@ struct Client; struct ConfItem; struct Listener; -struct DNSReply; struct MsgQ; /* @@ -79,8 +78,7 @@ * Proto types */ extern unsigned int deliver_it(struct Client *cptr, struct MsgQ *buf); -extern int connect_server(struct ConfItem* aconf, struct Client* by, - struct DNSReply* reply); +extern int connect_server(struct ConfItem* aconf, struct Client* by); extern void release_dns_reply(struct Client* cptr); extern int net_close_unregistered_connections(struct Client* source); extern void close_connection(struct Client *cptr); Index: ircd-ircdev/include/s_conf.h diff -u ircd-ircdev/include/s_conf.h:1.2 ircd-ircdev/include/s_conf.h:1.3 --- ircd-ircdev/include/s_conf.h:1.2 Sat Nov 1 07:26:45 2003 +++ ircd-ircdev/include/s_conf.h Sat Nov 1 16:47:33 2003 @@ -1,7 +1,7 @@ /* * s_conf.h * - * $Id: s_conf.h,v 1.2 2003/11/01 15:26:45 zolty Exp $ + * $Id: s_conf.h,v 1.3 2003/11/02 00:47:33 zolty Exp $ */ #ifndef INCLUDED_s_conf_h #define INCLUDED_s_conf_h @@ -64,6 +64,9 @@ int dns_pending; /* a dns request is pending */ unsigned short port; char bits; /* Number of bits for ipkills */ + struct Privs privs; /* Priviledges for opers. */ + /* Used to detect if a privilege has been touched. */ + struct Privs privs_dirty; }; struct ServerConf { Index: ircd-ircdev/ircd/.cvsignore diff -u ircd-ircdev/ircd/.cvsignore:1.1 ircd-ircdev/ircd/.cvsignore:1.2 --- ircd-ircdev/ircd/.cvsignore:1.1 Sat Nov 1 09:19:36 2003 +++ ircd-ircdev/ircd/.cvsignore Sat Nov 1 16:47:33 2003 @@ -1,6 +1,10 @@ - chkconf - table_gen - chattr.tab.c +Makefile +stamp-m +version.c +ircd +chkconf +table_gen +chattr.tab.c lex.yy.c y.tab.c y.tab.h Index: ircd-ircdev/ircd/Makefile.in diff -u ircd-ircdev/ircd/Makefile.in:1.4 ircd-ircdev/ircd/Makefile.in:1.5 --- ircd-ircdev/ircd/Makefile.in:1.4 Sat Nov 1 09:19:36 2003 +++ ircd-ircdev/ircd/Makefile.in Sat Nov 1 16:47:33 2003 @@ -44,6 +44,7 @@ GREP = grep OSDEP_C = @OSDEP_C@ ENGINE_C = @ENGINE_C@ +RES_C = @RES_C@ @SET_MAKE@ BINDIR = @bindir@ @@ -58,7 +59,7 @@ CC = @CC@ CFLAGS = @CFLAGS@ -CPPFLAGS = -I. -I.. -I${top_srcdir}/include @CPPFLAGS@ +CPPFLAGS = -I. -I.. -I${top_srcdir}/include -I${top_srcdir}/libs/adns/src @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ @@ -80,6 +81,10 @@ engine_kqueue.c \ engine_select.c +RES_SRC = \ + res_adns.c \ + res_libresolv.c + IRCD_SRC = \ IPcheck.c \ channel.c \ @@ -187,7 +192,6 @@ parse.c \ querycmds.c \ random.c \ - res.c \ s_auth.c \ s_bsd.c \ s_conf.c \ @@ -209,7 +213,7 @@ CHKCONF_SRC = chkconf.c -SRC = ${IRCD_SRC} ${OSDEP_C} ${ENGINE_C} +SRC = ${IRCD_SRC} ${OSDEP_C} ${ENGINE_C} ${RES_C} OBJS = ${SRC:%.c=%.o} Index: ircd-ircdev/ircd/client.c diff -u ircd-ircdev/ircd/client.c:1.1.1.1 ircd-ircdev/ircd/client.c:1.2 --- ircd-ircdev/ircd/client.c:1.1.1.1 Mon Sep 8 03:34:28 2003 +++ ircd-ircdev/ircd/client.c Sat Nov 1 16:47:33 2003 @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: client.c,v 1.1.1.1 2003/09/08 10:34:28 zolty Exp $ + * $Id: client.c,v 1.2 2003/11/02 00:47:33 zolty Exp $ */ #include "config.h" @@ -101,16 +101,21 @@ } } -static struct { +enum FeatureFlag +{ + FEATFLAG_NULL, + FEATFLAG_DISABLES_PRIV, + FEATFLAG_ENABLES_PRIV, + FEATFLAG_GLOBAL_OPERS, + FEATFLAG_LOCAL_OPERS, + FEATFLAG_ALL_OPERS +}; + +static struct +{ enum Priv priv; enum Feature feat; - enum { - FEATFLAG_DISABLES_PRIV, - FEATFLAG_ENABLES_PRIV, - FEATFLAG_GLOBAL_OPERS, - FEATFLAG_LOCAL_OPERS, - FEATFLAG_ALL_OPERS - } flag; + enum FeatureFlag flag; } feattab[] = { { PRIV_WHOX, FEAT_LAST_F, FEATFLAG_ALL_OPERS }, { PRIV_DISPLAY, FEAT_LAST_F, FEATFLAG_ALL_OPERS }, @@ -163,7 +168,7 @@ { PRIV_SEE_CHAN, FEAT_LOCOP_SEE_IN_SECRET_CHANNELS, FEATFLAG_LOCAL_OPERS }, { PRIV_WIDE_GLINE, FEAT_LOCOP_WIDE_GLINE, FEATFLAG_LOCAL_OPERS }, - { PRIV_LAST_PRIV, FEAT_LAST_F, 0 } + { PRIV_LAST_PRIV, FEAT_LAST_F, FEATFLAG_NULL } }; /* client_set_privs(struct Client* client) @@ -171,62 +176,75 @@ * Sets the privileges for opers. */ void -client_set_privs(struct Client* client) +client_set_privs(struct Client *client, struct ConfItem *oper) { - struct Privs privs; - struct Privs antiprivs; int i; - memset(&privs, 0, sizeof(struct Privs)); - memset(&antiprivs, 0, sizeof(struct Privs)); + memset(&(cli_privs(client)), 0, sizeof(struct Privs)); - if (!IsAnOper(client)) { /* clear privilege mask */ - memset(&(cli_privs(client)), 0, sizeof(struct Privs)); + if (!IsAnOper(client)) return; - } else if (!MyConnect(client)) { + else if (!MyConnect(client)) + { memset(&(cli_privs(client)), 255, sizeof(struct Privs)); PrivClr(&(cli_privs(client)), PRIV_SET); return; } + else if (oper == NULL) + return; - /* This sequence is temporary until the .conf is carefully rewritten */ + /* Copy across privs from the config. */ + cli_privs(client) = oper->privs; - for (i = 0; feattab[i].priv != PRIV_LAST_PRIV; i++) { - if (feattab[i].flag == FEATFLAG_ENABLES_PRIV) { + /* Now go through the features and set the non-dirty flags to their feature + * determined defaults... + */ + for (i = 0; feattab[i].priv != PRIV_LAST_PRIV; i++) + { + if (PrivHas(&oper->privs_dirty, feattab[i].priv)) + continue; + if (feattab[i].feat != FEAT_LAST_F && !feature_bool(feattab[i].feat)) + continue; + switch (feattab[i].flag) + { + case FEATFLAG_ENABLES_PRIV: if (!feature_bool(feattab[i].feat)) - PrivSet(&antiprivs, feattab[i].priv); - } else if (feattab[i].feat == FEAT_LAST_F || feature_bool(feattab[i].feat)) { - if (feattab[i].flag == FEATFLAG_DISABLES_PRIV) { - PrivSet(&antiprivs, feattab[i].priv); - } else if (feattab[i].flag == FEATFLAG_ALL_OPERS) { - if (IsAnOper(client)) - PrivSet(&privs, feattab[i].priv); - } else if (feattab[i].flag == FEATFLAG_GLOBAL_OPERS) { - if (IsOper(client)) - PrivSet(&privs, feattab[i].priv); - } else if (feattab[i].flag == FEATFLAG_LOCAL_OPERS) { - if (IsLocOp(client)) - PrivSet(&privs, feattab[i].priv); - } + continue; + PrivSet(&cli_privs(client), feattab[i].priv); + continue; + case FEATFLAG_DISABLES_PRIV: + PrivClr(&cli_privs(client), feattab[i].priv); + continue; + case FEATFLAG_ALL_OPERS: + if (IsAnOper(client)) + PrivSet(&cli_privs(client), feattab[i].priv); + continue; + case FEATFLAG_GLOBAL_OPERS: + if (IsOper(client)) + PrivSet(&cli_privs(client), feattab[i].priv); + continue; + case FEATFLAG_LOCAL_OPERS: + if (IsLocOp(client)) + PrivSet(&cli_privs(client), feattab[i].priv); + continue; + default: + continue; /* ?? */ } } - - /* This is the end of the gross section */ - if (PrivHas(&privs, PRIV_PROPAGATE)) - PrivSet(&privs, PRIV_DISPLAY); /* force propagating opers to display */ - else { /* if they don't propagate oper status, prevent desyncs */ - PrivSet(&antiprivs, PRIV_KILL); - PrivSet(&antiprivs, PRIV_GLINE); - PrivSet(&antiprivs, PRIV_JUPE); - PrivSet(&antiprivs, PRIV_OPMODE); - PrivSet(&antiprivs, PRIV_BADCHAN); + /* This should be handled in the config, but lets be sure... */ + if (PrivHas(&cli_privs(client), PRIV_PROPAGATE)) + /* force propagating opers to display */ + PrivSet(&cli_privs(client), PRIV_DISPLAY); + else + { + /* if they don't propagate oper status, prevent desyncs */ + PrivClr(&cli_privs(client), PRIV_KILL); + PrivClr(&cli_privs(client), PRIV_GLINE); + PrivClr(&cli_privs(client), PRIV_JUPE); + PrivClr(&cli_privs(client), PRIV_OPMODE); + PrivClr(&cli_privs(client), PRIV_BADCHAN); } - - for (i = 0; i <= _PRIV_IDX(PRIV_LAST_PRIV); i++) - privs.priv_mask[i] &= ~antiprivs.priv_mask[i]; - - cli_privs(client) = privs; } static struct { @@ -240,8 +258,8 @@ P(GLINE), P(LOCAL_GLINE), P(JUPE), P(LOCAL_JUPE), P(OPMODE), P(LOCAL_OPMODE), P(SET), P(WHOX), P(BADCHAN), P(LOCAL_BADCHAN), P(SEE_CHAN), P(PROPAGATE), - P(DISPLAY), P(SEE_OPERS), P(WIDE_GLINE), P(FORCE_OPMODE), - P(FORCE_LOCAL_OPMODE), + P(DISPLAY), P(SEE_OPERS), P(FORCE_OPMODE), P(FORCE_LOCAL_OPMODE), + P(WIDE_GLINE), #undef P { 0, 0 } }; Index: ircd-ircdev/ircd/ircd.c diff -u ircd-ircdev/ircd/ircd.c:1.2 ircd-ircdev/ircd/ircd.c:1.3 --- ircd-ircdev/ircd/ircd.c:1.2 Sat Nov 1 07:26:46 2003 +++ ircd-ircdev/ircd/ircd.c Sat Nov 1 16:47:33 2003 @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: ircd.c,v 1.2 2003/11/01 15:26:46 zolty Exp $ + * $Id: ircd.c,v 1.3 2003/11/02 00:47:33 zolty Exp $ */ #include "config.h" @@ -302,7 +302,7 @@ (*pconf = con_conf)->next = 0; } - if (connect_server(con_conf, 0, 0)) + if (connect_server(con_conf, 0)) sendto_opmask_butone(0, SNO_OLDSNO, "Connection to %s activated.", con_conf->name); } @@ -355,7 +355,7 @@ Debug((DEBUG_DEBUG, "check_pings(%s)=status:%s limit: %d current: %d", cli_name(cptr), - HasFlag(cptr, FLAG_PINGSENT) ? "[Ping Sent]" : "[]", + IsPingSent(cptr) ? "[Ping Sent]" : "[]", max_ping, (int)(CurrentTime - cli_lasttime(cptr)))); /* Ok, the thing that will happen most frequently, is that someone will @@ -416,11 +416,11 @@ continue; } - if (!HasFlag(cptr, FLAG_PINGSENT)) { + if (!IsPingSent(cptr)) { /* If we havent PINGed the connection and we havent heard from it in a * while, PING it to make sure it is still alive. */ - SetFlag(cptr, FLAG_PINGSENT); + SetPingSent(cptr); /* If we're late in noticing don't hold it against them :) */ cli_lasttime(cptr) = CurrentTime - max_ping; Index: ircd-ircdev/ircd/ircd_lexer.l diff -u ircd-ircdev/ircd/ircd_lexer.l:1.1 ircd-ircdev/ircd/ircd_lexer.l:1.2 --- ircd-ircdev/ircd/ircd_lexer.l:1.1 Sat Nov 1 07:26:46 2003 +++ ircd-ircdev/ircd/ircd_lexer.l Sat Nov 1 16:47:33 2003 @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. - * $Id: ircd_lexer.l,v 1.1 2003/11/01 15:26:46 zolty Exp $ + * $Id: ircd_lexer.l,v 1.2 2003/11/02 00:47:33 zolty Exp $ */ %{ @@ -123,5 +123,31 @@ quarantine return QUARANTINE; features return FEATURES; channel return CHANNEL; +bypass_local_channel_limits return TPRIV_CHAN_LIMIT; +set_local_channel_modes return TPRIV_MODE_LCHAN; +protected_local_channel return TPRIV_DEOP_LCHAN; +bypass_join_local_channels return TPRIV_WALK_LCHAN; +global_kill return TPRIV_KILL; +local_kill return TPRIV_LOCAL_KILL; +rehash return TPRIV_REHASH; +restart return TPRIV_RESTART; +die return TPRIV_DIE; +gline return TPRIV_GLINE; +local_gline return TPRIV_LOCAL_GLINE; +jupe_server return TPRIV_JUPE; +local_jupe_server return TPRIV_LOCAL_JUPE; +hack_channel_modes return TPRIV_OPMODE; +change_settings return TPRIV_SET; +extended_who_information return TPRIV_WHOX; +gline_channels return TPRIV_BADCHAN; +local_gline_channels return TPRIV_LOCAL_BADCHAN; +see_private_channels return TPRIV_SEE_CHAN; +see_invisible_users return TPRIV_SHOW_INVIS; +list_all_invisible_users return TPRIV_SHOW_ALL_INVIS; +globally_opered return TPRIV_PROPAGATE; +unlimited_who_queries return TPRIV_UNLIMIT_QUERY; +oper_status_display return TPRIV_DISPLAY; +see_other_opers return TPRIV_SEE_OPERS; +wide_glines return TPRIV_WIDE_GLINE; \n lineno++; . return yytext[0]; Index: ircd-ircdev/ircd/ircd_parser.y diff -u ircd-ircdev/ircd/ircd_parser.y:1.1 ircd-ircdev/ircd/ircd_parser.y:1.2 --- ircd-ircdev/ircd/ircd_parser.y:1.1 Sat Nov 1 07:26:46 2003 +++ ircd-ircdev/ircd/ircd_parser.y Sat Nov 1 16:47:33 2003 @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. - * $Id: ircd_parser.y,v 1.1 2003/11/01 15:26:46 zolty Exp $ + * $Id: ircd_parser.y,v 1.2 2003/11/02 00:47:33 zolty Exp $ */ %{ @@ -141,7 +141,6 @@ %token FEATURES %token QUARANTINE /* and now a lot of priviledges... */ -/* %token TPRIV_CHAN_LIMIT, TPRIV_MODE_LCHAN, TPRIV_DEOP_LCHAN, TPRIV_WALK_LCHAN %token TPRIV_KILL, TPRIV_LOCAL_KILL, TPRIV_REHASH, TPRIV_RESTART, TPRIV_DIE %token TPRIV_GLINE, TPRIV_LOCAL_GLINE, TPRIV_JUPE, TPRIV_LOCAL_JUPE @@ -149,14 +148,10 @@ %token TPRIV_LOCAL_BADCHAN %token TPRIV_SEE_CHAN, TPRIV_SHOW_INVIS, TPRIV_SHOW_ALL_INVIS, TPRIV_PROPAGATE %token TPRIV_UNLIMIT_QUERY, TPRIV_DISPLAY, TPRIV_SEE_OPERS, TPRIV_WIDE_GLINE -*/ /* and some types... */ %type <num> sizespec %type <num> timespec, timefactor, factoredtimes, factoredtime -/* %type <num> expr, yesorno, privtype -*/ -%type <num> expr, yesorno %left '+' '-' %left '*' '/' @@ -499,10 +494,7 @@ } }; operitems: operitem | operitems operitem; -/* operitem: opername | operpass | operlocal | operhost | operclass | operpriv; -*/ -operitem: opername | operpass | operlocal | operhost | operclass; opername: NAME '=' QSTRING ';' { @@ -546,7 +538,6 @@ aconf->conn_class = find_class(yylval.text); }; -/* operpriv: privtype '=' yesorno ';' { if ($3 == 1) @@ -588,7 +579,7 @@ TPRIV_DISPLAY { $$ = PRIV_DISPLAY; } | TPRIV_SEE_OPERS { $$ = PRIV_SEE_OPERS; } | TPRIV_WIDE_GLINE { $$ = PRIV_WIDE_GLINE; }; -*/ + yesorno: YES { $$ = 1; } | NO { $$ = 0; }; /* The port block... */ Index: ircd-ircdev/ircd/list.c diff -u ircd-ircdev/ircd/list.c:1.1.1.1 ircd-ircdev/ircd/list.c:1.2 --- ircd-ircdev/ircd/list.c:1.1.1.1 Mon Sep 8 03:34:29 2003 +++ ircd-ircdev/ircd/list.c Sat Nov 1 16:47:33 2003 @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: list.c,v 1.1.1.1 2003/09/08 10:34:29 zolty Exp $ + * $Id: list.c,v 1.2 2003/11/02 00:47:33 zolty Exp $ */ #include "config.h" @@ -154,8 +154,10 @@ Debug((DEBUG_LIST, "Deallocating connection %p", con)); - if (con_dns_reply(con)) - --(con_dns_reply(con)->ref_count); + if (con_dns_reply(con)) { + MyFree(con_dns_reply(con)); + con_dns_reply(con) = 0; + } if (-1 < con_fd(con)) close(con_fd(con)); MsgQClear(&(con_sendQ(con))); @@ -314,9 +316,9 @@ assert(!cli_next(cptr) || cli_verify(cli_next(cptr))); assert(!IsMe(cptr)); - /* Only remove from the list if it actually IS in the list. - * cli_next(cptr) cannot be NULL here if cptr is in the list, - * only &me is at the end, and we never try to remove &me -GW + /* Only try remove cptr from the list if it IS in the list. + * cli_next(cptr) cannot be NULL here, as &me is always the end + * the list, and we never remove &me. -GW */ if(cli_next(cptr)) { Index: ircd-ircdev/ircd/m_connect.c diff -u ircd-ircdev/ircd/m_connect.c:1.1.1.1 ircd-ircdev/ircd/m_connect.c:1.2 --- ircd-ircdev/ircd/m_connect.c:1.1.1.1 Mon Sep 8 03:34:29 2003 +++ ircd-ircdev/ircd/m_connect.c Sat Nov 1 16:47:33 2003 @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: m_connect.c,v 1.1.1.1 2003/09/08 10:34:29 zolty Exp $ + * $Id: m_connect.c,v 1.2 2003/11/02 00:47:33 zolty Exp $ */ /* @@ -202,7 +202,7 @@ log_write(LS_NETWORK, L_INFO, 0, "CONNECT From %C : %s %s", sptr, parv[1], parv[2] ? parv[2] : ""); - if (connect_server(aconf, sptr, 0)) { + if (connect_server(aconf, sptr)) { sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :*** Connecting to %s.", sptr, aconf->name); } @@ -332,7 +332,7 @@ tmpport = aconf->port; aconf->port = port; - if (connect_server(aconf, sptr, 0)) { + if (connect_server(aconf, sptr)) { sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :*** Connecting to %s.", sptr, aconf->name); } Index: ircd-ircdev/ircd/m_oper.c diff -u ircd-ircdev/ircd/m_oper.c:1.1.1.1 ircd-ircdev/ircd/m_oper.c:1.2 --- ircd-ircdev/ircd/m_oper.c:1.1.1.1 Mon Sep 8 03:34:29 2003 +++ ircd-ircdev/ircd/m_oper.c Sat Nov 1 16:47:33 2003 @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: m_oper.c,v 1.1.1.1 2003/09/08 10:34:29 zolty Exp $ + * $Id: m_oper.c,v 1.2 2003/11/02 00:47:33 zolty Exp $ */ /* @@ -180,7 +180,7 @@ SetFlag(sptr, FLAG_DEBUG); set_snomask(sptr, SNO_OPERDEFAULT, SNO_ADD); - client_set_privs(sptr); + client_set_privs(sptr, aconf); cli_max_sendq(sptr) = 0; /* Get the sendq from the oper's class */ send_umode_out(cptr, sptr, &old_mode, HasPriv(sptr, PRIV_PROPAGATE)); send_reply(sptr, RPL_YOUREOPER); Index: ircd-ircdev/ircd/res.c diff -u ircd-ircdev/ircd/res.c:1.1.1.1 ircd-ircdev/ircd/res.c:removed --- ircd-ircdev/ircd/res.c:1.1.1.1 Mon Sep 8 03:34:30 2003 +++ ircd-ircdev/ircd/res.c Sat Nov 1 16:47:44 2003 @@ -1,1824 +0,0 @@ -/* - * src/res.c (C)opyright 1992 Darren Reed. All rights reserved. - * This file may not be distributed without the author's permission in any - * shape or form. The author takes no responsibility for any damage or loss - * of property which results from the use of this software. - * - * $Id: res.c,v 1.1.1.1 2003/09/08 10:34:30 zolty Exp $ - * - * July 1999 - Rewrote a bunch of stuff here. Change hostent builder code, - * added callbacks and reference counting of returned hostents. - * --Bleep (Thomas Helvey <to...@in...>) - */ -#include "config.h" - -#include "res.h" -#include "client.h" -#include "ircd.h" -#include "ircd_alloc.h" -#include "ircd_events.h" -#include "ircd_log.h" -#include "ircd_osdep.h" -#include "ircd_reply.h" -#include "ircd_snprintf.h" -#include "ircd_string.h" -#include "msg.h" -#include "numeric.h" -#include "s_bsd.h" -#include "s_debug.h" -#include "s_misc.h" -#include "send.h" -#include "struct.h" -#include "support.h" -#include "sys.h" - -#include <assert.h> -#include <errno.h> -#include <string.h> -#include <stdlib.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <fcntl.h> -#include <unistd.h> -#include <regex.h> - -#include <arpa/nameser.h> -#include <resolv.h> -#include <netdb.h> -#include <arpa/inet.h> - -#include <limits.h> -#if (CHAR_BIT != 8) -#error this code needs to be able to address individual octets -#endif - -/* - * Some systems do not define INADDR_NONE (255.255.255.255) - * INADDR_NONE is actually a valid address, but it should never - * be returned from any nameserver. - * NOTE: The bit pattern for INADDR_NONE and INADDR_ANY (0.0.0.0) should be - * the same on all hosts so we shouldn't need to use htonl or ntohl to - * compare or set the values. - */ -#ifndef INADDR_NONE -#define INADDR_NONE ((unsigned int) 0xffffffff) -#endif - -#define MAXPACKET 1024 /* rfc sez 512 but we expand names so ... */ -#define RES_MAXALIASES 35 /* maximum aliases allowed */ -#define RES_MAXADDRS 35 /* maximum addresses allowed */ -/* - * OSF1 doesn't have RES_NOALIASES - */ -#ifndef RES_NOALIASES -#define RES_NOALIASES 0 -#endif - -/* - * macros used to calulate offsets into fixed query buffer - */ -#define ALIAS_BLEN ((RES_MAXALIASES + 1) * sizeof(char*)) -#define ADDRS_BLEN ((RES_MAXADDRS + 1) * sizeof(struct in_addr*)) - -#define ADDRS_OFFSET (ALIAS_BLEN + ADDRS_BLEN) -#define ADDRS_DLEN (RES_MAXADDRS * sizeof(struct in_addr)) -#define NAMES_OFFSET (ADDRS_OFFSET + ADDRS_DLEN) -#define MAXGETHOSTLEN (NAMES_OFFSET + MAXPACKET) - -#define AR_TTL 600 /* TTL in seconds for dns cache entries */ - -/* - * the following values should be prime - */ -#define ARES_CACSIZE 307 -#define MAXCACHED 281 - -/* - * RFC 1104/1105 wasn't very helpful about what these fields - * should be named, so for now, we'll just name them this way. - * we probably should look at what named calls them or something. - */ -#define TYPE_SIZE 2 -#define CLASS_SIZE 2 -#define TTL_SIZE 4 -#define RDLENGTH_SIZE 2 -#define ANSWER_FIXED_SIZE (TYPE_SIZE + CLASS_SIZE + TTL_SIZE + RDLENGTH_SIZE) - -/* - * Building the Hostent - * The Hostent struct is arranged like this: - * +-------------------------------+ - * Hostent: | struct hostent h | - * |-------------------------------| - * | char *buf | - * +-------------------------------+ - * - * allocated: - * - * +-------------------------------+ - * buf: | h_aliases pointer array | Max size: ALIAS_BLEN; - * | NULL | contains `char *'s - * |-------------------------------| - * | h_addr_list pointer array | Max size: ADDRS_BLEN; - * | NULL | contains `struct in_addr *'s - * |-------------------------------| - * | h_addr_list addresses | Max size: ADDRS_DLEN; - * | | contains `struct in_addr's - * |-------------------------------| - * | storage for hostname strings | Max size: ALIAS_DLEN; - * +-------------------------------+ contains `char's - * - * For requests the size of the h_aliases, and h_addr_list pointer - * array sizes are set to MAXALISES and MAXADDRS respectively, and - * buf is a fixed size with enough space to hold the largest expected - * reply from a nameserver, see RFC 1034 and RFC 1035. - * For cached entries the sizes are dependent on the actual number - * of aliases and addresses. If new aliases and addresses are found - * for cached entries, the buffer is grown and the new entries are added. - * The hostent struct is filled in with the addresses of the entries in - * the Hostent buf as follows: - * h_name - contains a pointer to the start of the hostname string area, - * or NULL if none is set. The h_name is followed by the - * aliases, in the storage for hostname strings area. - * h_aliases - contains a pointer to the start of h_aliases pointer array. - * This array contains pointers to the storage for hostname - * strings area and is terminated with a NULL. The first alias - * is stored directly after the h_name. - * h_addr_list - contains a pointer to the start of h_addr_list pointer array. - * This array contains pointers to in_addr structures in the - * h_addr_list addresses area and is terminated with a NULL. - * - * Filling the buffer this way allows for proper alignment of the h_addr_list - * addresses. - * - * This arrangement allows us to alias a Hostent struct pointer as a - * real struct hostent* without lying. It also allows us to change the - * values contained in the cached entries and requests without changing - * the actual hostent pointer, which is saved in a client struct and can't - * be changed without blowing things up or a lot more fiddling around. - * It also allows for defered allocation of the fixed size buffers until - * they are really needed. - * Nov. 17, 1997 --Bleep - */ - -struct Hostent { - struct hostent h; /* the hostent struct we are passing around */ - char* buf; /* buffer for data pointed to from hostent */ -}; - -struct ResRequest { - struct ResRequest* next; - int id; - int sent; /* number of requests sent */ - time_t ttl; - char type; - char retries; /* retry counter */ - char sends; /* number of sends (>1 means resent) */ - char resend; /* send flag. 0 == dont resend */ - time_t sentat; - time_t timeout; - struct in_addr addr; - char* name; - struct DNSQuery query; /* query callback for this request */ - struct Hostent he; -}; - -struct CacheEntry { - struct CacheEntry* hname_next; - struct CacheEntry* hnum_next; - struct CacheEntry* list_next; - time_t expireat; - time_t ttl; - struct Hostent he; - struct DNSReply reply; -}; - -struct CacheTable { - struct CacheEntry* num_list; - struct CacheEntry* name_list; -}; - - -int ResolverFileDescriptor = -1; /* GLOBAL - used in s_bsd.c */ - -static struct Socket resSock; /* Socket describing resolver */ -static struct Timer resExpireDNS; /* Timer for DNS expiration */ -static struct Timer resExpireCache; /* Timer for cache expiration */ - -static time_t nextDNSCheck = 0; -static time_t nextCacheExpire = 1; - -/* - * Keep a spare file descriptor open. res_init calls fopen to read the - * resolv.conf file. If ircd is hogging all the file descriptors below 256, - * on systems with crippled FILE structures this will cause wierd bugs. - * This is definitely needed for Solaris which uses an unsigned char to - * hold the file descriptor. --Dianora - */ -static int spare_fd = -1; - -static int cachedCount = 0; -static struct CacheTable hashtable[ARES_CACSIZE]; -static struct CacheEntry* cacheTop; -static struct ResRequest* requestListHead; /* head of resolver request list */ -static struct ResRequest* requestListTail; /* tail of resolver request list */ - - -static void add_request(struct ResRequest* request); -static void rem_request(struct ResRequest* request); -static struct ResRequest* make_request(const struct DNSQuery* query); -static time_t timeout_query_list(time_t now); -static time_t expire_cache(time_t now); -static void rem_cache(struct CacheEntry*); -static void do_query_name(const struct DNSQuery* query, - const char* name, - struct ResRequest* request); -static void do_query_number(const struct DNSQuery* query, - const struct in_addr*, - struct ResRequest* request); -static void query_name(const char* name, - int query_class, - int query_type, - struct ResRequest* request); -static void resend_query(struct ResRequest* request); -static struct CacheEntry* make_cache(struct ResRequest* request); -static struct CacheEntry* find_cache_name(const char* name); -static struct CacheEntry* find_cache_number(struct ResRequest* request, - const char* addr); -static struct ResRequest* find_id(int); - -static struct cacheinfo { - int ca_adds; - int ca_dels; - int ca_expires; - int ca_lookups; - int ca_na_hits; - int ca_nu_hits; - int ca_updates; -} cainfo; - -static struct resinfo { - int re_errors; - int re_nu_look; - int re_na_look; - int re_replies; - int re_requests; - int re_resends; - int re_sent; - int re_timeouts; - int re_shortttl; - int re_unkrep; -} reinfo; - - -/* - * From bind 8.3, these aren't declared in earlier versions of bind - */ -extern u_short _getshort(const u_char *); -extern u_int _getlong(const u_char *); -/* - * int - * res_isourserver(ina) - * looks up "ina" in _res.ns_addr_list[] - * returns: - * 0 : not found - * >0 : found - * author: - * paul vixie, 29may94 - */ -static int -res_ourserver(const struct __res_state* statp, const struct sockaddr_in* inp) -{ - struct sockaddr_in ina; - int ns; - - ina = *inp; - for (ns = 0; ns < statp->nscount; ns++) { - const struct sockaddr_in *srv = &statp->nsaddr_list[ns]; - - if (srv->sin_family == ina.sin_family && - srv->sin_port == ina.sin_port && - (srv->sin_addr.s_addr == INADDR_ANY || - srv->sin_addr.s_addr == ina.sin_addr.s_addr)) - return (1); - } - return (0); -} - -/* Socket callback for resolver */ -static void res_callback(struct Event* ev) -{ - assert(ev_type(ev) == ET_READ || ev_type(ev) == ET_ERROR); - - resolver_read(); -} - -/* - * start_resolver - do everything we need to read the resolv.conf file - * and initialize the resolver file descriptor if needed - */ -static void start_resolver(void) -{ - Debug((DEBUG_DNS, "Resolver: start_resolver")); - /* - * close the spare file descriptor so res_init can read resolv.conf - * successfully. Needed on Solaris - */ - if (spare_fd > -1) - close(spare_fd); - - res_init(); /* res_init always returns 0 */ - /* - * make sure we have a valid file descriptor below 256 so we can - * do this again. Needed on Solaris - */ - spare_fd = open("/dev/null",O_RDONLY,0); - if ((spare_fd < 0) || (spare_fd > 255)) { - char sparemsg[80]; - ircd_snprintf(0, sparemsg, sizeof(sparemsg), "invalid spare_fd %d", - spare_fd); - server_restart(sparemsg); - } - - if (!_res.nscount) { - _res.nscount = 1; - _res.nsaddr_list[0].sin_addr.s_addr = inet_addr("127.0.0.1"); - } - _res.options |= RES_NOALIASES; - - if (ResolverFileDescriptor < 0) { - ResolverFileDescriptor = socket(AF_INET, SOCK_DGRAM, 0); - if (-1 == ResolverFileDescriptor) { - report_error("Resolver: error creating socket for %s: %s", - cli_name(&me), errno); - return; - } - if (!os_set_nonblocking(ResolverFileDescriptor)) - report_error("Resolver: error setting non-blocking for %s: %s", - cli_name(&me), errno); - if (!socket_add(&resSock, res_callback, 0, SS_DATAGRAM, - SOCK_EVENT_READABLE, ResolverFileDescriptor)) - report_error("Resolver: unable to queue resolver file descriptor for %s", - cli_name(&me), ENFILE); - } -} - -/* Call the query timeout function */ -static void expire_DNS_callback(struct Event* ev) -{ - time_t next; - - next = timeout_query_list(CurrentTime); - - timer_add(&resExpireDNS, expire_DNS_callback, 0, TT_ABSOLUTE, next); -} - -/* Call the cache expire function */ -static void expire_cache_callback(struct Event* ev) -{ - time_t next; - - next = expire_cache(CurrentTime); - - timer_add(&resExpireCache, expire_cache_callback, 0, TT_ABSOLUTE, next); -} - -/* - * init_resolver - initialize resolver and resolver library - */ -int init_resolver(void) -{ - Debug((DEBUG_DNS, "Resolver: init_resolver")); -#ifdef LRAND48 - srand48(CurrentTime); -#endif - memset(&cainfo, 0, sizeof(cainfo)); - memset(hashtable, 0, sizeof(hashtable)); - memset(&reinfo, 0, sizeof(reinfo)); - - requestListHead = requestListTail = 0; - - /* initiate the resolver timers */ - timer_add(timer_init(&resExpireDNS), expire_DNS_callback, 0, - TT_RELATIVE, 1); - timer_add(timer_init(&resExpireCache), expire_cache_callback, 0, - TT_RELATIVE, 1); - - errno = h_errno = 0; - - start_resolver(); - Debug((DEBUG_DNS, "Resolver: fd %d errno: %d h_errno: %d: %s", - ResolverFileDescriptor, errno, h_errno, - (strerror(errno)) ? strerror(errno) : "Unknown")); - return ResolverFileDescriptor; -} - -/* - * restart_resolver - flush the cache, reread resolv.conf, reopen socket - */ -void restart_resolver(void) -{ - /* flush_cache(); flush the dns cache */ - start_resolver(); -} - -static int validate_hostent(const struct hostent* hp) -{ - const char* name; - int i = 0; - assert(0 != hp); - for (name = hp->h_name; name; name = hp->h_aliases[i++]) { - if (!string_is_hostname(name)) - return 0; - } - return 1; -} - -/* - * add_request - place a new request in the request list - */ -static void add_request(struct ResRequest* request) -{ - assert(0 != request); - if (!requestListHead) - requestListHead = requestListTail = request; - else { - requestListTail->next = request; - requestListTail = request; - } - request->next = NULL; - ++reinfo.re_requests; -} - -/* - * rem_request - remove a request from the list. - * This must also free any memory that has been allocated for - * temporary storage of DNS results. - */ -static void rem_request(struct ResRequest* request) -{ - struct ResRequest** current; - struct ResRequest* prev = NULL; - - assert(0 != request); - for (current = &requestListHead; *current; ) { - if (*current == request) { - *current = request->next; - if (requestListTail == request) - requestListTail = prev; - break; - } - prev = *current; - current = &(*current)->next; - } - MyFree(request->he.buf); - MyFree(request->name); - MyFree(request); -} - -/* - * make_request - Create a DNS request record for the server. - */ -static struct ResRequest* make_request(const struct DNSQuery* query) -{ - struct ResRequest* request; - assert(0 != query); - request = (struct ResRequest*) MyMalloc(sizeof(struct ResRequest)); - memset(request, 0, sizeof(struct ResRequest)); - - request->sentat = CurrentTime; - request->retries = 3; - request->resend = 1; - request->timeout = 5; /* start at 5 per RFC1123 */ - request->addr.s_addr = INADDR_NONE; - request->he.h.h_addrtype = AF_INET; - request->he.h.h_length = sizeof(struct in_addr); - request->query.vptr = query->vptr; - request->query.callback = query->callback; - -#if defined(NULL_POINTER_NOT_ZERO) - request->next = NULL; - request->he.buf = NULL; - request->he.h.h_name = NULL; - request->he.h.h_aliases = NULL; - request->he.h.h_addr_list = NULL; -#endif - add_request(request); - return request; -} - -/* - * timeout_query_list - Remove queries from the list which have been - * there too long without being resolved. - */ -static time_t timeout_query_list(time_t now) -{ - struct ResRequest* request; - struct ResRequest* next_request = 0; - time_t next_time = 0; - time_t timeout = 0; - - Debug((DEBUG_DNS, "Resolver: timeout_query_list at %s", myctime(now))); - for (request = requestListHead; request; request = next_request) { - next_request = request->next; - timeout = request->sentat + request->timeout; - if (timeout < now) { - if (--request->retries <= 0) { - ++reinfo.re_timeouts; - (*request->query.callback)(request->query.vptr, 0); - rem_request(request); - continue; - } - else { - request->sentat = now; - request->timeout += request->timeout; - resend_query(request); - } - } - if (!next_time || timeout < next_time) { - next_time = timeout; - } - } - return (next_time > now) ? next_time : (now + AR_TTL); -} - -/* - * expire_cache - removes entries from the cache which are older - * than their expiry times. returns the time at which the server - * should next poll the cache. - */ -static time_t expire_cache(time_t now) -{ - struct CacheEntry* cp; - struct CacheEntry* cp_next; - time_t expire = 0; - - Debug((DEBUG_DNS, "Resolver: expire_cache at %s", myctime(now))); - for (cp = cacheTop; cp; cp = cp_next) { - cp_next = cp->list_next; - if (cp->expireat < now) { - ++cainfo.ca_expires; - rem_cache(cp); - } - else if (!expire || expire > cp->expireat) - expire = cp->expireat; - } - return (expire > now) ? expire : (now + AR_TTL); -} - -/* - * timeout_resolver - check request list and cache for expired entries - */ -time_t timeout_resolver(time_t now) -{ - if (nextDNSCheck < now) - nextDNSCheck = timeout_query_list(now); - if (nextCacheExpire < now) - nextCacheExpire = expire_cache(now); - return IRCD_MIN(nextDNSCheck, nextCacheExpire); -} - - -/* - * delete_resolver_queries - cleanup outstanding queries - * for which there no longer exist clients or conf lines. - */ -void delete_resolver_queries(const void* vptr) -{ - struct ResRequest* request; - struct ResRequest* next_request; - - for (request = requestListHead; request; request = next_request) { - next_request = request->next; - if (vptr == request->query.vptr) - rem_request(request); - } -} - -/* - * send_res_msg - sends msg to all nameservers found in the "_res" structure. - * This should reflect /etc/resolv.conf. We will get responses - * which arent needed but is easier than checking to see if nameserver - * isnt present. Returns number of messages successfully sent to - * nameservers or -1 if no successful sends. - */ -static int send_res_msg(const u_char* msg, int len, int rcount) -{ - int i; - int sent = 0; - int max_queries = IRCD_MIN(_res.nscount, rcount); - - assert(0 != msg); - /* - * RES_PRIMARY option is not implemented - * if (_res.options & RES_PRIMARY || 0 == max_queries) - */ - if (0 == max_queries) - max_queries = 1; - - Debug((DEBUG_DNS, "Resolver: sendto %d", max_queries)); - - for (i = 0; i < max_queries; i++) { - if (sendto(ResolverFileDescriptor, msg, len, 0, - (struct sockaddr*) &(_res.nsaddr_list[i]), - sizeof(struct sockaddr_in)) == len) { - ++reinfo.re_sent; - ++sent; - } - else - log_write(LS_RESOLVER, L_ERROR, 0, "Resolver: send failed %m"); - } - return sent; -} - -/* - * find_id - find a dns request id (id is determined by dn_mkquery) - */ -static struct ResRequest* find_id(int id) -{ - struct ResRequest* request; - - for (request = requestListHead; request; request = request->next) { - if (request->id == id) - return request; - } - return NULL; -} - -/* - * gethost_byname - get host address from name - */ -struct DNSReply* gethost_byname(const char* name, - const struct DNSQuery* query) -{ - struct CacheEntry* cp; - assert(0 != name); - - Debug((DEBUG_DNS, "Resolver: gethost_byname %s", name)); - ++reinfo.re_na_look; - if ((cp = find_cache_name(name))) - return &(cp->reply); - - do_query_name(query, name, NULL); - nextDNSCheck = 1; - return NULL; -} - -/* - * gethost_byaddr - get host name from address - */ -struct DNSReply* gethost_byaddr(const char* addr, - const struct DNSQuery* query) -{ - struct CacheEntry *cp; - - assert(0 != addr); - - Debug((DEBUG_DNS, "Resolver: gethost_byaddr %s", ircd_ntoa(addr))); - - ++reinfo.re_nu_look; - if ((cp = find_cache_number(NULL, addr))) - return &(cp->reply); - - do_query_number(query, (const struct in_addr*) addr, NULL); - nextDNSCheck = 1; - return NULL; -} - -/* - * do_query_name - nameserver lookup name - */ -static void do_query_name(const struct DNSQuery* query, - const char* name, struct ResRequest* request) -{ - ... [truncated message content] |