irc2.11.2p3/0000755000175000017500000000000011431325174010335 5ustar kkkkirc2.11.2p3/configure0000755000175000017500000000224406700222763012251 0ustar kkkk#! /bin/sh quick_fwd= for arg do case "$arg" in -help | --help | --hel | --he) quick_fwd=yes break ;; -version | --version | --versio | --versi | --vers) quick_fwd=yes break ;; *) break ;; esac done if test "x$quick_fwd" = xyes then support/configure $* else echo "retrieving the system name, type and OS release..." rev=`support/config.guess` if test "${rev}" # test for no output then echo " your system seems to be ${rev}." if test ! -d "${rev}" then echo "creating directory ${rev}..." mkdir "${rev}" fi cd "${rev}" echo "now working in directory ${rev}..." cp -p ../support/configure . if test ! -f config.h then echo "copying config.h from config.h.dist..." cp -p ../support/config.h.dist config.h fi ./configure $* if test $? = 0 then echo "Have you read doc/README? (I hope so)" echo "Next cd ${rev}, edit \"config.h\" and \"Makefile\"," echo "run \"make all\" to build and \"make install\" to install." fi else echo Failed to determine your host type, giving up. echo Perhaps you should specify it manually. fi fi irc2.11.2p3/support/0000755000175000017500000000000012374741151012055 5ustar kkkkirc2.11.2p3/support/configure0000755000175000017500000104642611030265263013772 0ustar kkkk#! /bin/sh # From configure.in Id: configure.in,v 1.74 2008/06/09 16:16:08 chopin Exp . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for irc 2.11. # # Report bugs to . # # Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # Work around bugs in pre-3.0 UWIN ksh. $as_unset ENV MAIL MAILPATH PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)$' \| \ . : '\(.\)' 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } /^X\/\(\/\/\)$/{ s//\1/; q; } /^X\/\(\/\).*/{ s//\1/; q; } s/.*/./; q'` # PATH needs CR, and LINENO needs CR and PATH. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" || { # Find who we are. Look in the path if we contain no path at all # relative or not. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 { (exit 1); exit 1; }; } fi case $CONFIG_SHELL in '') as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for as_base in sh bash ksh sh5; do case $as_dir in /*) if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } CONFIG_SHELL=$as_dir/$as_base export CONFIG_SHELL exec "$CONFIG_SHELL" "$0" ${1+"$@"} fi;; esac done done ;; esac # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line before each line; the second 'sed' does the real # work. The second script uses 'N' to pair each line-number line # with the numbered line, and appends trailing '-' during # substitution so that $LINENO is not a special case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) sed '=' <$as_myself | sed ' N s,$,-, : loop s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, t loop s,-$,, s,^['$as_cr_digits']*\n,, ' >$as_me.lineno && chmod +x $as_me.lineno || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensible to this). . ./$as_me.lineno # Exit status is that of the last command. exit } case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C=' ' ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` exec 6>&1 # # Initializations. # ac_default_prefix=/usr/local ac_config_libobj_dir=. cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. # This variable seems obsolete. It should probably be removed, and # only ac_max_sed_lines should be used. : ${ac_max_here_lines=38} # Identity of this package. PACKAGE_NAME='irc' PACKAGE_TARNAME='irc' PACKAGE_VERSION='2.11' PACKAGE_STRING='irc 2.11' PACKAGE_BUGREPORT='ircd-bugs@irc.org' # Factoring default headers for most tests. ac_includes_default="\ #include #if HAVE_SYS_TYPES_H # include #endif #if HAVE_SYS_STAT_H # include #endif #if STDC_HEADERS # include # include #else # if HAVE_STDLIB_H # include # endif #endif #if HAVE_STRING_H # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif # include #endif #if HAVE_STRINGS_H # include #endif #if HAVE_INTTYPES_H # include #else # if HAVE_STDINT_H # include # endif #endif #if HAVE_UNISTD_H # include #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 logdir rundir INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP AWK SUM M4_PATH EGREP MATHLIBS IRC_ZLIB_INCLUDE IRC_ZLIB_LIBRARY IRC_DLIB LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. ac_init_help= ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_option in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir=$ac_optarg ;; -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/-/_/g'` eval "enable_$ac_feature=no" ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/-/_/g'` case $ac_option in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "enable_$ac_feature='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package| sed 's/-/_/g'` case $ac_option in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "with_$ac_package='$ac_optarg'" ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/-/_/g'` eval "with_$ac_package=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` eval "$ac_envvar='$ac_optarg'" export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi # Be sure to have absolute paths. for ac_var in exec_prefix prefix do eval ac_val=$`echo $ac_var` case $ac_val in [\\/$]* | ?:[\\/]* | NONE | '' ) ;; *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # Be sure to have absolute paths. for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ localstatedir libdir includedir oldincludedir infodir mandir do eval ac_val=$`echo $ac_var` case $ac_val in [\\/$]* | ?:[\\/]* ) ;; *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_confdir=`(dirname "$0") 2>/dev/null || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$0" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 { (exit 1); exit 1; }; } else { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi fi (cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 { (exit 1); exit 1; }; } srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` ac_env_build_alias_set=${build_alias+set} ac_env_build_alias_value=$build_alias ac_cv_env_build_alias_set=${build_alias+set} ac_cv_env_build_alias_value=$build_alias ac_env_host_alias_set=${host_alias+set} ac_env_host_alias_value=$host_alias ac_cv_env_host_alias_set=${host_alias+set} ac_cv_env_host_alias_value=$host_alias ac_env_target_alias_set=${target_alias+set} ac_env_target_alias_value=$target_alias ac_cv_env_target_alias_set=${target_alias+set} ac_cv_env_target_alias_value=$target_alias ac_env_CC_set=${CC+set} ac_env_CC_value=$CC ac_cv_env_CC_set=${CC+set} ac_cv_env_CC_value=$CC ac_env_CFLAGS_set=${CFLAGS+set} ac_env_CFLAGS_value=$CFLAGS ac_cv_env_CFLAGS_set=${CFLAGS+set} ac_cv_env_CFLAGS_value=$CFLAGS ac_env_LDFLAGS_set=${LDFLAGS+set} ac_env_LDFLAGS_value=$LDFLAGS ac_cv_env_LDFLAGS_set=${LDFLAGS+set} ac_cv_env_LDFLAGS_value=$LDFLAGS ac_env_CPPFLAGS_set=${CPPFLAGS+set} ac_env_CPPFLAGS_value=$CPPFLAGS ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} ac_cv_env_CPPFLAGS_value=$CPPFLAGS ac_env_CPP_set=${CPP+set} ac_env_CPP_value=$CPP ac_cv_env_CPP_set=${CPP+set} ac_cv_env_CPP_value=$CPP # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures irc 2.11 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] _ACEOF cat <<_ACEOF Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data [PREFIX/share] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --infodir=DIR info documentation [PREFIX/info] --mandir=DIR man documentation [PREFIX/man] _ACEOF cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of irc 2.11:";; esac cat <<\_ACEOF Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-ip6 enables IPv6 --enable-ipv6 enables IPv6 --enable-dsm enables dynamically shared modules for iauth Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-logdir=DIR log files in DIR [localstatedir/log] --with-rundir=DIR pid and tune files in DIR [localstatedir/run] --with-zlib[=ZDIR] checks for zlib; if found, enables compressed links --without-zlib does not check for zlib; disables compressed links --with-resconf=FILE use FILE as resolver config file [/etc/resolv.conf] Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. ac_popdir=`pwd` for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d $ac_dir || continue ac_builddir=. if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A "../" for each directory in $ac_dir_suffix. ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` else ac_dir_suffix= ac_top_builddir= fi case $srcdir in .) # No --srcdir option. We are building in place. ac_srcdir=. if test -z "$ac_top_builddir"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac # Do not use `cd foo && pwd` to compute absolute paths, because # the directories may not exist. case `pwd` in .) ac_abs_builddir="$ac_dir";; *) case "$ac_dir" in .) ac_abs_builddir=`pwd`;; [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; *) ac_abs_builddir=`pwd`/"$ac_dir";; esac;; esac case $ac_abs_builddir in .) ac_abs_top_builddir=${ac_top_builddir}.;; *) case ${ac_top_builddir}. in .) ac_abs_top_builddir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; esac;; esac case $ac_abs_builddir in .) ac_abs_srcdir=$ac_srcdir;; *) case $ac_srcdir in .) ac_abs_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; esac;; esac case $ac_abs_builddir in .) ac_abs_top_srcdir=$ac_top_srcdir;; *) case $ac_top_srcdir in .) ac_abs_top_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; esac;; esac cd $ac_dir # Check for guested configure; otherwise get Cygnus style configure. if test -f $ac_srcdir/configure.gnu; then echo $SHELL $ac_srcdir/configure.gnu --help=recursive elif test -f $ac_srcdir/configure; then echo $SHELL $ac_srcdir/configure --help=recursive elif test -f $ac_srcdir/configure.ac || test -f $ac_srcdir/configure.in; then echo $ac_configure --help else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi cd $ac_popdir done fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF irc configure 2.11 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit 0 fi exec 5>config.log cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by irc $as_me 2.11, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ _ACEOF { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` hostinfo = `(hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. echo "PATH: $as_dir" done } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_sep= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; 2) ac_configure_args1="$ac_configure_args1 '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" # Get rid of the leading space. ac_sep=" " ;; esac done done $as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Be sure not to use single quotes in there, as some shells, # such as our DU 5.0 friend, will then `close' the trap. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX echo # The following way of writing the cache mishandles newlines in values, { (set) 2>&1 | case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in *ac_space=\ *) sed -n \ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" ;; *) sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } echo cat <<\_ASBOX ## ----------------- ## ## Output variables. ## ## ----------------- ## _ASBOX echo for ac_var in $ac_subst_vars do eval ac_val=$`echo $ac_var` echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX ## ------------- ## ## Output files. ## ## ------------- ## _ASBOX echo for ac_var in $ac_subst_files do eval ac_val=$`echo $ac_var` echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo fi if test -s confdefs.h; then cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX echo sed "/^$/d" confdefs.h | sort echo fi test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 rm -f core *.core && rm -rf conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo >confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . $cache_file;; *) . ./$cache_file;; esac fi else { echo "$as_me:$LINENO: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in `(set) 2>&1 | sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val="\$ac_cv_env_${ac_var}_value" eval ac_new_val="\$ac_env_${ac_var}_value" case $ac_old_set,$ac_new_set in set,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Check whether --with-logdir or --without-logdir was given. if test "${with_logdir+set}" = set; then withval="$with_logdir" logdir=$with_logdir else logdir=$localstatedir'/log' fi; # Check whether --with-rundir or --without-rundir was given. if test "${with_rundir+set}" = set; then withval="$with_rundir" rundir=$with_rundir else rundir=$localstatedir'/run' fi; ac_config_headers="$ac_config_headers setup.h:../support/setup.h.in" ac_aux_dir= for ac_dir in ../support $srcdir/../support; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f $ac_dir/install.sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f $ac_dir/shtool; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in ../support $srcdir/../support" >&5 echo "$as_me: error: cannot find install-sh or install.sh in ../support $srcdir/../support" >&2;} { (exit 1); exit 1; }; } fi ac_config_guess="$SHELL $ac_aux_dir/config.guess" ac_config_sub="$SHELL $ac_aux_dir/config.sub" ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in ./ | .// | /cC/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi done done ;; esac done fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL=$ac_install_sh fi fi echo "$as_me:$LINENO: result: $INSTALL" >&5 echo "${ECHO_T}$INSTALL" >&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable cc found in \$PATH" >&5 echo "$as_me: error: no acceptable cc found in \$PATH" >&2;} { (exit 1); exit 1; }; } fi ac_test_CFLAGS="${CFLAGS+set}" if test x$ac_cv_c_compiler_gnu = xyes; then GCC=yes ac_save_CFLAGS="$CFLAGS" CFLAGS= if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" else CFLAGS="-O2" fi else GCC= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$ac_ct_CC" && break done CC=$ac_ct_CC fi fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:$LINENO:" \ "checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 (eval $ac_link_default) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Find the output, starting from the most likely. This scheme is # not robust to junk in `.', hence go to wildcards (a.*) only as a last # resort. # Be careful to initialize this variable, since it used to be cached. # Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. ac_cv_exeext= # b.out is created by i960 compilers. for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; conftest.$ac_ext ) # This is the source file. ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` # FIXME: I believe we export ac_cv_exeext for Libtool, # but it would be cool to find out if it's true. Does anybody # maintain Libtool? --akim. export ac_cv_exeext break;; * ) break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: C compiler cannot create executables See \`config.log' for more details." >&5 echo "$as_me: error: C compiler cannot create executables See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext echo "$as_me:$LINENO: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6 # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:$LINENO: checking whether the C compiler works" >&5 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (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 cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { echo "$as_me:$LINENO: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi fi fi echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 echo "$as_me:$LINENO: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6 echo "$as_me:$LINENO: checking for suffix of executables" >&5 echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 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); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` export ac_cv_exeext break;; * ) break;; esac done else { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest$ac_cv_exeext echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6 rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT echo "$as_me:$LINENO: checking for suffix of object files" >&5 echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6 OBJEXT=$ac_cv_objext ac_objext=$OBJEXT echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS CFLAGS="-g" echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_prog_cc_g=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 if test "${ac_cv_prog_cc_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_stdc=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std1 is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std1. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF # Don't try gcc -ansi; that turns off useful extensions and # breaks some systems' header files. # AIX -qlanglvl=ansi # Ultrix and OSF/1 -std1 # HP-UX 10.20 and later -Ae # HP-UX older versions -Aa -D_HPUX_SOURCE # SVR4 -Xc -D__EXTENSIONS__ for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_prog_cc_stdc=$ac_arg break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext done rm -f conftest.$ac_ext conftest.$ac_objext CC=$ac_save_CC fi case "x$ac_cv_prog_cc_stdc" in x|xno) echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6 ;; *) echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 CC="$CC $ac_cv_prog_cc_stdc" ;; esac # Some people use a C++ compiler to compile C. Since we use `exit', # in C++ we need to declare it. In case someone uses the same compiler # for both compiling C and C++ we need to have the C++ compiler decide # the declaration of exit, since it's the most demanding environment. cat >conftest.$ac_ext <<_ACEOF #ifndef __cplusplus choke me #endif _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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 for ac_declaration in \ '' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void exit (int) throw ();' \ 'extern "C" void exit (int);' \ 'void exit (int);' do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_declaration #include int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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 : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 continue fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_declaration int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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 break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done rm -f conftest* if test -n "$ac_declaration"; then echo '#ifdef __cplusplus' >>confdefs.h echo $ac_declaration >>confdefs.h echo '#endif' >>confdefs.h fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi echo "$as_me:$LINENO: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6 ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_AWK+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then echo "$as_me:$LINENO: result: $AWK" >&5 echo "${ECHO_T}$AWK" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$AWK" && break done #IRC_PROG_INSTALL for ac_prog in md5sum md5 sum cksum do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_SUM+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $SUM in [\\/]* | ?:[\\/]*) ac_cv_path_SUM="$SUM" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_SUM="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done ;; esac fi SUM=$ac_cv_path_SUM if test -n "$SUM"; then echo "$as_me:$LINENO: result: $SUM" >&5 echo "${ECHO_T}$SUM" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$SUM" && break done test -n "$SUM" || SUM="true" for ac_prog in gm4 gnum4 m4 do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_M4_PATH+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $M4_PATH in [\\/]* | ?:[\\/]*) ac_cv_path_M4_PATH="$M4_PATH" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_M4_PATH="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done ;; esac fi M4_PATH=$ac_cv_path_M4_PATH if test -n "$M4_PATH"; then echo "$as_me:$LINENO: result: $M4_PATH" >&5 echo "${ECHO_T}$M4_PATH" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$M4_PATH" && break done test -n "$M4_PATH" || M4_PATH="m4" echo "$as_me:$LINENO: checking for GNU m4" >&5 echo $ECHO_N "checking for GNU m4... $ECHO_C" >&6 if test "${irc_cv_gnum4+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "`(echo __"gnu"__ | $M4_PATH) 2>/dev/null`" = "__"gnu"__"; then irc_cv_gnum4=no else irc_cv_gnum4=yes fi fi if test $irc_cv_gnum4 = yes; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 cat >>confdefs.h <<\_ACEOF #define HAVE_GNU_M4 1 _ACEOF else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi echo "$as_me:$LINENO: checking for egrep" >&5 echo $ECHO_N "checking for egrep... $ECHO_C" >&6 if test "${ac_cv_prog_egrep+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if echo a | (grep -E '(a|b)') >/dev/null 2>&1 then ac_cv_prog_egrep='grep -E' else ac_cv_prog_egrep='egrep' fi fi echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 echo "${ECHO_T}$ac_cv_prog_egrep" >&6 EGREP=$ac_cv_prog_egrep if test $ac_cv_c_compiler_gnu = yes; then echo "$as_me:$LINENO: checking whether $CC needs -traditional" >&5 echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6 if test "${ac_cv_prog_gcc_traditional+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_pattern="Autoconf.*'x'" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include Autoconf TIOCGETP _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then ac_cv_prog_gcc_traditional=yes else ac_cv_prog_gcc_traditional=no fi rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include Autoconf TCGETA _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then ac_cv_prog_gcc_traditional=yes fi rm -f conftest* fi fi echo "$as_me:$LINENO: result: $ac_cv_prog_gcc_traditional" >&5 echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6 if test $ac_cv_prog_gcc_traditional = yes; then CC="$CC -traditional" fi fi echo "$as_me:$LINENO: checking for AIX" >&5 echo $ECHO_N "checking for AIX... $ECHO_C" >&6 if test "${irc_cv_aix+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "x`(uname) 2>/dev/null`" = "xAIX"; then irc_cv_aix="`uname -rv`" else irc_cv_aix=no fi fi if test "$irc_cv_aix" = no; then echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 else echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 echo "$as_me:$LINENO: checking for AIX" >&5 echo $ECHO_N "checking for AIX... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef _AIX yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 cat >>confdefs.h <<\_ACEOF #define _ALL_SOURCE 1 _ACEOF else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi rm -f conftest* if test "x$irc_cv_aix" = "x2 3"; then cat >>confdefs.h <<\_ACEOF #define AIX_3_2 1 _ACEOF fi if test x$CC = xcc; then CFLAGS="$CFLAGS -O3 -qstrict" fi fi echo "$as_me:$LINENO: checking for library containing strerror" >&5 echo $ECHO_N "checking for library containing strerror... $ECHO_C" >&6 if test "${ac_cv_search_strerror+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS ac_cv_search_strerror=no cat >conftest.$ac_ext <<_ACEOF /* 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 strerror (); int main () { strerror (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { 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_strerror="none required" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$ac_cv_search_strerror" = no; then for ac_lib in cposix; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" cat >conftest.$ac_ext <<_ACEOF /* 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 strerror (); int main () { strerror (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { 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_strerror="-l$ac_lib" break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err 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_strerror" >&5 echo "${ECHO_T}$ac_cv_search_strerror" >&6 if test "$ac_cv_search_strerror" != no; then test "$ac_cv_search_strerror" = "none required" || LIBS="$ac_cv_search_strerror $LIBS" fi echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_header_stdc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } _ACEOF rm -f 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='./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 : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6 if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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 eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done if test "${ac_cv_header_minix_config_h+set}" = set; then echo "$as_me:$LINENO: checking for minix/config.h" >&5 echo $ECHO_N "checking for minix/config.h... $ECHO_C" >&6 if test "${ac_cv_header_minix_config_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: $ac_cv_header_minix_config_h" >&5 echo "${ECHO_T}$ac_cv_header_minix_config_h" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking minix/config.h usability" >&5 echo $ECHO_N "checking minix/config.h usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? echo "$as_me:$LINENO: checking minix/config.h presence" >&5 echo $ECHO_N "checking minix/config.h presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: minix/config.h: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: minix/config.h: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: minix/config.h: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: minix/config.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: minix/config.h: present but cannot be compiled" >&5 echo "$as_me: WARNING: minix/config.h: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: minix/config.h: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: minix/config.h: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: minix/config.h: see the Autoconf documentation" >&5 echo "$as_me: WARNING: minix/config.h: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: minix/config.h: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: minix/config.h: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: minix/config.h: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: minix/config.h: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: minix/config.h: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: minix/config.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## -------------------------------- ## ## Report this to ircd-bugs@irc.org ## ## -------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for minix/config.h" >&5 echo $ECHO_N "checking for minix/config.h... $ECHO_C" >&6 if test "${ac_cv_header_minix_config_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_minix_config_h=$ac_header_preproc fi echo "$as_me:$LINENO: result: $ac_cv_header_minix_config_h" >&5 echo "${ECHO_T}$ac_cv_header_minix_config_h" >&6 fi if test $ac_cv_header_minix_config_h = yes; then MINIX=yes else MINIX= fi if test "$MINIX" = yes; then cat >>confdefs.h <<\_ACEOF #define _POSIX_SOURCE 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define _POSIX_1_SOURCE 2 _ACEOF cat >>confdefs.h <<\_ACEOF #define _MINIX 1 _ACEOF fi echo "$as_me:$LINENO: checking for SGI's cc" >&5 echo $ECHO_N "checking for SGI's cc... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef sgi yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then if test x$CC = xcc; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 CC="$CC -cckr" else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi rm -f conftest* echo "$as_me:$LINENO: checking for HPUX's cc" >&5 echo $ECHO_N "checking for HPUX's cc... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef hpux yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then if test x$CC = xcc; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 CC="$CC -Ae" else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi rm -f conftest* echo "$as_me:$LINENO: checking for SunOS" >&5 echo $ECHO_N "checking for SunOS... $ECHO_C" >&6 if test "${irc_cv_sun+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "x`(uname) 2>/dev/null`" = "xSunOS"; then irc_cv_sun="`uname -r`" else irc_cv_sun=no fi fi irc_cv_solaris_2=no if test "$irc_cv_sun" = no; then echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 else if uname -r 2>/dev/null | grep "^5" >/dev/null; then irc_cv_solaris_2="`uname -r | sed -e \"s/^5/2/g\"`" echo "$as_me:$LINENO: result: yes, Solaris $irc_cv_solaris_2" >&5 echo "${ECHO_T}yes, Solaris $irc_cv_solaris_2" >&6 cat >>confdefs.h <<\_ACEOF #define SOLARIS_2 1 _ACEOF if echo "$irc_cv_solaris_2" | egrep "^2\.(0|1|2)$" >/dev/null; then cat >>confdefs.h <<\_ACEOF #define SOLARIS_2_0_2_1_2_2 1 _ACEOF elif echo "$irc_cv_solaris_2" | grep "^2\.3" >/dev/null; then cat >>confdefs.h <<\_ACEOF #define SOLARIS_2_3 1 _ACEOF fi else echo "$as_me:$LINENO: result: yes, SunOS $irc_cv_sun" >&5 echo "${ECHO_T}yes, SunOS $irc_cv_sun" >&6 fi fi echo "$as_me:$LINENO: checking for Linux" >&5 echo $ECHO_N "checking for Linux... $ECHO_C" >&6 if test "${irc_cv_linux+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "x`(uname) 2>/dev/null`" = "xLinux"; then cat > conftest.$ac_ext < EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $AWK "{if (NR > 1) printf(\" \"); printf(\$0)}" | egrep "struct( | )+hostent( | )+\{.*const.*h_name" >/dev/null 2>&1; then rm -rf conftest* irc_cv_linux=bad else rm -rf conftest* irc_cv_linux=good fi rm -f conftest* else irc_cv_linux=no fi fi if test "$irc_cv_linux" = no; then echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 elif test "$irc_cv_linux" = good; then echo "$as_me:$LINENO: result: yes, with a good file" >&5 echo "${ECHO_T}yes, with a good file" >&6 else echo "$as_me:$LINENO: result: yes, with a bad file" >&5 echo "${ECHO_T}yes, with a bad file" >&6 cat >>confdefs.h <<\_ACEOF #define BAD___CONST_NETDB_H 1 _ACEOF fi echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_header_stdc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } _ACEOF rm -f 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='./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 : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6 if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi echo "$as_me:$LINENO: checking for sys/wait.h that is POSIX.1 compatible" >&5 echo $ECHO_N "checking for sys/wait.h that is POSIX.1 compatible... $ECHO_C" >&6 if test "${ac_cv_header_sys_wait_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif int main () { int s; wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_header_sys_wait_h=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_sys_wait_h=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_header_sys_wait_h" >&5 echo "${ECHO_T}$ac_cv_header_sys_wait_h" >&6 if test $ac_cv_header_sys_wait_h = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_SYS_WAIT_H 1 _ACEOF fi for ac_header in stdio.h stdlib.h sys/types.h sys/bitypes.h stddef.h stdarg.h unistd.h ctype.h memory.h errno.h sys/errno.h sys/syscall.h pwd.h math.h utmp.h fcntl.h signal.h sys/ioctl.h sys/file.h sys/filio.h sys/socket.h sys/stat.h sys/resource.h sys/select.h sys/poll.h stropts.h netdb.h netinet/in.h arpa/inet.h sys/param.h syslog.h sys/syslog.h string.h strings.h sys/time.h time.h sys/times.h netinet/in_systm.h netinfo/ni.h arpa/nameser.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## -------------------------------- ## ## Report this to ircd-bugs@irc.org ## ## -------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done echo "$as_me:$LINENO: checking whether string.h and strings.h may both be included" >&5 echo $ECHO_N "checking whether string.h and strings.h may both be included... $ECHO_C" >&6 if test "${ac_cv_header_string+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #include #include _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_header_string=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_string=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_header_string" >&5 echo "${ECHO_T}$ac_cv_header_string" >&6 if test "$ac_cv_header_string" = "yes"; then cat >>confdefs.h <<\_ACEOF #define HAVE_STRING_WITH_STRINGS 1 _ACEOF fi # autoconf now checks not only inclusion, but also compilation for ac_header in resolv.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #if HAVE_NETINET_IN_H # include #endif #if HAVE_ARPA_NAMESER_H # include #endif #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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 eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Some systems need (and ?) before for ac_header in sys/un.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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 eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done echo "$as_me:$LINENO: checking for sys_nerr declaration in stdio.h, errno.h or sys/errno.h" >&5 echo $ECHO_N "checking for sys_nerr declaration in stdio.h, errno.h or sys/errno.h... $ECHO_C" >&6 if test "${irc_cv_decl_sys_nerr+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #if HAVE_SYS_TYPES_H #include #endif #if HAVE_STDIO_H #include #endif #if HAVE_ERRNO_H #include #endif #if HAVE_SYS_ERRNO_H #include #endif int main () { int num = sys_nerr; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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 irc_cv_decl_sys_nerr=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 irc_cv_decl_sys_nerr=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $irc_cv_decl_sys_nerr" >&5 echo "${ECHO_T}$irc_cv_decl_sys_nerr" >&6 if test $irc_cv_decl_sys_nerr = yes; then cat >>confdefs.h <<\_ACEOF #define SYS_NERR_DECLARED 1 _ACEOF fi echo "$as_me:$LINENO: checking for errno declaration in errno.h or sys/errno.h" >&5 echo $ECHO_N "checking for errno declaration in errno.h or sys/errno.h... $ECHO_C" >&6 if test "${irc_cv_decl_errno+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #if HAVE_SYS_TYPES_H #include #endif #if HAVE_ERRNO_H #include #endif #if HAVE_SYS_ERRNO_H #include #endif int main () { int num = errno; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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 irc_cv_decl_errno=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 irc_cv_decl_errno=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $irc_cv_decl_errno" >&5 echo "${ECHO_T}$irc_cv_decl_errno" >&6 if test $irc_cv_decl_errno = yes; then cat >>confdefs.h <<\_ACEOF #define ERRNO_DECLARED 1 _ACEOF fi echo "$as_me:$LINENO: checking for h_errno declaration in errno.h, sys/errno.h or netdb.h" >&5 echo $ECHO_N "checking for h_errno declaration in errno.h, sys/errno.h or netdb.h... $ECHO_C" >&6 if test "${irc_cv_decl_h_errno+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #if HAVE_SYS_TYPES_H #include #endif #if HAVE_ERRNO_H #include #endif #if HAVE_SYS_ERRNO_H #include #endif #if HAVE_NETDB_H #include #endif int main () { int num = h_errno; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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 irc_cv_decl_h_errno=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 irc_cv_decl_h_errno=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $irc_cv_decl_h_errno" >&5 echo "${ECHO_T}$irc_cv_decl_h_errno" >&6 if test $irc_cv_decl_h_errno = yes; then cat >>confdefs.h <<\_ACEOF #define H_ERRNO_DECLARED 1 _ACEOF fi echo "$as_me:$LINENO: checking whether stat file-mode macros are broken" >&5 echo $ECHO_N "checking whether stat file-mode macros are broken... $ECHO_C" >&6 if test "${ac_cv_header_stat_broken+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #if defined(S_ISBLK) && defined(S_IFDIR) # if S_ISBLK (S_IFDIR) You lose. # endif #endif #if defined(S_ISBLK) && defined(S_IFCHR) # if S_ISBLK (S_IFCHR) You lose. # endif #endif #if defined(S_ISLNK) && defined(S_IFREG) # if S_ISLNK (S_IFREG) You lose. # endif #endif #if defined(S_ISSOCK) && defined(S_IFREG) # if S_ISSOCK (S_IFREG) You lose. # endif #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "You lose" >/dev/null 2>&1; then ac_cv_header_stat_broken=yes else ac_cv_header_stat_broken=no fi rm -f conftest* fi echo "$as_me:$LINENO: result: $ac_cv_header_stat_broken" >&5 echo "${ECHO_T}$ac_cv_header_stat_broken" >&6 if test $ac_cv_header_stat_broken = yes; then cat >>confdefs.h <<\_ACEOF #define STAT_MACROS_BROKEN 1 _ACEOF fi echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6 if test "${ac_cv_header_time+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_header_time=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_time=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 echo "${ECHO_T}$ac_cv_header_time" >&6 if test $ac_cv_header_time = yes; then cat >>confdefs.h <<\_ACEOF #define TIME_WITH_SYS_TIME 1 _ACEOF fi echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5 echo $ECHO_N "checking whether struct tm is in sys/time.h or time.h... $ECHO_C" >&6 if test "${ac_cv_struct_tm+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { struct tm *tp; tp->tm_sec; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_struct_tm=time.h else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_struct_tm=sys/time.h fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5 echo "${ECHO_T}$ac_cv_struct_tm" >&6 if test $ac_cv_struct_tm = sys/time.h; then cat >>confdefs.h <<\_ACEOF #define TM_IN_SYS_TIME 1 _ACEOF fi echo "$as_me:$LINENO: checking for mode_t" >&5 echo $ECHO_N "checking for mode_t... $ECHO_C" >&6 if test "${ac_cv_type_mode_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { if ((mode_t *) 0) return 0; if (sizeof (mode_t)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_mode_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_mode_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_mode_t" >&5 echo "${ECHO_T}$ac_cv_type_mode_t" >&6 if test $ac_cv_type_mode_t = yes; then : else cat >>confdefs.h <<_ACEOF #define mode_t int _ACEOF fi echo "$as_me:$LINENO: checking for off_t" >&5 echo $ECHO_N "checking for off_t... $ECHO_C" >&6 if test "${ac_cv_type_off_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { if ((off_t *) 0) return 0; if (sizeof (off_t)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_off_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_off_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 echo "${ECHO_T}$ac_cv_type_off_t" >&6 if test $ac_cv_type_off_t = yes; then : else cat >>confdefs.h <<_ACEOF #define off_t long _ACEOF fi echo "$as_me:$LINENO: checking for pid_t" >&5 echo $ECHO_N "checking for pid_t... $ECHO_C" >&6 if test "${ac_cv_type_pid_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { if ((pid_t *) 0) return 0; if (sizeof (pid_t)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_pid_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_pid_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5 echo "${ECHO_T}$ac_cv_type_pid_t" >&6 if test $ac_cv_type_pid_t = yes; then : else cat >>confdefs.h <<_ACEOF #define pid_t int _ACEOF fi echo "$as_me:$LINENO: checking return type of signal handlers" >&5 echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6 if test "${ac_cv_type_signal+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #ifdef signal # undef signal #endif #ifdef __cplusplus extern "C" void (*signal (int, void (*)(int)))(int); #else void (*signal ()) (); #endif int main () { int i; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_signal=void else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_signal=int fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 echo "${ECHO_T}$ac_cv_type_signal" >&6 cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal _ACEOF echo "$as_me:$LINENO: checking for size_t" >&5 echo $ECHO_N "checking for size_t... $ECHO_C" >&6 if test "${ac_cv_type_size_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { if ((size_t *) 0) return 0; if (sizeof (size_t)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_size_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_size_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 echo "${ECHO_T}$ac_cv_type_size_t" >&6 if test $ac_cv_type_size_t = yes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned _ACEOF fi echo "$as_me:$LINENO: checking for uid_t in sys/types.h" >&5 echo $ECHO_N "checking for uid_t in sys/types.h... $ECHO_C" >&6 if test "${ac_cv_type_uid_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "uid_t" >/dev/null 2>&1; then ac_cv_type_uid_t=yes else ac_cv_type_uid_t=no fi rm -f conftest* fi echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5 echo "${ECHO_T}$ac_cv_type_uid_t" >&6 if test $ac_cv_type_uid_t = no; then cat >>confdefs.h <<\_ACEOF #define uid_t int _ACEOF cat >>confdefs.h <<\_ACEOF #define gid_t int _ACEOF fi echo "$as_me:$LINENO: checking whether an union wait * is mandatory in waitpid" >&5 echo $ECHO_N "checking whether an union wait * is mandatory in waitpid... $ECHO_C" >&6 if test "${irc_cv_type_union_wait+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #if HAVE_SYS_WAIT_H #include #endif _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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 irc_cv_type_union_wait=no else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #if HAVE_SYS_WAIT_H #include #endif _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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 irc_cv_type_union_wait=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 irc_cv_type_union_wait=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $irc_cv_type_union_wait = yes; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 cat >>confdefs.h <<\_ACEOF #define USE_UNION_WAIT 1 _ACEOF else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi echo "$as_me:$LINENO: checking for int8_t" >&5 echo $ECHO_N "checking for int8_t... $ECHO_C" >&6 if test "${ac_cv_type_int8_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #if HAVE_SYS_BITYPES_H #include #endif int main () { if ((int8_t *) 0) return 0; if (sizeof (int8_t)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_int8_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_int8_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_int8_t" >&5 echo "${ECHO_T}$ac_cv_type_int8_t" >&6 if test $ac_cv_type_int8_t = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_INT8_T 1 _ACEOF fi echo "$as_me:$LINENO: checking for uint8_t" >&5 echo $ECHO_N "checking for uint8_t... $ECHO_C" >&6 if test "${ac_cv_type_uint8_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #if HAVE_SYS_BITYPES_H #include #endif int main () { if ((uint8_t *) 0) return 0; if (sizeof (uint8_t)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_uint8_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_uint8_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_uint8_t" >&5 echo "${ECHO_T}$ac_cv_type_uint8_t" >&6 if test $ac_cv_type_uint8_t = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_UINT8_T 1 _ACEOF fi echo "$as_me:$LINENO: checking for u_int8_t" >&5 echo $ECHO_N "checking for u_int8_t... $ECHO_C" >&6 if test "${ac_cv_type_u_int8_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #if HAVE_SYS_BITYPES_H #include #endif int main () { if ((u_int8_t *) 0) return 0; if (sizeof (u_int8_t)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_u_int8_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_u_int8_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_u_int8_t" >&5 echo "${ECHO_T}$ac_cv_type_u_int8_t" >&6 if test $ac_cv_type_u_int8_t = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_U_INT8_T 1 _ACEOF fi echo "$as_me:$LINENO: checking for int16_t" >&5 echo $ECHO_N "checking for int16_t... $ECHO_C" >&6 if test "${ac_cv_type_int16_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #if HAVE_SYS_BITYPES_H #include #endif int main () { if ((int16_t *) 0) return 0; if (sizeof (int16_t)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_int16_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_int16_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_int16_t" >&5 echo "${ECHO_T}$ac_cv_type_int16_t" >&6 if test $ac_cv_type_int16_t = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_INT16_T 1 _ACEOF fi echo "$as_me:$LINENO: checking for uint16_t" >&5 echo $ECHO_N "checking for uint16_t... $ECHO_C" >&6 if test "${ac_cv_type_uint16_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #if HAVE_SYS_BITYPES_H #include #endif int main () { if ((uint16_t *) 0) return 0; if (sizeof (uint16_t)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_uint16_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_uint16_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_uint16_t" >&5 echo "${ECHO_T}$ac_cv_type_uint16_t" >&6 if test $ac_cv_type_uint16_t = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_UINT16_T 1 _ACEOF fi echo "$as_me:$LINENO: checking for u_int16_t" >&5 echo $ECHO_N "checking for u_int16_t... $ECHO_C" >&6 if test "${ac_cv_type_u_int16_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #if HAVE_SYS_BITYPES_H #include #endif int main () { if ((u_int16_t *) 0) return 0; if (sizeof (u_int16_t)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_u_int16_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_u_int16_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_u_int16_t" >&5 echo "${ECHO_T}$ac_cv_type_u_int16_t" >&6 if test $ac_cv_type_u_int16_t = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_U_INT16_T 1 _ACEOF fi echo "$as_me:$LINENO: checking for int32_t" >&5 echo $ECHO_N "checking for int32_t... $ECHO_C" >&6 if test "${ac_cv_type_int32_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #if HAVE_SYS_BITYPES_H #include #endif int main () { if ((int32_t *) 0) return 0; if (sizeof (int32_t)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_int32_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_int32_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_int32_t" >&5 echo "${ECHO_T}$ac_cv_type_int32_t" >&6 if test $ac_cv_type_int32_t = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_INT32_T 1 _ACEOF fi echo "$as_me:$LINENO: checking for uint32_t" >&5 echo $ECHO_N "checking for uint32_t... $ECHO_C" >&6 if test "${ac_cv_type_uint32_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #if HAVE_SYS_BITYPES_H #include #endif int main () { if ((uint32_t *) 0) return 0; if (sizeof (uint32_t)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_uint32_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_uint32_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_uint32_t" >&5 echo "${ECHO_T}$ac_cv_type_uint32_t" >&6 if test $ac_cv_type_uint32_t = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_UINT32_T 1 _ACEOF fi echo "$as_me:$LINENO: checking for u_int32_t" >&5 echo $ECHO_N "checking for u_int32_t... $ECHO_C" >&6 if test "${ac_cv_type_u_int32_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #if HAVE_SYS_BITYPES_H #include #endif int main () { if ((u_int32_t *) 0) return 0; if (sizeof (u_int32_t)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_u_int32_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_u_int32_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_u_int32_t" >&5 echo "${ECHO_T}$ac_cv_type_u_int32_t" >&6 if test $ac_cv_type_u_int32_t = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_U_INT32_T 1 _ACEOF fi echo "$as_me:$LINENO: checking for u_char" >&5 echo $ECHO_N "checking for u_char... $ECHO_C" >&6 if test "${ac_cv_type_u_char+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #if HAVE_SYS_BITYPES_H #include #endif int main () { if ((u_char *) 0) return 0; if (sizeof (u_char)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_u_char=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_u_char=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_u_char" >&5 echo "${ECHO_T}$ac_cv_type_u_char" >&6 if test $ac_cv_type_u_char = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_U_CHAR 1 _ACEOF fi echo "$as_me:$LINENO: checking for u_short" >&5 echo $ECHO_N "checking for u_short... $ECHO_C" >&6 if test "${ac_cv_type_u_short+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #if HAVE_SYS_BITYPES_H #include #endif int main () { if ((u_short *) 0) return 0; if (sizeof (u_short)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_u_short=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_u_short=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_u_short" >&5 echo "${ECHO_T}$ac_cv_type_u_short" >&6 if test $ac_cv_type_u_short = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_U_SHORT 1 _ACEOF fi echo "$as_me:$LINENO: checking for u_int" >&5 echo $ECHO_N "checking for u_int... $ECHO_C" >&6 if test "${ac_cv_type_u_int+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #if HAVE_SYS_BITYPES_H #include #endif int main () { if ((u_int *) 0) return 0; if (sizeof (u_int)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_u_int=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_u_int=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_u_int" >&5 echo "${ECHO_T}$ac_cv_type_u_int" >&6 if test $ac_cv_type_u_int = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_U_INT 1 _ACEOF fi echo "$as_me:$LINENO: checking for u_long" >&5 echo $ECHO_N "checking for u_long... $ECHO_C" >&6 if test "${ac_cv_type_u_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #if HAVE_SYS_BITYPES_H #include #endif int main () { if ((u_long *) 0) return 0; if (sizeof (u_long)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_u_long=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_u_long=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_u_long" >&5 echo "${ECHO_T}$ac_cv_type_u_long" >&6 if test $ac_cv_type_u_long = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_U_LONG 1 _ACEOF fi echo "$as_me:$LINENO: checking for socklen_t" >&5 echo $ECHO_N "checking for socklen_t... $ECHO_C" >&6 if test "${ac_cv_type_socklen_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #if HAVE_SYS_BITYPES_H #include #endif int main () { if ((socklen_t *) 0) return 0; if (sizeof (socklen_t)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_type_socklen_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_socklen_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_socklen_t" >&5 echo "${ECHO_T}$ac_cv_type_socklen_t" >&6 if test $ac_cv_type_socklen_t = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_SOCKLEN_T 1 _ACEOF fi echo "$as_me:$LINENO: checking types of arguments for accept()" >&5 echo $ECHO_N "checking types of arguments for accept()... $ECHO_C" >&6 if test "${ac_cv_func_accept_arg1+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "${ac_cv_func_accept_arg2+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "${ac_cv_func_accept_arg3+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else for ac_cv_func_accept_arg1 in 'int' 'unsigned int'; do for ac_cv_func_accept_arg2 in 'struct sockaddr' 'const struct sockaddr' 'void'; do for ac_cv_func_accept_arg3 in 'socklen_t' 'size_t' 'unsigned int' 'int'; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif extern accept ($ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2 *, $ac_cv_func_accept_arg3 *); int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_not_found=no ; break 3 else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_not_found=yes fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done done done fi fi fi if test "$ac_not_found" = no; then echo "$as_me:$LINENO: result: $ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2 *, $ac_cv_func_accept_arg3 *" >&5 echo "${ECHO_T}$ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2 *, $ac_cv_func_accept_arg3 *" >&6 cat >>confdefs.h <<_ACEOF #define ACCEPT_TYPE_ARG3 $ac_cv_func_accept_arg3 _ACEOF else echo "$as_me:$LINENO: result: Not found" >&5 echo "${ECHO_T}Not found" >&6 { echo "$as_me:$LINENO: WARNING: Using default types for arguments to accept()" >&5 echo "$as_me: WARNING: Using default types for arguments to accept()" >&2;} fi echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 if test "${ac_cv_c_bigendian+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # See if sys/param.h defines the BYTE_ORDER macro. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN bogus endian macros #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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 # It does; now see whether it defined to BIG_ENDIAN or not. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_c_bigendian=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_c_bigendian=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # It does not; compile a test program. if test "$cross_compiling" = yes; then # try to guess the endianness by grepping values into an object file ac_cv_c_bigendian=unknown cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } int main () { _ascii (); _ebcdic (); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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 if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long l; char c[sizeof (long)]; } u; u.l = 1; exit (u.c[sizeof (long) - 1] == 1); } _ACEOF rm -f 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='./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_c_bigendian=no else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_c_bigendian=yes fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 echo "${ECHO_T}$ac_cv_c_bigendian" >&6 case $ac_cv_c_bigendian in yes) cat >>confdefs.h <<\_ACEOF #define WORDS_BIGENDIAN 1 _ACEOF ;; no) ;; *) { { echo "$as_me:$LINENO: error: unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" >&5 echo "$as_me: error: unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} { (exit 1); exit 1; }; } ;; esac echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 if test "${ac_cv_c_const+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset x; /* SunOS 4.1.1 cc rejects this. */ char const *const *ccp; char **p; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; ccp = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++ccp; p = (char**) ccp; ccp = (char const *const *) p; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; } #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_c_const=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_c_const=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 echo "${ECHO_T}$ac_cv_c_const" >&6 if test $ac_cv_c_const = no; then cat >>confdefs.h <<\_ACEOF #define const _ACEOF fi echo "$as_me:$LINENO: checking for crypt in -lcrypt" >&5 echo $ECHO_N "checking for crypt in -lcrypt... $ECHO_C" >&6 if test "${ac_cv_lib_crypt_crypt+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcrypt $LIBS" cat >conftest.$ac_ext <<_ACEOF /* 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 crypt (); int main () { crypt (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { 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_lib_crypt_crypt=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_crypt_crypt=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_crypt_crypt" >&5 echo "${ECHO_T}$ac_cv_lib_crypt_crypt" >&6 if test $ac_cv_lib_crypt_crypt = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBCRYPT 1 _ACEOF LIBS="-lcrypt $LIBS" fi echo "$as_me:$LINENO: checking for socket in -lsocket" >&5 echo $ECHO_N "checking for socket in -lsocket... $ECHO_C" >&6 if test "${ac_cv_lib_socket_socket+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $LIBS" cat >conftest.$ac_ext <<_ACEOF /* 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 socket (); int main () { socket (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { 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_lib_socket_socket=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_socket_socket=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_socket_socket" >&5 echo "${ECHO_T}$ac_cv_lib_socket_socket" >&6 if test $ac_cv_lib_socket_socket = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBSOCKET 1 _ACEOF LIBS="-lsocket $LIBS" fi echo "$as_me:$LINENO: checking for socket in -lnsl" >&5 echo $ECHO_N "checking for socket in -lnsl... $ECHO_C" >&6 if test "${ac_cv_lib_nsl_socket+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" cat >conftest.$ac_ext <<_ACEOF /* 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 socket (); int main () { socket (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { 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_lib_nsl_socket=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_nsl_socket=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_socket" >&5 echo "${ECHO_T}$ac_cv_lib_nsl_socket" >&6 if test $ac_cv_lib_nsl_socket = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBNSL 1 _ACEOF LIBS="-lnsl $LIBS" fi echo "$as_me:$LINENO: checking for pow in -lm" >&5 echo $ECHO_N "checking for pow in -lm... $ECHO_C" >&6 if test "${ac_cv_lib_m_pow+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" cat >conftest.$ac_ext <<_ACEOF /* 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 pow (); int main () { pow (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { 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_lib_m_pow=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_m_pow=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_m_pow" >&5 echo "${ECHO_T}$ac_cv_lib_m_pow" >&6 if test $ac_cv_lib_m_pow = yes; then MATHLIBS=-lm fi echo "$as_me:$LINENO: checking for zlib package" >&5 echo $ECHO_N "checking for zlib package... $ECHO_C" >&6 # Check whether --with-zlib or --without-zlib was given. if test "${with_zlib+set}" = set; then withval="$with_zlib" fi; # Check whether --with-zlib or --without-zlib was given. if test "${with_zlib+set}" = set; then withval="$with_zlib" fi; if test "x$with_zlib" = xno; then no_zlib=yes else irc_zlib_prefix=$with_zlib if test "${irc_cv_path_zlib+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else no_zlib=yes no_zlib_include=yes no_zlib_library=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then no_zlib_include= irc_zlib_include= else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 for irc_dir in "$irc_zlib_include" \ `test -z "$irc_zlib_prefix" || echo "$irc_zlib_prefix/include"` \ `echo "$irc_zlib_library" | sed s/lib/include/` \ /usr/include /usr/local/include /usr/unsupported/include \ /usr/share/include /usr/local/share/include /include \ /usr/zlib/include /usr/local/zlib/include \ /usr/include/zlib /usr/local/include/zlib \ /usr/unsupported/include/zlib /usr/share/include/zlib \ /usr/local/share/include/zlib /include/zlib \ /usr/zlib/include/zlib /usr/local/zlib/include/zlib; \ do if test -r "$irc_dir/zlib.h"; then no_zlib_include= irc_zlib_include=$irc_dir break fi done fi rm -f conftest.err conftest.$ac_ext irc_save_LIBS="$LIBS" LIBS="-lz $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { inflate() ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { 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 no_zlib_library= irc_zlib_library= LIBS="$irc_save_LIBS" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 LIBS="$irc_save_LIBS" for irc_dir in "$irc_zlib_library" \ `test -z "$irc_zlib_prefix" || echo "$irc_zlib_prefix/lib"` \ `echo "$irc_zlib_include" | sed s/include/lib/` \ /usr/lib /usr/local/lib /usr/unsupported/lib \ /usr/share/lib /usr/local/share/lib /lib /usr/zlib/lib \ /usr/local/zlib/lib /usr/lib/zlib /usr/local/lib/zlib \ /usr/unsupported/lib/zlib /usr/share/lib/zlib \ /usr/local/share/lib/zlib /lib/zlib \ /usr/zlib/lib/zlib /usr/local/zlib/lib/zlib; \ do for irc_extension in a so sl; do if test -r $irc_dir/libz.$irc_extension; then no_zlib_library= irc_zlib_library=$irc_dir break 2 fi done done fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "x$no_zlib_include" = x && test "x$no_zlib_library" = x; then no_zlib= fi if test "$no_zlib" = yes; then irc_cv_path_zlib="no_zlib=yes" else irc_cv_path_zlib="no_zlib= irc_zlib_include=$irc_zlib_include irc_zlib_library=$irc_zlib_library" fi fi eval "$irc_cv_path_zlib" fi if test "$no_zlib" = yes; then IRC_ZLIB_LIBRARY= IRC_ZLIB_INCLUDE= echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 else cat >>confdefs.h <<\_ACEOF #define USE_ZLIB 1 _ACEOF if test "x$irc_zlib_library" = x; then irc_zlib_library_message="found by the linker" IRC_ZLIB_LIBRARY=-lz else irc_zlib_library_message="in $irc_zlib_library" IRC_ZLIB_LIBRARY=-L$irc_zlib_library if test ! "$irc_cv_solaris_2" = no; then IRC_ZLIB_LIBRARY="$IRC_ZLIB_LIBRARY -R$irc_zlib_library" fi IRC_ZLIB_LIBRARY="$IRC_ZLIB_LIBRARY -lz" fi if test "x$irc_zlib_include" = x; then irc_zlib_include_message="found by the compiler" IRC_ZLIB_INCLUDE= else irc_zlib_include_message="in $irc_zlib_include" IRC_ZLIB_INCLUDE=-I$irc_zlib_include fi echo "$as_me:$LINENO: result: " >&5 echo "${ECHO_T}" >&6 echo "$as_me:$LINENO: result: library $irc_zlib_library_message" >&5 echo "${ECHO_T} library $irc_zlib_library_message" >&6 echo "$as_me:$LINENO: result: header $irc_zlib_include_message" >&5 echo "${ECHO_T} header $irc_zlib_include_message" >&6 fi echo "$as_me:$LINENO: checking whether setpgrp takes no argument" >&5 echo $ECHO_N "checking whether setpgrp takes no argument... $ECHO_C" >&6 if test "${ac_cv_func_setpgrp_void+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then { { echo "$as_me:$LINENO: error: cannot check setpgrp when cross compiling" >&5 echo "$as_me: error: cannot check setpgrp when cross compiling" >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #if HAVE_UNISTD_H # include #endif int main () { /* If this system has a BSD-style setpgrp which takes arguments, setpgrp(1, 1) will fail with ESRCH and return -1, in that case exit successfully. */ exit (setpgrp (1,1) == -1 ? 0 : 1); ; return 0; } _ACEOF rm -f 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='./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_func_setpgrp_void=no else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_setpgrp_void=yes fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi echo "$as_me:$LINENO: result: $ac_cv_func_setpgrp_void" >&5 echo "${ECHO_T}$ac_cv_func_setpgrp_void" >&6 if test $ac_cv_func_setpgrp_void = yes; then cat >>confdefs.h <<\_ACEOF #define SETPGRP_VOID 1 _ACEOF fi echo "$as_me:$LINENO: checking for function prototypes" >&5 echo $ECHO_N "checking for function prototypes... $ECHO_C" >&6 if test "$ac_cv_prog_cc_stdc" != no; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 cat >>confdefs.h <<\_ACEOF #define PROTOTYPES 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define __PROTOTYPES 1 _ACEOF else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi echo "$as_me:$LINENO: checking whether setvbuf arguments are reversed" >&5 echo $ECHO_N "checking whether setvbuf arguments are reversed... $ECHO_C" >&6 if test "${ac_cv_func_setvbuf_reversed+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_func_setvbuf_reversed=no cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include # if PROTOTYPES int (setvbuf) (FILE *, int, char *, size_t); # endif int main () { char buf; return setvbuf (stdout, _IOLBF, &buf, 1); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { 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 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include # if PROTOTYPES int (setvbuf) (FILE *, int, char *, size_t); # endif int main () { char buf; return setvbuf (stdout, &buf, _IOLBF, 1); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { 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 # It compiles and links either way, so it must not be declared # with a prototype and most likely this is a K&R C compiler. # Try running it. if test "$cross_compiling" = yes; then : # Assume setvbuf is not reversed when cross-compiling. else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { /* This call has the arguments reversed. A reversed system may check and see that the address of buf is not _IOLBF, _IONBF, or _IOFBF, and return nonzero. */ char buf; if (setvbuf (stdout, _IOLBF, &buf, 1) != 0) exit (1); putchar ('\r'); exit (0); /* Non-reversed systems SEGV here. */ ; return 0; } _ACEOF rm -f 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='./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_func_setvbuf_reversed=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) rm -f core *.core fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi ac_cv_func_setvbuf_reversed=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_setvbuf_reversed" >&5 echo "${ECHO_T}$ac_cv_func_setvbuf_reversed" >&6 if test $ac_cv_func_setvbuf_reversed = yes; then cat >>confdefs.h <<\_ACEOF #define SETVBUF_REVERSED 1 _ACEOF fi for ac_header in unistd.h vfork.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## -------------------------------- ## ## Report this to ircd-bugs@irc.org ## ## -------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in fork vfork do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* 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 $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else char (*f) () = $ac_func; #endif #ifdef __cplusplus } #endif int main () { return f != $ac_func; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { 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 eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done if test "x$ac_cv_func_fork" = xyes; then echo "$as_me:$LINENO: checking for working fork" >&5 echo $ECHO_N "checking for working fork... $ECHO_C" >&6 if test "${ac_cv_func_fork_works+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_fork_works=cross else cat >conftest.$ac_ext <<_ACEOF /* By Ruediger Kuhlmann. */ #include #if HAVE_UNISTD_H # include #endif /* Some systems only have a dummy stub for fork() */ int main () { if (fork() < 0) exit (1); exit (0); } _ACEOF rm -f 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='./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_func_fork_works=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_fork_works=no fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi echo "$as_me:$LINENO: result: $ac_cv_func_fork_works" >&5 echo "${ECHO_T}$ac_cv_func_fork_works" >&6 else ac_cv_func_fork_works=$ac_cv_func_fork fi if test "x$ac_cv_func_fork_works" = xcross; then case $host in *-*-amigaos* | *-*-msdosdjgpp*) # Override, as these systems have only a dummy fork() stub ac_cv_func_fork_works=no ;; *) ac_cv_func_fork_works=yes ;; esac { echo "$as_me:$LINENO: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&5 echo "$as_me: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&2;} fi ac_cv_func_vfork_works=$ac_cv_func_vfork if test "x$ac_cv_func_vfork" = xyes; then echo "$as_me:$LINENO: checking for working vfork" >&5 echo $ECHO_N "checking for working vfork... $ECHO_C" >&6 if test "${ac_cv_func_vfork_works+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_vfork_works=cross else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Thanks to Paul Eggert for this test. */ #include #include #include #include #include #if HAVE_UNISTD_H # include #endif #if HAVE_VFORK_H # include #endif /* On some sparc systems, changes by the child to local and incoming argument registers are propagated back to the parent. The compiler is told about this with #include , but some compilers (e.g. gcc -O) don't grok . Test for this by using a static variable whose address is put into a register that is clobbered by the vfork. */ static void #ifdef __cplusplus sparc_address_test (int arg) # else sparc_address_test (arg) int arg; #endif { static pid_t child; if (!child) { child = vfork (); if (child < 0) { perror ("vfork"); _exit(2); } if (!child) { arg = getpid(); write(-1, "", 0); _exit (arg); } } } int main () { pid_t parent = getpid (); pid_t child; sparc_address_test (0); child = vfork (); if (child == 0) { /* Here is another test for sparc vfork register problems. This test uses lots of local variables, at least as many local variables as main has allocated so far including compiler temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should reuse the register of parent for one of the local variables, since it will think that parent can't possibly be used any more in this routine. Assigning to the local variable will thus munge parent in the parent process. */ pid_t p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(), p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid(); /* Convince the compiler that p..p7 are live; otherwise, it might use the same hardware register for all 8 local variables. */ if (p != p1 || p != p2 || p != p3 || p != p4 || p != p5 || p != p6 || p != p7) _exit(1); /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent from child file descriptors. If the child closes a descriptor before it execs or exits, this munges the parent's descriptor as well. Test for this by closing stdout in the child. */ _exit(close(fileno(stdout)) != 0); } else { int status; struct stat st; while (wait(&status) != child) ; exit( /* Was there some problem with vforking? */ child < 0 /* Did the child fail? (This shouldn't happen.) */ || status /* Did the vfork/compiler bug occur? */ || parent != getpid() /* Did the file descriptor bug occur? */ || fstat(fileno(stdout), &st) != 0 ); } } _ACEOF rm -f 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='./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_func_vfork_works=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_vfork_works=no fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi echo "$as_me:$LINENO: result: $ac_cv_func_vfork_works" >&5 echo "${ECHO_T}$ac_cv_func_vfork_works" >&6 fi; if test "x$ac_cv_func_fork_works" = xcross; then ac_cv_func_vfork_works=$ac_cv_func_vfork { echo "$as_me:$LINENO: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&5 echo "$as_me: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&2;} fi if test "x$ac_cv_func_vfork_works" = xyes; then cat >>confdefs.h <<\_ACEOF #define HAVE_WORKING_VFORK 1 _ACEOF else cat >>confdefs.h <<\_ACEOF #define vfork fork _ACEOF fi if test "x$ac_cv_func_fork_works" = xyes; then cat >>confdefs.h <<\_ACEOF #define HAVE_WORKING_FORK 1 _ACEOF fi for ac_func in setpgrp strchr strrchr memcmp memset memmove memcpy index rindex bcmp bcopy bzero select inet_ntoa inet_aton inet_addr inet_netof getrusage times strerror strtoken strtok sigaction sigset truncate poll vsyslog strlcpy do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* 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 $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else char (*f) () = $ac_func; #endif #ifdef __cplusplus } #endif int main () { return f != $ac_func; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { 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 eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done echo "$as_me:$LINENO: checking for sys_errlist declaration in stdio.h, errno.h or sys/errno.h" >&5 echo $ECHO_N "checking for sys_errlist declaration in stdio.h, errno.h or sys/errno.h... $ECHO_C" >&6 if test "${irc_cv_decl_sys_errlist+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #if HAVE_SYS_TYPES_H #include #endif #if HAVE_STDIO_H #include #endif #if HAVE_ERRNO_H #include #endif #if HAVE_SYS_ERRNO_H #include #endif int main () { char *msg = sys_errlist[0]; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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 irc_cv_decl_sys_errlist=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 irc_cv_decl_sys_errlist=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $irc_cv_decl_sys_errlist" >&5 echo "${ECHO_T}$irc_cv_decl_sys_errlist" >&6 if test $irc_cv_decl_sys_errlist = yes; then cat >>confdefs.h <<\_ACEOF #define SYS_ERRLIST_DECLARED 1 _ACEOF elif test $ac_cv_func_strerror != yes; then { echo "$as_me:$LINENO: WARNING: Neither strerror() nor sys_errlist found." >&5 echo "$as_me: WARNING: Neither strerror() nor sys_errlist found." >&2;} fi echo "$as_me:$LINENO: checking for 8-bit clean memcmp" >&5 echo $ECHO_N "checking for 8-bit clean memcmp... $ECHO_C" >&6 if test "${irc_cv_func_memcmp_clean+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then irc_cv_func_memcmp_clean=no else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ main() { char c0 = 0x40, c1 = 0x80, c2 = 0x81; exit(memcmp(&c0, &c2, 1) < 0 && memcmp(&c1, &c2, 1) < 0 ? 0 : 1); } _ACEOF rm -f 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='./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 irc_cv_func_memcmp_clean=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) irc_cv_func_memcmp_clean=no fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi echo "$as_me:$LINENO: result: $irc_cv_func_memcmp_clean" >&5 echo "${ECHO_T}$irc_cv_func_memcmp_clean" >&6 if test $irc_cv_func_memcmp_clean = no; then cat >>confdefs.h <<\_ACEOF #define MEMCMP_BROKEN 1 _ACEOF fi echo "$as_me:$LINENO: checking whether select or poll system call will be used" >&5 echo $ECHO_N "checking whether select or poll system call will be used... $ECHO_C" >&6 if test "${irc_cv_select_poll+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$irc_cv_sun" != "no" && test "x$irc_cv_solaris_2" = "xno"; then # we don't like SunOS' poll() function irc_cv_select_poll=select else if test "$ac_cv_func_poll" = "yes"; then irc_cv_select_poll=poll else irc_cv_select_poll=select fi fi fi if test "$irc_cv_select_poll" = "poll"; then echo "$as_me:$LINENO: result: poll" >&5 echo "${ECHO_T}poll" >&6 cat >>confdefs.h <<\_ACEOF #define USE_POLL 1 _ACEOF else echo "$as_me:$LINENO: result: select" >&5 echo "${ECHO_T}select" >&6 fi echo "$as_me:$LINENO: checking for signal implementation" >&5 echo $ECHO_N "checking for signal implementation... $ECHO_C" >&6 #AC_CACHE_VAL(irc_cv_signal_implementation, #[if test x$ac_cv_func_sigaction = xyes; then if test x$ac_cv_func_sigaction = xyes; then irc_cv_signal_implementation=posix_sigaction elif test x$ac_cv_func_sigset = xyes; then irc_cv_signal_implementation=bsd_sigset else if test "$cross_compiling" = yes; then { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling See \`config.log' for more details." >&5 echo "$as_me: error: cannot run test program while cross compiling See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #if HAVE_SYS_TYPES_H #include #endif #if HAVE_SIGNAL_H #include #endif #ifndef SIGCHLD #define SIGCHLD SIGCLD #endif int got = 0; RETSIGTYPE hand() { got++; } main() { (void)signal(SIGCHLD, hand); kill(getpid(), SIGCHLD); kill(getpid(), SIGCHLD); if (got < 2) exit(1); exit(0); } _ACEOF rm -f 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='./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 irc_cv_signal_implementation=bsd_signal else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) irc_cv_signal_implementation=sysv_signal fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi #]) if test $irc_cv_signal_implementation = posix_sigaction; then echo "$as_me:$LINENO: result: using POSIX sigaction" >&5 echo "${ECHO_T}using POSIX sigaction" >&6 cat >>confdefs.h <<\_ACEOF #define POSIX_SIGNALS 1 _ACEOF elif test $irc_cv_signal_implementation = bsd_sigset; then echo "$as_me:$LINENO: result: using BSD sigset" >&5 echo "${ECHO_T}using BSD sigset" >&6 cat >>confdefs.h <<\_ACEOF #define BSD_RELIABLE_SIGNALS 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define signal sigset _ACEOF elif test $irc_cv_signal_implementation = bsd_signal; then echo "$as_me:$LINENO: result: using reliable BSD signal" >&5 echo "${ECHO_T}using reliable BSD signal" >&6 cat >>confdefs.h <<\_ACEOF #define BSD_RELIABLE_SIGNALS 1 _ACEOF else echo "$as_me:$LINENO: result: using unreliable SystemV signal" >&5 echo "${ECHO_T}using unreliable SystemV signal" >&6 cat >>confdefs.h <<\_ACEOF #define SYSV_UNRELIABLE_SIGNALS 1 _ACEOF fi echo "$as_me:$LINENO: checking for a working non-blocking system" >&5 echo $ECHO_N "checking for a working non-blocking system... $ECHO_C" >&6 if test "${irc_cv_non_blocking_system+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else irc_precode='#include "confdefs.h" #ifdef HAVE_SYS_TYPES_H #include #endif #if HAVE_SYS_SOCKET_H #include #endif #if HAVE_FCNTL_H #include #endif #if HAVE_SYS_IOCTL_H #include #endif #if HAVE_SYS_FILE_H #include #endif #if HAVE_SIGNAL_H #include #endif #if HAVE_NETINET_IN_H #include #endif RETSIGTYPE alarmed() { exit(1); } main() { char b[12]; struct sockaddr_in x; int f, l = sizeof(x); f = socket(AF_INET, SOCK_DGRAM, 0); if (f >= 0 && !(fcntl(f, F_SETFL, ' irc_postcode='))) { signal(SIGALRM, alarmed); alarm(3); recvfrom(f, b, 12, 0, &x, &l); alarm(0); exit(0); } exit(1); }' irc_code_posix="${irc_precode}O_NONBLOCK${irc_postcode}" irc_code_bsd="${irc_precode}O_NDELAY${irc_postcode}" irc_code_sysv="${irc_precode}FIONBIO${irc_postcode}" if test "$cross_compiling" = yes; then { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling See \`config.log' for more details." >&5 echo "$as_me: error: cannot run test program while cross compiling See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF $irc_code_posix _ACEOF rm -f 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='./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 irc_cv_non_blocking_system=posix else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) if test "$cross_compiling" = yes; then { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling See \`config.log' for more details." >&5 echo "$as_me: error: cannot run test program while cross compiling See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF $irc_code_bsd _ACEOF rm -f 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='./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 irc_cv_non_blocking_system=bsd else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) if test "$cross_compiling" = yes; then { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling See \`config.log' for more details." >&5 echo "$as_me: error: cannot run test program while cross compiling See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF $irc_code_sysv _ACEOF rm -f 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='./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 irc_cv_non_blocking_system=sysv else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) irc_cv_non_blocking_system=none fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi if test $irc_cv_non_blocking_system = posix; then echo "$as_me:$LINENO: result: using POSIX O_NONBLOCK" >&5 echo "${ECHO_T}using POSIX O_NONBLOCK" >&6 cat >>confdefs.h <<\_ACEOF #define NBLOCK_POSIX 1 _ACEOF elif test $irc_cv_non_blocking_system = bsd; then echo "$as_me:$LINENO: result: using BSD O_NDELAY" >&5 echo "${ECHO_T}using BSD O_NDELAY" >&6 cat >>confdefs.h <<\_ACEOF #define NBLOCK_BSD 1 _ACEOF elif test $irc_cv_non_blocking_system = sysv; then echo "$as_me:$LINENO: result: using SystemV FIONBIO" >&5 echo "${ECHO_T}using SystemV FIONBIO" >&6 cat >>confdefs.h <<\_ACEOF #define NBLOCK_SYSV 1 _ACEOF else echo "$as_me:$LINENO: result: using none" >&5 echo "${ECHO_T}using none" >&6 { echo "$as_me:$LINENO: WARNING: I can't find a working non-blocking system." >&5 echo "$as_me: WARNING: I can't find a working non-blocking system." >&2;} fi echo "$as_me:$LINENO: checking for resolver configuration file" >&5 echo $ECHO_N "checking for resolver configuration file... $ECHO_C" >&6 # Check whether --with-resconf or --without-resconf was given. if test "${with_resconf+set}" = set; then withval="$with_resconf" irc_cv_path_resconf="$withval" else irc_cv_path_resconf="/etc/resolv.conf" fi; echo "$as_me:$LINENO: result: $irc_cv_path_resconf" >&5 echo "${ECHO_T}$irc_cv_path_resconf" >&6 cat >>confdefs.h <<_ACEOF #define IRC_RESCONF "$irc_cv_path_resconf" _ACEOF if test ! -r "$irc_cv_path_resconf"; then { echo "$as_me:$LINENO: WARNING: Unable to read \"$irc_cv_path_resconf\"! Without resolver configuration file, the server won't work." >&5 echo "$as_me: WARNING: Unable to read \"$irc_cv_path_resconf\"! Without resolver configuration file, the server won't work." >&2;} fi # Check whether --enable-ip6 or --disable-ip6 was given. if test "${enable_ip6+set}" = set; then enableval="$enable_ip6" fi; # Check whether --enable-ipv6 or --disable-ipv6 was given. if test "${enable_ipv6+set}" = set; then enableval="$enable_ipv6" fi; if test "x$enableval" = xyes; then cat >>confdefs.h <<\_ACEOF #define INET6 1 _ACEOF echo "$as_me:$LINENO: checking IPv6 system type" >&5 echo $ECHO_N "checking IPv6 system type... $ECHO_C" >&6 if test "${irc_cv_v6type+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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 irc_cv_v6type=native else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext if test "x$irc_cv_v6type" = x; then if test -d /usr/inet6; then cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include "/usr/inet6/include/netinet/in.h" #ifdef _INET6APPS_NETINET_IN_H yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then irc_cv_v6type=linux fi rm -f conftest* fi fi if test "x$irc_cv_v6type" = x; then irc_cv_v6type=unknown fi fi echo "$as_me:$LINENO: result: $irc_cv_v6type" >&5 echo "${ECHO_T}$irc_cv_v6type" >&6 if test "x$irc_cv_v6type" = xunknown; then { echo "$as_me:$LINENO: WARNING: You have an unknown IPv6 system. You will probably need to change the Makefile manually, or #undef INET6 in setup.h" >&5 echo "$as_me: WARNING: You have an unknown IPv6 system. You will probably need to change the Makefile manually, or #undef INET6 in setup.h" >&2;} fi case $irc_cv_v6type in linux) LIBS="-L/usr/inet6/lib -linet6 $LIBS" CFLAGS="$CFLAGS -I/usr/inet6/include" ;; esac for ac_func in getipnodebyname do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* 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 $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else char (*f) () = $ac_func; #endif #ifdef __cplusplus } #endif int main () { return f != $ac_func; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { 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 eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done fi # Check whether --enable-dsm or --disable-dsm was given. if test "${enable_dsm+set}" = set; then enableval="$enable_dsm" fi; if test "x$enable_dsm" != x; then cat >>confdefs.h <<\_ACEOF #define USE_DSM 1 _ACEOF for ac_header in dlfcn.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { ac_try='test -s conftest.$ac_objext' { (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_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## -------------------------------- ## ## Report this to ircd-bugs@irc.org ## ## -------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done echo "$as_me:$LINENO: checking for dlclose in -ldl" >&5 echo $ECHO_N "checking for dlclose in -ldl... $ECHO_C" >&6 if test "${ac_cv_lib_dl_dlclose+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat >conftest.$ac_ext <<_ACEOF /* 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 dlclose (); int main () { dlclose (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (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); }; } && { 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_lib_dl_dlclose=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dl_dlclose=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlclose" >&5 echo "${ECHO_T}$ac_cv_lib_dl_dlclose" >&6 if test $ac_cv_lib_dl_dlclose = yes; then IRC_DLIB="-ldl" fi fi echo "$as_me:$LINENO: checking whether this is an alpha/beta release" >&5 echo $ECHO_N "checking whether this is an alpha/beta release... $ECHO_C" >&6 if test "${irc_cv_alpha_beta+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include "../common/patchlevel.h" #ifdef PATCHLEVEL PATCHLEVEL #else "0000000000" #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "^ *\"......00" >/dev/null 2>&1; then irc_cv_alpha_beta= else irc_cv_alpha_beta=yes fi rm -f conftest* fi if test x$irc_cv_alpha_beta = xyes; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 { echo "$as_me:$LINENO: WARNING: This is a development version of the package, it is not intended to be used in a production environment. " >&5 echo "$as_me: WARNING: This is a development version of the package, it is not intended to be used in a production environment. " >&2;} else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi ac_config_files="$ac_config_files Makefile:../support/Makefile.in version.c.SH:../ircd/version.c.SH.in sums:../support/sums.in tkconf.h:../support/tkconf.h.dist" ac_config_commands="$ac_config_commands chmod" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. { (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } | sed ' t clear : clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ : end' >>confcache if diff $cache_file confcache >/dev/null 2>&1; then :; else if test -w $cache_file; then test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" cat confcache >$cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/; s/:*\${srcdir}:*/:/; s/:*@srcdir@:*/:/; s/^\([^=]*=[ ]*\):*/\1/; s/:*$//; s/^[^=]*=[ ]*$//; }' fi DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_i=`echo "$ac_i" | sed 's/\$U\././;s/\.o$//;s/\.obj$//'` # 2. Add them. ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # Work around bugs in pre-3.0 UWIN ksh. $as_unset ENV MAIL MAILPATH PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)$' \| \ . : '\(.\)' 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } /^X\/\(\/\/\)$/{ s//\1/; q; } /^X\/\(\/\).*/{ s//\1/; q; } s/.*/./; q'` # PATH needs CR, and LINENO needs CR and PATH. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" || { # Find who we are. Look in the path if we contain no path at all # relative or not. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} { (exit 1); exit 1; }; } fi case $CONFIG_SHELL in '') as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for as_base in sh bash ksh sh5; do case $as_dir in /*) if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } CONFIG_SHELL=$as_dir/$as_base export CONFIG_SHELL exec "$CONFIG_SHELL" "$0" ${1+"$@"} fi;; esac done done ;; esac # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line before each line; the second 'sed' does the real # work. The second script uses 'N' to pair each line-number line # with the numbered line, and appends trailing '-' during # substitution so that $LINENO is not a special case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) sed '=' <$as_myself | sed ' N s,$,-, : loop s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, t loop s,-$,, s,^['$as_cr_digits']*\n,, ' >$as_me.lineno && chmod +x $as_me.lineno || { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensible to this). . ./$as_me.lineno # Exit status is that of the last command. exit } case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C=' ' ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH exec 6>&1 # Open the log real soon, to keep \$[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. Logging --version etc. is OK. exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX } >&5 cat >&5 <<_CSEOF This file was extended by irc $as_me 2.11, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ _CSEOF echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 echo >&5 _ACEOF # Files that config.status was made for. if test -n "$ac_config_files"; then echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS fi if test -n "$ac_config_headers"; then echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS fi if test -n "$ac_config_links"; then echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS fi if test -n "$ac_config_commands"; then echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS fi cat >>$CONFIG_STATUS <<\_ACEOF ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ irc config.status 2.11 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2003 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." srcdir=$srcdir INSTALL="$INSTALL" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If no file are specified by the user, then we need to provide default # value. By we need to know if files were specified by the user. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "x$1" : 'x\([^=]*\)='` ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` ac_shift=: ;; -*) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; *) # This is not an option, so the user has probably given explicit # arguments. ac_option=$1 ac_need_defaults=false;; esac case $ac_option in # Handling of the options. _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --vers* | -V ) echo "$ac_cs_version"; exit 0 ;; --he | --h) # Conflict between --help and --header { { echo "$as_me:$LINENO: error: ambiguous option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; };; --help | --hel | -h ) echo "$ac_cs_usage"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift CONFIG_FILES="$CONFIG_FILES $ac_optarg" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" ac_need_defaults=false;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; } ;; *) ac_config_targets="$ac_config_targets $1" ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF if \$ac_cs_recheck; then echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF for ac_config_target in $ac_config_targets do case "$ac_config_target" in # Handling of arguments. "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile:../support/Makefile.in" ;; "version.c.SH" ) CONFIG_FILES="$CONFIG_FILES version.c.SH:../ircd/version.c.SH.in" ;; "sums" ) CONFIG_FILES="$CONFIG_FILES sums:../support/sums.in" ;; "tkconf.h" ) CONFIG_FILES="$CONFIG_FILES tkconf.h:../support/tkconf.h.dist" ;; "chmod" ) CONFIG_COMMANDS="$CONFIG_COMMANDS chmod" ;; "setup.h" ) CONFIG_HEADERS="$CONFIG_HEADERS setup.h:../support/setup.h.in" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason to put it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Create a temporary directory, and hook for its removal unless debugging. $debug || { trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./confstat$$-$RANDOM (umask 077 && mkdir $tmp) } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } _ACEOF cat >>$CONFIG_STATUS <<_ACEOF # # CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h if test -n "\$CONFIG_FILES"; then # Protect against being on the right side of a sed subst in config.status. sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF s,@SHELL@,$SHELL,;t t s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t s,@exec_prefix@,$exec_prefix,;t t s,@prefix@,$prefix,;t t s,@program_transform_name@,$program_transform_name,;t t s,@bindir@,$bindir,;t t s,@sbindir@,$sbindir,;t t s,@libexecdir@,$libexecdir,;t t s,@datadir@,$datadir,;t t s,@sysconfdir@,$sysconfdir,;t t s,@sharedstatedir@,$sharedstatedir,;t t s,@localstatedir@,$localstatedir,;t t s,@libdir@,$libdir,;t t s,@includedir@,$includedir,;t t s,@oldincludedir@,$oldincludedir,;t t s,@infodir@,$infodir,;t t s,@mandir@,$mandir,;t t s,@build_alias@,$build_alias,;t t s,@host_alias@,$host_alias,;t t s,@target_alias@,$target_alias,;t t s,@DEFS@,$DEFS,;t t s,@ECHO_C@,$ECHO_C,;t t s,@ECHO_N@,$ECHO_N,;t t s,@ECHO_T@,$ECHO_T,;t t s,@LIBS@,$LIBS,;t t s,@logdir@,$logdir,;t t s,@rundir@,$rundir,;t t s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t s,@INSTALL_DATA@,$INSTALL_DATA,;t t s,@CC@,$CC,;t t s,@CFLAGS@,$CFLAGS,;t t s,@LDFLAGS@,$LDFLAGS,;t t s,@CPPFLAGS@,$CPPFLAGS,;t t s,@ac_ct_CC@,$ac_ct_CC,;t t s,@EXEEXT@,$EXEEXT,;t t s,@OBJEXT@,$OBJEXT,;t t s,@CPP@,$CPP,;t t s,@AWK@,$AWK,;t t s,@SUM@,$SUM,;t t s,@M4_PATH@,$M4_PATH,;t t s,@EGREP@,$EGREP,;t t s,@MATHLIBS@,$MATHLIBS,;t t s,@IRC_ZLIB_INCLUDE@,$IRC_ZLIB_INCLUDE,;t t s,@IRC_ZLIB_LIBRARY@,$IRC_ZLIB_LIBRARY,;t t s,@IRC_DLIB@,$IRC_DLIB,;t t s,@LIBOBJS@,$LIBOBJS,;t t s,@LTLIBOBJS@,$LTLIBOBJS,;t t CEOF _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_lines=48 ac_sed_frag=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_lines # Line after last line for current file. ac_more_lines=: ac_sed_cmds= while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag else sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag fi if test ! -s $tmp/subs.frag; then ac_more_lines=false else # The purpose of the label and of the branching condition is to # speed up the sed processing (if there are no `@' at all, there # is no need to browse any of the substitutions). # These are the two extra sed commands mentioned above. (echo ':t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" else ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" fi ac_sed_frag=`expr $ac_sed_frag + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_lines` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi fi # test -n "$CONFIG_FILES" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case $ac_file in - | *:- | *:-:* ) # input from stdin cat >$tmp/stdin ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. ac_dir=`(dirname "$ac_file") 2>/dev/null || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` { if $as_mkdir_p; then mkdir -p "$ac_dir" else as_dir="$ac_dir" as_dirs= while test ! -d "$as_dir"; do as_dirs="$as_dir $as_dirs" as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` done test ! -n "$as_dirs" || mkdir $as_dirs fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A "../" for each directory in $ac_dir_suffix. ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` else ac_dir_suffix= ac_top_builddir= fi case $srcdir in .) # No --srcdir option. We are building in place. ac_srcdir=. if test -z "$ac_top_builddir"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac # Do not use `cd foo && pwd` to compute absolute paths, because # the directories may not exist. case `pwd` in .) ac_abs_builddir="$ac_dir";; *) case "$ac_dir" in .) ac_abs_builddir=`pwd`;; [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; *) ac_abs_builddir=`pwd`/"$ac_dir";; esac;; esac case $ac_abs_builddir in .) ac_abs_top_builddir=${ac_top_builddir}.;; *) case ${ac_top_builddir}. in .) ac_abs_top_builddir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; esac;; esac case $ac_abs_builddir in .) ac_abs_srcdir=$ac_srcdir;; *) case $ac_srcdir in .) ac_abs_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; esac;; esac case $ac_abs_builddir in .) ac_abs_top_srcdir=$ac_top_srcdir;; *) case $ac_top_srcdir in .) ac_abs_top_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; esac;; esac case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_builddir$INSTALL ;; esac if test x"$ac_file" != x-; then { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} rm -f "$ac_file" fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ if test x"$ac_file" = x-; then configure_input= else configure_input="$ac_file. " fi configure_input=$configure_input"Generated from `echo $ac_file_in | sed 's,.*/,,'` by configure." # First look for the input files in the build tree, otherwise in the # src tree. ac_file_inputs=`IFS=: for f in $ac_file_in; do case $f in -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo "$f";; *) # Relative if test -f "$f"; then # Build tree echo "$f" elif test -f "$srcdir/$f"; then # Source tree echo "$srcdir/$f" else # /dev/null tree { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; esac done` || { (exit 1); exit 1; } _ACEOF cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s,@configure_input@,$configure_input,;t t s,@srcdir@,$ac_srcdir,;t t s,@abs_srcdir@,$ac_abs_srcdir,;t t s,@top_srcdir@,$ac_top_srcdir,;t t s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t s,@builddir@,$ac_builddir,;t t s,@abs_builddir@,$ac_abs_builddir,;t t s,@top_builddir@,$ac_top_builddir,;t t s,@abs_top_builddir@,$ac_abs_top_builddir,;t t s,@INSTALL@,$ac_INSTALL,;t t " $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out rm -f $tmp/stdin if test x"$ac_file" != x-; then mv $tmp/out $ac_file else cat $tmp/out rm -f $tmp/out fi done _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # # CONFIG_HEADER section. # # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' ac_dB='[ ].*$,\1#\2' ac_dC=' ' ac_dD=',;t' # ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_uB='$,\1#\2define\3' ac_uC=' ' ac_uD=',;t' for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case $ac_file in - | *:- | *:-:* ) # input from stdin cat >$tmp/stdin ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} # First look for the input files in the build tree, otherwise in the # src tree. ac_file_inputs=`IFS=: for f in $ac_file_in; do case $f in -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } # Do quote $f, to prevent DOS paths from being IFS'd. echo "$f";; *) # Relative if test -f "$f"; then # Build tree echo "$f" elif test -f "$srcdir/$f"; then # Source tree echo "$srcdir/$f" else # /dev/null tree { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; esac done` || { (exit 1); exit 1; } # Remove the trailing spaces. sed 's/[ ]*$//' $ac_file_inputs >$tmp/in _ACEOF # Transform confdefs.h into two sed scripts, `conftest.defines' and # `conftest.undefs', that substitutes the proper values into # config.h.in to produce config.h. The first handles `#define' # templates, and the second `#undef' templates. # And first: Protect against being on the right side of a sed subst in # config.status. Protect against being in an unquoted here document # in config.status. rm -f conftest.defines conftest.undefs # Using a here document instead of a string reduces the quoting nightmare. # Putting comments in sed scripts is not portable. # # `end' is used to avoid that the second main sed command (meant for # 0-ary CPP macros) applies to n-ary macro definitions. # See the Autoconf documentation for `clear'. cat >confdef2sed.sed <<\_ACEOF s/[\\&,]/\\&/g s,[\\$`],\\&,g t clear : clear s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp t end s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp : end _ACEOF # If some macros were called several times there might be several times # the same #defines, which is useless. Nevertheless, we may not want to # sort them, since we want the *last* AC-DEFINE to be honored. uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs rm -f confdef2sed.sed # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. cat >>conftest.undefs <<\_ACEOF s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, _ACEOF # Break up conftest.defines because some shells have a limit on the size # of here documents, and old seds have small limits too (100 cmds). echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS echo ' :' >>$CONFIG_STATUS rm -f conftest.tail while grep . conftest.defines >/dev/null do # Write a limited-size here document to $tmp/defines.sed. echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS # Speed up: don't consider the non `#define' lines. echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS # Work around the forget-to-reset-the-flag bug. echo 't clr' >>$CONFIG_STATUS echo ': clr' >>$CONFIG_STATUS sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS echo 'CEOF sed -f $tmp/defines.sed $tmp/in >$tmp/out rm -f $tmp/in mv $tmp/out $tmp/in ' >>$CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail rm -f conftest.defines mv conftest.tail conftest.defines done rm -f conftest.defines echo ' fi # grep' >>$CONFIG_STATUS echo >>$CONFIG_STATUS # Break up conftest.undefs because some shells have a limit on the size # of here documents, and old seds have small limits too (100 cmds). echo ' # Handle all the #undef templates' >>$CONFIG_STATUS rm -f conftest.tail while grep . conftest.undefs >/dev/null do # Write a limited-size here document to $tmp/undefs.sed. echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS # Speed up: don't consider the non `#undef' echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS # Work around the forget-to-reset-the-flag bug. echo 't clr' >>$CONFIG_STATUS echo ': clr' >>$CONFIG_STATUS sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS echo 'CEOF sed -f $tmp/undefs.sed $tmp/in >$tmp/out rm -f $tmp/in mv $tmp/out $tmp/in ' >>$CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail rm -f conftest.undefs mv conftest.tail conftest.undefs done rm -f conftest.undefs cat >>$CONFIG_STATUS <<\_ACEOF # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ if test x"$ac_file" = x-; then echo "/* Generated by configure. */" >$tmp/config.h else echo "/* $ac_file. Generated by configure. */" >$tmp/config.h fi cat $tmp/in >>$tmp/config.h rm -f $tmp/in if test x"$ac_file" != x-; then if diff $ac_file $tmp/config.h >/dev/null 2>&1; then { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else ac_dir=`(dirname "$ac_file") 2>/dev/null || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` { if $as_mkdir_p; then mkdir -p "$ac_dir" else as_dir="$ac_dir" as_dirs= while test ! -d "$as_dir"; do as_dirs="$as_dir $as_dirs" as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` done test ! -n "$as_dirs" || mkdir $as_dirs fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} { (exit 1); exit 1; }; }; } rm -f $ac_file mv $tmp/config.h $ac_file fi else cat $tmp/config.h rm -f $tmp/config.h fi done _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # # CONFIG_COMMANDS section. # for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue ac_dest=`echo "$ac_file" | sed 's,:.*,,'` ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_dir=`(dirname "$ac_dest") 2>/dev/null || $as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_dest" : 'X\(//\)[^/]' \| \ X"$ac_dest" : 'X\(//\)$' \| \ X"$ac_dest" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_dest" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` { if $as_mkdir_p; then mkdir -p "$ac_dir" else as_dir="$ac_dir" as_dirs= while test ! -d "$as_dir"; do as_dirs="$as_dir $as_dirs" as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` done test ! -n "$as_dirs" || mkdir $as_dirs fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A "../" for each directory in $ac_dir_suffix. ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` else ac_dir_suffix= ac_top_builddir= fi case $srcdir in .) # No --srcdir option. We are building in place. ac_srcdir=. if test -z "$ac_top_builddir"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac # Do not use `cd foo && pwd` to compute absolute paths, because # the directories may not exist. case `pwd` in .) ac_abs_builddir="$ac_dir";; *) case "$ac_dir" in .) ac_abs_builddir=`pwd`;; [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; *) ac_abs_builddir=`pwd`/"$ac_dir";; esac;; esac case $ac_abs_builddir in .) ac_abs_top_builddir=${ac_top_builddir}.;; *) case ${ac_top_builddir}. in .) ac_abs_top_builddir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; esac;; esac case $ac_abs_builddir in .) ac_abs_srcdir=$ac_srcdir;; *) case $ac_srcdir in .) ac_abs_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; esac;; esac case $ac_abs_builddir in .) ac_abs_top_srcdir=$ac_top_srcdir;; *) case $ac_top_srcdir in .) ac_abs_top_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; esac;; esac { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 echo "$as_me: executing $ac_dest commands" >&6;} case $ac_dest in chmod ) chmod a+x version.c.SH ;; esac done _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF { (exit 0); exit 0; } _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || { (exit 1); exit 1; } fi irc2.11.2p3/support/config.h.dist0000644000175000017500000007144711431321237014442 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, support/config.h * Copyright (C) 1990 Jarkko Oikarinen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * ircdwatch configuration options. */ /* how often (in seconds) should we check that ircd runs? */ #define IRCDWATCH_POLLING_INTERVAL 30 /* * should we check for config file changes and HUP the server * if a change is detected? */ #undef IRCDWATCH_HUP_ON_CONFIG_CHANGE /* * although you may not want to log ircd-messages to syslog you * may want to log when ircdwatch reloads the config or when * ircd croaks and ircdwatch has to restart it */ #define IRCDWATCH_USE_SYSLOG #ifdef IRCDWATCH_USE_SYSLOG # define IRCDWATCH_SYSLOG_IDENT "ircdwatch" # define IRCDWATCH_SYSLOG_OPTIONS (LOG_PID) # define IRCDWATCH_SYSLOG_FACILITY LOG_DAEMON #endif /* * irc[d] configuration options. * */ /* CHROOTDIR * * Define for value added security if you are a rooter. * WARNING! Better to use external chroot and then run ircd without * this option. * * CPATH, MPATH, LPATH, PPATH, TPATH, QPATH, OPATH, * FNAME_USERLOG, FNAME_OPERLOG, FNAME_CONNLOG, FNAME_AUTHLOG * must have RPATH as root directory! Set them in Makefile * * You may want to define IRC_UID and IRC_GID */ #undef CHROOTDIR #if defined(CHROOTDIR) #define ROOT_PATH "/where/to/change/root/dir" #endif /* ENABLE_SUMMON * * The SUMMON command requires the ircd to be run as group tty in order * to work properly in many cases. If you are on a machine where it * won't work, or simply don't want local users to be summoned, undefine * this. * Consider its security implications before defining. */ #undef ENABLE_SUMMON /* local summon */ /* * If you want to have "USERS" output strictly RFC 1459 (showing * who/finger of your ircd or returning "USERS disabled"), define this. * Undefining leads to sending RPL_LOCALUSERS and RPL_GLOBALUSERS. * upon "USERS" request. */ #undef USERS_RFC1459 #ifdef USERS_RFC1459 /* * If defined, outputs who/finger alike output from ircd box. * Note that some boxes no longer have /etc/utmp. When undefined, it will * return ERR_USERSDISABLED numeric. * Consider its security implications before defining. */ #undef USERS_SHOWS_UTMP #endif /* DEFAULT_INVISIBLE * * When defined, your users will automatically be attributed with user * mode "i" (i == invisible). Invisibility means people dont showup in * WHO or NAMES unless they are on the same channel as you. */ #undef DEFAULT_INVISIBLE /* * Define this if you want to have KLINE command for opers and services. */ #undef KLINE /* * Define this if you want to have TKLINE and UNTKLINE commands * for opers and services. */ #define TKLINE /* If you want tklines to be limited in time, define this (seconds). */ /* #define TKLINE_MAXTIME 86400 */ /* Choose tkill notices to be sent either to &OPER or &NOTICES */ /* #define SCH_TKILL SCH_OPER */ #define SCH_TKILL SCH_NOTICE /* * Operator rights can be precisely defined in O:line flags. However * if you undefine any of the following, it will make given function * unaccessible to your operators, disregarding their O:line flags. */ #define OPER_CONNECT #define OPER_DIE #define OPER_REHASH #define OPER_RESTART #define OPER_SET #define OPER_SQUIT #define OPER_SQUIT_REMOTE #define OPER_KLINE #define OPER_TKLINE /* In a perfect world these two (or at least second) would be undefined. */ #define OPER_KILL #define OPER_KILL_REMOTE /* * Maximum number of network connections your server will allow. This must * not exceed OS limit of max. number of open file descriptors available upon * ircd start. * If you have a lot of server connections, it may be worth splitting the load * over 2 or more servers. * 1 server = 1 connection, 1 user = 1 connection. * Due to various sanity checks during startup, minimum is 13. */ #define MAXCONNECTIONS 50 /* MAXIMUM LINKS * * This define is useful for leaf nodes and gateways. It keeps you from * connecting to too many places. It works by keeping you from * connecting to more than "n" nodes which you have C:blah::blah:6667 * lines for. * * Note that any number of nodes can still connect to you. This only * limits the number that you actively reach out to connect to. * * Leaf nodes are nodes which are on the edge of the tree. If you want * to have a backup link, then sometimes you end up connected to both * your primary and backup, routing traffic between them. To prevent * this, #define MAXIMUM_LINKS 1 and set up both primary and * secondary with C:blah::blah:6667 lines. THEY SHOULD NOT TRY TO * CONNECT TO YOU, YOU SHOULD CONNECT TO THEM. * * Gateways such as the server which connects Australia to the US can * do a similar thing. Put the American nodes you want to connect to * in with C:blah::blah:6667 lines, and the Australian nodes with * C:blah::blah lines. Have the Americans put you in with C:blah::blah * lines. Then you will only connect to one of the Americans. * * This value is only used if you don't have server classes defined, and * a server is in class 0 (the default class if none is set). * */ #define MAXIMUM_LINKS 1 /* * A pure non-routing leaf server can undefine HUB for best performance. * If your server is running as a a HUB Server then define this. * A HUB Server has many servers connect to it at the same as opposed * to a leaf which just has 1 server (typically the uplink). */ #undef HUB #ifdef HUB /* * MAXSERVERS is the maximum number of servers that will be linked * to your server at the same time. This number is not a limit, * it is used to allocate memory when ircd is started. */ # define MAXSERVERS 3 #else # define MAXSERVERS 1 #endif /* * If you want to use timed klines, set it to frequence in seconds, * how often to check if client is to be removed; usually 60 seconds * (smallest granularity you can get in K:line anyway). * * Advised not to use it ;-) --Beeth */ /* #define TIMEDKLINES 300 */ /* * NOTE: defining CMDLINE_CONFIG and installing ircd SUID or SGID is a MAJOR * security problem - they can use the "-f" option to read any files * that the 'new' access lets them. Note also that defining this is * a major security hole if your ircd goes down and some other user * starts up the server with a new conf file that has some extra * O-lines. So don't use this unless you're debugging. */ /* allow conf-file to be specified on command line */ #undef CMDLINE_CONFIG /* * To use m4 as a preprocessor on the ircd.conf file, define M4_PREPROC. * The server will then call m4 each time it reads the ircd.conf file, * reading m4 output as the server's ircd.conf file. * Defining USE_M4_PREFIXES makes GNU m4 use -P flag. */ #undef M4_PREPROC #undef USE_M4_PREFIXES /* * Define if you want to use #include "file" in ircd.conf without M4. * If file is not absolute path, ircd etc path is prepended. * Note that "#include" must be at the beginning of the line. */ #undef CONFIG_DIRECTIVE_INCLUDE /* * If you wish to have the server send 'vital' messages about server * through syslog, define USE_SYSLOG. Only system errors and events critical * to the server are logged although if this is defined with FNAME_USERLOG, * syslog() is used additionally to the above file. It is not recommended that * this option is used unless you tell the system administrator beforehand * and obtain their permission to send messages to the system log files. */ #undef USE_SYSLOG #ifdef USE_SYSLOG /* * If you use syslog above, you may want to turn some (none) of the * spurious log messages for KILL/SQUIT off. */ #undef SYSLOG_KILL /* log all operator kills to syslog */ #undef SYSLOG_SQUIT /* log all remote squits for all servers to syslog */ #undef SYSLOG_CONNECT /* log remote connect messages for other all servs */ #undef SYSLOG_USERS /* send userlog stuff to syslog */ #undef SYSLOG_OPER /* log all users who successfully become an Op */ #undef SYSLOG_CONN /* log all uncomplete/rejected connections */ /* * If you want to log to a different facility than DAEMON, change * this define. */ #define LOG_FACILITY LOG_DAEMON #endif /* USE_SYSLOG */ /* ** If you want your server channels logged to a file, define this and ** any of LOG_SCH_* you want. Logfile names are taken from channel names ** (like: ircd.ERRORS) and they must exist to be used. */ #undef LOG_SERVER_CHANNELS #ifdef LOG_SERVER_CHANNELS #undef LOG_SCH_ERROR /* &ERRORS */ #undef LOG_SCH_NOTICE /* &NOTICES */ #undef LOG_SCH_KILL /* &KILLS */ #undef LOG_SCH_CHAN /* &CHANNEL */ #undef LOG_SCH_NUM /* &NUMERICS */ #undef LOG_SCH_SERVER /* &SERVERS */ #undef LOG_SCH_HASH /* &HASH */ #undef LOG_SCH_LOCAL /* &LOCAL */ #undef LOG_SCH_SERVICE /* &SERVICES */ #undef LOG_SCH_DEBUG /* &DEBUG */ #undef LOG_SCH_AUTH /* &AUTH */ #undef LOG_SCH_SAVE /* &SAVE */ #undef LOG_SCH_WALLOP /* &WALLOPS */ #undef LOG_SCH_CLIENT /* &CLIENTS (if defined to exist) */ #undef LOG_SCH_OPER /* &OPER */ #endif /* LOG_SERVER_CHANNELS */ /* * LOG_OLDFORMAT * * Define this if you want old format of logs. (Mind, you will lose * additional information, like remote ip, port, etc.) */ #undef LOG_OLDFORMAT /* * Define this if you want to log failed /oper attempts. */ #undef FAILED_OPERLOG /* * Define this to make ircd create logfiles if they do not exist. */ #undef LOGFILES_ALWAYS_CREATE /* * Define this if you want to use crypted passwords for operators in your * ircd.conf file. See contrib/mkpasswd/README for more details on this. */ #undef CRYPT_OPER_PASSWORD /* * If you want to store encrypted passwords in N-lines for server links, * define this. For a C/N pair in your ircd.conf file, the password * need not be the same for both, as long as hte opposite end has the * right password in the opposite line. See INSTALL doc for more details. */ #undef CRYPT_LINK_PASSWORD /* * define this if you enable summon and if you want summon to look for the * least idle tty a user is logged in on. */ #undef LEAST_IDLE /* * IDLE_FROM_MSG * * Idle-time nullified only from privmsg, if undefined idle-time * is nullified from everything except ping/pong. * Added 3.8.1992, kny@cs.hut.fi (nam) */ #define IDLE_FROM_MSG /* * use these to setup a Unix domain socket to connect clients/servers to. */ #undef UNIXPORT /* * IRC_UID * IRC_GID * * If you start the server as root but wish to have it run as another user, * define IRC_UID to that user id (and IRC_GID to the desired group id). * This should only be defined if you are running as root... * and even then perhaps not. */ /* #undef IRC_UID 65534 */ /* #undef IRC_GID 65534 */ /* * CLIENT_FLOOD * * this controls the number of bytes the server will allow a client to * send to the server without processing before disconnecting the client for * flooding it. Values greater than 8000 make no difference to the server. */ #define CLIENT_FLOOD 1000 /* Remote query flood protection. */ #define CHREPLLEN 8192 /* * If you wish to run services, define USE_SERVICES. * This can make the server noticeably bigger and slower. * services are not fully implemented yet, so don't use it unless you really * know what you are doing. */ #undef USE_SERVICES /* * Define the following to make the delay for nicks random. * Some people believe a bot can exactly time the delay and don't like it, * I think this is a useless concern. -krys */ #undef RANDOM_NDELAY /* * You've read the BOFH saga and you liked it, then define the following. * * The two following will change the nick delay and channel delay features * making them totally user unfriendly but more efficient. */ #undef BETTER_NDELAY #undef BETTER_CDELAY /* * Defining this will enable the use of compressed server-server links. * In order to have it work, you must have the zlib version 1.0 or higher. * The library and the include files must have been found by configure, * if you have installed the zlib after running configure, run it again. */ #undef ZIP_LINKS /* * Defining this will add an artificial 2 seconds delay for accepting * connections. This is the OLD behaviour of the server. * * NOTE: Undefining this leads to a significant increase in CPU usage if * you reject client which keeps connecting. */ #undef SLOW_ACCEPT /* * Defining this will make the server check for rapid connections from a single * host and reject new connections from this host if the limit is reached. * * NOTE: Enabling this feature will significantly increase the CPU usage * for servers carrying several hundred clients and getting many connections. */ #define CLONE_CHECK /* ** Servers with many clients and lots of K:lines are having noticable ** lag after rehash. Define this to the number of clients you want to ** be checked each time (all clients will eventually be checked, of course). ** This will lessen the load and eliminate the lag during rehash. ** Undefine (or define to bigger than MAXCONNECTIONS) to check all clients ** in one sweep. */ #define MAXDELAYEDKILLS 200 /* ** This defines the message that is sent to clients upon connect. ** Keep it short. */ #define HELLO_MSG "Please wait while we process your connection." /* * Connections rejected by check_clones() will be delayed for this many seconds * before final error is sent to them and their socket is closed. * This effectively reduces bouncing (fast reconnecting clients). * CLONE_CHECK must be defined for this to work. * * Note: it may lead to file descriptors exhaustion. ("All connections in use" * error message.) */ #define DELAY_CLOSE 15 /* Recommended value: 15 */ /* ** Define this to get oper-only &CLIENTS channel with clients connects, ** quits and nick changes. */ #undef CLIENTS_CHANNEL /* ** Bitmask defining type of information sent to &CLIENTS, combine from ** CCL_CONN (client uid, nick, username, host and IP), CCL_CONNINFO ** (also user info), CCL_QUIT (client uid, nick, username, host and IP), ** CCL_QUITINFO (also quit reason), CCL_NICK (all nick changes). */ /* #define CLIENTS_CHANNEL_LEVEL (CCL_CONN|CCL_QUIT) */ /* ** This adds ability to ban users with specified realnames from ** connecting to the server. May be useful for various drones. */ #undef XLINE /* ** Define the reason users get as a rejection message. ** Some may use first form for the sake of transparency, some may believe it ** is not good that users can see the real reason behind X-rejection. */ /* #define XLINE_EXIT_REASON "X-denied user" */ #define XLINE_EXIT_REASON "Too many host connections (global)" /* ** Define this to whatever you want to see after successful OPER */ #define TXT_YOUREOPER "You are now an IRC Operator" /* ** If you have huge number of K-lines and provide your users with ** some other means of looking at them (or you are mean and simply ** do not want to show it at all), define this. ** Note that operators will get list of K anyway. */ /* #define TXT_NOSTATSK "Please use http://example.org/klines instead" */ /* ** If you don't want non-oper clients to see tkline list (like when you run ** some service which automatically tklines open proxies), define this. */ /* #undef DISABLE_STATSTKLINE */ /* ** If you have problems with two servers autoconnecting to each other ** all the time and thus squitting, define this. It will eat a little ** CPU during AC and it will not allow to try to connect to server that ** is trying to connect to you. */ /* #undef DISABLE_DOUBLE_CONNECTS */ /* ** Define delimiter of fields in ircd.conf. */ #ifdef INET6 # define IRCDCONF_DELIMITER '%' #else # define IRCDCONF_DELIMITER ':' #endif /* * Max number of channels a user is allowed to join. */ #define MAXCHANNELSPERUSER 21 /* Recommended value: 21 */ /* * USE_IAUTH makes ircd use the iauth program for authentication. * it can always be overriden by using the -s switch */ #define USE_IAUTH /* Following notice is sent before and after /LIST output. * If you do not want such behaviour, undefine. */ #define LIST_ALIS_NOTE "Usage of /list for listing all channels is " \ "deprecated. Please use \"/squery alis help\" instead." /* Define this to see when a channel topic was set and who it was set by. ** Warning: eats memory (around 5MB) */ #define TOPIC_WHO_TIME /* ** Define this to show local clients signon time in whois */ #define WHOIS_SIGNON_TIME /* * Split detection * This defines default thresholds for turning on and off the split-mode, * where joins to new channels do not give chanop status. * This should always be bigger than the max counts of * users/servers in your TLD (or some other close group), so you * get in split when you split. It is also a good practice to set * around 90% of what your whole network counts minimally (servers * inside masks are also counted), so that splits of smaller parts * would be noticed on each side. * * Defining to 0 disables entering split-mode. */ #define DEFAULT_SPLIT_USERS 65000 #define DEFAULT_SPLIT_SERVERS 80 /* ** Notice sent to connecting users if the server is in the split-mode. */ #define SPLIT_CONNECT_NOTICE "Server is currently in split-mode." /* * Undefining NO_OPER_REMOTE removes the restriction that O-lines only become * fully effective for people on the 'same network' as the server. * Defined, it slightly increases the security of the server by * placing restrictions on where people can become operator from. * Dubious consideration, IMO. */ #undef NO_OPER_REMOTE /* ** CLCHNO defines changes in local clients count, which are shown ** as "Local in/de-crease" ** I guess rule of thumb would be 5% of your average user count. --B. */ #define CLCHNO 100 /* ** CLCHSEC defines minimum time in seconds between two consecutive ** "New highest local/global clients count" messages (prevents flood). */ #define CLCHSEC 300 /* ** Define this to allow MOTD for unregistered clients. Note that this is ** required by some European countries laws. */ #undef MOTD_UNREG /* ** For standard "Gone" away reply for remote clients, undefine this. ** Leave defined for more helpful message. */ #define AWAY_MOREINFO /* ** If you do not wish your clients to use "nick 0" during registration, ** define this. */ #undef DISABLE_NICK0_REGISTRATION /* ** Define this if you want to use Japanese channel names in JIS encoding. */ #undef JAPANESE /* ** If you want to allow your opers to be able to use SIDTRACE command to ** see all clients from all servers that share the same SID prefix as your ** own, enable this. Useful for server "clusters", like 0PN. Requires also ** proper ACLs in O-line. */ #undef ENABLE_SIDTRACE /* STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP */ /* You shouldn't change anything below this line, unless absolutely needed. */ /* ** Accept only hostnames conforming to RFC1034/1035/1123. ** Conformance of the internal resolver to RFC1123. */ #define RESTRICT_HOSTNAMES /* ** Allow only "proper" chars in username. ** Disallow '^', '~', '+', '=', '-' as a first char. ** Require at least one alphanum and no more than two nonalphanum. */ #define RESTRICT_USERNAMES /* Maximum length the queue of pending connections to one port may grow to. * Note that your system limits this, too. FreeBSD, for instance, has sysctl * kern.ipc.somaxconn for that. Such must be bigger than this define prior to * ircd start. */ #define LISTENQUEUE 128 /* define DEBUGMODE to enable debugging mode.*/ #undef DEBUGMODE /* * Time interval to wait and if no messages have been received, then check for * PINGFREQUENCY and CONNECTFREQUENCY */ #define TIMESEC 60 /* Recommended value: 60 */ /* * If daemon doesn't receive anything from any of its links within * PINGFREQUENCY seconds, then the server will attempt to check for * an active link with a PING message. If no reply is received within * (PINGFREQUENCY * 2) seconds, then the connection will be closed. */ #define PINGFREQUENCY 120 /* Recommended value: 120 */ /* * If the connection to to uphost is down, then attempt to reconnect every * CONNECTFREQUENCY seconds. */ #define CONNECTFREQUENCY 600 /* Recommended value: 600 */ /* * Often net breaks for a short time and it's useful to try to * establishing the same connection again faster than CONNECTFREQUENCY * would allow. But, to keep trying on bad connection, we require * that connection has been open for certain minimum time * (HANGONGOODLINK) and we give the net few seconds to steady * (HANGONRETRYDELAY). This latter has to be long enough that the * other end of the connection has time to notice it broke too. */ #define HANGONRETRYDELAY 30 /* Recommended value: 30 seconds */ #define HANGONGOODLINK 900 /* Recommended value: 15 minutes */ /* * Number of seconds to wait for write to complete if stuck. */ #define WRITEWAITDELAY 15 /* Recommended value: 15 */ /* * Number of seconds to wait for DNS/authentication to complete. * Note that iauth's default timeout per module is 30 seconds, so this value * should be at least 30 * number of modules. Extra time should really be * given to be safe. */ #define ACCEPTTIMEOUT 90 /* Recommended value: 90 */ /* * Max time from the nickname change that still causes KILL * automaticly to switch for the current nick of that user. (seconds) */ #define KILLCHASETIMELIMIT 90 /* Recommended value: 90 */ #ifdef ZIP_LINKS /* * the compression level used. (Suggested values: 3, 4, 5) * Above 5 will only give a *very* marginal increase in compression for a * *very* large increase in CPU usage. */ # define ZIP_LEVEL 5 #endif #ifdef CLONE_CHECK /* * If CLONE_CHECK has been defined, these control how the checks are performed, * and how the alarm is triggered. * This triggers alarm when more than 10 clients in 2 seconds from the same host * try to connect to ircd. */ # define CLONE_MAX 10 # define CLONE_PERIOD 2 #endif /* * define NO_IDENT if you don't want to support ident (RFC1413). * it is a VERY bad idea to do so, since this will make it impossible to * efficientely track abusers. * NO_PREFIX should always be undefined. */ /* #undef NO_IDENT */ /* #undef NO_PREFIX */ /* ** LISTENER_DELAY, if defined, adds an artificial delay between checking ** listeners for new connections. If undefined, it accepts clients faster ** but the CPU load increases. ** LISTENER_MAXACCEPT defines how many clients will be accepted during one ** listener check. */ #ifdef SLOW_ACCEPT #define LISTENER_DELAY 2 #define LISTENER_MAXACCEPT 1 #else #define LISTENER_DELAY 1 #define LISTENER_MAXACCEPT 10 #endif /* ** If you don't feel your users should use too long nicknames, you can ** restrict length of their dnicks here. */ #define LOCALNICKLEN 15 /* ** If you don't want your users to have too short nicknames, define ** minimum nicklen allowed. */ /* #define MINLOCALNICKLEN 2 */ /* ** You probably don't want to disable it, but if you run into any problems, ** here's the knob. */ #define ENABLE_CIDR_LIMITS /* ** Define this to significantly speed up rehash with large amounts of I-lines. ** Wastes some memory each rehash (luckily not indefinitely). */ #define FASTER_ILINE_REHASH /* ** Restores old behaviour of Y-lines maxlinks limit, which was counted ** separately per each I-line using it. ** Note: if you use it with FASTER_ILINE_REHASH, clients will be able ** to exceed maxlinks limits after each rehash. Sorry. */ #undef YLINE_LIMITS_OLD_BEHAVIOUR /* ** Y-line [user@]host limits are now using ip hash instead of hostname hash, ** which means counts are against IPs, not hostnames. ** If you don't like that behaviour, you can undefine it. */ #define YLINE_LIMITS_IPHASH /* ** find_userhost (used in PRIVMSG user%host@server syntax) uses hostname ** hash. Noone really used that syntax anyway, so noone should notice. ** If you are rebellious or just don't want to waste memory -- define it. ** Note that if there's a hostname hash needed (and thus compiled in) ** for other reasons, it will be used in find_userhost anyway. ** Also note that defining this breaks compatibility with RFC 2812, as ** clients no longer will be able to PRIVMSG user%host@server (though they ** will be able to use user%ip@server), but it would still be compatible ** with RFC 1459, which defined only "user@server" syntax. */ #undef FIND_USERHOST_IPHASH /* ** Default behaviour of the server after the first netjoin is done. ** Possible values: 0 (SET CACCEPT OFF), 1 (SET CACCEPT ON) ** and 2 (SET CACCEPT SPLIT). */ #define CACCEPT_DEFAULT 2 /* Minimum values admin can set. */ #define SPLIT_USERS 50000 #define SPLIT_SERVERS 50 /* STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP */ /* STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP */ /* STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP */ /* ------------------------- END CONFIGURATION SECTION -------------------- */ #ifndef ENABLE_SUMMON # undef LEAST_IDLE #endif #define SEQ_NOFILE 128 /* For Dynix (sequent OS) users : * set to your current kernel impl, * max number of socket connections; * ignored on other OS. */ /* * safety margin so we can always have one spare fd, for motd/authd or * whatever else. -5 allows "safety" margin of 1 and space reserved. */ #define MAXCLIENTS (MAXCONNECTIONS-5) /* In fact, if using server channels logs, it would be even more. */ #if (MAXCONNECTIONS < 13) # error Sorry, MAXCONNECTIONS minimum 13 for ircd to start. #endif #if defined(CLIENT_FLOOD) # if (CLIENT_FLOOD > 8000) || (CLIENT_FLOOD < 512) #error CLIENT_FLOOD needs redefining. # endif #else #error CLIENT_FLOOD undefined #endif /* sanity check */ #if defined(DELAY_CLOSE) # if defined(SLOW_ACCEPT) || !defined(CLONE_CHECK) # error define CLONE_CHECK and undefine SLOW_ACCEPT to use DELAY_CLOSE. # endif # if (DELAY_CLOSE < 1) # error DELAY_CLOSE needs redefining. # endif #endif #if defined(ZIP_LINKS) # if (ZIP_MINIMUM > ZIP_MAXIMUM) #error ZIP_MINIMUM needs redefining. # endif #endif /* I think we may allow undefining both SLOW_ACCEPT and CLONE_CHECK --B. */ #if 0 #if !defined(SLOW_ACCEPT) && !defined(CLONE_CHECK) # define CLONE_CHECK # define CLONE_MAX 2 # define CLONE_PERIOD 10 #endif #endif /* ** you wouldn't want to compress messages one by one.. would you? ** (it's not implemented anyways) */ #ifdef ZIP_LINKS # define SENDQ_ALWAYS #endif #if ! USE_POLL # if (MAXCONNECTIONS > FD_SETSIZE) #error FD_SETSIZE must be bigger than MAXCONNECTIONS # endif #endif /* ** buffer used for iauth-ircd communication ** very big servers might consider increasing it */ #ifdef USE_IAUTH # define IAUTH_BUFFER 65535 #endif /* ** Make sure that if zlib isn't found, or you don't want to use it, that you ** don't define ZIP_LINKS */ #ifndef USE_ZLIB #undef ZIP_LINKS #endif #if defined(TIMEDKLINES) # if (TIMEDKLINES + 0 < 60) # error TIMEDKLINES must be bigger than 60 seconds # endif #endif #ifndef SPLIT_USERS #error SPLIT_USERS must be defined #endif #ifndef SPLIT_SERVERS #error SPLIT_SERVERS must be defined #endif #if defined(CONFIG_DIRECTIVE_INCLUDE) && defined(M4_PREPROC) #error CONFIG_DIRECTIVE_INCLUDE and M4_PREPROC are mutually exclusive #endif #ifndef TKLINE #undef OPER_TKLINE #endif #if defined(LOGFILES_ALWAYS_CREATE) && !defined(HAVE_SYS_STAT_H) #error LOGFILES_ALWAYS_CREATE requires sys/stat.h #endif #ifndef IRCDCONF_DELIMITER #error IRCDCONF_DELIMITER must be defined #endif #if !defined(HELLO_MSG) #error HELLO_MSG must be defined #endif #if defined(TKLINE_MAXTIME) && (TKLINE_MAXTIME + 0) == 0 #undef TKLINE_MAXTIME #endif /* Hard limit tkline time (more than 3 years) */ #if !defined(TKLINE_MAXTIME) || (TKLINE_MAXTIME > 99999999) #define TKLINE_MAXTIME 99999999 #endif #if !defined(SCH_TKILL) #define SCH_TKILL SCH_NOTICE #endif #if defined(CLIENTS_CHANNEL) && !defined(CLIENTS_CHANNEL_LEVEL) #error define CLIENTS_CHANNEL_LEVEL #endif #if defined(MINLOCALNICKLEN) && ((MINLOCALNICKLEN + 0) < 2) #undef MINLOCALNICKLEN #endif #if defined(MINLOCALNICKLEN) && (MINLOCALNICKLEN > LOCALNICKLEN) #error MINLOCALNICKLEN bigger than (max)LOCALNICKLEN #endif /* we should probably not bother with that :) */ #if !defined(NBLOCK_POSIX) && !defined(NBLOCK_BSD) && !defined(NBLOCK_SYSV) #undef LISTENER_MAXACCEPT #define LISTENER_MAXACCEPT 1 #endif /* well, we save some memory if we don't actually need either of the hashes */ #if defined(YLINE_LIMITS_IPHASH) || defined(FIND_USERHOST_IPHASH) #define USE_IPHASH #endif #if !defined(YLINE_LIMITS_IPHASH) || !defined(FIND_USERHOST_IPHASH) #define USE_HOSTHASH #endif #if defined(CACCEPT_DEFAULT) #if ((CACCEPT_DEFAULT) > 2) || ((CACCEPT_DEFAULT) < 0) #error CACCEPT_DEFAULT can be 0, 1 or 2. #endif #endif irc2.11.2p3/support/config.sub0000644000175000017500000007535310165774004014051 0ustar kkkk#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. timestamp='2004-11-30' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit 0;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | m32r | m32rle | m68000 | m68k | m88k | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64vr | mips64vrel \ | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | msp430 \ | ns16k | ns32k \ | openrisc | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \ | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | v850 | v850e \ | we32k \ | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* \ | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64vr-* | mips64vrel-* \ | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | msp430-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ | xstormy16-* | xtensa-* \ | ymp-* \ | z8k-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; c90) basic_machine=c90-cray os=-unicos ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16c) basic_machine=cr16c-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; or32 | or32-*) basic_machine=or32-unknown os=-coff ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tic55x | c55x*) basic_machine=tic55x-unknown os=-coff ;; tic6x | c6x*) basic_machine=tic6x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sh64) basic_machine=sh64-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: irc2.11.2p3/support/setup.h.in0000644000175000017500000003026011030265263013765 0ustar kkkk/* ../support/setup.h.in. Generated from configure.in by autoheader. */ /* Type of the 3rd argument of accept() */ #undef ACCEPT_TYPE_ARG3 /* Define if the operating system is AIX 3.2. */ #undef AIX_3_2 /* Define if contains bad __const usages (Linux). */ #undef BAD___CONST_NETDB_H /* Define if the system provides reliable BSD signals. */ #undef BSD_RELIABLE_SIGNALS /* Define if errno is declared in errno.h. */ #undef ERRNO_DECLARED /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_NAMESER_H /* Define to 1 if you have the `bcmp' function. */ #undef HAVE_BCMP /* Define to 1 if you have the `bcopy' function. */ #undef HAVE_BCOPY /* Define to 1 if you have the `bzero' function. */ #undef HAVE_BZERO /* Define to 1 if you have the header file. */ #undef HAVE_CTYPE_H /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the header file. */ #undef HAVE_ERRNO_H /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the `fork' function. */ #undef HAVE_FORK /* Define to 1 if you have the `getipnodebyname' function. */ #undef HAVE_GETIPNODEBYNAME /* Define to 1 if you have the `getrusage' function. */ #undef HAVE_GETRUSAGE /* Define if you have GNU m4. */ #undef HAVE_GNU_M4 /* Define to 1 if you have the `index' function. */ #undef HAVE_INDEX /* Define to 1 if you have the `inet_addr' function. */ #undef HAVE_INET_ADDR /* Define to 1 if you have the `inet_aton' function. */ #undef HAVE_INET_ATON /* Define to 1 if you have the `inet_netof' function. */ #undef HAVE_INET_NETOF /* Define to 1 if you have the `inet_ntoa' function. */ #undef HAVE_INET_NTOA /* Define to 1 if the system has the type `int16_t'. */ #undef HAVE_INT16_T /* Define to 1 if the system has the type `int32_t'. */ #undef HAVE_INT32_T /* Define to 1 if the system has the type `int8_t'. */ #undef HAVE_INT8_T /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `crypt' library (-lcrypt). */ #undef HAVE_LIBCRYPT /* Define to 1 if you have the `nsl' library (-lnsl). */ #undef HAVE_LIBNSL /* Define to 1 if you have the `socket' library (-lsocket). */ #undef HAVE_LIBSOCKET /* Define to 1 if you have the header file. */ #undef HAVE_MATH_H /* Define to 1 if you have the `memcmp' function. */ #undef HAVE_MEMCMP /* Define to 1 if you have the `memcpy' function. */ #undef HAVE_MEMCPY /* Define to 1 if you have the `memmove' function. */ #undef HAVE_MEMMOVE /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the header file. */ #undef HAVE_NETDB_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_SYSTM_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINFO_NI_H /* Define to 1 if you have the `poll' function. */ #undef HAVE_POLL /* Define to 1 if you have the header file. */ #undef HAVE_PWD_H /* Define to 1 if you have the header file. */ #undef HAVE_RESOLV_H /* Define to 1 if you have the `rindex' function. */ #undef HAVE_RINDEX /* Define to 1 if you have the `select' function. */ #undef HAVE_SELECT /* Define to 1 if you have the `setpgrp' function. */ #undef HAVE_SETPGRP /* Define to 1 if you have the `sigaction' function. */ #undef HAVE_SIGACTION /* Define to 1 if you have the header file. */ #undef HAVE_SIGNAL_H /* Define to 1 if you have the `sigset' function. */ #undef HAVE_SIGSET /* Define to 1 if the system has the type `socklen_t'. */ #undef HAVE_SOCKLEN_T /* Define to 1 if you have the header file. */ #undef HAVE_STDARG_H /* Define to 1 if you have the header file. */ #undef HAVE_STDDEF_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDIO_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strchr' function. */ #undef HAVE_STRCHR /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if string.h may be included along with strings.h */ #undef HAVE_STRING_WITH_STRINGS /* Define to 1 if you have the `strlcpy' function. */ #undef HAVE_STRLCPY /* Define to 1 if you have the header file. */ #undef HAVE_STROPTS_H /* Define to 1 if you have the `strrchr' function. */ #undef HAVE_STRRCHR /* Define to 1 if you have the `strtok' function. */ #undef HAVE_STRTOK /* Define to 1 if you have the `strtoken' function. */ #undef HAVE_STRTOKEN /* Define to 1 if you have the header file. */ #undef HAVE_SYSLOG_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_BITYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_ERRNO_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_FILE_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_FILIO_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IOCTL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_POLL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_RESOURCE_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SYSCALL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SYSLOG_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIMES_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_UN_H /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H /* Define to 1 if you have the `times' function. */ #undef HAVE_TIMES /* Define to 1 if you have the header file. */ #undef HAVE_TIME_H /* Define to 1 if you have the `truncate' function. */ #undef HAVE_TRUNCATE /* Define to 1 if the system has the type `uint16_t'. */ #undef HAVE_UINT16_T /* Define to 1 if the system has the type `uint32_t'. */ #undef HAVE_UINT32_T /* Define to 1 if the system has the type `uint8_t'. */ #undef HAVE_UINT8_T /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the header file. */ #undef HAVE_UTMP_H /* Define to 1 if the system has the type `u_char'. */ #undef HAVE_U_CHAR /* Define to 1 if the system has the type `u_int'. */ #undef HAVE_U_INT /* Define to 1 if the system has the type `u_int16_t'. */ #undef HAVE_U_INT16_T /* Define to 1 if the system has the type `u_int32_t'. */ #undef HAVE_U_INT32_T /* Define to 1 if the system has the type `u_int8_t'. */ #undef HAVE_U_INT8_T /* Define to 1 if the system has the type `u_long'. */ #undef HAVE_U_LONG /* Define to 1 if the system has the type `u_short'. */ #undef HAVE_U_SHORT /* Define to 1 if you have the `vfork' function. */ #undef HAVE_VFORK /* Define to 1 if you have the header file. */ #undef HAVE_VFORK_H /* Define to 1 if you have the `vsyslog' function. */ #undef HAVE_VSYSLOG /* Define to 1 if `fork' works. */ #undef HAVE_WORKING_FORK /* Define to 1 if `vfork' works. */ #undef HAVE_WORKING_VFORK /* Define if h_errno is declared in errno.h or netdb.h. */ #undef H_ERRNO_DECLARED /* Define to enable IPv6 support */ #undef INET6 /* Define as the resolver configuration file. */ #undef IRC_RESCONF /* Define if memcmp is not 8-bit clean. */ #undef MEMCMP_BROKEN /* Define if the system provides BSD non-blocking system. */ #undef NBLOCK_BSD /* Define if the system provides POSIX non-blocking system. */ #undef NBLOCK_POSIX /* Define if the system provides SystemV non-blocking system. */ #undef NBLOCK_SYSV /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define if the system provides POSIX sigaction. */ #undef POSIX_SIGNALS /* Define to 1 if the C compiler supports function prototypes. */ #undef PROTOTYPES /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* Define to 1 if the `setpgrp' function takes no argument. */ #undef SETPGRP_VOID /* Define to 1 if the `setvbuf' function takes the buffering type as its second argument and the buffer pointer as the third, as on System V before release 3. */ #undef SETVBUF_REVERSED /* Define if the operating system is Solaris 2.x (SunOS 5.x). */ #undef SOLARIS_2 /* Define if the operating system is Solaris 2.[0-2] (SunOS 5.[0-2]). */ #undef SOLARIS_2_0_2_1_2_2 /* Define if the operating system is Solaris 2.3 (SunOS 5.3). */ #undef SOLARIS_2_3 /* Define to 1 if the `S_IS*' macros in do not work properly. */ #undef STAT_MACROS_BROKEN /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define if the system provides unreliable SystemV signals. */ #undef SYSV_UNRELIABLE_SIGNALS /* Define if sys_errlist is declared in stdio.h or errno.h. */ #undef SYS_ERRLIST_DECLARED /* Define if sys_nerr is declared in stdio.h or errno.h. */ #undef SYS_NERR_DECLARED /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define to 1 if your declares `struct tm'. */ #undef TM_IN_SYS_TIME /* Define to enable dynamically shared iauth module support. */ #undef USE_DSM /* Define if poll(2) must be used instead of select(2). Note: some systems (e.g. linux 2.0.x) have a non-working poll() */ #undef USE_POLL /* Define if the second argument of waitpid must be an "union wait *" instead of an "int *". */ #undef USE_UNION_WAIT /* Define if zlib package must be used for compilation/linking. */ #undef USE_ZLIB /* Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ #undef WORDS_BIGENDIAN /* Define to 1 if on AIX 3. System headers sometimes define this. We just want to avoid a redefinition error message. */ #ifndef _ALL_SOURCE # undef _ALL_SOURCE #endif /* Define to 1 if on MINIX. */ #undef _MINIX /* Define to 2 if the system does not provide POSIX.1 features except with this defined. */ #undef _POSIX_1_SOURCE /* Define to 1 if you need to in order for `stat' and other things to work. */ #undef _POSIX_SOURCE /* Define like PROTOTYPES; this can be used by system headers. */ #undef __PROTOTYPES /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `int' if doesn't define. */ #undef gid_t /* Define to `int' if does not define. */ #undef mode_t /* Define to `long' if does not define. */ #undef off_t /* Define to `int' if does not define. */ #undef pid_t /* Define this to sigset if the system provides reliable BSD signals through sigset instead of signal. */ #undef signal /* Define to `unsigned' if does not define. */ #undef size_t /* Define to `int' if doesn't define. */ #undef uid_t /* Define as `fork' if `vfork' does not work. */ #undef vfork irc2.11.2p3/support/install-sh0000755000175000017500000001303006650477461014070 0ustar kkkk#! /bin/sh # # $Id: install-sh,v 1.3 1999/01/18 00:24:17 kalt Exp $ # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 irc2.11.2p3/support/sums.in0000644000175000017500000000331506512510100013357 0ustar kkkk#!/bin/sh # trap "" 1 2 3 13 14 15 21 22 # $Id: sums.in,v 1.1 1998/04/07 20:44:48 kalt Exp $ trap "" 1 2 3 13 14 15 /bin/cp hash.c hash.c.old 2>/dev/null /bin/mv -f hash.c hash.c.temp 1>/dev/null 2>&1 csum=`(cd ../ircd; @SUM@ s_bsd.c) 2>/dev/null` sed -e "s/SUSER/[${csum}]/g" hash.c.temp > hash.c 2>/dev/null /bin/mv -f hash.c hash.c.temp 1>/dev/null 2>&1 csum=`(cd ../ircd; @SUM@ s_user.c) 2>/dev/null` sed -e "s/SSERV/[${csum}]/g" hash.c.temp > hash.c 2>/dev/null /bin/mv -f hash.c hash.c.temp 1>/dev/null 2>&1 csum=`(cd ../ircd; @SUM@ s_serv.c) 2>/dev/null` sed -e "s/SBSDC/[${csum}]/g" hash.c.temp > hash.c 2>/dev/null /bin/mv -f hash.c hash.c.temp 1>/dev/null 2>&1 csum=`(cd ../ircd; @SUM@ channel.c) 2>/dev/null` sed -e "s/CHANC/[$csum]/g" hash.c.temp > hash.c 2>/dev/null /bin/mv -f hash.c hash.c.temp 1>/dev/null 2>&1 csum=`(cd ../ircd; @SUM@ ircd.c) 2>/dev/null` sed -e "s/IRCDC/[$csum]/g" hash.c.temp > hash.c 2>/dev/null /bin/mv -f hash.c hash.c.temp 1>/dev/null 2>&1 csum=`(cd ../ircd; @SUM@ s_misc.c) 2>/dev/null` sed -e "s/SMISC/[$csum]/g" hash.c.temp > hash.c 2>/dev/null /bin/mv -f hash.c hash.c.temp 1>/dev/null 2>&1 csum=`@SUM@ hash.c.old 2>/dev/null` sed -e "s/HASHC/[$csum]/g" hash.c.temp > hash.c 2>/dev/null /bin/mv -f hash.c hash.c.temp 1>/dev/null 2>&1 csum=`@SUM@ version.c.SH 2>/dev/null` sed -e "s/VERSH/[$csum]/g" hash.c.temp > hash.c 2>/dev/null /bin/mv -f hash.c hash.c.temp 1>/dev/null 2>&1 csum=`(cd ../ircd; @SUM@ s_bsd.c) 2>/dev/null` sed -e "s/MAKEF/[$csum]/g" hash.c.temp > hash.c 2>/dev/null if [ -f /bin/hostid ] ; then /bin/mv -f hash.c hash.c.temp 1>/dev/null 2>&1 csum=`hostid 2>/dev/null` sed -e "s/HOSTID/[$csum]/g" hash.c.temp > hash.c 2>/dev/null fi /bin/rm -f hash.c.temp 1>/dev/null 2>&1 irc2.11.2p3/support/configure.in0000644000175000017500000005571711030265263014376 0ustar kkkkdnl configure.in for irc-2.11.x dnl Matthew Green (mrg@mame.mu.oz.au), Alain Nissen (Alain.Nissen@ulg.ac.be) dnl using portions of Avalon's Config and GNU Autoconf 1.12. dnl heavily updated to autoconf 2.5x Piotr Kucharski dnl --------- dnl new tests dnl --------- AC_DEFUN(IRC_MATHLIB, [ AC_CHECK_LIB([m], [pow], [MATHLIBS=-lm], []) AC_SUBST(MATHLIBS) ]) dns based on the version from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_func_accept_argtypes.html dnl AC_DEFUN([AC_FUNC_ACCEPT_ARGTYPES], [AC_MSG_CHECKING([types of arguments for accept()]) AC_CACHE_VAL(ac_cv_func_accept_arg1,dnl [AC_CACHE_VAL(ac_cv_func_accept_arg2,dnl [AC_CACHE_VAL(ac_cv_func_accept_arg3,dnl [for ac_cv_func_accept_arg1 in 'int' 'unsigned int'; do for ac_cv_func_accept_arg2 in 'struct sockaddr' 'const struct sockaddr' 'void'; do for ac_cv_func_accept_arg3 in 'socklen_t' 'size_t' 'unsigned int' 'int'; do AC_TRY_COMPILE(dnl [#ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif extern accept ($ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2 *, $ac_cv_func_accept_arg3 *);],,dnl [ac_not_found=no ; break 3], ac_not_found=yes) done done done ])dnl AC_CACHE_VAL ])dnl AC_CACHE_VAL ])dnl AC_CACHE_VAL if test "$ac_not_found" = no; then AC_MSG_RESULT([$ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2 *, $ac_cv_func_accept_arg3 *]) dnl AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG1,$ac_cv_func_accept_arg1) dnl AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG2,$ac_cv_func_accept_arg2) AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG3,$ac_cv_func_accept_arg3, [Type of the 3rd argument of accept()]) else AC_MSG_RESULT([Not found]) AC_MSG_WARN([Using default types for arguments to accept()]) fi ]) AC_DEFUN(IRC_PATH_ZLIB, [AC_MSG_CHECKING(for zlib package) AC_ARG_WITH(zlib, [ --with-zlib[[=ZDIR]] checks for zlib; if found, enables compressed links]) AC_ARG_WITH(zlib, [ --without-zlib does not check for zlib; disables compressed links]) if test "x$with_zlib" = xno; then no_zlib=yes else irc_zlib_prefix=$with_zlib AC_CACHE_VAL(irc_cv_path_zlib, [no_zlib=yes no_zlib_include=yes no_zlib_library=yes AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include ]])],[no_zlib_include= irc_zlib_include=],[for irc_dir in "$irc_zlib_include" \ `test -z "$irc_zlib_prefix" || echo "$irc_zlib_prefix/include"` \ `echo "$irc_zlib_library" | sed s/lib/include/` \ /usr/include /usr/local/include /usr/unsupported/include \ /usr/share/include /usr/local/share/include /include \ /usr/zlib/include /usr/local/zlib/include \ /usr/include/zlib /usr/local/include/zlib \ /usr/unsupported/include/zlib /usr/share/include/zlib \ /usr/local/share/include/zlib /include/zlib \ /usr/zlib/include/zlib /usr/local/zlib/include/zlib; \ do if test -r "$irc_dir/zlib.h"; then no_zlib_include= irc_zlib_include=$irc_dir break fi done ]) irc_save_LIBS="$LIBS" LIBS="-lz $LIBS" AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[inflate()]])],[no_zlib_library= irc_zlib_library= LIBS="$irc_save_LIBS"],[LIBS="$irc_save_LIBS" for irc_dir in "$irc_zlib_library" \ `test -z "$irc_zlib_prefix" || echo "$irc_zlib_prefix/lib"` \ `echo "$irc_zlib_include" | sed s/include/lib/` \ /usr/lib /usr/local/lib /usr/unsupported/lib \ /usr/share/lib /usr/local/share/lib /lib /usr/zlib/lib \ /usr/local/zlib/lib /usr/lib/zlib /usr/local/lib/zlib \ /usr/unsupported/lib/zlib /usr/share/lib/zlib \ /usr/local/share/lib/zlib /lib/zlib \ /usr/zlib/lib/zlib /usr/local/zlib/lib/zlib; \ do for irc_extension in a so sl; do if test -r $irc_dir/libz.$irc_extension; then no_zlib_library= irc_zlib_library=$irc_dir break 2 fi done done ]) if test "x$no_zlib_include" = x && test "x$no_zlib_library" = x; then no_zlib= fi if test "$no_zlib" = yes; then irc_cv_path_zlib="no_zlib=yes" else irc_cv_path_zlib="no_zlib= irc_zlib_include=$irc_zlib_include irc_zlib_library=$irc_zlib_library" fi]) eval "$irc_cv_path_zlib" fi if test "$no_zlib" = yes; then IRC_ZLIB_LIBRARY= IRC_ZLIB_INCLUDE= AC_MSG_RESULT(no) else AC_DEFINE([USE_ZLIB], [1], [Define if zlib package must be used for compilation/linking.]) if test "x$irc_zlib_library" = x; then irc_zlib_library_message="found by the linker" IRC_ZLIB_LIBRARY=-lz else irc_zlib_library_message="in $irc_zlib_library" IRC_ZLIB_LIBRARY=-L$irc_zlib_library if test ! "$irc_cv_solaris_2" = no; then IRC_ZLIB_LIBRARY="$IRC_ZLIB_LIBRARY -R$irc_zlib_library" fi IRC_ZLIB_LIBRARY="$IRC_ZLIB_LIBRARY -lz" fi if test "x$irc_zlib_include" = x; then irc_zlib_include_message="found by the compiler" IRC_ZLIB_INCLUDE= else irc_zlib_include_message="in $irc_zlib_include" IRC_ZLIB_INCLUDE=-I$irc_zlib_include fi AC_MSG_RESULT([]) AC_MSG_RESULT([ library $irc_zlib_library_message]) AC_MSG_RESULT([ header $irc_zlib_include_message]) fi AC_SUBST(IRC_ZLIB_INCLUDE) AC_SUBST(IRC_ZLIB_LIBRARY) ]) AC_DEFUN(IRC_UNION_WAIT, [AC_MSG_CHECKING(whether an union wait * is mandatory in waitpid) AC_CACHE_VAL(irc_cv_type_union_wait, AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #if HAVE_SYS_WAIT_H #include #endif]], [[ int status; waitpid(-1, &status, 0); ]])], [irc_cv_type_union_wait=no], [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #if HAVE_SYS_WAIT_H #include #endif]], [[ union wait status; waitpid(-1, &status, 0); ]])], irc_cv_type_union_wait=yes, irc_cv_type_union_wait=no)])) if test $irc_cv_type_union_wait = yes; then AC_MSG_RESULT(yes) AC_DEFINE([USE_UNION_WAIT], [1], [Define if the second argument of waitpid must be an "union wait *" instead of an "int *".]) else AC_MSG_RESULT(no) fi ]) AC_DEFUN(IRC_SUN, [AC_MSG_CHECKING([for SunOS]) AC_CACHE_VAL(irc_cv_sun, [if test "x`(uname) 2>/dev/null`" = "xSunOS"; then irc_cv_sun="`uname -r`" else irc_cv_sun=no fi ]) irc_cv_solaris_2=no if test "$irc_cv_sun" = no; then AC_MSG_RESULT(no) else if uname -r 2>/dev/null | grep "^5" >/dev/null; then irc_cv_solaris_2="`uname -r | sed -e \"s/^5/2/g\"`" AC_MSG_RESULT([yes, Solaris $irc_cv_solaris_2]) AC_DEFINE([SOLARIS_2], [1], [Define if the operating system is Solaris 2.x (SunOS 5.x).]) if echo "$irc_cv_solaris_2" | egrep "^2\.(0|1|2)$" >/dev/null; then AC_DEFINE([SOLARIS_2_0_2_1_2_2], [1], [Define if the operating system is Solaris 2.[0-2] (SunOS 5.[0-2]).]) elif echo "$irc_cv_solaris_2" | grep "^2\.3" >/dev/null; then AC_DEFINE([SOLARIS_2_3], [1], [Define if the operating system is Solaris 2.3 (SunOS 5.3).]) fi else AC_MSG_RESULT([yes, SunOS $irc_cv_sun]) fi fi ]) AC_DEFUN(IRC_DECL_SYS_ERRLIST, [AC_CACHE_CHECK([for sys_errlist declaration in stdio.h, errno.h or sys/errno.h], irc_cv_decl_sys_errlist, [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if HAVE_SYS_TYPES_H #include #endif #if HAVE_STDIO_H #include #endif #if HAVE_ERRNO_H #include #endif #if HAVE_SYS_ERRNO_H #include #endif]], [[char *msg = sys_errlist[0];]])],[irc_cv_decl_sys_errlist=yes],[irc_cv_decl_sys_errlist=no])]) if test $irc_cv_decl_sys_errlist = yes; then AC_DEFINE([SYS_ERRLIST_DECLARED], [1], [Define if sys_errlist is declared in stdio.h or errno.h.]) elif test $ac_cv_func_strerror != yes; then AC_MSG_WARN([Neither strerror() nor sys_errlist found.]) fi ]) AC_DEFUN(IRC_DECL_SYS_NERR, [AC_CACHE_CHECK([for sys_nerr declaration in stdio.h, errno.h or sys/errno.h], irc_cv_decl_sys_nerr, [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if HAVE_SYS_TYPES_H #include #endif #if HAVE_STDIO_H #include #endif #if HAVE_ERRNO_H #include #endif #if HAVE_SYS_ERRNO_H #include #endif]], [[int num = sys_nerr;]])],[irc_cv_decl_sys_nerr=yes],[irc_cv_decl_sys_nerr=no])]) if test $irc_cv_decl_sys_nerr = yes; then AC_DEFINE([SYS_NERR_DECLARED], [1], [Define if sys_nerr is declared in stdio.h or errno.h.]) fi ]) AC_DEFUN(IRC_DECL_ERRNO, [AC_CACHE_CHECK([for errno declaration in errno.h or sys/errno.h], irc_cv_decl_errno, [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if HAVE_SYS_TYPES_H #include #endif #if HAVE_ERRNO_H #include #endif #if HAVE_SYS_ERRNO_H #include #endif]], [[int num = errno;]])],[irc_cv_decl_errno=yes],[irc_cv_decl_errno=no])]) if test $irc_cv_decl_errno = yes; then AC_DEFINE([ERRNO_DECLARED], [1], [Define if errno is declared in errno.h.]) fi ]) AC_DEFUN(IRC_DECL_H_ERRNO, [AC_CACHE_CHECK([for h_errno declaration in errno.h, sys/errno.h or netdb.h], irc_cv_decl_h_errno, [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if HAVE_SYS_TYPES_H #include #endif #if HAVE_ERRNO_H #include #endif #if HAVE_SYS_ERRNO_H #include #endif #if HAVE_NETDB_H #include #endif]], [[int num = h_errno;]])],[irc_cv_decl_h_errno=yes],[irc_cv_decl_h_errno=no])]) if test $irc_cv_decl_h_errno = yes; then AC_DEFINE([H_ERRNO_DECLARED], [1], [Define if h_errno is declared in errno.h or netdb.h.]) fi ]) AC_DEFUN(IRC_SGI_CC, [AC_MSG_CHECKING([for SGI's cc]) AC_EGREP_CPP(yes, [#ifdef sgi yes #endif], if test x$CC = xcc; then AC_MSG_RESULT(yes) CC="$CC -cckr" else AC_MSG_RESULT(no) fi, AC_MSG_RESULT(no)) ]) AC_DEFUN(IRC_HPUX_CC, [AC_MSG_CHECKING([for HPUX's cc]) AC_EGREP_CPP(yes, [#ifdef hpux yes #endif], if test x$CC = xcc; then AC_MSG_RESULT(yes) CC="$CC -Ae" else AC_MSG_RESULT(no) fi, AC_MSG_RESULT(no)) ]) AC_DEFUN(IRC_ALPHA_BETA, [AC_MSG_CHECKING(whether this is an alpha/beta release) AC_CACHE_VAL(irc_cv_alpha_beta, [AC_EGREP_CPP(^ *\"......00, [#include "../common/patchlevel.h" #ifdef PATCHLEVEL PATCHLEVEL #else "0000000000" #endif ],irc_cv_alpha_beta=, irc_cv_alpha_beta=yes) ]) if test x$irc_cv_alpha_beta = xyes; then AC_MSG_RESULT(yes) AC_MSG_WARN([ This is a development version of the package, it is not intended to be used in a production environment. ]) else AC_MSG_RESULT(no) fi ]) AC_DEFUN(IRC_SELECT_POLL, [AC_MSG_CHECKING([whether select or poll system call will be used]) AC_CACHE_VAL(irc_cv_select_poll, [if test "$irc_cv_sun" != "no" && test "x$irc_cv_solaris_2" = "xno"; then # we don't like SunOS' poll() function irc_cv_select_poll=select else if test "$ac_cv_func_poll" = "yes"; then irc_cv_select_poll=poll else irc_cv_select_poll=select fi fi]) if test "$irc_cv_select_poll" = "poll"; then AC_MSG_RESULT(poll) AC_DEFINE([USE_POLL], [1], [Define if poll(2) must be used instead of select(2). Note: some systems (e.g. linux 2.0.x) have a non-working poll()]) else AC_MSG_RESULT(select) fi ]) AC_DEFUN(IRC_SIGNAL_IMPLEMENTATION, [AC_MSG_CHECKING([for signal implementation]) #AC_CACHE_VAL(irc_cv_signal_implementation, #[if test x$ac_cv_func_sigaction = xyes; then if test x$ac_cv_func_sigaction = xyes; then irc_cv_signal_implementation=posix_sigaction elif test x$ac_cv_func_sigset = xyes; then irc_cv_signal_implementation=bsd_sigset else AC_RUN_IFELSE([AC_LANG_SOURCE([[ #if HAVE_SYS_TYPES_H #include #endif #if HAVE_SIGNAL_H #include #endif #ifndef SIGCHLD #define SIGCHLD SIGCLD #endif int got = 0; RETSIGTYPE hand() { got++; } main() { (void)signal(SIGCHLD, hand); kill(getpid(), SIGCHLD); kill(getpid(), SIGCHLD); if (got < 2) exit(1); exit(0); } ]])],[irc_cv_signal_implementation=bsd_signal],[irc_cv_signal_implementation=sysv_signal],[]) fi #]) if test $irc_cv_signal_implementation = posix_sigaction; then AC_MSG_RESULT([using POSIX sigaction]) AC_DEFINE([POSIX_SIGNALS], [1], [Define if the system provides POSIX sigaction.]) elif test $irc_cv_signal_implementation = bsd_sigset; then AC_MSG_RESULT([using BSD sigset]) AC_DEFINE([BSD_RELIABLE_SIGNALS], [1], [Define if the system provides reliable BSD signals.]) AC_DEFINE([signal], [sigset], [Define this to sigset if the system provides reliable BSD signals through sigset instead of signal.]) elif test $irc_cv_signal_implementation = bsd_signal; then AC_MSG_RESULT([using reliable BSD signal]) AC_DEFINE([BSD_RELIABLE_SIGNALS], [1], [Define if the system provides reliable BSD signals.]) else AC_MSG_RESULT([using unreliable SystemV signal]) AC_DEFINE([SYSV_UNRELIABLE_SIGNALS], [1], [Define if the system provides unreliable SystemV signals.]) fi ]) AC_DEFUN(IRC_NON_BLOCKING_SYSTEM, [AC_MSG_CHECKING([for a working non-blocking system]) AC_CACHE_VAL(irc_cv_non_blocking_system, [ changequote(<<, >>)dnl irc_precode='#include "confdefs.h" #ifdef HAVE_SYS_TYPES_H #include #endif #if HAVE_SYS_SOCKET_H #include #endif #if HAVE_FCNTL_H #include #endif #if HAVE_SYS_IOCTL_H #include #endif #if HAVE_SYS_FILE_H #include #endif #if HAVE_SIGNAL_H #include #endif #if HAVE_NETINET_IN_H #include #endif RETSIGTYPE alarmed() { exit(1); } main() { char b[12]; struct sockaddr_in x; int f, l = sizeof(x); f = socket(AF_INET, SOCK_DGRAM, 0); if (f >= 0 && !(fcntl(f, F_SETFL, ' irc_postcode='))) { signal(SIGALRM, alarmed); alarm(3); recvfrom(f, b, 12, 0, &x, &l); alarm(0); exit(0); } exit(1); }' changequote([, ])dnl irc_code_posix="${irc_precode}O_NONBLOCK${irc_postcode}" irc_code_bsd="${irc_precode}O_NDELAY${irc_postcode}" irc_code_sysv="${irc_precode}FIONBIO${irc_postcode}" AC_RUN_IFELSE($irc_code_posix, irc_cv_non_blocking_system=posix, AC_RUN_IFELSE($irc_code_bsd, irc_cv_non_blocking_system=bsd, AC_RUN_IFELSE($irc_code_sysv, irc_cv_non_blocking_system=sysv, irc_cv_non_blocking_system=none))) ]) if test $irc_cv_non_blocking_system = posix; then AC_MSG_RESULT([using POSIX O_NONBLOCK]) AC_DEFINE([NBLOCK_POSIX], [1], [Define if the system provides POSIX non-blocking system.]) elif test $irc_cv_non_blocking_system = bsd; then AC_MSG_RESULT([using BSD O_NDELAY]) AC_DEFINE([NBLOCK_BSD], [1], [Define if the system provides BSD non-blocking system.]) elif test $irc_cv_non_blocking_system = sysv; then AC_MSG_RESULT([using SystemV FIONBIO]) AC_DEFINE([NBLOCK_SYSV], [1], [Define if the system provides SystemV non-blocking system.]) else AC_MSG_RESULT([using none]) AC_MSG_WARN([I can't find a working non-blocking system.]) fi ]) AC_DEFUN(IRC_PATH_RESCONF, [AC_MSG_CHECKING([for resolver configuration file]) AC_ARG_WITH(resconf, [ --with-resconf=FILE use FILE as resolver config file [[/etc/resolv.conf]]], irc_cv_path_resconf="$withval", irc_cv_path_resconf="/etc/resolv.conf") AC_MSG_RESULT($irc_cv_path_resconf) AC_DEFINE_UNQUOTED([IRC_RESCONF], ["$irc_cv_path_resconf"], [Define as the resolver configuration file.]) if test ! -r "$irc_cv_path_resconf"; then AC_MSG_WARN([Unable to read "$irc_cv_path_resconf"! Without resolver configuration file, the server won't work.]) fi ]) AC_DEFUN(IRC_EGREP_RMLF_CPP, [cat > conftest.$ac_ext <&AS_MESSAGE_LOG_FD() | $AWK "{if (NR > 1) printf(\" \"); printf(\[$]0)}" | changequote(, )dnl egrep "$1" >/dev/null 2>&1; then changequote([, ])dnl ifelse([$3], , :, [rm -rf conftest* $3]) ifelse([$4], , , [else rm -rf conftest* $4 ])dnl fi rm -f conftest* ]) AC_DEFUN(IRC_LINUX, [AC_MSG_CHECKING(for Linux) AC_CACHE_VAL(irc_cv_linux, [if test "x`(uname) 2>/dev/null`" = "xLinux"; then IRC_EGREP_RMLF_CPP( [struct( | )+hostent( | )+\{.*const.*h_name], [#include ], irc_cv_linux=bad, irc_cv_linux=good) else irc_cv_linux=no fi ]) if test "$irc_cv_linux" = no; then AC_MSG_RESULT(no) elif test "$irc_cv_linux" = good; then AC_MSG_RESULT([yes, with a good file]) else AC_MSG_RESULT([yes, with a bad file]) AC_DEFINE([BAD___CONST_NETDB_H], [1], [Define if contains bad __const usages (Linux).]) fi ]) AC_DEFUN(IRC_IP6, [AC_ARG_ENABLE(ip6, [ --enable-ip6 enables IPv6]) AC_ARG_ENABLE(ipv6, [ --enable-ipv6 enables IPv6]) if test "x$enableval" = xyes; then AC_DEFINE([INET6], [1], [Define to enable IPv6 support]) dnl be smart about it AC_MSG_CHECKING([IPv6 system type]) AC_CACHE_VAL(irc_cv_v6type, [ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #include #include ]], [[struct in6_addr addr]])], [irc_cv_v6type=native]) if test "x$irc_cv_v6type" = x; then if test -d /usr/inet6; then AC_EGREP_CPP(yes, [ #include "/usr/inet6/include/netinet/in.h" #ifdef _INET6APPS_NETINET_IN_H yes #endif], irc_cv_v6type=linux) fi fi if test "x$irc_cv_v6type" = x; then irc_cv_v6type=unknown fi ]) AC_MSG_RESULT($irc_cv_v6type) if test "x$irc_cv_v6type" = xunknown; then AC_MSG_WARN([[You have an unknown IPv6 system. You will probably need to change the Makefile manually, or #undef INET6 in setup.h]]) fi dnl eventually update LIBS case $irc_cv_v6type in linux) LIBS="-L/usr/inet6/lib -linet6 $LIBS" CFLAGS="$CFLAGS -I/usr/inet6/include" ;; esac dnl RFC 2553 check AC_CHECK_FUNCS(getipnodebyname) fi ]) AC_DEFUN(IRC_SHAREDMODULES, [AC_ARG_ENABLE(dsm, [ --enable-dsm enables dynamically shared modules for iauth]) if test "x$enable_dsm" != x; then AC_DEFINE([USE_DSM], [1], [Define to enable dynamically shared iauth module support.]) dnl AC_CONFIG_HEADER(dl.h) AC_CHECK_HEADERS(dlfcn.h) AC_CHECK_LIB(dl, dlclose, IRC_DLIB="-ldl") AC_SUBST(IRC_DLIB) fi ]) dnl ------------------------------------------------------------------- dnl modified Autoconf tests; their names begin with IRC_ instead of AC_ dnl ------------------------------------------------------------------- AC_DEFUN(IRC_PROG_CC, [define(AC_PROVIDE_AC_PROG_CC) AC_BEFORE([$0], [AC_PROG_CPP])dnl AC_CHECK_PROG(CC, gcc, gcc) if test -z "$CC"; then AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc) test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH]) fi ac_test_CFLAGS="${CFLAGS+set}" if test x$ac_cv_c_compiler_gnu = xyes; then GCC=yes ac_save_CFLAGS="$CFLAGS" CFLAGS= if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" else CFLAGS="-O2" fi else GCC= fi ]) AC_DEFUN(IRC_AIX, [AC_MSG_CHECKING(for AIX) AC_CACHE_VAL(irc_cv_aix, [if test "x`(uname) 2>/dev/null`" = "xAIX"; then irc_cv_aix="`uname -rv`" else irc_cv_aix=no fi ]) if test "$irc_cv_aix" = no; then AC_MSG_RESULT(no) else AC_MSG_RESULT(yes) AC_AIX if test "x$irc_cv_aix" = "x2 3"; then AC_DEFINE([AIX_3_2], [1], [Define if the operating system is AIX 3.2.]) fi if test x$CC = xcc; then CFLAGS="$CFLAGS -O3 -qstrict" fi fi ]) AC_DEFUN(IRC_FUNC_MEMCMP, [AC_CACHE_CHECK(for 8-bit clean memcmp, irc_cv_func_memcmp_clean, [AC_RUN_IFELSE([AC_LANG_SOURCE([[ main() { char c0 = 0x40, c1 = 0x80, c2 = 0x81; exit(memcmp(&c0, &c2, 1) < 0 && memcmp(&c1, &c2, 1) < 0 ? 0 : 1); } ]])],[irc_cv_func_memcmp_clean=yes],[irc_cv_func_memcmp_clean=no],[irc_cv_func_memcmp_clean=no])]) if test $irc_cv_func_memcmp_clean = no; then AC_DEFINE([MEMCMP_BROKEN], [1], [Define if memcmp is not 8-bit clean.]) fi ]) AC_DEFUN(IRC_GNUM4, [AC_MSG_CHECKING(for GNU m4) AC_CACHE_VAL(irc_cv_gnum4, [if test "`(echo __"gnu"__ | $M4_PATH) 2>/dev/null`" = "__"gnu"__"; then irc_cv_gnum4=no else irc_cv_gnum4=yes fi ]) if test $irc_cv_gnum4 = yes; then AC_MSG_RESULT(yes) AC_DEFINE([HAVE_GNU_M4], [1], [Define if you have GNU m4.]) else AC_MSG_RESULT(no) fi ]) dnl ---- dnl main dnl ---- AC_INIT([irc],[2.11],[ircd-bugs@irc.org]) AC_REVISION([$Id: configure.in,v 1.75 2008/06/24 21:44:19 chopin Exp $]) AC_PREREQ(2.59) AC_ARG_WITH(logdir, [ --with-logdir=DIR log files in DIR [[localstatedir/log]]], [ logdir=$with_logdir ],[ logdir=$localstatedir'/log' ]) AC_SUBST(logdir) AC_ARG_WITH(rundir, [ --with-rundir=DIR pid and tune files in DIR [[localstatedir/run]]], [ rundir=$with_rundir ],[ rundir=$localstatedir'/run' ]) AC_SUBST(rundir) AC_CONFIG_HEADER(setup.h:../support/setup.h.in) AC_CONFIG_AUX_DIR(../support) AC_PROG_INSTALL IRC_PROG_CC AC_PROG_CPP AC_PROG_AWK #IRC_PROG_INSTALL AC_PATH_PROGS(SUM, md5sum md5 sum cksum, true) AC_PATH_PROGS(M4_PATH, gm4 gnum4 m4, m4) IRC_GNUM4 AC_PROG_GCC_TRADITIONAL IRC_AIX AC_ISC_POSIX AC_MINIX IRC_SGI_CC IRC_HPUX_CC IRC_SUN IRC_LINUX AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(stdio.h stdlib.h sys/types.h sys/bitypes.h stddef.h stdarg.h unistd.h ctype.h memory.h errno.h sys/errno.h sys/syscall.h pwd.h math.h utmp.h fcntl.h signal.h sys/ioctl.h sys/file.h sys/filio.h sys/socket.h sys/stat.h sys/resource.h sys/select.h sys/poll.h stropts.h netdb.h netinet/in.h arpa/inet.h sys/param.h syslog.h sys/syslog.h string.h strings.h sys/time.h time.h sys/times.h netinet/in_systm.h netinfo/ni.h arpa/nameser.h) dnl See whether we can include both string.h and strings.h. AC_CACHE_CHECK([whether string.h and strings.h may both be included], ac_cv_header_string, [ AC_COMPILE_IFELSE( [#include #include ], [ac_cv_header_string=yes], [ac_cv_header_string=no]) ]) if test "$ac_cv_header_string" = "yes"; then AC_DEFINE([HAVE_STRING_WITH_STRINGS], [1], [Define to 1 if string.h may be included along with strings.h]) fi # autoconf now checks not only inclusion, but also compilation AC_CHECK_HEADERS([resolv.h], [], [], [#if HAVE_NETINET_IN_H # include #endif #if HAVE_ARPA_NAMESER_H # include #endif ]) # Some systems need (and ?) before AC_CHECK_HEADERS([sys/un.h], [], [], [#ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif ]) IRC_DECL_SYS_NERR IRC_DECL_ERRNO IRC_DECL_H_ERRNO AC_HEADER_STAT AC_HEADER_TIME AC_STRUCT_TM AC_TYPE_MODE_T AC_TYPE_OFF_T AC_TYPE_PID_T AC_TYPE_SIGNAL AC_TYPE_SIZE_T AC_TYPE_UID_T IRC_UNION_WAIT AC_CHECK_TYPES([int8_t, uint8_t, u_int8_t, int16_t, uint16_t, u_int16_t, int32_t, uint32_t, u_int32_t, u_char, u_short, u_int, u_long, socklen_t], [], [], [AC_INCLUDES_DEFAULT #if HAVE_SYS_BITYPES_H #include #endif]) AC_FUNC_ACCEPT_ARGTYPES AC_C_BIGENDIAN AC_C_CONST AC_CHECK_LIB(crypt, crypt) AC_CHECK_LIB(socket, socket) AC_CHECK_LIB(nsl, socket) IRC_MATHLIB IRC_PATH_ZLIB AC_FUNC_SETPGRP AC_FUNC_SETVBUF_REVERSED AC_FUNC_FORK AC_CHECK_FUNCS(setpgrp strchr strrchr memcmp memset memmove memcpy index rindex bcmp bcopy bzero select inet_ntoa inet_aton inet_addr inet_netof getrusage times strerror strtoken strtok sigaction sigset truncate poll vsyslog strlcpy) dnl --- dnl Note: additional tests should be performed and used inside the source code dnl for the following functions: dnl gethostname gettimeofday lrand48 mkdir socket dnl --- IRC_DECL_SYS_ERRLIST IRC_FUNC_MEMCMP IRC_SELECT_POLL IRC_SIGNAL_IMPLEMENTATION IRC_NON_BLOCKING_SYSTEM IRC_PATH_RESCONF IRC_IP6 IRC_SHAREDMODULES IRC_ALPHA_BETA AC_CONFIG_FILES([Makefile:../support/Makefile.in version.c.SH:../ircd/version.c.SH.in sums:../support/sums.in tkconf.h:../support/tkconf.h.dist]) AC_CONFIG_COMMANDS([chmod],[[chmod a+x version.c.SH]]) AC_OUTPUT irc2.11.2p3/support/mkdirhier0000755000175000017500000000206506365125052013763 0ustar kkkk#!/bin/sh # $XConsortium: mkdirhier.sh,v 1.7 94/03/24 15:46:34 gildea Exp $ # Courtesy of Paul Eggert # # $Id: mkdirhier,v 1.2 1997/07/22 12:40:10 kalt Exp $ # newline=' ' IFS=$newline case ${1--} in -*) echo >&2 "mkdirhier: usage: mkdirhier directory ..."; exit 1 esac status= for directory do case $directory in '') echo >&2 "mkdirhier: empty directory name" status=1 continue;; *"$newline"*) echo >&2 "mkdirhier: directory name contains a newline: \`\`$directory''" status=1 continue;; ///*) prefix=/;; # See Posix 2.3 "path". //*) prefix=//;; /*) prefix=/;; -*) prefix=./;; *) prefix= esac IFS=/ set x $directory case $2 in */*) # IFS parsing is broken IFS=' ' set x `echo $directory | tr / ' '` ;; esac IFS=$newline shift for filename do path=$prefix$filename prefix=$path/ shift test -d "$path" || { paths=$path for filename do if [ "$filename" != "." ]; then path=$path/$filename paths=$paths$newline$path fi done mkdir $paths || status=$? break } done done exit $status irc2.11.2p3/support/config.guess0000755000175000017500000012470210165774004014402 0ustar kkkk#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. timestamp='2004-11-12' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner . # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit build system type. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit 0 ;; amd64:OpenBSD:*:*) echo x86_64-unknown-openbsd${UNAME_RELEASE} exit 0 ;; amiga:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; cats:OpenBSD:*:*) echo arm-unknown-openbsd${UNAME_RELEASE} exit 0 ;; hp300:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; luna88k:OpenBSD:*:*) echo m88k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mac68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; macppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme88k:OpenBSD:*:*) echo m88k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvmeppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sgi:OpenBSD:*:*) echo mips64-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sun3:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit 0 ;; macppc:MirBSD:*:*) echo powerppc-unknown-mirbsd${UNAME_RELEASE} exit 0 ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit 0 ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit 0;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit 0 ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit 0 ;; *:OS/390:*:*) echo i370-ibm-openedition exit 0 ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit 0 ;; *:OS400:*:*) echo powerpc-ibm-os400 exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit 0;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit 0 ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit 0 ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7 && exit 0 ;; esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit 0 ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit 0 ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit 0 ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c \ && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ && exit 0 echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit 0 ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit 0 ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit 0 ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit 0 ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit 0 ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then # avoid double evaluation of $set_cc_for_build test -n "$CC_FOR_BUILD" || eval $set_cc_for_build if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit 0 ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit 0 ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit 0 ;; x86:Interix*:[34]*) echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' exit 0 ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit 0 ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit 0 ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit 0 ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit 0 ;; crisv32:Linux:*:*) echo crisv32-axis-linux-gnu exit 0 ;; frv:Linux:*:*) echo frv-unknown-linux-gnu exit 0 ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; mips:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips #undef mipsel #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mipsel #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 ;; mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips64 #undef mips64el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mips64el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips64 #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit 0 ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit 0 ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit 0 ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit 0 ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit 0 ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit 0 ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit 0 ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. # Set LC_ALL=C to ensure ld outputs messages in English. ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// s/ .*// p'` case "$ld_supported_targets" in elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit 0 ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit 0 ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" exit 0 ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 LIBC=gnu # else LIBC=gnulibc1 # endif # else LIBC=gnulibc1 # endif #else #ifdef __INTEL_COMPILER LIBC=gnu #else LIBC=gnuaout #endif #endif #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit 0 ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit 0 ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit 0 ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit 0 ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit 0 ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit 0 ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit 0 ;; i*86:*:5:[78]*) case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit 0 ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; paragon:*:*:*) echo i860-intel-osf1 exit 0 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit 0 ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit 0 ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4.3${OS_REL} && exit 0 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit 0 ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit 0 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit 0 ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit 0 ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit 0 ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit 0 ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit 0 ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit 0 ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit 0 ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit 0 ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit 0 ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in *86) UNAME_PROCESSOR=i686 ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit 0 ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit 0 ;; *:QNX:*:4*) echo i386-pc-qnx exit 0 ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit 0 ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit 0 ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit 0 ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit 0 ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit 0 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit 0 ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit 0 ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit 0 ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit 0 ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit 0 ;; *:ITS:*:*) echo pdp10-unknown-its exit 0 ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit 0 ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms && exit 0 ;; I*) echo ia64-dec-vms && exit 0 ;; V*) echo vax-dec-vms && exit 0 ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; c34*) echo c34-convex-bsd exit 0 ;; c38*) echo c38-convex-bsd exit 0 ;; c4*) echo c4-convex-bsd exit 0 ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: irc2.11.2p3/support/tkconf.h.dist0000644000175000017500000000214410202723017014442 0ustar kkkk/* * TkServ configuration definitions * * Make sure the ircd conf files are located in the server_bin_dir * (see Makefile) and that USE_SERVICES is #define'd if you intend * to use this service. * */ /* This will be shown on ADMIN requests */ #define TKSERV_ADMIN_NAME "Admin: Someone Somewhere" #define TKSERV_ADMIN_CONTACT "Mail: i.didnt@edit.my.ADMIN.info" /* Can be undefined */ #define TKSERV_ADMIN_OTHER "SomeAdmin@IRCnet" /* This is the name of the service which appears on /servlist */ #define TKSERV_NAME "TkServ" /* The description of the service (appears on /SERVLIST) */ #define TKSERV_DESC "Temporary K-line Service" /* The distribution of the server */ #define TKSERV_DIST "*" /* The password for the service (must match the one in the S: line) */ #define TKSERV_PASSWORD "blah" /* Debugging (displays service<->server traffic to standard output) */ #undef TKSERV_DEBUG /* The name of the ircd config file backup (suffix after CPATH) */ #define TKSERV_IRCD_CONFIG_BAK CPATH".bak" /* The name of the ircd temp config file (suffix after CPATH) */ #define TKSERV_IRCD_CONFIG_TMP CPATH".tmp" irc2.11.2p3/support/Makefile.in0000644000175000017500000004173711022346576014137 0ustar kkkk#************************************************************************ #* IRC - Internet Relay Chat, Makefile #* Copyright (C) 1990, Jarkko Oikarinen #* #* This program is free software; you can redistribute it and/or modify #* it under the terms of the GNU General Public License as published by #* the Free Software Foundation; either version 1, or (at your option) #* any later version. #* #* This program is distributed in the hope that it will be useful, #* but WITHOUT ANY WARRANTY; without even the implied warranty of #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #* GNU General Public License for more details. #* #* You should have received a copy of the GNU General Public License #* along with this program; if not, write to the Free Software #* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #* #* $Id: Makefile.in,v 1.70 2008/06/06 23:51:26 chopin Exp $ #* #*/ # ------------------------------------------------------------------------- # Start of system configuration section. # prefix = @prefix@ exec_prefix = @exec_prefix@ # compiler program CC = @CC@ # compiler flags used for the server S_CFLAGS = @CFLAGS@ -I. -I../ircd -I../common @IRC_ZLIB_INCLUDE@ # compiler flags used for the authentication slave A_CFLAGS = @CFLAGS@ -I. -I../iauth -I../common @IRC_ZLIB_INCLUDE@ # compiler flags used for chkconfig CC_CFLAGS = @CFLAGS@ -I. -I../ircd -I../common # compiler flags used for the client C_CFLAGS = @CFLAGS@ -I. -I../ircd -I../common -DCLIENT_COMPILE # compiler flags used for other things (in contrib/) O_CFLAGS = @CFLAGS@ -I. -I../common -DCONTRIB_COMPILE # linker flags LDFLAGS = @LDFLAGS@ # required libraries, except zlib LIBS = @LIBS@ MATHLIBS = @MATHLIBS@ # zlib, eventually ZLIBS = @IRC_ZLIB_LIBRARY@ # for DSM support (dlopen(), dlsym(), dlclose()) DLIBS = @IRC_DLIB@ # install and related programs INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ MKDIRHIER = ../support/mkdirhier # # Binary names # # Note: $(IRCD) is basename for config, log and var files. Make sure to # make clean after changing this one. IRCD = ircd IRCD_BIN = $(IRCD) IAUTH = iauth IRCDWATCH = ircdwatch # TK line service binary TKSERV = tkserv # # Directories definitions # # Directory in which to install ircd, iauth, ircdwatch, mkpasswd and chkconf. server_bin_dir = @sbindir@ # Directory in which to install the configuration manual page. conf_man_dir = @mandir@/man5 # Directory in which to install the server manual page. server_man_dir = @mandir@/man8 # Directory where config files (ircd.conf, ircd.motd and iauth.conf) live. ircd_conf_dir = @sysconfdir@ # Directory where state files (ircd.pid, ircd.tune) live. ircd_var_dir = @rundir@ # Directory where log files (users, opers, rejects and auth) live. ircd_log_dir = @logdir@ # # Most of these PATHs are hardcoded in the binaries. # They should all be absolute. # # Path to server binary IRCD_PATH = $(server_bin_dir)/$(IRCD_BIN) # Path to authentication slave binary IAUTH_PATH = $(server_bin_dir)/$(IAUTH) # Path to the m4 configuration file IRCDM4_PATH = $(ircd_conf_dir)/$(IRCD).m4 # Path to the m4 executable M4_PATH = @M4_PATH@ # server configuration file IRCDCONF_PATH = $(ircd_conf_dir)/$(IRCD).conf # server configuration file (only for writing klines to) KLINE_PATH = $(ircd_conf_dir)/$(IRCD).kline # server Message Of The Day IRCDMOTD_PATH = $(ircd_conf_dir)/$(IRCD).motd # authentication slave configuration file IAUTHCONF_PATH = $(ircd_conf_dir)/$(IAUTH).conf # server PID file IRCDPID_PATH = $(ircd_var_dir)/$(IRCD).pid # authentication slave PID file IAUTHPID_PATH = $(ircd_var_dir)/$(IAUTH).pid # server state file IRCDTUNE_PATH = $(ircd_var_dir)/$(IRCD).tune # ircdwatch PID file IRCDWATCHPID_PATH = $(ircd_var_dir)/$(IRCDWATCH).pid # Define these filenames to maintain a list of persons who log # into this server. Logging will stop when the file does not exist. # Logging will be disabled also if you do not define this. FNAME_USERLOG = $(ircd_log_dir)/$(IRCD).users FNAME_OPERLOG = $(ircd_log_dir)/$(IRCD).opers FNAME_CONNLOG = $(ircd_log_dir)/$(IRCD).rejects FNAME_AUTHLOG = $(ircd_log_dir)/$(IRCD).auth # If defined in config.h, server channels will be logged at this # location with name of server channel (without '&') appended to # this prefix. FNAME_SCH_PREFIX = $(ircd_log_dir)/$(IRCD) # files used for debugging purposes IRCDDBG_PATH = $(ircd_log_dir)/$(IRCD).debug IAUTHDBG_PATH = $(ircd_log_dir)/$(IAUTH).debug # Access mode for irc. irc_mode = 755 # Access mode for ircd. ircd_mode = 711 # # TK line service configuration # # TK line service logfile TKSERV_LOGFILE = $(ircd_log_dir)/$(TKSERV).log # TK line service access file TKSERV_ACCESSFILE = $(ircd_conf_dir)/$(TKSERV).access # TK config file to append tklines to. # It could be $(IRCDCONF_PATH), but is not recommended. TKSERV_CONF_PATH = $(ircd_conf_dir)/$(TKSERV).kline # End of system configuration section. # ------------------------------------------------------------------------ # Please don't change anything below this point - no need really - I hope. RM = rm -f CLIENT_COMMON_OBJS = clbsd.o cldbuf.o clpacket.o clsend.o clmatch.o \ clparse.o clsupport.o IRCD_COMMON_OBJS = bsd.o dbuf.o packet.o send.o match.o parse.o \ support.o IRCD_OBJS = channel.o class.o hash.o ircd.o list.o res.o s_auth.o \ s_bsd.o s_conf.o s_debug.o s_err.o s_id.o s_misc.o s_numeric.o \ s_send.o s_serv.o s_service.o s_user.o s_zip.o whowas.o \ res_init.o res_comp.o res_mkquery.o patricia.o IAUTH_COMMON_OBJS = clsupport.o clmatch.o # This is a little evil IAUTH_OBJS = iauth.o a_conf.o a_io.o a_log.o \ mod_lhex.o mod_pipe.o mod_rfc931.o mod_socks.o mod_webproxy.o CHKCONF_COMMON_OBJS = match.o CHKCONF_OBJS = chkconf.o CHKCONF = chkconf help: @echo "Choose one of the following:" @echo " all : build everything" @echo " server : build server programs" @echo " $(IRCD_BIN) : build the irc daemon" @echo " $(IAUTH) : build the authentication slave" @echo " chkconf : build the configuration file checker" @echo " ircd-mkpasswd : build ircd-mkpasswd" @echo " $(IRCDWATCH) : build ircdwatch" @echo " $(TKSERV) : build tkserv" @echo @echo " install : build and install server programs" @echo " install-server : build and install server programs" @echo " install-tkserv : build and install tkserv" all: server server: $(IRCD_BIN) $(IAUTH) $(CHKCONF) ircd-mkpasswd $(IRCDWATCH) $(IRCD_BIN): $(IRCD_COMMON_OBJS) $(IRCD_OBJS) $(RM) $@ ./version.c.SH $(CC) $(S_CFLAGS) -c -o version.o version.c $(CC) $(LDFLAGS) -o $@ $(IRCD_COMMON_OBJS) version.o $(IRCD_OBJS) $(ZLIBS) $(MATHLIBS) $(LIBS) $(IAUTH): $(IAUTH_COMMON_OBJS) $(IAUTH_OBJS) $(RM) $@ $(CC) $(LDFLAGS) -o $@ $(IAUTH_COMMON_OBJS) $(IAUTH_OBJS) $(LIBS) $(DLIBS) $(CHKCONF): $(CHKCONF_COMMON_OBJS) $(CHKCONF_OBJS) $(RM) $@ $(CC) $(LDFLAGS) -o $@ $(CHKCONF_COMMON_OBJS) $(CHKCONF_OBJS) $(LIBS) # stuff in contrib/ $(IRCDWATCH): ircdwatch.o clsupport.o clmatch.o $(RM) $(IRCDWATCH) $(CC) $(LDFLAGS) -o $(IRCDWATCH) clsupport.o clmatch.o ircdwatch.o $(LIBS) ircd-mkpasswd: mkpasswd.o $(RM) ircd-mkpasswd $(CC) $(LDFLAGS) -o ircd-mkpasswd mkpasswd.o $(LIBS) $(TKSERV): tkserv.o $(RM) $(TKSERV) $(CC) $(LDFLAGS) -o $(TKSERV) tkserv.o $(LIBS) install: install-server install-ircd: $(IRCD_BIN) -@if [ ! -d $(server_bin_dir) ]; then \ $(MKDIRHIER) $(server_bin_dir); \ fi $(INSTALL_PROGRAM) -m $(ircd_mode) $(IRCD_BIN) $(server_bin_dir) install-server: install-ircd server -@if [ ! -d $(server_man_dir) ]; then \ $(MKDIRHIER) $(server_man_dir); \ fi -@if [ ! -d $(conf_man_dir) ]; then \ $(MKDIRHIER) $(conf_man_dir); \ fi -@if [ ! -d $(ircd_conf_dir) ]; then \ $(MKDIRHIER) $(ircd_conf_dir); \ fi -@if [ ! -d $(ircd_var_dir) ]; then \ $(MKDIRHIER) $(ircd_var_dir); \ fi -@if [ ! -d $(ircd_log_dir) ]; then \ $(MKDIRHIER) $(ircd_log_dir); \ fi $(INSTALL_PROGRAM) -m $(ircd_mode) $(IAUTH) $(server_bin_dir) $(INSTALL_PROGRAM) -m $(ircd_mode) $(CHKCONF) $(server_bin_dir) $(INSTALL_PROGRAM) -m $(ircd_mode) ircd-mkpasswd $(server_bin_dir) $(INSTALL_PROGRAM) -m $(ircd_mode) $(IRCDWATCH) $(server_bin_dir) $(RM) $(IRCDM4_PATH) ../ircd/buildm4 $(IRCDM4_PATH) $(INSTALL_DATA) ../doc/ircd.8 $(server_man_dir) $(INSTALL_DATA) ../doc/iauth.8 $(server_man_dir) $(INSTALL_DATA) ../doc/iauth.conf.5 $(conf_man_dir) $(INSTALL_DATA) ../contrib/ircdwatch/ircdwatch.8 $(server_man_dir) $(INSTALL_DATA) ../doc/ircd.conf.example $(ircd_conf_dir) $(INSTALL_DATA) ../doc/iauth.conf.example $(ircd_conf_dir) -@if [ ! -f $(IAUTHCONF_PATH) ]; then \ $(INSTALL_DATA) ../doc/iauth.conf.example $(IAUTHCONF_PATH); \ fi -@if [ ! -f $(IRCDMOTD_PATH) ]; then \ $(INSTALL_DATA) ../support/ircd.motd $(IRCDMOTD_PATH); \ fi @echo "installation of server done." install-tkserv: $(TKSERV) -@if [ ! -d $(server_bin_dir) ]; then \ $(MKDIRHIER) $(server_bin_dir); \ fi -@if [ ! -d $(ircd_conf_dir) ]; then \ $(MKDIRHIER) $(ircd_conf_dir); \ fi $(INSTALL_PROGRAM) -m $(ircd_mode) $(TKSERV) $(server_bin_dir) @echo "installation of tkserv done." clbsd.o: ../common/bsd.c setup.h config.h ../common/struct_def.h $(CC) $(C_CFLAGS) -c -o $@ ../common/bsd.c cldbuf.o: ../common/dbuf.c setup.h config.h ../common/struct_def.h $(CC) $(C_CFLAGS) -c -o $@ ../common/dbuf.c clpacket.o: ../common/packet.c setup.h config.h ../common/struct_def.h $(CC) $(C_CFLAGS) -c -o $@ ../common/packet.c clsend.o: ../common/send.c setup.h config.h ../common/struct_def.h $(CC) $(C_CFLAGS) -c -o $@ ../common/send.c clmatch.o: ../common/match.c setup.h config.h ../common/struct_def.h $(CC) $(C_CFLAGS) -c -o $@ ../common/match.c clparse.o: ../common/parse.c setup.h config.h ../common/struct_def.h $(CC) $(C_CFLAGS) -c -o $@ ../common/parse.c clsupport.o: ../common/support.c setup.h config.h ../common/struct_def.h ../common/patchlevel.h $(CC) $(C_CFLAGS) -c -o $@ ../common/support.c bsd.o: ../common/bsd.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../common/bsd.c dbuf.o: ../common/dbuf.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../common/dbuf.c packet.o: ../common/packet.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../common/packet.c send.o: ../common/send.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -DFNAME_USERLOG="\"$(FNAME_USERLOG)\"" \ -DFNAME_CONNLOG="\"$(FNAME_CONNLOG)\"" \ -DFNAME_SCH_PREFIX="\"$(FNAME_SCH_PREFIX)\"" \ -c -o $@ ../common/send.c match.o: ../common/match.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../common/match.c parse.o: ../common/parse.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../common/parse.c support.o: ../common/support.c setup.h config.h ../common/struct_def.h ../common/patchlevel.h $(CC) $(S_CFLAGS) -c -o $@ ../common/support.c channel.o: ../ircd/channel.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../ircd/channel.c class.o: ../ircd/class.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../ircd/class.c hash.o: ../common/struct_def.h ../common/os.h ../ircd/hash_def.h \ ../ircd/hash_ext.h ../ircd/hash.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../ircd/hash.c ircd.o: ../ircd/ircd.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -DIRCDCONF_PATH="\"$(IRCDCONF_PATH)\"" \ -DIRCDTUNE_PATH="\"$(IRCDTUNE_PATH)\"" \ -DIRCDMOTD_PATH="\"$(IRCDMOTD_PATH)\"" \ -DIRCD_PATH="\"$(IRCD_PATH)\"" -DIAUTH_PATH="\"$(IAUTH_PATH)\"" \ -DIAUTH="\"$(IAUTH)\"" -DIRCDDBG_PATH="\"$(IRCDDBG_PATH)\"" \ -c -o $@ ../ircd/ircd.c list.o: ../ircd/list.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../ircd/list.c patricia.o: ../ircd/patricia.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../ircd/patricia.c res.o: ../ircd/res.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../ircd/res.c s_auth.o: ../ircd/s_auth.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../ircd/s_auth.c s_bsd.o: ../ircd/s_bsd.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -DIRCDPID_PATH="\"$(IRCDPID_PATH)\"" -DIAUTH_PATH="\"$(IAUTH_PATH)\"" -DIAUTH="\"$(IAUTH)\"" -c -o $@ ../ircd/s_bsd.c s_conf.o: ../ircd/s_conf.c setup.h config.h ../common/struct_def.h ../ircd/config_read.c $(CC) $(S_CFLAGS) -DIRCDMOTD_PATH="\"$(IRCDMOTD_PATH)\"" \ -DIRCDM4_PATH="\"$(IRCDM4_PATH)\"" -DIRCDCONF_PATH="\"$(IRCDCONF_PATH)\"" \ -DKLINE_PATH="\"$(KLINE_PATH)\"" \ -DIRCDCONF_DIR="\"$(ircd_conf_dir)/\"" \ -DM4_PATH="\"$(M4_PATH)\"" -c -o $@ ../ircd/s_conf.c s_debug.o: ../ircd/s_debug.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../ircd/s_debug.c s_err.o: ../ircd/s_err.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../ircd/s_err.c s_id.o: ../ircd/s_id.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../ircd/s_id.c s_misc.o: ../ircd/s_misc.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -DFNAME_USERLOG="\"$(FNAME_USERLOG)\"" -DFNAME_CONNLOG="\"$(FNAME_CONNLOG)\"" -c -o $@ ../ircd/s_misc.c s_numeric.o: ../ircd/s_numeric.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../ircd/s_numeric.c s_serv.o: ../ircd/s_serv.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -DIRCDMOTD_PATH="\"$(IRCDMOTD_PATH)\"" -c -o $@ ../ircd/s_serv.c s_send.o: ../ircd/s_send.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../ircd/s_send.c s_service.o: ../ircd/s_service.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../ircd/s_service.c s_user.o: ../ircd/s_user.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -DFNAME_USERLOG="\"$(FNAME_USERLOG)\"" -DFNAME_CONNLOG="\"$(FNAME_CONNLOG)\"" -DFNAME_OPERLOG="\"$(FNAME_OPERLOG)\"" -c -o $@ ../ircd/s_user.c s_zip.o: ../ircd/s_zip.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../ircd/s_zip.c whowas.o: ../ircd/whowas.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../ircd/whowas.c res_init.o: ../ircd/res_init.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../ircd/res_init.c res_comp.o: ../ircd/res_comp.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../ircd/res_comp.c res_mkquery.o: ../ircd/res_mkquery.c setup.h config.h ../common/struct_def.h $(CC) $(S_CFLAGS) -c -o $@ ../ircd/res_mkquery.c iauth.o: ../iauth/iauth.c config.h ../common/struct_def.h setup.h $(CC) $(A_CFLAGS) -DIAUTHPID_PATH="\"$(IAUTHPID_PATH)\"" -c -o $@ ../iauth/iauth.c a_conf.o: ../iauth/a_conf.c config.h ../common/struct_def.h setup.h $(CC) $(A_CFLAGS) -DIAUTHCONF_PATH="\"$(IAUTHCONF_PATH)\"" -c -o $@ ../iauth/a_conf.c a_dyn.o: ../iauth/a_dyn.c config.h ../common/struct_def.h setup.h $(CC) $(A_CFLAGS) -c -o $@ ../iauth/a_dyn.c a_io.o: ../iauth/a_io.c config.h ../common/struct_def.h setup.h $(CC) $(A_CFLAGS) -c -o $@ ../iauth/a_io.c a_log.o: ../iauth/a_log.c config.h ../common/struct_def.h setup.h $(CC) $(A_CFLAGS) -DIAUTHDBG_PATH="\"$(IAUTHDBG_PATH)\"" -DFNAME_AUTHLOG="\"$(FNAME_AUTHLOG)\"" -c -o $@ ../iauth/a_log.c mod_lhex.o: ../iauth/mod_lhex.c config.h ../common/struct_def.h setup.h $(CC) $(A_CFLAGS) -c -o $@ ../iauth/mod_lhex.c mod_pipe.o: ../iauth/mod_pipe.c config.h ../common/struct_def.h setup.h $(CC) $(A_CFLAGS) -c -o $@ ../iauth/mod_pipe.c mod_rfc931.o: ../iauth/mod_rfc931.c config.h ../common/struct_def.h setup.h $(CC) $(A_CFLAGS) -c -o $@ ../iauth/mod_rfc931.c mod_socks.o: ../iauth/mod_socks.c config.h ../common/struct_def.h setup.h $(CC) $(A_CFLAGS) -c -o $@ ../iauth/mod_socks.c mod_webproxy.o: ../iauth/mod_webproxy.c config.h ../common/struct_def.h setup.h $(CC) $(A_CFLAGS) -c -o $@ ../iauth/mod_webproxy.c chkconf.o: ../ircd/chkconf.c setup.h config.h ../common/struct_def.h ../ircd/config_read.c $(CC) $(CC_CFLAGS) -DCHKCONF_COMPILE -DIRCDCONF_PATH="\"$(IRCDCONF_PATH)\"" \ -DIRCDCONF_DIR="\"$(ircd_conf_dir)/\"" \ -DM4_PATH="\"$(M4_PATH)\"" -DIRCDM4_PATH="\"$(IRCDM4_PATH)\"" -c -o $@ ../ircd/chkconf.c # stuff in contrib/ ircdwatch.o: ../contrib/ircdwatch/ircdwatch.c $(CC) $(O_CFLAGS) -DIRCDWATCH_PID_FILENAME="\"$(IRCDWATCHPID_PATH)\"" -DIRCD_PATH="\"$(IRCD_PATH)\"" -DIRCDCONF_PATH="\"$(IRCDCONF_PATH)\"" -DIRCDPID_PATH="\"$(IRCDPID_PATH)\"" -c -o $@ ../contrib/ircdwatch/ircdwatch.c mkpasswd.o: ../contrib/mkpasswd/mkpasswd.c $(CC) $(O_CFLAGS) -c -o $@ ../contrib/mkpasswd/mkpasswd.c tkserv.o: ../contrib/tkserv/tkserv.c tkconf.h $(CC) $(O_CFLAGS) -DTKSERV_LOGFILE="\"$(TKSERV_LOGFILE)\"" -DTKSERV_ACCESSFILE="\"$(TKSERV_ACCESSFILE)\"" -DCPATH="\"$(TKSERV_CONF_PATH)\"" -DPPATH="\"$(IRCDPID_PATH)\"" -c -o $@ ../contrib/tkserv/tkserv.c clean: $(RM) $(IRCD_BIN) $(IAUTH) $(CHKCONF) ircd-mkpasswd $(IRCDWATCH) $(TKSERV) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut "#"* version.c distclean: @echo "To make distclean, just delete the current directory." rcs: (cd ..; cii -H -R configure common doc include irc ircd support) irc2.11.2p3/support/ircd.motd0000644000175000017500000000037610131004726013656 0ustar kkkk .===============================================. : Being a fresh installation of an irc server, : : I have this default MOTD. Remind my admin to : : fix this and reread INSTALL file, please. :) : `==============================================' irc2.11.2p3/iauth/0000755000175000017500000000000012374741151011453 5ustar kkkkirc2.11.2p3/iauth/a_conf.c0000644000175000017500000003433510145435132013045 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/a_conf.c * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: a_conf.c,v 1.39 2004/11/13 16:46:18 chopin Exp $"; #endif #include "os.h" #include "a_defines.h" #define A_CONF_C #include "a_externs.h" #undef A_CONF_C static aModule *Mlist[16]; #define DEFAULT_TIMEOUT 30 u_int debuglevel = 0; AnInstance *instances = NULL; static void conf_err(u_int nb, char *msg, char *chk) { if (chk) fprintf(stderr, "configuration error line %d: %s\n", nb, msg); else sendto_log(ALOG_IRCD|ALOG_DCONF, LOG_ERR, "Configuration error line %d: %s", nb, msg); exit(1); } /* * Match address by #IP bitmask (10.11.12.128/27) */ static int match_ipmask(aTarget *mask, char *ipaddr) { #ifdef INET6 return 1; #else int i1, i2, i3, i4; u_long iptested; if (sscanf(ipaddr, "%d.%d.%d.%d", &i1, &i2, &i3, &i4) != 4) return -1; iptested = htonl(i1 * 0x1000000 + i2 * 0x10000 + i3 * 0x100 + i4); return ((iptested & mask->lmask) == mask->baseip) ? 0 : 1; #endif } /* conf_read: read the configuration file, instanciate modules */ char *conf_read(char *cfile) { AnInstance *ident = NULL; /* make sure this module is used */ u_char needh = 0; /* do we need hostname information for any host? */ u_char o_req = 0, o_dto = 0, o_wup = 0, o_del = 0; static char o_all[5]; u_int timeout = DEFAULT_TIMEOUT, totto = 0; u_int lnnb = 0, i; u_char icount = 0, Mcnt = 0; char buffer[160], *ch; AnInstance **last = &instances, *itmp; FILE *cfh; Mlist[Mcnt++] = &Module_rfc931; Mlist[Mcnt++] = &Module_socks; Mlist[Mcnt++] = &Module_pipe; Mlist[Mcnt++] = &Module_lhex; Mlist[Mcnt++] = &Module_webproxy; Mlist[Mcnt] = NULL; cfh = fopen((cfile) ? cfile : IAUTHCONF_PATH, "r"); if (!cfh) { if (cfile) { perror("Couldn't open config file"); exit(0); } } else { while (fgets(buffer, 160, cfh)) { if ((ch = index(buffer, '\n'))) { lnnb += 1; } else { conf_err(lnnb, "line too long, ignoring.", cfile); /* now skip what's left */ while (fgets(buffer, 160, cfh)) { if (index(buffer, '\n')) { break; } } continue; } if (buffer[0] == '#' || buffer[0] == '\n') continue; *ch = '\0'; if ((ch = index(buffer, '#'))) { *ch = '\0'; } if (!strncmp("required", buffer, 8)) { o_req = 1; continue; } if (!strncmp("notimeout", buffer, 9)) { o_dto = 1; continue; } if (!strncmp("extinfo", buffer, 7)) { o_wup = 1; continue; } if (!strncmp("delayed", buffer, 7)) { o_del = 1; continue; } if (!strncmp("timeout = ", buffer, 10)) { if (sscanf(buffer, "timeout = %u", &timeout) != 1) conf_err(lnnb, "Invalid setting.", cfile); continue; } /* debugmode setting */ if (!strncmp("debuglvl = 0x", buffer, 13)) { if (sscanf(buffer, "debuglvl = %x", &debuglevel) != 1) conf_err(lnnb, "Invalid setting.", cfile); else if (!cfile) sendto_log(ALOG_DCONF, LOG_DEBUG, "debuglevel = %X", debuglevel); continue; } #if defined(USE_DSM) if (!strncmp("shared ", buffer, 7)) { char lfname[80]; void *mod_handle; aModule *(*load_func)(); ch = index(buffer+7, ' '); if (ch == NULL) { conf_err(lnnb, "Syntax error.", cfile); continue; } *ch++ = '\0'; # if defined(RTLD_NOW) mod_handle = dlopen(ch, RTLD_NOW); # else mod_handle = dlopen(ch, RTLD_LAZY); # endif if (mod_handle == NULL) { conf_err(lnnb, dlerror(), cfile); continue; } # if defined(DLSYM_NEEDS_UNDERSCORE) sprintf(lfname, "_%s_load", buffer+7); # else sprintf(lfname, "%s_load", buffer+7); # endif load_func = (aModule *(*)())dlsym(mod_handle, lfname); if (load_func == NULL) { conf_err(lnnb,"Invalid shared object.", cfile); dlclose(mod_handle); continue; } Mlist[Mcnt] = load_func(); if (Mlist[Mcnt]) { Mcnt += 1; Mlist[Mcnt] = NULL; } else { conf_err(lnnb, "Failed.", cfile); dlclose(mod_handle); } continue; } #endif if (!strncmp("exit", buffer, 4)) { break; } if (buffer[0] == '\t') { conf_err(lnnb, "Ignoring unexpected property.", cfile); continue; } /* at this point, it has to be the following */ if (strncasecmp("module ", buffer, 7)) { conf_err(lnnb, "Unexpected line: not a module.", cfile); continue; } for (i = 0; Mlist[i] != NULL; i++) if (!strcasecmp(buffer+7, Mlist[i]->name)) break; if (Mlist[i] == NULL) { conf_err(lnnb, "Unknown module name.", cfile); continue; } if (Mlist[i] == &Module_rfc931 && ident) { conf_err(lnnb, "This module can only be loaded once.", cfile); continue; } *last = (AnInstance *) malloc(sizeof(AnInstance)); (*last)->nexti = NULL; (*last)->in = icount++; (*last)->mod = Mlist[i]; (*last)->opt = NULL; (*last)->popt = NULL; (*last)->data = NULL; (*last)->hostname = NULL; (*last)->address = NULL; (*last)->timeout = timeout; (*last)->reason = NULL; (*last)->delayed = o_del; (*last)->port = 0; if (Mlist[i] == &Module_rfc931) ident = *last; while (fgets(buffer, 160, cfh)) { aTarget **ttmp; u_long baseip = 0, lmask = 0; int inverse = 0; if ((ch = index(buffer, '\n'))) { lnnb += 1; } else { conf_err(lnnb, "line too long, ignoring.", cfile); /* now skip what's left */ while (fgets(buffer, 160, cfh)) if (index(buffer,'\n')) break; continue; } if (buffer[0] == '#') continue; if (buffer[0] == '\n') break; if (buffer[0] != '\t') { conf_err(lnnb, "Invalid syntax.", cfile); continue; } *ch = '\0'; if (!strncasecmp(buffer+1, "option = ", 9)) { if ((*last)->opt) conf_err(lnnb, "Duplicate option keyword: ignored.", cfile); else (*last)->opt = mystrdup(buffer + 10); continue; } if (!strncasecmp(buffer+1, "reason = ", 9)) { if ((*last)->reason) conf_err(lnnb, "Duplicate reason keyword: ignored.", cfile); else (*last)->reason = mystrdup(buffer + 10); continue; } if (!strncasecmp(buffer+1, "host = ", 7)) { needh = 1; ttmp = &((*last)->hostname); ch = buffer + 8; if (*ch == '!') { inverse = 1; ch++; } } else if (!strncasecmp(buffer+1, "ip = ", 5)) { ttmp = &((*last)->address); ch = buffer + 6; if (*ch == '!') { inverse = 1; ch++; } if (strchr(ch, '/')) { int i1, i2, i3, i4, m; if (sscanf(ch,"%d.%d.%d.%d/%d", &i1, &i2, &i3, &i4, &m) != 5 || m < 1 || m > 31) { conf_err(lnnb, "Bad mask.", cfile); continue; } lmask = htonl((u_long)0xffffffffL << (32 - m)); baseip = htonl(i1 * 0x1000000 + i2 * 0x10000 + i3 * 0x100 + i4); } else { lmask = 0; baseip = 0; } } else if (!strncmp(buffer+1, "timeout = ", 10)) { u_int local_timeout; if (sscanf(buffer+1, "timeout = %u", &local_timeout) != 1) conf_err(lnnb, "Invalid setting.", cfile); (*last)->timeout = local_timeout; continue; } else if (!strncmp(buffer+1, "port = ", 7)) { u_int local_port; if (sscanf(buffer+1, "port = %u", &local_port) != 1) conf_err(lnnb, "Invalid setting.", cfile); (*last)->port = local_port; continue; } else { conf_err(lnnb, "Invalid keyword.", cfile); continue; } if (Mlist[i] == &Module_rfc931) continue; while (*ttmp) ttmp = &((*ttmp)->nextt); *ttmp = (aTarget *) malloc(sizeof(aTarget)); (*ttmp)->yes = inverse ? -1 : 0; (*ttmp)->value = mystrdup(ch); if ((*ttmp)->baseip) { (*ttmp)->lmask = lmask; (*ttmp)->baseip = baseip; } (*ttmp)->nextt = NULL; } if ((*last)->port == 0 && (Mlist[i] == &Module_webproxy || Mlist[i] == &Module_socks)) { conf_err(lnnb, "port here is mandatory.", cfile); } last = &((*last)->nexti); } fclose(cfh); } if (ident == NULL) { ident = *last = (AnInstance *) malloc(sizeof(AnInstance)); (*last)->nexti = NULL; (*last)->opt = NULL; (*last)->mod = &Module_rfc931; (*last)->hostname = NULL; (*last)->address = NULL; (*last)->timeout = DEFAULT_TIMEOUT; (*last)->in = icount; (*last)->popt = NULL; (*last)->address = NULL; (*last)->delayed = o_del; (*last)->port = 0; } if (ident->timeout < DEFAULT_TIMEOUT) { if (cfile) { printf("Warning: rfc913 is less than %d.\n", DEFAULT_TIMEOUT); } else { sendto_log(ALOG_IRCD|ALOG_DCONF, LOG_ERR, "Warning: rfc913 is less than %d.", DEFAULT_TIMEOUT); } } if (ident->delayed) { if (cfile) { printf("Warning: rfc913 should not be delayed.\n"); } else { sendto_log(ALOG_IRCD|ALOG_DCONF, LOG_ERR, "Warning: rfc913 should not be delayed."); } } itmp = instances; while (itmp) { if (!itmp->delayed) totto += itmp->timeout; itmp = itmp->nexti; } if (totto > ACCEPTTIMEOUT) { if (cfile) { printf("Warning: sum of timeouts exceeds " "ACCEPTTIMEOUT!\n"); } else { sendto_log(ALOG_IRCD|ALOG_DCONF, LOG_ERR, "Warning: sum of timeouts exceeds " "ACCEPTTIMEOUT!"); } if (o_dto) { if (cfile) { printf("Error: \"notimeout\" is set!\n"); } else { sendto_log(ALOG_IRCD|ALOG_DCONF, LOG_ERR, "Error: \"notimeout\" is set!"); } } } itmp = instances; if (cfile) { aTarget *ttmp; char *err; printf("\nModule(s) loaded:\n"); while (itmp) { printf("\t%s\t%s\n", itmp->mod->name, (itmp->opt) ? itmp->opt : ""); if ((ttmp = itmp->hostname)) { printf("\t\tHost = %s%s", (ttmp->yes == 0) ? "" : "!", ttmp->value); while ((ttmp = ttmp->nextt)) printf(",%s%s", (ttmp->yes == 0) ? "" : "!", ttmp->value); printf("\n"); } if ((ttmp = itmp->address)) { printf("\t\tIP = %s%s", ((ttmp->yes == 0) ? "" : "!"), ttmp->value); while ((ttmp = ttmp->nextt)) { printf(",%s%s", ((ttmp->yes == 0) ? "" : "!"), ttmp->value); } printf("\n"); } if (itmp->timeout != DEFAULT_TIMEOUT) printf("\t\ttimeout: %u seconds\n", itmp->timeout); if (itmp->port != 0) printf("\t\tport: %u\n", itmp->port); if (itmp->mod->init) { err = itmp->mod->init(itmp); printf("\t\tInitialization: %s\n", (err) ? err : "Successful"); } itmp = itmp->nexti; } } else { while (itmp) { if (itmp->mod->init) { itmp->mod->init(itmp); } itmp = itmp->nexti; } } ch = o_all; if (o_req) *ch++ = 'R'; if (o_dto) *ch++ = 'T'; if (o_wup) *ch++ = 'A'; if (needh) *ch++ = 'W'; *ch++ = '\0'; return o_all; } /* conf_match: check if an instance is to be applied to a connection Returns -1: no match, and never will 0: got a match, doIt[tm] 1: no match, but might be later so ask again */ int conf_match(u_int cl, AnInstance *inst) { aTarget *ttmp; /* general case, always matches */ if (inst->address == NULL && inst->hostname == NULL) return 0; /* feature case, "host = *" to force to wait for DNS info */ if ((cldata[cl].state & A_NOH) && inst->hostname && !strcmp(inst->hostname->value, "*")) return 0; /* check matches on IP addresses */ if ((ttmp = inst->address)) { while (ttmp) { if (ttmp->baseip) { if (match_ipmask(ttmp, cldata[cl].itsip) == 0) { return ttmp->yes; } } else { if (match(ttmp->value, cldata[cl].itsip) == 0) { return ttmp->yes; } } ttmp = ttmp->nextt; } } /* check matches on hostnames */ if ((ttmp = inst->hostname)) { if (cldata[cl].state & A_GOTH) { while (ttmp) { if (match(ttmp->value, cldata[cl].host) == 0) return ttmp->yes; ttmp = ttmp->nextt; } /* no match, will never match */ return -1; } else if (cldata[cl].state & A_NOH) return -1; else /* may be later, once we have DNS information */ return 1; } /* fall through, no match, will never match */ return -1; } /* conf_ircd: send the configuration to the ircd daemon */ void conf_ircd(void) { AnInstance *itmp = instances; aTarget *ttmp; sendto_ircd("a"); while (itmp) { if (itmp->address == NULL && itmp->hostname == NULL) sendto_ircd("A * %s %s", itmp->mod->name, (itmp->popt) ? itmp->popt : ""); else { ttmp = itmp->address; while (ttmp) { sendto_ircd("A %s %s %s", ttmp->value, itmp->mod->name, (itmp->popt) ? itmp->popt : ""); ttmp = ttmp->nextt; } ttmp = itmp->hostname; while (ttmp) { sendto_ircd("A %s %s %s", ttmp->value, itmp->mod->name, (itmp->popt) ? itmp->popt : ""); ttmp = ttmp->nextt; } } itmp = itmp->nexti; } } irc2.11.2p3/iauth/a_externs.h0000644000175000017500000000233710124044476013616 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/a_externs.h * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file includes all *_ext.h files containing external declarations * for the authentication process. */ #include "match_ext.h" #include "support_ext.h" #include "a_conf_ext.h" #include "a_io_ext.h" #include "a_log_ext.h" #include "mod_rfc931_ext.h" #include "mod_socks_ext.h" #include "mod_pipe_ext.h" #include "mod_lhex_ext.h" #include "mod_webproxy_ext.h" irc2.11.2p3/iauth/mod_socks_ext.h0000644000175000017500000000214306561743402014467 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/mod_socks_ext.h * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in iauth/mod_socks.c. */ /* External definitions for global variables. */ #ifndef MOD_SOCKS_C extern aModule Module_socks; #endif /* MOD_SOCKS_C */ irc2.11.2p3/iauth/a_struct_def.h0000644000175000017500000000556010124125535014265 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/a_struct_def.h * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ typedef struct AuthData anAuthData; #define INBUFSIZE 4096 /* I/O buffer size */ #define MAXI 16 /* maximum number of instances */ #define BDSIZE ((MAXI + 7) / 8) /* bit data size */ struct AuthData { /* the following are set by a_io.c and may be read by modules */ char user[USERLEN+1]; /* username */ char passwd[PASSWDLEN+1]; /* password */ char host[HOSTLEN+1]; /* hostname */ char itsip[HOSTLEN+1]; /* client ip */ u_short itsport; /* client port */ char ourip[HOSTLEN+1]; /* our ip */ u_short ourport; /* our port */ u_int state; /* state (general) */ /* the following are set by modules */ char *authuser; /* authenticated username */ u_char authfrom; /* where we got authuser from */ /* the following are for use by a_io.c only */ char idone[BDSIZE]; /* keeping track of instances' work */ u_char ileft; /* time saver, anything left? */ /* the following are shared by a_io.c & modules */ char *inbuffer; /* input buffer */ u_int buflen; /* length of data in buffer */ int rfd, wfd; /* fd's */ AnInstance *instance; /* the module instanciation working */ u_int mod_status; /* used by the module only! */ time_t timeout; /* timeout */ }; #define A_ACTIVE 0x0001 /* entry is active */ #define A_START 0x0002 /* go through modules from beginning */ #define A_DONE 0x0004 /* nothing left to be done */ #define A_IGNORE 0x0010 /* ignore subsequent messages from ircd */ #define A_LATE 0x0080 /* ircd is no longer waiting for a reply */ #define A_GOTU 0x0100 /* got username (from ircd) */ #define A_GOTP 0x0200 /* got password (from ircd) */ #define A_GOTH 0x0400 /* got hostname (from ircd) */ #define A_NOH 0x0800 /* no hostname available */ #define A_UNIX 0x1000 /* authuser is suitable for use by ircd */ #define A_DELAYEDSENT 0x2000 /* client already has been let in to ircd */ #define A_DENY 0x8000 /* connection should be denied access */ #define SetBit(v,n) v[n/8] |= (1 << (n % 8)) #define UnsetBit(v,n) v[n/8] &= ~(1 << (n % 8)) #define CheckBit(v,n) (v[n/8] & (1 << (n % 8))) irc2.11.2p3/iauth/mod_lhex.c0000644000175000017500000001757110127336165013430 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/mod_lhex.c * Copyright (C) 1998-1999 Christophe Kalt and Andrew Snare * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id mod_lhex.c,v 1.12 1999/02/06 21:43:52 kalt Exp $"; #endif #include "os.h" #include "a_defines.h" #define MOD_LHEX_C #include "a_externs.h" #undef MOD_LHEX_C /****************************** PRIVATE *************************************/ #define LHEXPORT 9674 struct lhex_private { /* stats */ u_int ok, banned; u_int tried, clean, timeout; }; /******************************** PUBLIC ************************************/ /* * lhex_init * * This procedure is called when a particular module is loaded. * Returns NULL if everything went fine, * an error message otherwise. */ static char *lhex_init(AnInstance *self) { struct lhex_private *mydata; #if defined(INET6) return "IPv6 unsupported."; #endif if(self->opt == NULL) return "Aie! no option(s): no LHEx server to connect to!"; if(!inetaton(self->opt,NULL)) return "Aie! Option wasn't a valid IP address!"; /* Allocate the module data */ mydata = (struct lhex_private *) malloc(sizeof(struct lhex_private)); bzero((char *) mydata, sizeof(struct lhex_private)); self->popt = mystrdup(self->opt); self->data = mydata; return NULL; } /* * lhex_release * * This procedure is called when a particular module is unloaded. */ static void lhex_release(AnInstance *self) { struct lhex_private *mydata = self->data; free(mydata); free(self->popt); } /* * lhex_stats * * This procedure is called regularly to update statistics sent to ircd. */ static void lhex_stats(AnInstance *self) { struct lhex_private *mydata = self->data; sendto_ircd("S lhex ok %u banned %u", mydata->ok, mydata->banned); sendto_ircd("S lhex tried %u aborted %u / %u", mydata->tried, mydata->clean, mydata->timeout); } /* * lhex_start * * This procedure is called to start the LHEx check procedure. * Returns 0 if everything went fine, * anything else otherwise (nothing to be done, or failure) * * It is responsible for sending error messages where appropriate. * In case of failure, it's responsible for cleaning up (e.g. lhex_clean * will NOT be called) */ static int lhex_start(u_int cl) { char *error; int fd; struct lhex_private *mydata = cldata[cl].instance->data; if (cldata[cl].state & A_DENY) { /* no point of doing anything */ DebugLog((ALOG_DLHEX, 0, "lhex_start(%d): A_DENY already set ", cl)); return -1; } DebugLog((ALOG_DLHEX, 0, "lhex_start(%d): Connecting to %s", cl, cldata[cl].instance->opt)); mydata->tried += 1; fd= tcp_connect(cldata[cl].ourip, cldata[cl].instance->opt, LHEXPORT, &error); if (fd < 0) { DebugLog((ALOG_DLHEX, 0, "lhex_start(%d): tcp_connect() reported %s", cl, error)); return -1; } cldata[cl].wfd = fd; /*so that lhex_work() is called when connected*/ return 0; } /* * lhex_work * * This procedure is called whenever there's new data in the buffer. * Returns 0 if everything went fine, and there is more work to be done, * Returns -1 if the module has finished its work (and cleaned up). * * It is responsible for sending error messages where appropriate. */ static int lhex_work(u_int cl) { DebugLog((ALOG_DLHEX, 0, "lhex_work(%d): %d %d buflen=%d", cl, cldata[cl].rfd, cldata[cl].wfd, cldata[cl].buflen)); if (cldata[cl].wfd > 0) { /* ** We haven't sent the query yet, the connection was just ** established. */ char query[3+7+6+4+USERLEN+2*HOSTLEN+8+3];/*strlen(atoi(cl))<=8*/ char *ident = cldata[cl].authuser; /* This is part of every request */ sprintf(query, "id:%u ip:%s", cl, cldata[cl].itsip); /* These bits are optional, depending on what's known */ if (ident) { strcat(query, " ident:"); strcat(query, ident); } if (cldata[cl].state & A_GOTH) { strcat(query, " host:"); strcat(query, cldata[cl].host); } /* Terminate the request */ strcat(query, "\r\n"); DebugLog((ALOG_DLHEX, 0, "lhex_work(%u): Sending query [%s]", cl, query)); if (write(cldata[cl].wfd, query, strlen(query)) < 0) { /* most likely the connection failed */ DebugLog((ALOG_DLHEX, 0, "lhex_work(%u): write() failed: %s", cl, strerror(errno))); close(cldata[cl].wfd); cldata[cl].rfd = cldata[cl].wfd = 0; return 1; } cldata[cl].rfd = cldata[cl].wfd; cldata[cl].wfd = 0; } else { /* data's in from the other end */ char *ch, *nch; u_int id; int retval = 0; cldata[cl].inbuffer[cldata[cl].buflen] = '\0'; nch = cldata[cl].inbuffer; while((nch < (cldata[cl].inbuffer + cldata[cl].buflen)) && (ch = index(nch, '\r')) && !retval) { char *och = nch; nch = ch+2; /* Skip the \r\n */ *ch = '\0'; DebugLog((ALOG_DLHEX, 0, "lhex_work(%u): Got [%s]", cl, och)); /* Have a go at parsing the return info */ if(sscanf(och, "%u", &id) != 1) DebugLog((ALOG_DLHEX, 0, "lhex_work(%u): " "Malformed data!", cl)); else { struct lhex_private *d=cldata[cl].instance->data; ch = index(och, ':'); while(isspace(*(++ch))); if(!strcmp(ch,"OK")) { d->ok++; DebugLog((ALOG_DLHEX, 0, "lhex_work(%u): OK", id)); close(cldata[cl].rfd); cldata[cl].rfd = 0; retval = -1; } else if(!strcmp(ch,"Not OK")) { d->banned++; DebugLog((ALOG_DLHEX, 0, "lhex_work(%u): Not OK", id)); cldata[cl].state |= A_DENY; /* I really wish we could send the client a "reason" here :P */ sendto_ircd("K %d %s %u ", cl, cldata[cl].itsip, cldata[cl].itsport); close(cldata[cl].rfd); cldata[cl].rfd = 0; retval = -1; } else { #if 0 /* Call this info for the client */ sendto_ircd("I %d %s %u NOTICE AUTH :%s", cl, cldata[cl].itsip, cldata[cl].itsport, ch); #endif retval = 0; } } } return retval; } return 0; } /* * lhex_clean * * This procedure is called whenever the module should interrupt its work. * It is responsible for cleaning up any allocated data, and in particular * closing file descriptors. */ static void lhex_clean(u_int cl) { struct lhex_private *mydata = cldata[cl].instance->data; mydata->clean += 1; DebugLog((ALOG_DLHEX, 0, "lhex_clean(%d): cleaning up", cl)); /* ** only one of rfd and wfd may be set at the same time, ** in any case, they would be the same fd, so only close() once */ if (cldata[cl].rfd) close(cldata[cl].rfd); else if (cldata[cl].wfd) close(cldata[cl].wfd); cldata[cl].rfd = cldata[cl].wfd = 0; } /* * lhex_timeout * * This procedure is called whenever the timeout set by the module is * reached. * * Returns 0 if things are okay, -1 if check was aborted. */ static int lhex_timeout(u_int cl) { struct lhex_private *mydata = cldata[cl].instance->data; mydata->timeout += 1; DebugLog((ALOG_DLHEX, 0, "lhex_timeout(%d): calling lhex_clean ", cl)); lhex_clean(cl); return -1; } aModule Module_lhex = { "lhex", lhex_init, lhex_release, lhex_stats, lhex_start, lhex_work, lhex_timeout, lhex_clean }; irc2.11.2p3/iauth/a_log_def.h0000644000175000017500000000323007364335405013525 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/a_log_def.h * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #if defined(IAUTH_DEBUG) # define DebugLog(x) sendto_log x #else # define DebugLog(x) #endif #define ALOG_FLOG 0x01 /* file log */ #define ALOG_IRCD 0x02 /* notice sent to ircd (then sent to &AUTH) */ #define ALOG_DCONF 0x000100 /* debug: configuration file */ #define ALOG_DMISC 0x000200 /* debug: misc stuff */ #define ALOG_DIO 0x000400 /* debug: IO stuff */ #define ALOG_DSPY 0x001000 /* debug: show ircd stream */ #define ALOG_DIRCD 0x002000 /* debug: errors reported by ircd */ #define ALOG_D931 0x010000 /* debug: module rfc931 */ #define ALOG_DSOCKS 0x020000 /* debug: module socks */ #define ALOG_DSOCKSC 0x040000 /* debug: module socks cache */ #define ALOG_DPIPE 0x080000 /* debug: module pipe */ #define ALOG_DLHEX 0x100000 /* debug: module pipe */ #define ALOG_DALL 0x1F3700 /* any debug flag */ irc2.11.2p3/iauth/mod_lhex_ext.h0000644000175000017500000000216406704446535014316 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/mod_lhex_ext.h * Copyright (C) 1998-1999 Christophe Kalt and Andrew Snare * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in iauth/mod_lhex.c. */ /* External definitions for global variables. */ #ifndef MOD_LHEX_C extern aModule Module_lhex; #endif /* MOD_LHEX_C */ irc2.11.2p3/iauth/a_log.c0000644000175000017500000000525010127336165012701 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/a_log.c * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: a_log.c,v 1.11 2004/10/01 20:22:13 chopin Exp $"; #endif #include "os.h" #include "a_defines.h" #define A_LOG_C #include "a_externs.h" #undef A_LOG_C #if defined(IAUTH_DEBUG) static FILE *debug = NULL; #endif static FILE *authlog = NULL; void init_filelogs(void) { #if defined(IAUTH_DEBUG) if (debug) fclose(debug); if (debuglevel) { debug = fopen(IAUTHDBG_PATH, "w"); # if defined(USE_SYSLOG) if (!debug) syslog(LOG_ERR, "Failed to open \"%s\" for writing", IAUTHDBG_PATH); # endif } #endif /* IAUTH_DEBUG */ if (authlog) fclose(authlog); authlog = fopen(FNAME_AUTHLOG, "a"); #if defined(USE_SYSLOG) if (!authlog) syslog(LOG_NOTICE, "Failed to open \"%s\" for writing", FNAME_AUTHLOG); #endif } void init_syslog(void) { #if defined(USE_SYSLOG) openlog("iauth", LOG_PID|LOG_NDELAY, LOG_FACILITY); #endif } void vsendto_log(int flags, int slflag, char *pattern, va_list va) { char logbuf[4096]; logbuf[0] = '>'; vsprintf(logbuf+1, pattern, va); #if defined(USE_SYSLOG) if (slflag) syslog(slflag, "%s", logbuf+1); #endif strcat(logbuf, "\n"); #if defined(IAUTH_DEBUG) if ((flags & ALOG_DALL) && (flags & debuglevel) && debug) { fprintf(debug, "%s", logbuf+1); fflush(debug); } #endif if (authlog && (flags & ALOG_FLOG)) { fprintf(authlog, "%s: %s", myctime(time(NULL)), logbuf+1); fflush(authlog); } if (flags & ALOG_IRCD) { write(0, logbuf, strlen(logbuf)); #if defined(IAUTH_DEBUG) if ((ALOG_DSPY & debuglevel) && debug) { fprintf(debug, "To ircd: %s", logbuf+1); fflush(debug); } #endif } } void sendto_log(int flags, int slflag, char *pattern, ...) { va_list va; va_start(va, pattern); vsendto_log(flags, slflag, pattern, va); va_end(va); } irc2.11.2p3/iauth/a_io_ext.h0000644000175000017500000000303410124044476013410 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/a_io_ext.h * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in iauth/a_io.c. */ /* External definitions for global variables. */ #ifndef A_IO_C extern anAuthData cldata[MAXCONNECTIONS]; #endif /* A_IO_C */ /* External definitions for global functions. */ #ifndef A_IO_C #define EXTERN extern #else /* A_IO_C */ #define EXTERN #endif /* A_IO_C */ EXTERN void io_init(void); EXTERN void vsendto_ircd (char *, va_list); EXTERN void sendto_ircd (char *, ...); EXTERN void init_io (void); EXTERN void loop_io (void); EXTERN int tcp_connect (char *, char *, u_short, char **); EXTERN char strConn[256]; EXTERN int strConnLen; /* () */ #undef EXTERN irc2.11.2p3/iauth/a_conf_ext.h0000644000175000017500000000260307744057365013746 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/a_conf_ext.h * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in iauth/a_conf.c. */ /* External definitions for global variables. */ #ifndef A_CONF_C extern u_int debuglevel; extern AnInstance *instances; #endif /* A_CONF_C */ /* External definitions for global functions. */ #ifndef A_CONF_C # define EXTERN extern #else /* A_CONF_C */ # define EXTERN #endif /* A_CONF_C */ EXTERN char *conf_read (char *); EXTERN int conf_match (u_int, AnInstance *); EXTERN void conf_ircd(void); #undef EXTERN irc2.11.2p3/iauth/mod_rfc931.c0000644000175000017500000002151510127336165013470 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/mod_rfc931.c * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: mod_rfc931.c,v 1.20 2004/10/01 20:22:13 chopin Exp $"; #endif #include "os.h" #include "a_defines.h" #define MOD_RFC931_C #include "a_externs.h" #undef MOD_RFC931_C #define OPT_PROTOCOL 0x1 #define OPT_LAZY 0x2 struct _instance_data { u_char options; u_int tried; u_int connected; u_int unx; u_int other; u_int bad; u_int skipped; u_int clean, timeout; }; /* * rfc931_init * * This procedure is called when a particular module is loaded. * Returns NULL if everything went fine, * an error message otherwise. */ static char *rfc931_init(AnInstance *self) { struct _instance_data *dt; dt = (struct _instance_data *) malloc(sizeof(struct _instance_data)); bzero((char *) dt, sizeof(struct _instance_data)); self->data = (void *) dt; /* undocumented option */ if (self->opt && strstr(self->opt, "protocol")) dt->options |= OPT_PROTOCOL; if (self->opt && strstr(self->opt, "lazy")) dt->options |= OPT_LAZY; if (dt->options & (OPT_LAZY|OPT_PROTOCOL)) self->popt = "protocol,lazy"; else if (dt->options & OPT_LAZY) self->popt = "lazy"; else if (dt->options & OPT_PROTOCOL) self->popt = "protocol"; else return NULL; return self->popt; } /* * rfc931_release * * This procedure is called when a particular module is unloaded. */ static void rfc931_release(AnInstance *self) { struct _instance_data *st = self->data; free(st); } /* * rfc931_stats * * This procedure is called regularly to update statistics sent to ircd. */ static void rfc931_stats(AnInstance *self) { struct _instance_data *st = self->data; sendto_ircd("S rfc931 connected %u unix %u other %u bad %u out of %u", st->connected, st->unx, st->other, st->bad, st->tried); sendto_ircd("S rfc931 skipped %u aborted %u / %u", st->skipped, st->clean, st->timeout); } /* * rfc931_start * * This procedure is called to start an authentication. * Returns 0 if everything went fine, * -1 else otherwise (nothing to be done, or failure) * * It is responsible for sending error messages where appropriate. * In case of failure, it's responsible for cleaning up (e.g. rfc931_clean * will NOT be called) */ static int rfc931_start(u_int cl) { char *error; int fd; struct _instance_data *st = cldata[cl].instance->data; if (st->options & OPT_LAZY && cldata[cl].state & A_DENY) { DebugLog((ALOG_D931, 0, "rfc931_start(%d): Lazy.", cl)); return -1; } if (cldata[cl].authuser && cldata[cl].authfrom < cldata[cl].instance->in) { DebugLog((ALOG_D931, 0, "rfc931_start(%d): Instance %d already got the info", cl, cldata[cl].authfrom)); return -1; } DebugLog((ALOG_D931, 0, "rfc931_start(%d): Connecting to %s %u", cl, cldata[cl].itsip, 113)); st->tried += 1; fd = tcp_connect(cldata[cl].ourip, cldata[cl].itsip, 113, &error); if (fd < 0) { DebugLog((ALOG_D931, 0, "rfc931_start(%d): tcp_connect() reported %s", cl, error)); return -1; } cldata[cl].wfd = fd; /*so that rfc931_work() is called when connected*/ return 0; } /* * rfc931_work * * This procedure is called whenever there's new data in the buffer. * Returns 0 if everything went fine, and there is more work to be done, * Returns -1 if the module has finished its work (and cleaned up). * * It is responsible for sending error messages where appropriate. */ static int rfc931_work(u_int cl) { struct _instance_data *st = cldata[cl].instance->data; DebugLog((ALOG_D931, 0, "rfc931_work(%d): %d %d buflen=%d", cl, cldata[cl].rfd, cldata[cl].wfd, cldata[cl].buflen)); if (cldata[cl].wfd > 0) { /* ** We haven't sent the query yet, the connection was just ** established. */ char query[32]; sprintf(query, "%u , %u\r\n", cldata[cl].itsport, cldata[cl].ourport); if (write(cldata[cl].wfd, query, strlen(query)) < 0) { /* most likely the connection failed */ DebugLog((ALOG_D931, 0, "rfc931_work(%d): write() failed: %s", cl, strerror(errno))); close(cldata[cl].wfd); cldata[cl].rfd = cldata[cl].wfd = 0; return 1; } else st->connected += 1; cldata[cl].rfd = cldata[cl].wfd; cldata[cl].wfd = 0; } else { /* data's in from the ident server */ char *ch; u_char bad = 0; cldata[cl].inbuffer[cldata[cl].buflen] = '\0'; ch = index(cldata[cl].inbuffer, '\r'); if (ch) { /* got all of it! */ *ch = '\0'; DebugLog((ALOG_D931, 0, "rfc931_work(%d): Got [%s]", cl, cldata[cl].inbuffer)); if (cldata[cl].buflen > 1024) cldata[cl].inbuffer[1024] = '\0'; if ((ch = index(cldata[cl].inbuffer, '\n'))) { /* delimiter for ircd<->iauth messages. */ *ch = '\0'; } ch = cldata[cl].inbuffer; while (*ch && !isdigit(*ch)) ch++; if (!*ch || atoi(ch) != cldata[cl].itsport) { DebugLog((ALOG_D931, 0, "remote port mismatch.")); ch = NULL; } while (ch && *ch && *ch != ',') ch++; while (ch && *ch && !isdigit(*ch)) ch++; if (ch && (!*ch || atoi(ch) != cldata[cl].ourport)) { DebugLog((ALOG_D931, 0, "local port mismatch.")); ch = NULL; } if (ch) ch = index(ch, ':'); if (ch) ch += 1; while (ch && *ch && *ch == ' ') ch++; if (ch && strncmp(ch, "USERID", 6)) { DebugLog((ALOG_D931, 0, "No USERID.")); ch = NULL; } if (ch) ch = index(ch, ':'); if (ch) ch += 1; while (ch && *ch && *ch == ' ') ch++; if (ch) { int other = 0; if (!strncmp(ch, "OTHER", 5)) other = 1; ch = rindex(ch, ':'); if (ch) ch += 1; while (ch && *ch && *ch == ' ') ch++; if (ch && *ch) { if (cldata[cl].authuser) free(cldata[cl].authuser); cldata[cl].authuser = mystrdup(ch); cldata[cl].authfrom = cldata[cl].instance->in; if (other) st->other += 1; else { st->unx += 1; cldata[cl].state |= A_UNIX; } sendto_ircd("%c %d %s %u %s", (other) ? 'u' : 'U', cl, cldata[cl].itsip, cldata[cl].itsport, cldata[cl].authuser); } else bad = 1; } else bad = 1; if (bad) { st->bad += 1; if (st->options & OPT_PROTOCOL) { ch = cldata[cl].inbuffer; while (*ch) { if (!(isalnum(*ch) || ispunct(*ch) || isspace(*ch))) break; ch += 1; } *ch = '\0'; sendto_log(ALOG_IRCD|ALOG_FLOG, LOG_WARNING, "rfc931: bad reply from %s[%s] to \"%u, %u\": %u, \"%s\"", cldata[cl].host, cldata[cl].itsip, cldata[cl].itsport, cldata[cl].ourport, cldata[cl].buflen, cldata[cl].inbuffer); } } /* ** In any case, our job is done, let's cleanup. */ close(cldata[cl].rfd); cldata[cl].rfd = 0; return -1; } else return 0; } return 0; } /* * rfc931_clean * * This procedure is called whenever the module should interrupt its work. * It is responsible for cleaning up any allocated data, and in particular * closing file descriptors. */ static void rfc931_clean(u_int cl) { struct _instance_data *st = cldata[cl].instance->data; st->clean += 1; DebugLog((ALOG_D931, 0, "rfc931_clean(%d): cleaning up", cl)); /* ** only one of rfd and wfd may be set at the same time, ** in any case, they would be the same fd, so only close() once */ if (cldata[cl].rfd) close(cldata[cl].rfd); else if (cldata[cl].wfd) close(cldata[cl].wfd); cldata[cl].rfd = cldata[cl].wfd = 0; } /* * rfc931_timeout * * This procedure is called whenever the timeout set by the module is * reached. * * Returns 0 if things are okay, -1 if authentication was aborted. */ static int rfc931_timeout(u_int cl) { struct _instance_data *st = cldata[cl].instance->data; st->timeout += 1; DebugLog((ALOG_D931, 0, "rfc931_timeout(%d): calling rfc931_clean ", cl)); rfc931_clean(cl); return -1; } aModule Module_rfc931 = { "rfc931", rfc931_init, rfc931_release, rfc931_stats, rfc931_start, rfc931_work, rfc931_timeout, rfc931_clean }; irc2.11.2p3/iauth/a_conf_def.h0000644000175000017500000000400310123600747013657 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/a_conf_def.h * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ typedef struct Module aModule; typedef struct Instance AnInstance; typedef struct Target aTarget; struct Module { char *name; /* module name */ char *(*init)(AnInstance *); /* instance initialization */ void (*release)(AnInstance *);/* instance releasing >UNUSED< */ void (*stats)(AnInstance *); /* send instance stats to ircd */ int (*start)(u_int); /* start authentication */ int (*work)(u_int); /* called whenever something has to be * done (incoming data, timeout..) */ int (*timeout)(u_int); /* called when timeout is reached */ void (*clean)(u_int); /* finish/abort: cleanup*/ }; struct Instance { AnInstance *nexti; u_char in; /* instance number */ aModule *mod; /* module */ char *opt; /* options read from file */ char *popt; /* options to send to ircd */ void *data; /* private data: stats, ... */ aTarget *address; aTarget *hostname; u_int timeout; u_int port; char *reason; /* reject reason */ u_char delayed; /* delayed execution mode */ }; struct Target { char *value; u_long baseip, lmask; /* a.b.c.d/z */ char yes; aTarget *nextt; }; irc2.11.2p3/iauth/mod_webproxy.c0000644000175000017500000002737010176237130014341 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/mod_webproxy.c * Copyright (C) 1998 Christophe Kalt * Copyright (C) 2004 Piotr Kucharski * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: mod_webproxy.c,v 1.4 2005/01/27 19:17:44 chopin Exp $"; #endif #include "os.h" #include "a_defines.h" #define MOD_PROXY_C #include "a_externs.h" #undef MOD_PROXY_C /****************************** PRIVATE *************************************/ static int proxy_start(u_int cl); #define CACHETIME 30 #define PROXYPORT (cldata[cl].instance->port) struct proxylog { struct proxylog *next; char ip[HOSTLEN+1]; u_char state; /* 0 = no proxy, 1 = open proxy, 2 = closed proxy */ time_t expire; }; #define OPT_LOG 0x001 #define OPT_DENY 0x002 #define OPT_CAREFUL 0x008 #define PROXY_NONE 0 #define PROXY_OPEN 1 #define PROXY_CLOSE 2 struct proxy_private { struct proxylog *cache; u_int lifetime; u_char options; /* stats */ u_int chitc, chito, chitn, cmiss, cnow, cmax; u_int noproxy, open, closed; }; /* * proxy_open_proxy * * Found an open proxy for cl: deal with it! */ static void proxy_open_proxy(int cl) { struct proxy_private *mydata = cldata[cl].instance->data; char *reason = cldata[cl].instance->reason; if (!reason) { reason = "Denied access (insecure proxy found)"; } /* open proxy */ if (mydata->options & OPT_DENY) { cldata[cl].state |= A_DENY; sendto_ircd("k %d %s %u :%s", cl, cldata[cl].itsip, cldata[cl].itsport, reason); } if (mydata->options & OPT_LOG) { sendto_log(ALOG_FLOG, LOG_INFO, "webproxy%u: open proxy: %s[%s]", PROXYPORT, cldata[cl].host, cldata[cl].itsip); } } /* * proxy_add_cache * * Add an entry to the cache. */ static void proxy_add_cache(int cl, int state) { struct proxy_private *mydata = cldata[cl].instance->data; struct proxylog *next; if (state == PROXY_OPEN) { mydata->open += 1; } else if (state == PROXY_NONE) { mydata->noproxy += 1; } else { mydata->closed += 1; } if (mydata->lifetime == 0) { return; } mydata->cnow += 1; if (mydata->cnow > mydata->cmax) { mydata->cmax = mydata->cnow; } next = mydata->cache; mydata->cache = (struct proxylog *)malloc(sizeof(struct proxylog)); mydata->cache->expire = time(NULL) + mydata->lifetime; strcpy(mydata->cache->ip, cldata[cl].itsip); mydata->cache->state = state; mydata->cache->next = next; DebugLog((ALOG_DSOCKSC, 0, "webproxy_add_cache(%d): new cache %s, open=%d", cl, mydata->cache->ip, state)); } /* * proxy_check_cache * * Check cache for an entry. */ static int proxy_check_cache(u_int cl) { struct proxy_private *mydata = cldata[cl].instance->data; struct proxylog **last, *pl; time_t now = time(NULL); if (mydata->lifetime == 0) { return 0; } DebugLog((ALOG_DSOCKSC, 0, "webproxy_check_cache(%d): Checking cache for %s", cl, cldata[cl].itsip)); last = &(mydata->cache); while ((pl = *last)) { DebugLog((ALOG_DSOCKSC, 0, "webproxy_check_cache(%d): cache %s", cl, pl->ip)); if (pl->expire < now) { DebugLog((ALOG_DSOCKSC, 0, "webproxy_check_cache(%d): free %s (%d < %d)", cl, pl->ip, pl->expire, now)); *last = pl->next; free(pl); mydata->cnow -= 1; continue; } if (!strcasecmp(pl->ip, cldata[cl].itsip)) { DebugLog((ALOG_DSOCKSC, 0, "webproxy_check_cache(%d): match (%u)", cl, pl->state)); pl->expire = now + mydata->lifetime; /* dubious */ if (pl->state == 1) { proxy_open_proxy(cl); mydata->chito += 1; } else if (pl->state == 0) { mydata->chitn += 1; } else { mydata->chitc += 1; } return -1; } last = &(pl->next); } mydata->cmiss += 1; return 0; } static int proxy_write(u_int cl) { char query[128]; /* big enough to hold all queries */ int query_len; /* length of query */ #ifndef INET6 u_int a, b, c, d; #else struct in6_addr addr; #endif #ifndef INET6 if (sscanf(cldata[cl].ourip, "%u.%u.%u.%u", &a,&b,&c,&d) != 4) #else if (inetpton(AF_INET6, cldata[cl].ourip, (void *) addr.s6_addr) != 1) #endif { sendto_log(ALOG_DSOCKS|ALOG_IRCD, LOG_ERR, "webproxy_write(%d): " #ifndef INET6 "sscanf" #else "inetpton" #endif "(\"%s\") failed", cl, cldata[cl].ourip); close(cldata[cl].wfd); cldata[cl].wfd = 0; return -1; } query_len = sprintf(query, "CONNECT %s:%d HTTP/1.0\r\n\r\n", cldata[cl].ourip, cldata[cl].ourport); DebugLog((ALOG_DSOCKS, 0, "webproxy_write(%d): Checking %s %u", cl, cldata[cl].itsip, PROXYPORT)); if (write(cldata[cl].wfd, query, query_len) != query_len) { /* most likely the connection failed */ DebugLog((ALOG_DSOCKS, 0, "webproxy_write(%d): write() failed: %s", cl, strerror(errno))); proxy_add_cache(cl, PROXY_NONE); close(cldata[cl].wfd); cldata[cl].rfd = cldata[cl].wfd = 0; return 1; } cldata[cl].rfd = cldata[cl].wfd; cldata[cl].wfd = 0; return 0; } static int proxy_read(u_int cl) { struct proxy_private *mydata = cldata[cl].instance->data; u_char state = PROXY_CLOSE; /* not enough data from the other end */ if (cldata[cl].buflen < ((mydata->options & OPT_CAREFUL) ? strConnLen + /* strlen("HTTP/1.0 200 Connection established\n\n") = */ 38 : /* strlen("HTTP/1.0 200") = */ 12)) { return 0; } /* got all we need */ DebugLog((ALOG_DSOCKS, 0, "webproxy%u_read(%d): Got [%-64.64s]", PROXYPORT, cl, cldata[cl].inbuffer)); if (mydata->options & OPT_CAREFUL) { /* strConn is welcome banner */ if (strstr(cldata[cl].inbuffer, strConn)) { state = PROXY_OPEN; } } else { /* little cheating to save on one strncmp for HTTP/1.1 */ cldata[cl].inbuffer[7] = '0'; /* Some Apache change "CONNECT" to "GET" and return * "HTTP/1.0 200 OK" -- oops. Luckily they also return * "Date:" header, let's hope it's in inbuffer already. --B. */ if (!strstr(cldata[cl].inbuffer, "Date:") && !strncmp(cldata[cl].inbuffer, "HTTP/1.0 200", 12)) { state = PROXY_OPEN; } } /* Here state can be only OPEN, CLOSE or NONE */ if (state == PROXY_OPEN) { proxy_open_proxy(cl); } proxy_add_cache(cl, state); close(cldata[cl].rfd); cldata[cl].rfd = 0; return -1; } /******************************** PUBLIC ************************************/ /* * proxy_init * * This procedure is called when a particular module is loaded. * Returns NULL if everything went fine, * an error message otherwise. */ static char *proxy_init(AnInstance *self) { struct proxy_private *mydata; char tmpbuf[80], cbuf[32]; static char txtbuf[80]; char *ch; if (self->opt == NULL) { return "Aie! no option(s): nothing to be done!"; } mydata = (struct proxy_private *) malloc(sizeof(struct proxy_private)); bzero((char *) mydata, sizeof(struct proxy_private)); mydata->cache = NULL; mydata->lifetime = CACHETIME; tmpbuf[0] = txtbuf[0] = '\0'; /* for stats a */ sprintf(tmpbuf, "port=%d", self->port); if (self->delayed) { strcat(tmpbuf, ",delayed"); strcat(txtbuf, ", Delayed"); } if (strstr(self->opt, "log")) { mydata->options |= OPT_LOG; strcat(tmpbuf, ",log"); strcat(txtbuf, ", Log"); } if (strstr(self->opt, "reject")) { mydata->options |= OPT_DENY; strcat(tmpbuf, ",reject"); strcat(txtbuf, ", Reject"); } if (strstr(self->opt, "careful")) { mydata->options |= OPT_CAREFUL; strcat(tmpbuf, ",careful"); strcat(txtbuf, ", Careful"); } if (mydata->options == 0) { return "Aie! unknown option(s): nothing to be done!"; } if ((ch = strstr(self->opt, "cache="))) { mydata->lifetime = atoi(ch+6); } sprintf(cbuf, ",cache=%d", mydata->lifetime); strcat(tmpbuf, cbuf); sprintf(cbuf, ", Cache %d (min)", mydata->lifetime); strcat(txtbuf, cbuf); mydata->lifetime *= 60; self->popt = mystrdup(tmpbuf); self->data = mydata; return txtbuf+2; } /* * proxy_release * * This procedure is called when a particular module is unloaded. */ static void proxy_release(AnInstance *self) { struct proxy_private *mydata = self->data; free(mydata); free(self->popt); } /* * proxy_stats * * This procedure is called regularly to update statistics sent to ircd. */ static void proxy_stats(AnInstance *self) { struct proxy_private *mydata = self->data; sendto_ircd("S %s:%u open %u closed %u noproxy %u", self->mod->name, self->port, mydata->open, mydata->closed, mydata->noproxy); sendto_ircd("S %s:%u cache open %u closed %u noproxy %u miss %u" " (%u <= %u)", self->mod->name, self->port, mydata->chito, mydata->chitc, mydata->chitn, mydata->cmiss, mydata->cnow, mydata->cmax); } /* * proxy_start * * This procedure is called to start the socks check procedure. * Returns 0 if everything went fine, * -1 otherwise (nothing to be done, or failure) * * It is responsible for sending error messages where appropriate. * In case of failure, it's responsible for cleaning up (e.g. proxy_clean * will NOT be called) */ static int proxy_start(u_int cl) { char *error; int fd; if (cldata[cl].state & A_DENY) { /* no point of doing anything */ DebugLog((ALOG_DSOCKS, 0, "webproxy_start(%d): A_DENY already set ", cl)); return -1; } if (proxy_check_cache(cl)) { return -1; } DebugLog((ALOG_DSOCKS, 0, "webproxy_start(%d): Connecting to %s", cl, cldata[cl].itsip)); fd= tcp_connect(cldata[cl].ourip, cldata[cl].itsip, PROXYPORT, &error); if (fd < 0) { DebugLog((ALOG_DSOCKS, 0, "webproxy_start(%d): tcp_connect() reported %s", cl, error)); proxy_add_cache(cl, PROXY_NONE); return -1; } /* so that proxy_work() is called when connected */ cldata[cl].wfd = fd; return 0; } /* * proxy_work * * This procedure is called whenever there's new data in the buffer. * Returns 0 if everything went fine, and there is more work to be done, * Returns -1 if the module has finished its work (and cleaned up). * * It is responsible for sending error messages where appropriate. */ static int proxy_work(u_int cl) { DebugLog((ALOG_DSOCKS, 0, "webproxy_work(%d): %d %d buflen=%d", cl, cldata[cl].rfd, cldata[cl].wfd, cldata[cl].buflen)); if (cldata[cl].wfd > 0) { /* ** We haven't sent the query yet, the connection ** was just established. */ return proxy_write(cl); } else { return proxy_read(cl); } } /* * proxy_clean * * This procedure is called whenever the module should interrupt its work. * It is responsible for cleaning up any allocated data, and in particular * closing file descriptors. */ static void proxy_clean(u_int cl) { DebugLog((ALOG_DSOCKS, 0, "webproxy_clean(%d): cleaning up", cl)); /* ** only one of rfd and wfd may be set at the same time, ** in any case, they would be the same fd, so only close() once */ if (cldata[cl].rfd) { close(cldata[cl].rfd); } else if (cldata[cl].wfd) { close(cldata[cl].wfd); } cldata[cl].rfd = cldata[cl].wfd = 0; } /* * proxy_timeout * * This procedure is called whenever the timeout set by the module is * reached. * * Returns 0 if things are okay, -1 if check was aborted. */ static int proxy_timeout(u_int cl) { DebugLog((ALOG_DSOCKS, 0, "webproxy_timeout(%d): calling proxy_clean ", cl)); proxy_clean(cl); return -1; } aModule Module_webproxy = { "webproxy", proxy_init, proxy_release, proxy_stats, proxy_start, proxy_work, proxy_timeout, proxy_clean }; irc2.11.2p3/iauth/mod_socks.c0000644000175000017500000004301510130031506013563 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/mod_socks.c * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: mod_socks.c,v 1.43 2004/10/03 17:13:42 chopin Exp $"; #endif #include "os.h" #include "a_defines.h" #define MOD_SOCKS_C #include "a_externs.h" #undef MOD_SOCKS_C /****************************** PRIVATE *************************************/ static int socks_start(u_int cl); #define CACHETIME 30 #define SOCKSPORT (cldata[cl].instance->port) struct proxylog { struct proxylog *next; char ip[HOSTLEN+1]; u_char state; /* 0 = no proxy, 1 = open proxy, 2 = closed proxy */ time_t expire; }; #define OPT_LOG 0x001 #define OPT_DENY 0x002 #define OPT_PARANOID 0x004 #define OPT_CAREFUL 0x008 #define OPT_V4ONLY 0x010 #define OPT_V5ONLY 0x020 #define OPT_PROTOCOL 0x040 #define OPT_BOFH 0x080 #define PROXY_NONE 0 #define PROXY_OPEN 1 #define PROXY_CLOSE 2 #define PROXY_UNEXPECTED 3 #define PROXY_BADPROTO 4 #define ST_V4 0x01 #define ST_V5 0x02 #define ST_V5b 0x04 struct socks_private { struct proxylog *cache; u_int lifetime; u_char options; /* stats */ u_int chitc, chito, chitn, cmiss, cnow, cmax; u_int noproxy, open, closed; }; /* * socks_open_proxy * * Found an open proxy for cl: deal with it! */ static void socks_open_proxy(int cl, char *strver) { struct socks_private *mydata = cldata[cl].instance->data; char *reason = cldata[cl].instance->reason; if (!reason) { reason = "Denied access (insecure proxy found)"; } /* open proxy */ if (mydata->options & OPT_DENY) { cldata[cl].state |= A_DENY; sendto_ircd("k %d %s %u :%s", cl, cldata[cl].itsip, cldata[cl].itsport, reason); } if (mydata->options & OPT_LOG) { sendto_log(ALOG_FLOG, LOG_INFO, "socks%s: open proxy: %s[%s]", strver, cldata[cl].host, cldata[cl].itsip); } } /* * socks_add_cache * * Add an entry to the cache. */ static void socks_add_cache(int cl, int state) { struct socks_private *mydata = cldata[cl].instance->data; struct proxylog *next; if (state == PROXY_OPEN) { mydata->open += 1; } else if (state == PROXY_NONE) { mydata->noproxy += 1; } else { mydata->closed += 1; } if (mydata->lifetime == 0) { return; } mydata->cnow += 1; if (mydata->cnow > mydata->cmax) { mydata->cmax = mydata->cnow; } next = mydata->cache; mydata->cache = (struct proxylog *)malloc(sizeof(struct proxylog)); mydata->cache->expire = time(NULL) + mydata->lifetime; strcpy(mydata->cache->ip, cldata[cl].itsip); mydata->cache->state = state; mydata->cache->next = next; DebugLog((ALOG_DSOCKSC, 0, "socks_add_cache(%d): new cache %s, open=%d", cl, mydata->cache->ip, state)); } /* * socks_check_cache * * Check cache for an entry. */ static int socks_check_cache(u_int cl) { struct socks_private *mydata = cldata[cl].instance->data; struct proxylog **last, *pl; time_t now = time(NULL); if (mydata->lifetime == 0) { return 0; } DebugLog((ALOG_DSOCKSC, 0, "socks_check_cache(%d): Checking cache for %s", cl, cldata[cl].itsip)); last = &(mydata->cache); while ((pl = *last)) { DebugLog((ALOG_DSOCKSC, 0, "socks_check_cache(%d): cache %s", cl, pl->ip)); if (pl->expire < now) { DebugLog((ALOG_DSOCKSC, 0, "socks_check_cache(%d): free %s (%d < %d)", cl, pl->ip, pl->expire, now)); *last = pl->next; free(pl); mydata->cnow -= 1; continue; } if (!strcasecmp(pl->ip, cldata[cl].itsip)) { DebugLog((ALOG_DSOCKSC, 0, "socks_check_cache(%d): match (%u)", cl, pl->state)); pl->expire = now + mydata->lifetime; /* dubious */ if (pl->state == 1) { socks_open_proxy(cl, "C"); mydata->chito += 1; } else if (pl->state == 0) { mydata->chitn += 1; } else { mydata->chitc += 1; } return -1; } last = &(pl->next); } mydata->cmiss += 1; return 0; } static int socks_write(u_int cl, char *strver) { u_char query[128]; /* big enough to hold all queries */ int query_len; /* length of query */ #ifndef INET6 u_int a, b, c, d; #else struct in6_addr addr; struct socks_private *mydata = cldata[cl].instance->data; #endif #ifndef INET6 if (sscanf(cldata[cl].ourip, "%u.%u.%u.%u", &a,&b,&c,&d) != 4) #else if (inetpton(AF_INET6, cldata[cl].ourip, (void *) addr.s6_addr) != 1) #endif { sendto_log(ALOG_DSOCKS|ALOG_IRCD, LOG_ERR, "socks_write%s(%d): " #ifndef INET6 "sscanf" #else "inetpton" #endif "(\"%s\") failed", strver, cl, cldata[cl].ourip); close(cldata[cl].wfd); cldata[cl].wfd = 0; return -1; } #ifdef INET6 /* * socks4 does not support ipv6, so we switch to socks5, if * address is not ipv4 mapped in ipv6 */ if (cldata[cl].mod_status == ST_V4 && !IN6_IS_ADDR_V4MAPPED(&addr)) { if (mydata->options & OPT_V4ONLY) { /* we cannot do work! */ sendto_log(ALOG_DSOCKS|ALOG_IRCD, LOG_WARNING, "socks4 does not work on ipv6"); close(cldata[cl].wfd); cldata[cl].wfd = 0; return -1; } else { cldata[cl].mod_status = ST_V5; } } #endif if (cldata[cl].mod_status == ST_V4) { query[0] = 4; query[1] = 1; query[2] = ((cldata[cl].ourport & 0xff00) >> 8); query[3] = (cldata[cl].ourport & 0x00ff); #ifndef INET6 query[4] = a; query[5] = b; query[6] = c; query[7] = d; #else /* socks v4 only supports IPv4, * so it must be a ipv4 mapped ipv6. * Just copy the ipv4 portion. */ memcpy(query + 4, ((char *)addr.s6_addr) + 12, 4); #endif query[8] = 'u'; query[9] = 's'; query[10] = 'e'; query[11] = 'r'; query[12] = 0; query_len = 13; } else { query[0] = 5; query[1] = 1; query[2] = 0; query_len = 3; if (cldata[cl].mod_status == ST_V5b) { #ifndef INET6 query_len = 10; query[3] = 1; query[4] = a; query[5] = b; query[6] = c; query[7] = d; query[8] = ((cldata[cl].ourport & 0xff00) >>8); query[9] = (cldata[cl].ourport & 0x00ff); #else if (IN6_IS_ADDR_V4MAPPED(&addr)) { query_len = 10; query[3] = 1; /* ipv4 address */ memcpy(query + 4, ((char *)addr.s6_addr) + 12, 4); query[8] = ((cldata[cl].ourport & 0xff00) >>8); query[9] = (cldata[cl].ourport & 0x00ff); } else { query_len = 22; query[3] = 4; memcpy(query + 4, addr.s6_addr, 16); query[20] = ((cldata[cl].ourport & 0xff00) >>8); query[21] = (cldata[cl].ourport & 0x00ff); } #endif } } DebugLog((ALOG_DSOCKS, 0, "socks%s_write(%d): Checking %s %u", strver, cl, cldata[cl].ourip, SOCKSPORT)); if (write(cldata[cl].wfd, query, query_len) != query_len) { /* most likely the connection failed */ DebugLog((ALOG_DSOCKS, 0, "socks%s_write(%d): write() failed: %s", strver, cl, strerror(errno))); socks_add_cache(cl, PROXY_NONE); close(cldata[cl].wfd); cldata[cl].rfd = cldata[cl].wfd = 0; return 1; } cldata[cl].rfd = cldata[cl].wfd; cldata[cl].wfd = 0; return 0; } static int socks_read(u_int cl, char *strver) { struct socks_private *mydata = cldata[cl].instance->data; u_char state = PROXY_CLOSE; /* not enough data from the other end */ if (cldata[cl].buflen < 2) { return 0; } /* got all we need */ DebugLog((ALOG_DSOCKS, 0, "socks%s_read(%d): Got [%d %d]", strver, cl, cldata[cl].inbuffer[0], cldata[cl].inbuffer[1])); if (cldata[cl].mod_status == ST_V4) { if (cldata[cl].inbuffer[0] == 0 /* A lot of socks v4 proxies return 4,91 instead of 0,91 otherwise working perfectly -- this will deal with them. */ #define BROKEN_PROXIES #ifdef BROKEN_PROXIES || cldata[cl].inbuffer[0] == 4 #endif ) { if (cldata[cl].inbuffer[1] < 90 || cldata[cl].inbuffer[1] > 93) { state = PROXY_UNEXPECTED; } else { if (cldata[cl].inbuffer[1] == 90) { state = PROXY_OPEN; } else if ((mydata->options & OPT_PARANOID) && cldata[cl].inbuffer[1] != 91) { state = PROXY_OPEN; } } } else { state = PROXY_BADPROTO; } } else /* ST_V5 or ST_V5b */ { if (cldata[cl].inbuffer[0] == 5) { if (cldata[cl].inbuffer[1] == 0) { state = PROXY_OPEN; } else { if (cldata[cl].mod_status == ST_V5) { if ((u_char)cldata[cl].inbuffer[1] == 4 || ((u_char)cldata[cl].inbuffer[1] > 9 && (u_char)cldata[cl].inbuffer[1] != 255)) { state = PROXY_UNEXPECTED; } } else /* ST_V5b */ { if ((u_char) cldata[cl].inbuffer[1] > 8) { state = PROXY_UNEXPECTED; } else if ((mydata->options&OPT_PARANOID) && cldata[cl].inbuffer[1] != 2) { state = PROXY_OPEN; } } } } else { state = PROXY_BADPROTO; } } if (cldata[cl].mod_status == ST_V4) { /* we just checked socks 4 */ if (!(mydata->options & OPT_V4ONLY) && state != PROXY_OPEN) { /* if we're not configured to do only v4 and proxy state was not OPEN, try v5 */ cldata[cl].mod_status = ST_V5; cldata[cl].buflen = 0; close(cldata[cl].rfd); cldata[cl].rfd = 0; goto again; } } else if (cldata[cl].mod_status == ST_V5) { /* we just checked socks 5 */ if (state == PROXY_OPEN && mydata->options & OPT_CAREFUL) { /* we found socks 5 OPEN, but (option says so) we will double check in second stage */ cldata[cl].mod_status = ST_V5b; cldata[cl].buflen = 0; cldata[cl].wfd = cldata[cl].rfd; cldata[cl].rfd = 0; goto again; } } else /* ST_V5b */ { /* we just checked second phase of socks 5b. nothing left to do. */ } if (state == PROXY_UNEXPECTED) { sendto_log(ALOG_FLOG, LOG_WARNING, "socks%s: unexpected reply: %u,%u %s[%s]", strver, cldata[cl].inbuffer[0], cldata[cl].inbuffer[1], cldata[cl].host, cldata[cl].itsip); sendto_log(ALOG_IRCD, 0, "socks%s: unexpected reply: %u,%u", strver, cldata[cl].inbuffer[0], cldata[cl].inbuffer[1]); /* oh well. unexpected response can mean anything. so if we're megaparanoid, we assume it's open proxy */ state = mydata->options & OPT_BOFH ? PROXY_OPEN : PROXY_CLOSE; } else if (state == PROXY_BADPROTO) { if (mydata->options & OPT_PROTOCOL) { sendto_log(ALOG_FLOG, LOG_WARNING, "socks%s: protocol error: %u,%u %s[%s]", strver, cldata[cl].inbuffer[0], cldata[cl].inbuffer[1], cldata[cl].host, cldata[cl].itsip); sendto_log(ALOG_IRCD, 0, "socks%s: protocol error: %u,%u", strver, cldata[cl].inbuffer[0], cldata[cl].inbuffer[1]); } /* oh well. protocol error can mean anything. so if we're megaparanoid, we assume it's open proxy */ state = mydata->options & OPT_BOFH ? PROXY_OPEN : PROXY_CLOSE; } /* We're past checking of socks 4, socks 5 and even socks 5b, if it was needed. Now deal with final state */ /* Here state can be only OPEN, CLOSE or NONE */ if (state == PROXY_OPEN) { socks_open_proxy(cl, strver); } socks_add_cache(cl, state); close(cldata[cl].rfd); cldata[cl].rfd = 0; return -1; again: if (cldata[cl].mod_status != ST_V5b) { return socks_start(cl); } return 0; } /******************************** PUBLIC ************************************/ /* * socks_init * * This procedure is called when a particular module is loaded. * Returns NULL if everything went fine, * an error message otherwise. */ static char *socks_init(AnInstance *self) { struct socks_private *mydata; char tmpbuf[80], cbuf[32]; static char txtbuf[80]; if (self->opt == NULL) { return "Aie! no option(s): nothing to be done!"; } mydata = (struct socks_private *) malloc(sizeof(struct socks_private)); bzero((char *) mydata, sizeof(struct socks_private)); mydata->cache = NULL; mydata->lifetime = CACHETIME; tmpbuf[0] = txtbuf[0] = '\0'; /* for stats a */ sprintf(tmpbuf, "port=%d", self->port); if (self->delayed) { strcat(tmpbuf, ",delayed"); strcat(txtbuf, ", Delayed"); } if (strstr(self->opt, "log")) { mydata->options |= OPT_LOG; strcat(tmpbuf, ",log"); strcat(txtbuf, ", Log"); } if (strstr(self->opt, "reject")) { mydata->options |= OPT_DENY; strcat(tmpbuf, ",reject"); strcat(txtbuf, ", Reject"); } if (strstr(self->opt, "megaparanoid")) { mydata->options |= OPT_PARANOID|OPT_BOFH; strcat(tmpbuf, ",megaparanoid"); strcat(txtbuf, ", Megaparanoid"); } else if (strstr(self->opt, "paranoid")) { mydata->options |= OPT_PARANOID; strcat(tmpbuf, ",paranoid"); strcat(txtbuf, ", Paranoid"); } if (strstr(self->opt, "careful")) { mydata->options |= OPT_CAREFUL; strcat(tmpbuf, ",careful"); strcat(txtbuf, ", Careful"); } if (strstr(self->opt, "v4only")) { mydata->options |= OPT_V4ONLY; strcat(tmpbuf, ",v4only"); strcat(txtbuf, ", V4only"); } if (strstr(self->opt, "v5only")) { mydata->options |= OPT_V5ONLY; strcat(tmpbuf, ",v5only"); strcat(txtbuf, ", V5only"); } if (strstr(self->opt, "protocol")) { mydata->options |= OPT_PROTOCOL; strcat(tmpbuf, ",protocol"); strcat(txtbuf, ", Protocol"); } if (mydata->options == 0) { return "Aie! unknown option(s): nothing to be done!"; } if (strstr(self->opt, "cache")) { char *ch = index(self->opt, '='); if (ch) { mydata->lifetime = atoi(ch+1); } } sprintf(cbuf, ",cache=%d", mydata->lifetime); strcat(tmpbuf, cbuf); sprintf(cbuf, ", Cache %d (min)", mydata->lifetime); strcat(txtbuf, cbuf); mydata->lifetime *= 60; self->popt = mystrdup(tmpbuf); self->data = mydata; return txtbuf+2; } /* * socks_release * * This procedure is called when a particular module is unloaded. */ static void socks_release(AnInstance *self) { struct sock_private *mydata = self->data; free(mydata); free(self->popt); } /* * socks_stats * * This procedure is called regularly to update statistics sent to ircd. */ static void socks_stats(AnInstance *self) { struct socks_private *mydata = self->data; sendto_ircd("S socks:%u open %u closed %u noproxy %u", self->port, mydata->open, mydata->closed, mydata->noproxy); sendto_ircd("S socks:%u cache open %u closed %u noproxy %u miss %u (%u <= %u)", self->port, mydata->chito, mydata->chitc, mydata->chitn, mydata->cmiss, mydata->cnow, mydata->cmax); } /* * socks_start * * This procedure is called to start the socks check procedure. * Returns 0 if everything went fine, * -1 otherwise (nothing to be done, or failure) * * It is responsible for sending error messages where appropriate. * In case of failure, it's responsible for cleaning up (e.g. socks_clean * will NOT be called) */ static int socks_start(u_int cl) { char *error; int fd; if (cldata[cl].state & A_DENY) { /* no point of doing anything */ DebugLog((ALOG_DSOCKS, 0, "socks_start(%d): A_DENY already set ", cl)); return -1; } if (socks_check_cache(cl)) { return -1; } DebugLog((ALOG_DSOCKS, 0, "socks_start(%d): Connecting to %s", cl, cldata[cl].itsip)); fd= tcp_connect(cldata[cl].ourip, cldata[cl].itsip, SOCKSPORT, &error); if (fd < 0) { DebugLog((ALOG_DSOCKS, 0, "socks_start(%d): tcp_connect() reported %s", cl, error)); socks_add_cache(cl, PROXY_NONE); return -1; } /* so that socks_work() is called when connected */ cldata[cl].wfd = fd; return 0; } /* * socks_work * * This procedure is called whenever there's new data in the buffer. * Returns 0 if everything went fine, and there is more work to be done, * Returns -1 if the module has finished its work (and cleaned up). * * It is responsible for sending error messages where appropriate. */ static int socks_work(u_int cl) { char *strver = "4"; struct socks_private *mydata = cldata[cl].instance->data; if (cldata[cl].mod_status == 0) { if (mydata->options & OPT_V5ONLY) { cldata[cl].mod_status = ST_V5; } else { cldata[cl].mod_status = ST_V4; } } if (cldata[cl].mod_status & ST_V5) { strver = "5"; } else if (cldata[cl].mod_status & ST_V5b) { strver = "5b"; } DebugLog((ALOG_DSOCKS, 0, "socks%s_work(%d): %d %d buflen=%d", strver, cl, cldata[cl].rfd, cldata[cl].wfd, cldata[cl].buflen)); if (cldata[cl].wfd > 0) { /* ** We haven't sent the query yet, the connection ** was just established. */ return socks_write(cl, strver); } else { return socks_read(cl, strver); } } /* * socks_clean * * This procedure is called whenever the module should interrupt its work. * It is responsible for cleaning up any allocated data, and in particular * closing file descriptors. */ static void socks_clean(u_int cl) { DebugLog((ALOG_DSOCKS, 0, "socks_clean(%d): cleaning up", cl)); /* ** only one of rfd and wfd may be set at the same time, ** in any case, they would be the same fd, so only close() once */ if (cldata[cl].rfd) { close(cldata[cl].rfd); } else if (cldata[cl].wfd) { close(cldata[cl].wfd); } cldata[cl].rfd = cldata[cl].wfd = 0; } /* * socks_timeout * * This procedure is called whenever the timeout set by the module is * reached. * * Returns 0 if things are okay, -1 if check was aborted. */ static int socks_timeout(u_int cl) { DebugLog((ALOG_DSOCKS, 0, "socks_timeout(%d): calling socks_clean ", cl)); socks_clean(cl); return -1; } aModule Module_socks = { "socks", socks_init, socks_release, socks_stats, socks_start, socks_work, socks_timeout, socks_clean }; irc2.11.2p3/iauth/a_io.c0000644000175000017500000005514710166301003012523 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/a_io.c * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: a_io.c,v 1.31 2005/01/03 17:33:55 q Exp $"; #endif #include "os.h" #include "a_defines.h" #define A_IO_C #include "a_externs.h" #undef A_IO_C anAuthData cldata[MAXCONNECTIONS]; /* index == ircd fd */ static int cl_highest = -1; #if defined(USE_POLL) static int fd2cl[MAXCONNECTIONS]; /* fd -> cl mapping */ #endif #define IOBUFSIZE 4096 static char iobuf[IOBUFSIZE+1]; static char rbuf[IOBUFSIZE+1]; /* incoming ircd stream */ static int iob_len = 0, rb_len = 0; void init_io(void) { bzero((char *) cldata, sizeof(cldata)); } /* sendto_ircd() functions */ void vsendto_ircd(char *pattern, va_list va) { char ibuf[4096]; vsprintf(ibuf, pattern, va); DebugLog((ALOG_DSPY, 0, "To ircd: [%s]", ibuf)); strcat(ibuf, "\n"); if (write(0, ibuf, strlen(ibuf)) != strlen(ibuf)) { sendto_log(ALOG_DMISC, LOG_NOTICE, "Daemon exiting. [w %s]", strerror(errno)); exit(0); } } void sendto_ircd(char *pattern, ...) { va_list va; va_start(va, pattern); vsendto_ircd(pattern, va); va_end(va); } /* * next_io * * given an entry, look for the next module instance to start */ static void next_io(int cl, AnInstance *last) { DebugLog((ALOG_DIO, 0, "next_io(#%d, %x): last=%s state=0x%X", cl, last, (last) ? last->mod->name : "", cldata[cl].state)); /* first, bail out immediately if the entry is flagged A_DONE */ if (cldata[cl].state & A_DONE) return; /* second, make sure the last instance which ran cleaned up */ if (cldata[cl].rfd > 0 || cldata[cl].wfd > 0) { /* last is defined here */ sendto_log(ALOG_IRCD|ALOG_DMISC, LOG_ERR, "module \"%s\" didn't clean up fd's! (%d %d)", last->mod->name, cldata[cl].rfd, cldata[cl].wfd); if (cldata[cl].rfd > 0) close(cldata[cl].rfd); if (cldata[cl].wfd > 0 && cldata[cl].rfd != cldata[cl].wfd) close(cldata[cl].wfd); cldata[cl].rfd = cldata[cl].wfd = 0; } cldata[cl].buflen = 0; cldata[cl].mod_status = 0; cldata[cl].instance = NULL; cldata[cl].timeout = 0; /* third, if A_START is set, a new pass has to be started */ if (cldata[cl].state & A_START) { cldata[cl].state ^= A_START; DebugLog((ALOG_DIO, 0, "next_io(#%d, %x): Starting again", cl, last)); last = NULL; /* start from beginning */ } /* fourth, find next instance to be ran */ if (last == NULL) { cldata[cl].instance = instances; cldata[cl].ileft = 0; } else cldata[cl].instance = last->nexti; while (cldata[cl].instance) { int cm; if (CheckBit(cldata[cl].idone, cldata[cl].instance->in)) { DebugLog((ALOG_DIO, 0, "conf_match(#%d, %x, goth=%d, noh=%d) skipped %x (%s)", cl, last, (cldata[cl].state & A_GOTH) == A_GOTH, (cldata[cl].state & A_NOH) == A_NOH, cldata[cl].instance, cldata[cl].instance->mod->name)); cldata[cl].instance = cldata[cl].instance->nexti; continue; } cm = conf_match(cl, cldata[cl].instance); DebugLog((ALOG_DIO, 0, "conf_match(#%d, %x, goth=%d, noh=%d) said \"%s\" for %x (%s)", cl, last, (cldata[cl].state & A_GOTH) == A_GOTH, (cldata[cl].state & A_NOH) == A_NOH, (cm==-1) ? "no match" : (cm==0) ? "match" : "try again", cldata[cl].instance, cldata[cl].instance->mod->name)); if (cm == 0) break; if (cm == -1) SetBit(cldata[cl].idone, cldata[cl].instance->in); else /* cm == 1 */ cldata[cl].ileft += 1; cldata[cl].instance = cldata[cl].instance->nexti; } if (cldata[cl].instance == NULL) /* fifth, when there's no instance to try.. */ { DebugLog((ALOG_DIO, 0, "next_io(#%d, %x): no more instances to try (%d)", cl, last, cldata[cl].ileft)); if (cldata[cl].ileft == 0) { /* we are done */ sendto_ircd("D %d %s %u ", cl, cldata[cl].itsip, cldata[cl].itsport); cldata[cl].state |= A_DONE; free(cldata[cl].inbuffer); cldata[cl].inbuffer = NULL; } return; } else /* sixth, we've got an instance to try */ { int r; if (cldata[cl].instance->delayed && !(cldata[cl].state & A_DELAYEDSENT)) { /* fake to ircd that we're done */ sendto_ircd("D %d %s %u ", cl, cldata[cl].itsip, cldata[cl].itsport); cldata[cl].state |= A_DELAYEDSENT; } cldata[cl].timeout = time(NULL) + cldata[cl].instance->timeout; r = cldata[cl].instance->mod->start(cl); DebugLog((ALOG_DIO, 0, "next_io(#%d, %x): %s->start() returned %d", cl, last, cldata[cl].instance->mod->name, r)); if (r != 1) /* started, or nothing to do or failed: don't try again */ SetBit(cldata[cl].idone, cldata[cl].instance->in); if (r == 1) cldata[cl].ileft += 1; if (r != 0) /* start() didn't start something */ next_io(cl, cldata[cl].instance); } } /* * parse_ircd * * parses data coming from ircd (doh ;-) */ static void parse_ircd(void) { char *ch, *chp, *buf = iobuf; int cl = -1, ncl; iobuf[iob_len] = '\0'; while ((ch = index(buf, '\n'))) { *ch = '\0'; DebugLog((ALOG_DSPY, 0, "parse_ircd(): got [%s]", buf)); cl = atoi(chp = buf); if (cl >= MAXCONNECTIONS) { sendto_log(ALOG_IRCD, LOG_CRIT, "Recompile iauth, (fatal %d>=%d)", cl, MAXCONNECTIONS); exit(1); } while (*chp++ != ' '); switch (chp[0]) { case 'C': /* new connection */ case 'O': /* old connection: do nothing, just update data */ if (cldata[cl].state & A_ACTIVE) { /* this is not supposed to happen!!! */ sendto_log(ALOG_IRCD, LOG_CRIT, "Entry %d [%c] is already active (fatal)!", cl, chp[0]); exit(1); } if (cldata[cl].instance || cldata[cl].rfd > 0 || cldata[cl].wfd > 0) { sendto_log(ALOG_IRCD, LOG_CRIT, "Entry %d [%c] is already active! (fatal)", cl, chp[0]); exit(1); } if (cldata[cl].authuser) { /* shouldn't be here - hmmpf */ sendto_log(ALOG_IRCD|ALOG_DIO, LOG_WARNING, "Unreleased data [%c %d]!", chp[0], cl); free(cldata[cl].authuser); cldata[cl].authuser = NULL; } if (cldata[cl].inbuffer) { /* shouldn't be here - hmmpf */ sendto_log(ALOG_IRCD|ALOG_DIO, LOG_WARNING, "Unreleased buffer [%c %d]!", chp[0], cl); free(cldata[cl].inbuffer); cldata[cl].inbuffer = NULL; } cldata[cl].user[0] = '\0'; cldata[cl].passwd[0] = '\0'; cldata[cl].host[0] = '\0'; bzero(cldata[cl].idone, BDSIZE); cldata[cl].buflen = 0; if (chp[0] == 'C') cldata[cl].state = A_ACTIVE; else { cldata[cl].state = A_ACTIVE|A_IGNORE; break; } if (sscanf(chp+2, "%[^ ] %hu %[^ ] %hu", cldata[cl].itsip, &cldata[cl].itsport, cldata[cl].ourip, &cldata[cl].ourport) != 4) { sendto_log(ALOG_IRCD, LOG_CRIT, "Bad data from ircd [%s] (fatal)", chp); exit(1); } /* we should really be using a pool of buffer here */ cldata[cl].inbuffer = malloc(INBUFSIZE+1); if (cl > cl_highest) cl_highest = cl; next_io(cl, NULL); /* get started */ break; case 'D': /* client disconnect */ if (!(cldata[cl].state & A_ACTIVE)) /* ** this is not fatal, it happens with servers ** we connected to (and more?). ** It's better/safer to ignore here rather ** than try to filter in ircd. -kalt */ sendto_log(ALOG_IRCD, LOG_WARNING, "Warning: Entry %d [D] is not active.", cl); cldata[cl].state = 0; if (cldata[cl].rfd > 0 || cldata[cl].wfd > 0) cldata[cl].instance->mod->clean(cl); cldata[cl].instance = NULL; /* log something here? hmmpf */ if (cldata[cl].authuser) free(cldata[cl].authuser); cldata[cl].authuser = NULL; if (cldata[cl].inbuffer) free(cldata[cl].inbuffer); cldata[cl].inbuffer = NULL; break; case 'R': /* fd remap */ if (!(cldata[cl].state & A_ACTIVE)) { /* this should really not happen */ sendto_log(ALOG_IRCD, LOG_CRIT, "Entry %d [R] is not active!", cl); break; } ncl = atoi(chp+2); if (cldata[ncl].state & A_ACTIVE) { /* this is not supposed to happen!!! */ sendto_log(ALOG_IRCD, LOG_CRIT, "Entry %d [R] is already active (fatal)!", ncl); exit(1); } if (cldata[ncl].instance || cldata[ncl].rfd > 0 || cldata[ncl].wfd > 0) { sendto_log(ALOG_IRCD, LOG_CRIT, "Entry %d is already active! (fatal)", ncl); exit(1); } if (cldata[ncl].authuser) { /* shouldn't be here - hmmpf */ sendto_log(ALOG_IRCD|ALOG_DIO, LOG_WARNING, "Unreleased data [%d]!", ncl); free(cldata[ncl].authuser); cldata[ncl].authuser = NULL; } if (cldata[ncl].inbuffer) { /* shouldn't be here - hmmpf */ sendto_log(ALOG_IRCD|ALOG_DIO, LOG_WARNING, "Unreleased buffer [%c %d]!", chp[0], ncl); free(cldata[ncl].inbuffer); cldata[ncl].inbuffer = NULL; } bcopy(cldata+cl, cldata+ncl, sizeof(anAuthData)); cldata[cl].state = 0; cldata[cl].rfd = cldata[cl].wfd = 0; cldata[cl].instance = NULL; cldata[cl].authuser = NULL; cldata[cl].inbuffer = NULL; /* ** this is the ugly part of having a slave (considering ** that ircd remaps fd's: there is lag between the ** server and the slave. ** I can't think of any better way to handle this at ** the moment -kalt */ if (cldata[ncl].state & A_IGNORE) break; if (cldata[ncl].state & A_LATE) /* pointless 99.9% of the time */ break; if (cldata[ncl].authuser) sendto_ircd("%c %d %s %u %s", (cldata[ncl].state&A_UNIX)?'U':'u', ncl, cldata[ncl].itsip, cldata[ncl].itsport, cldata[ncl].authuser); if (cldata[ncl].state & A_DENY) sendto_ircd("K %d %s %u ", ncl, cldata[ncl].itsip, cldata[ncl].itsport, cldata[ncl].authuser); if (cldata[ncl].state & A_DONE) sendto_ircd("D %d %s %u ", ncl, cldata[ncl].itsip, cldata[ncl].itsport, cldata[ncl].authuser); break; case 'N': /* hostname */ if (!(cldata[cl].state & A_ACTIVE)) { /* let's be conservative and just ignore */ sendto_log(ALOG_IRCD, LOG_WARNING, "Warning: Entry %d [N] is not active.", cl); break; } if (cldata[cl].state & A_IGNORE) break; strcpy(cldata[cl].host, chp+2); cldata[cl].state |= A_GOTH|A_START; if (cldata[cl].instance == NULL) next_io(cl, NULL); break; case 'A': /* host alias */ if (!(cldata[cl].state & A_ACTIVE)) { /* let's be conservative and just ignore */ sendto_log(ALOG_IRCD, LOG_WARNING, "Warning: Entry %d [A] is not active.", cl); break; } if (cldata[cl].state & A_IGNORE) break; /* hmmpf */ break; case 'U': /* user provided username */ if (!(cldata[cl].state & A_ACTIVE)) { /* let's be conservative and just ignore */ sendto_log(ALOG_IRCD, LOG_WARNING, "Warning: Entry %d [U] is not active.", cl); break; } if (cldata[cl].state & A_IGNORE) break; strcpy(cldata[cl].user, chp+2); cldata[cl].state |= A_GOTU|A_START; if (cldata[cl].instance == NULL) next_io(cl, NULL); break; case 'P': /* user provided password */ if (!(cldata[cl].state & A_ACTIVE)) { /* let's be conservative and just ignore */ sendto_log(ALOG_IRCD, LOG_WARNING, "Warning: Entry %d [P] is not active.", cl); break; } if (cldata[cl].state & A_IGNORE) break; strcpy(cldata[cl].passwd, chp+2); cldata[cl].state |= A_GOTP; /* ** U message will follow immediately, ** no need to do any thing else here */ break; case 'T': /* ircd is registering the client */ /* what to do with this? abort/continue? */ cldata[cl].state |= A_LATE; break; case 'd': /* DNS timeout */ case 'n': /* No hostname information, but no timeout either */ if (!(cldata[cl].state & A_ACTIVE)) { /* let's be conservative and just ignore */ sendto_log(ALOG_IRCD, LOG_WARNING, "Warning: Entry %d [%c] is not active.", cl, chp[0]); break; } cldata[cl].state |= A_NOH|A_START; if (cldata[cl].instance == NULL) next_io(cl, NULL); break; case 'E': /* error message from ircd */ sendto_log(ALOG_DIRCD, LOG_DEBUG, "Error from ircd: %s", chp); break; case 'M': /* RPL_HELLO to be exact, but who cares. */ strConnLen = sprintf(strConn, ":%s 020 * :", chp+2); break; default: sendto_log(ALOG_IRCD, LOG_ERR, "Unexpected data [%s]", chp); break; } buf = ch+1; } rb_len = 0; iob_len = 0; if (strlen(buf)) bcopy(buf, rbuf, rb_len = strlen(buf)); } /* * loop_io * * select()/poll() loop */ void loop_io(void) { /* the following is from ircd/s_bsd.c */ #if !defined(USE_POLL) # define SET_READ_EVENT( thisfd ) FD_SET( thisfd, &read_set) # define SET_WRITE_EVENT( thisfd ) FD_SET( thisfd, &write_set) # define CLR_READ_EVENT( thisfd ) FD_CLR( thisfd, &read_set) # define CLR_WRITE_EVENT( thisfd ) FD_CLR( thisfd, &write_set) # define TST_READ_EVENT( thisfd ) FD_ISSET( thisfd, &read_set) # define TST_WRITE_EVENT( thisfd ) FD_ISSET( thisfd, &write_set) fd_set read_set, write_set; int highfd = -1; #else /* most of the following use pfd */ # define POLLSETREADFLAGS (POLLIN|POLLRDNORM) # define POLLREADFLAGS (POLLSETREADFLAGS|POLLHUP|POLLERR) # define POLLSETWRITEFLAGS (POLLOUT|POLLWRNORM) # define POLLWRITEFLAGS (POLLOUT|POLLWRNORM|POLLHUP|POLLERR) # define SET_READ_EVENT( thisfd ){ CHECK_PFD( thisfd );\ pfd->events |= POLLSETREADFLAGS;} # define SET_WRITE_EVENT( thisfd ){ CHECK_PFD( thisfd );\ pfd->events |= POLLSETWRITEFLAGS;} # define CLR_READ_EVENT( thisfd ) pfd->revents &= ~POLLSETREADFLAGS # define CLR_WRITE_EVENT( thisfd ) pfd->revents &= ~POLLSETWRITEFLAGS # define TST_READ_EVENT( thisfd ) pfd->revents & POLLREADFLAGS # define TST_WRITE_EVENT( thisfd ) pfd->revents & POLLWRITEFLAGS # define CHECK_PFD( thisfd ) \ if ( pfd->fd != thisfd ) { \ pfd = &poll_fdarray[nbr_pfds++];\ pfd->fd = thisfd; \ pfd->events = 0; \ } struct pollfd poll_fdarray[MAXCONNECTIONS]; struct pollfd * pfd = poll_fdarray; int nbr_pfds = 0; #endif int i, nfds = 0; struct timeval wait; time_t now = time(NULL); #if !defined(USE_POLL) FD_ZERO(&read_set); FD_ZERO(&write_set); highfd = 0; #else /* set up such that CHECK_FD works */ nbr_pfds = 0; pfd = poll_fdarray; pfd->fd = -1; #endif /* USE_POLL */ SET_READ_EVENT(0); nfds = 1; /* ircd stream */ #if defined(USE_POLL) && defined(IAUTH_DEBUG) for (i = 0; i < MAXCONNECTIONS; i++) fd2cl[i] = -1; /* sanity */ #endif for (i = 0; i <= cl_highest; i++) { if (cldata[i].timeout && cldata[i].timeout < now && cldata[i].instance /* shouldn't be needed.. but it is */) { DebugLog((ALOG_DIO, 0, "io_loop(): module %s timeout [%d]", cldata[i].instance->mod->name, i)); if (cldata[i].instance->mod->timeout(i) != 0) next_io(i, cldata[i].instance); } if (cldata[i].rfd > 0) { SET_READ_EVENT(cldata[i].rfd); #if !defined(USE_POLL) if (cldata[i].rfd > highfd) highfd = cldata[i].rfd; #else fd2cl[cldata[i].rfd] = i; #endif nfds++; } else if (cldata[i].wfd > 0) { SET_WRITE_EVENT(cldata[i].wfd); #if !defined(USE_POLL) if (cldata[i].wfd > highfd) highfd = cldata[i].wfd; #else fd2cl[cldata[i].wfd] = i; #endif nfds++; } } DebugLog((ALOG_DIO, 0, "io_loop(): checking for %d fd's", nfds)); wait.tv_sec = 5; wait.tv_usec = 0; #if !defined(USE_POLL) nfds = select(highfd + 1, (SELECT_FDSET_TYPE *)&read_set, (SELECT_FDSET_TYPE *)&write_set, 0, &wait); DebugLog((ALOG_DIO, 0, "io_loop(): select() returned %d, errno = %d", nfds, errno)); #else nfds = poll(poll_fdarray, nbr_pfds, wait.tv_sec * 1000 + wait.tv_usec/1000 ); DebugLog((ALOG_DIO, 0, "io_loop(): poll() returned %d, errno = %d", nfds, errno)); pfd = poll_fdarray; #endif if (nfds == -1) { if (errno == EINTR) { return; } else { sendto_log(ALOG_IRCD, LOG_CRIT, "fatal select/poll error: %s", strerror(errno)); exit(1); } } if (nfds == 0) /* end of timeout */ return; /* no matter select() or poll() this is also fd # 0 */ if (TST_READ_EVENT(0)) nfds--; #if !defined(USE_POLL) for (i = 0; i <= cl_highest && nfds; i++) #else for (pfd = poll_fdarray+1; pfd != poll_fdarray+nbr_pfds && nfds; pfd++) #endif { #if defined(USE_POLL) i = fd2cl[pfd->fd]; # if defined(IAUTH_DEBUG) if (i == -1) { sendto_log(ALOG_DALL, LOG_CRIT,"io_loop(): fatal bug"); exit(1); } # endif #endif if (cldata[i].rfd <= 0 && cldata[i].wfd <= 0) { #if defined(USE_POLL) sendto_log(ALOG_IRCD, LOG_CRIT, "io_loop(): fatal data inconsistency #%d (%d, %d)", i, cldata[i].rfd, cldata[i].wfd); exit(1); #else continue; #endif } if (cldata[i].rfd > 0 && TST_READ_EVENT(cldata[i].rfd)) { int len; len = recv(cldata[i].rfd, cldata[i].inbuffer + cldata[i].buflen, INBUFSIZE - cldata[i].buflen, 0); DebugLog((ALOG_DIO, 0, "io_loop(): i = #%d: recv(%d) returned %d, errno = %d", i, cldata[i].rfd, len, errno)); if (len < 0) { cldata[i].instance->mod->clean(i); next_io(i, cldata[i].instance); } else { cldata[i].buflen += len; if (cldata[i].instance->mod->work(i) != 0) next_io(i, cldata[i].instance); else if (len == 0) { cldata[i].instance->mod->clean(i); next_io(i, cldata[i].instance); } } nfds--; } else if (cldata[i].wfd > 0 && TST_WRITE_EVENT(cldata[i].wfd)) { if (cldata[i].instance->mod->work(i) != 0) next_io(i, cldata[i].instance); nfds--; } } /* ** no matter select() or poll() this is also fd # 0 ** this has to be done last (for the USE_POLL version) because ** of R messages we may get from the server :/ */ #if defined(USE_POLL) pfd = poll_fdarray; #endif if (TST_READ_EVENT(0)) { /* data from the ircd.. */ while (1) { if (rb_len) bcopy(rbuf, iobuf, iob_len = rb_len); if ((i=recv(0,iobuf+iob_len,IOBUFSIZE-iob_len,0)) <= 0) { DebugLog((ALOG_DIO, 0, "io_loop(): recv(0) returned %d, errno = %d", i, errno)); break; } iob_len += i; DebugLog((ALOG_DIO, 0, "io_loop(): got %d bytes from ircd [%d]", i, iob_len)); parse_ircd(); } if (i == 0) { sendto_log(ALOG_DMISC, LOG_NOTICE, "Daemon exiting. [r]"); exit(0); } } #if 0 /* stupid code that tries to find a bug, but does nothing --Q */ #if defined(IAUTH_DEBUG) if (nfds > 0) sendto_log(ALOG_DIO, 0, "io_loop(): nfds = %d !!!", nfds); # if !defined(USE_POLL) /* the equivalent should be written for poll() */ if (nfds == 0) while (i <= cl_highest) { /* Q got core here, he had i=-1 */ if (cldata[i].rfd > 0 && TST_READ_EVENT(cldata[i].rfd)) { /* this should not happen! */ /* hmmpf */ } i++; } # endif #endif #endif } /* * set_non_blocking (ripped from ircd/s_bsd.c) */ static void set_non_blocking(int fd, char *ip, u_short port) { int res, nonb = 0; #ifdef NBLOCK_POSIX nonb |= O_NONBLOCK; #endif #ifdef NBLOCK_BSD nonb |= O_NDELAY; #endif #ifdef NBLOCK_SYSV /* This portion of code might also apply to NeXT. -LynX */ res = 1; if (ioctl (fd, FIONBIO, &res) < 0) sendto_log(ALOG_IRCD, 0, "ioctl(fd,FIONBIO) failed for %s:%u", ip, port); #else if ((res = fcntl(fd, F_GETFL, 0)) == -1) sendto_log(ALOG_IRCD, 0, "fcntl(fd, F_GETFL) failed for %s:%u", ip, port); else if (fcntl(fd, F_SETFL, res | nonb) == -1) sendto_log(ALOG_IRCD, 0, "fcntl(fd, F_SETL, nonb) failed for %s:%u", ip, port); #endif } /* * tcp_connect * * utility function for use in modules, creates a socket and connects * it to an IP/port * * Returns the fd */ int tcp_connect(char *ourIP, char *theirIP, u_short port, char **error) { int fd; static char errbuf[BUFSIZ]; struct SOCKADDR_IN sk; fd = socket(AFINET, SOCK_STREAM, 0); if (fd < 0) { sprintf(errbuf, "socket() failed: %s", strerror(errno)); *error = errbuf; return -1; } /* * this bzero() shouldn't be needed.. should it? * AIX 4.1.5 doesn't like not having it tho.. I have no clue why -kalt */ bzero((char *)&sk, sizeof(sk)); sk.SIN_FAMILY = AFINET; #if defined(INET6) if(!inetpton(AF_INET6, ourIP, sk.sin6_addr.s6_addr)) bcopy(minus_one, sk.sin6_addr.s6_addr, IN6ADDRSZ); #else sk.sin_addr.s_addr = inetaddr(ourIP); #endif sk.SIN_PORT = htons(0); if (bind(fd, (SAP)&sk, sizeof(sk)) < 0) { sprintf(errbuf, "bind() failed: %s", strerror(errno)); *error = errbuf; close(fd); return -1; } set_non_blocking(fd, theirIP, port); #if defined(INET6) if(!inetpton(AF_INET6, theirIP, sk.sin6_addr.s6_addr)) bcopy(minus_one, sk.sin6_addr.s6_addr, IN6ADDRSZ); #else sk.sin_addr.s_addr = inetaddr(theirIP); #endif sk.SIN_PORT = htons(port); if (connect(fd, (SAP)&sk, sizeof(sk)) < 0 && errno != EINPROGRESS) { sprintf(errbuf, "connect() to %s %u failed: %s", theirIP, port, strerror(errno)); *error = errbuf; close(fd); return -1; } *error = NULL; return fd; } irc2.11.2p3/iauth/a_defines.h0000644000175000017500000000261210127401061013525 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/a_defines.h * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file includes all files defining constants, macros and types definitions used by the authentication process. */ #undef IAUTH_DEBUG #include "config.h" #include "patchlevel.h" #include "dbuf_def.h" /* needed for struct_def.h, sigh */ #include "class_def.h" /* needed for struct_def.h, sigh */ #include "struct_def.h" #ifdef INET6 # include "../ircd/nameser_def.h" #endif #include "support_def.h" #include "common_def.h" /* for isdigit, isalpha etc. */ #include "a_conf_def.h" #include "a_struct_def.h" #include "a_log_def.h" irc2.11.2p3/iauth/mod_rfc931_ext.h0000644000175000017500000000264707744057365014377 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/mod_rfc931_ext.h * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in iauth/mod_rfc931.c. */ /* External definitions for global variables. */ #ifndef MOD_RFC931_C extern aModule Module_rfc931; #endif /* MOD_RFC931_C */ /* External definitions for global functions. */ #ifndef MOD_RFC931_C # define EXTERN extern #else /* MOD_RFC931_C */ # define EXTERN #endif /* MOD_RFC931_C */ /* EXTERN int rfc931_start (u_int); EXTERN int rfc931_work (u_int); EXTERN int rfc931_timeout (u_int); EXTERN void rfc931_clean (u_int); */ #undef EXTERN irc2.11.2p3/iauth/iauth.c0000644000175000017500000001304510166342133012726 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/iauthd.c * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: iauth.c,v 1.18 2005/01/03 22:16:59 q Exp $"; #endif #include "os.h" #include "a_defines.h" #define IAUTH_C #include "a_externs.h" #undef IAUTH_C static int do_log = 0; static RETSIGTYPE dummy(int s) { /* from common/bsd.c */ #ifndef HAVE_RELIABLE_SIGNALS (void)signal(SIGALRM, dummy); (void)signal(SIGPIPE, dummy); # ifndef HPUX /* Only 9k/800 series require this, but don't know how to.. */ # ifdef SIGWINCH (void)signal(SIGWINCH, dummy); # endif # endif #else # if POSIX_SIGNALS struct sigaction act; act.sa_handler = dummy; act.sa_flags = 0; (void)sigemptyset(&act.sa_mask); (void)sigaddset(&act.sa_mask, SIGALRM); (void)sigaddset(&act.sa_mask, SIGPIPE); # ifdef SIGWINCH (void)sigaddset(&act.sa_mask, SIGWINCH); # endif (void)sigaction(SIGALRM, &act, (struct sigaction *)NULL); (void)sigaction(SIGPIPE, &act, (struct sigaction *)NULL); # ifdef SIGWINCH (void)sigaction(SIGWINCH, &act, (struct sigaction *)NULL); # endif # endif #endif } static RETSIGTYPE s_log(int s) { # if POSIX_SIGNALS struct sigaction act; act.sa_handler = s_log; act.sa_flags = 0; (void)sigemptyset(&act.sa_mask); (void)sigaddset(&act.sa_mask, SIGUSR2); (void)sigaction(SIGUSR2, &act, NULL); # else (void)signal(SIGUSR2, s_log); # endif do_log = 1; } static void init_signals(void) { /* from ircd/ircd.c setup_signals() */ #if POSIX_SIGNALS struct sigaction act; act.sa_handler = SIG_IGN; act.sa_flags = 0; (void)sigemptyset(&act.sa_mask); (void)sigaddset(&act.sa_mask, SIGPIPE); (void)sigaddset(&act.sa_mask, SIGALRM); # ifdef SIGWINCH (void)sigaddset(&act.sa_mask, SIGWINCH); (void)sigaction(SIGWINCH, &act, NULL); # endif (void)sigaction(SIGPIPE, &act, NULL); act.sa_handler = dummy; (void)sigaction(SIGALRM, &act, NULL); /* act.sa_handler = s_rehash; (void)sigemptyset(&act.sa_mask); (void)sigaddset(&act.sa_mask, SIGHUP); (void)sigaction(SIGHUP, &act, NULL); act.sa_handler = s_restart; (void)sigaddset(&act.sa_mask, SIGINT); (void)sigaction(SIGINT, &act, NULL); act.sa_handler = s_die; (void)sigaddset(&act.sa_mask, SIGTERM); (void)sigaction(SIGTERM, &act, NULL); */ act.sa_handler = s_log; (void)sigaddset(&act.sa_mask, SIGUSR2); (void)sigaction(SIGUSR2, &act, NULL); #else # ifndef HAVE_RELIABLE_SIGNALS (void)signal(SIGPIPE, dummy); # ifdef SIGWINCH (void)signal(SIGWINCH, dummy); # endif # else # ifdef SIGWINCH (void)signal(SIGWINCH, SIG_IGN); # endif (void)signal(SIGPIPE, SIG_IGN); # endif (void)signal(SIGALRM, dummy); /* (void)signal(SIGHUP, s_rehash); (void)signal(SIGTERM, s_die); (void)signal(SIGINT, s_restart); */ (void)signal(SIGUSR2, s_log); #endif } void write_pidfile(void) { int fd; char pidbuf[32]; (void) truncate(IAUTHPID_PATH, 0); if (( fd = open(IAUTHPID_PATH, O_CREAT|O_WRONLY, 0600)) >= 0) { memset(pidbuf, '0', sizeof(pidbuf)); (void) sprintf(pidbuf, "%d\n", (int)getpid()); if (write(fd, pidbuf, strlen(pidbuf)) == -1) { (void) printf("Error writing pidfile %s\n", IAUTHPID_PATH); } (void) close(fd); } else { (void) printf("Error opening pidfile %s\n", IAUTHPID_PATH); } return; } int main(int argc, char *argv[]) { time_t nextst = time(NULL) + 90; char *xopt; if (argc == 2 && !strcmp(argv[1], "-X")) exit(0); if (isatty(0)) { (void)printf("iauth %s", make_version()); #if defined(USE_DSM) (void)printf(" (with DSM support)\n"); #else (void)printf("\n"); #endif if (argc == 3 && !strcmp(argv[1], "-c")) { (void)printf("\nReading \"%s\"\n\n", argv[2]); conf_read(argv[2]); } else { #if defined(INET6) (void)printf("\t+INET6\n"); #endif #if defined(IAUTH_DEBUG) (void)printf("\t+IAUTH_DEBUG\n"); #endif #if defined(USE_POLL) (void)printf("\t+USE_POLL\n"); #endif } exit(0); } init_signals(); init_syslog(); xopt = conf_read(NULL); init_filelogs(); sendto_log(ALOG_DMISC, LOG_NOTICE, "Daemon starting (%s%s).", make_version(), #if defined(IAUTH_DEBUG) "+debug" #else "" #endif ); init_io(); sendto_ircd("V %s", make_version()); sendto_ircd("O %s", xopt); conf_ircd(); #if defined(IAUTH_DEBUG) if (debuglevel & ALOG_DIRCD) sendto_ircd("G 1"); else #endif sendto_ircd("G 0"); write_pidfile(); while (1) { loop_io(); if (do_log) { sendto_log(ALOG_IRCD|ALOG_DMISC, LOG_INFO, "Got SIGUSR2, reinitializing log file(s)."); init_filelogs(); do_log = 0; } if (time(NULL) > nextst) { AnInstance *itmp = instances; sendto_ircd("s"); while (itmp) { if (itmp->mod->stats) itmp->mod->stats(itmp); itmp = itmp->nexti; } nextst = time(NULL) + 60; } } } irc2.11.2p3/iauth/mod_pipe_ext.h0000644000175000017500000000213606647002711014300 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/mod_pipe_ext.h * Copyright (C) 1999 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in iauth/mod_pipe.c. */ /* External definitions for global variables. */ #ifndef MOD_PIPE_C extern aModule Module_pipe; #endif /* MOD_PIPE_C */ irc2.11.2p3/iauth/mod_webproxy_ext.h0000644000175000017500000000215410124030004015177 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/mod_webproxy_ext.h * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in iauth/mod_webproxy.c. */ /* External definitions for global variables. */ #ifndef MOD_PROXY_C extern aModule Module_webproxy; #endif /* MOD_PROXY_C */ irc2.11.2p3/iauth/mod_pipe.c0000644000175000017500000001230110466047147013414 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/mod_pipe.c * Copyright (C) 1999 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: mod_pipe.c,v 1.8 2006/08/08 08:42:15 chopin Exp $"; #endif #include "os.h" #include "a_defines.h" #define MOD_PIPE_C #include "a_externs.h" #undef MOD_PIPE_C /* * pipe_init * * This procedure is called when a particular module is loaded. * Returns NULL if everything went fine, * an error message otherwise. */ static char *pipe_init(AnInstance *self) { if (self->opt == NULL) return "Aie! no option(s): nothing to be done!"; if (strncasecmp(self->opt, "prog=", 5)) return "Aie! unknown option(s): nothing to be done!"; self->popt = self->opt + 5; return self->popt; } /* * pipe_release * * This procedure is called when a particular module is unloaded. static void pipe_release(AnInstance *self) { } */ /* * pipe_stats * * This procedure is called regularly to update statistics sent to ircd. static void pipe_stats(AnInstance *self) { } */ /* * pipe_start * * This procedure is called to start an authentication. * Returns 0 if everything went fine, * -1 otherwise (nothing to be done, or failure) * * It is responsible for sending error messages where appropriate. * In case of failure, it's responsible for cleaning up (e.g. pipe_clean * will NOT be called) */ static int pipe_start(u_int cl) { int pp[2], rc; DebugLog((ALOG_DPIPE, 0, "pipe_start(%d): Forking for %s %u", cl, cldata[cl].itsip, cldata[cl].itsport)); if (pipe(pp) == -1) { DebugLog((ALOG_DPIPE, 0, "pipe_start(%d): Error creating pipe: %s", cl, strerror(errno))); return -1; } switch (rc = vfork()) { case -1 : DebugLog((ALOG_DPIPE, 0, "pipe_start(%d): Error forking: %s", cl, strerror(errno))); return -1; case 0 : { char portbuf[6]; /* 5 chars to hold the port number */ (void)close(pp[0]); for (rc = 2; rc < MAXCONNECTIONS; rc++) if (rc != pp[1]) (void)close(rc); if (pp[1] != 2) (void)dup2(pp[1], 2); (void)dup2(2, 1); if (pp[1] != 2 && pp[1] != 1) (void)close(pp[1]); snprintf(portbuf, sizeof(portbuf), "%d", cldata[cl].itsport); (void)execlp(cldata[cl].instance->popt, cldata[cl].instance->popt, cldata[cl].itsip, portbuf, (char *) NULL); _exit(-1); } default : (void)close(pp[1]); break; } cldata[cl].rfd = pp[0]; return 0; } /* * pipe_work * * This procedure is called whenever there's new data in the buffer. * Returns 0 if everything went fine, and there is more work to be done, * Returns -1 if the module has finished its work (and cleaned up). * * It is responsible for sending error messages where appropriate. */ static int pipe_work(u_int cl) { DebugLog((ALOG_DPIPE, 0, "pipe_work(%d): %d %d buflen=%d %c", cl, cldata[cl].rfd, cldata[cl].wfd, cldata[cl].buflen, cldata[cl].inbuffer[0])); switch (cldata[cl].inbuffer[0]) { case 'Y': break; case 'N': cldata[cl].state |= A_DENY; sendto_ircd("K %d %s %u ", cl, cldata[cl].itsip, cldata[cl].itsport); break; #if 0 /* hm.. need deeper mods to ircd */ case 'y': /* restricted connection only */ cldata[cl].state |= A_RESTRICT; sendto_ircd("k %d %s %u ", cl, cldata[cl].itsip, cldata[cl].itsport); break; #endif default : /* error */ sendto_log(ALOG_FLOG|ALOG_IRCD, LOG_WARNING, "pipe: unexpected %c for %s[%s]", cldata[cl].inbuffer[0], cldata[cl].host, cldata[cl].itsip); break; } /* We're done */ close(cldata[cl].rfd); cldata[cl].rfd = 0; return -1; } /* * pipe_clean * * This procedure is called whenever the module should interrupt its work. * It is responsible for cleaning up any allocated data, and in particular * closing file descriptors. */ static void pipe_clean(u_int cl) { DebugLog((ALOG_DPIPE, 0, "pipe_clean(%d): cleaning up", cl)); if (cldata[cl].rfd) close(cldata[cl].rfd); cldata[cl].rfd = 0; } /* * pipe_timeout * * This procedure is called whenever the timeout set by the module is * reached. * * Returns 0 if things are okay, -1 if authentication was aborted. */ static int pipe_timeout(u_int cl) { DebugLog((ALOG_DPIPE, 0, "pipe_timeout(%d): calling pipe_clean ", cl)); pipe_clean(cl); return -1; } aModule Module_pipe = { "pipe", pipe_init, NULL, NULL, pipe_start, pipe_work, pipe_timeout, pipe_clean }; irc2.11.2p3/iauth/a_log_ext.h0000644000175000017500000000257707744046162013605 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, iauth/a_log_ext.h * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in iauth/a_log.c. */ /* External definitions for global variables. */ #ifndef A_LOG_C #endif /* A_LOG_C */ /* External definitions for global functions. */ #ifndef A_LOG_C # define EXTERN extern #else /* A_LOG_C */ # define EXTERN #endif /* A_LOG_C */ EXTERN void init_filelogs(void); EXTERN void init_syslog(void); EXTERN void vsendto_log (int, int, char *, va_list); EXTERN void sendto_log (int, int, char *, ...); #undef EXTERN irc2.11.2p3/ircd/0000755000175000017500000000000011431325174011256 5ustar kkkkirc2.11.2p3/ircd/res_init.c0000644000175000017500000004711010166342134013240 0ustar kkkk/* * ++Copyright++ 1985, 1989, 1993 * - * Copyright (c) 1985, 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Portions Copyright (c) 1993 by Digital Equipment Corporation. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies, and that * the name of Digital Equipment Corporation not be used in advertising or * publicity pertaining to distribution of the document or software without * specific, written prior permission. * * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * - * --Copyright-- */ #if defined(LIBC_SCCS) && !defined(lint) static const volatile char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93"; static const volatile char rcsid[] = "$Id: res_init.c,v 1.16 2005/01/03 22:17:00 q Exp $"; #endif /* LIBC_SCCS and not lint */ #include "os.h" #include "s_defines.h" #define RES_INIT_C #include "s_externs.h" #undef RES_INIT_C /*-------------------------------------- info about "sortlist" -------------- * Marc Majka 1994/04/16 * Allan Nathanson 1994/10/29 (BIND 4.9.3.x) * * NetInfo resolver configuration directory support. * * Allow a NetInfo directory to be created in the hierarchy which * contains the same information as the resolver configuration file. * * - The local domain name is stored as the value of the "domain" property. * - The Internet address(es) of the name server(s) are stored as values * of the "nameserver" property. * - The name server addresses are stored as values of the "nameserver" * property. * - The search list for host-name lookup is stored as values of the * "search" property. * - The sortlist comprised of IP address netmask pairs are stored as * values of the "sortlist" property. The IP address and optional netmask * should be seperated by a slash (/) or ampersand (&) character. * - Internal resolver variables can be set from the value of the "options" * property. */ #if defined(NEXT) # define NI_PATH_RESCONF "/locations/resolver" # define NI_TIMEOUT 10 static int ircd_netinfo_res_init (int *haveenv, int *havesearch); #endif static void ircd_res_setoptions (char *, char *); #ifdef RESOLVSORT static const char sort_mask[] = "/&"; #define ISSORTMASK(ch) (strchr(sort_mask, ch) != NULL) #ifdef INET6 static u_int32_t ircd_net_mask (struct in_addr); #else static u_int32_t ircd_net_mask (struct in_addr); #endif #endif #if !defined(isascii) /* XXX - could be a function */ # define isascii(c) (!(c & 0200)) #endif /* * Resolver state default settings. */ struct __res_state ircd_res # if defined(__BIND_RES_TEXT) = { RES_TIMEOUT, } /* Motorola, et al. */ # endif ; /* * Set up default settings. If the configuration file exist, the values * there will have precedence. Otherwise, the server address is set to * INADDR_ANY and the default domain name comes from the gethostname(). * * An interrim version of this code (BIND 4.9, pre-4.4BSD) used 127.0.0.1 * rather than INADDR_ANY ("0.0.0.0") as the default name server address * since it was noted that INADDR_ANY actually meant ``the first interface * you "ifconfig"'d at boot time'' and if this was a SLIP or PPP interface, * it had to be "up" in order for you to reach your own name server. It * was later decided that since the recommended practice is to always * install local static routes through 127.0.0.1 for all your network * interfaces, that we could solve this problem without a code change. * * The configuration file should always be used, since it is the only way * to specify a default domain. If you are running a server on your local * machine, you should say "nameserver 0.0.0.0" or "nameserver 127.0.0.1" * in the configuration file. * * Return 0 if completes successfully, -1 on error */ int ircd_res_init(void) { register FILE *fp; register char *cp, **pp; register int n; char buf[MAXDNAME]; int nserv = 0; /* number of nameserver records read from file */ int haveenv = 0; int havesearch = 0; #ifdef RESOLVSORT int nsort = 0; char *net; #endif #ifndef RFC1535 int dots; #endif /* * These three fields used to be statically initialized. This made * it hard to use this code in a shared library. It is necessary, * now that we're doing dynamic initialization here, that we preserve * the old semantics: if an application modifies one of these three * fields of _res before res_init() is called, res_init() will not * alter them. Of course, if an application is setting them to * _zero_ before calling res_init(), hoping to override what used * to be the static default, we can't detect it and unexpected results * will follow. Zero for any of these fields would make no sense, * so one can safely assume that the applications were already getting * unexpected results. * * _res.options is tricky since some apps were known to diddle the bits * before res_init() was first called. We can't replicate that semantic * with dynamic initialization (they may have turned bits off that are * set in RES_DEFAULT). Our solution is to declare such applications * "broken". They could fool us by setting RES_INIT but none do (yet). */ if (!ircd_res.retrans) ircd_res.retrans = RES_TIMEOUT; if (!ircd_res.retry) ircd_res.retry = 4; if (!(ircd_res.options & RES_INIT)) ircd_res.options = RES_DEFAULT; /* * This one used to initialize implicitly to zero, so unless the app * has set it to something in particular, we can randomize it now. */ if (!ircd_res.id) ircd_res.id = ircd_res_randomid(); #ifdef INET6 # ifdef USELOOPBACK ircd_res.nsaddr.sin6_addr = in6addr_loopback; # else ircd_res.nsaddr.sin6_addr = in6addr_any; # endif #else # ifdef USELOOPBACK ircd_res.nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1); # else ircd_res.nsaddr.sin_addr.s_addr = INADDR_ANY; # endif #endif /* INET6 */ ircd_res.nsaddr.SIN_FAMILY = AFINET; ircd_res.nsaddr.SIN_PORT = htons(NAMESERVER_PORT); ircd_res.nscount = 1; ircd_res.ndots = 1; ircd_res.pfcode = 0; /* Allow user to override the local domain definition */ if ((cp = getenv("LOCALDOMAIN")) != NULL) { strncpyzt(ircd_res.defdname, cp, sizeof(ircd_res.defdname)); haveenv++; /* * Set search list to be blank-separated strings * from rest of env value. Permits users of LOCALDOMAIN * to still have a search list, and anyone to set the * one that they want to use as an individual (even more * important now that the rfc1535 stuff restricts searches) */ cp = ircd_res.defdname; pp = ircd_res.dnsrch; *pp++ = cp; for (n = 0; *cp && pp < ircd_res.dnsrch + MAXDNSRCH; cp++) { if (*cp == '\n') /* silly backwards compat */ break; else if (*cp == ' ' || *cp == '\t') { *cp = 0; n = 1; } else if (n) { *pp++ = cp; n = 0; havesearch = 1; } } /* null terminate last domain if there are excess */ while (*cp != '\0' && *cp != ' ' && *cp != '\t' && *cp != '\n') cp++; *cp = '\0'; *pp++ = 0; } #define MATCH(line, name) \ (!strncmp(line, name, sizeof(name) - 1) && \ (line[sizeof(name) - 1] == ' ' || \ line[sizeof(name) - 1] == '\t')) #ifdef NEXT if (ircd_netinfo_res_init(&haveenv, &havesearch) == 0) #endif if ((fp = fopen(IRC_RESCONF, "r")) != NULL) { /* read the config file */ while (fgets(buf, sizeof(buf), fp) != NULL) { /* skip comments */ if (*buf == ';' || *buf == '#') continue; /* read default domain name */ if (MATCH(buf, "domain")) { if (haveenv) /* skip if have from environ */ continue; cp = buf + sizeof("domain") - 1; while (*cp == ' ' || *cp == '\t') cp++; if ((*cp == '\0') || (*cp == '\n')) continue; strncpyzt(ircd_res.defdname, cp, sizeof(ircd_res.defdname)); if ((cp = strpbrk(ircd_res.defdname, " \t\n")) != NULL) *cp = '\0'; havesearch = 0; continue; } /* set search list */ if (MATCH(buf, "search")) { if (haveenv) /* skip if have from environ */ continue; cp = buf + sizeof("search") - 1; while (*cp == ' ' || *cp == '\t') cp++; if ((*cp == '\0') || (*cp == '\n')) continue; strncpyzt(ircd_res.defdname, cp, sizeof(ircd_res.defdname)); if ((cp = strchr(ircd_res.defdname, '\n')) != NULL) *cp = '\0'; /* * Set search list to be blank-separated strings * on rest of line. */ cp = ircd_res.defdname; pp = ircd_res.dnsrch; *pp++ = cp; for (n = 0; *cp && pp < ircd_res.dnsrch + MAXDNSRCH; cp++) { if (*cp == ' ' || *cp == '\t') { *cp = 0; n = 1; } else if (n) { *pp++ = cp; n = 0; } } /* null terminate last domain if there are excess */ while (*cp != '\0' && *cp != ' ' && *cp != '\t') cp++; *cp = '\0'; *pp++ = 0; havesearch = 1; continue; } /* read nameservers to query */ if (MATCH(buf, "nameserver") && nserv < MAXNS) { struct IN_ADDR a; char *tmp; cp = buf + sizeof("nameserver") - 1; while (*cp == ' ' || *cp == '\t') cp++; if ((*cp == '\0') || (*cp == '\n')) continue; /* strip ending \n or inetpton fails */ if ((tmp=index(cp, '\n')) || (tmp=index(cp, '\r'))) *tmp = '\0'; if ( #ifdef INET6 inetpton(AF_INET6, cp, a.s6_addr) #else inetaton(cp, &a) #endif ) { ircd_res.nsaddr_list[nserv].SIN_ADDR = a; ircd_res.nsaddr_list[nserv].SIN_FAMILY = AFINET; ircd_res.nsaddr_list[nserv].SIN_PORT = htons(NAMESERVER_PORT); nserv++; } continue; } #ifdef RESOLVSORT #ifdef INET6 #error No support for RESOLVSORT and INET6 #endif if (MATCH(buf, "sortlist")) { struct in_addr a; cp = buf + sizeof("sortlist") - 1; while (nsort < MAXRESOLVSORT) { while (*cp == ' ' || *cp == '\t') cp++; if (*cp == '\0' || *cp == '\n' || *cp == ';') break; net = cp; while (*cp && !ISSORTMASK(*cp) && *cp != ';' && isascii(*cp) && !isspace(*cp)) cp++; n = *cp; *cp = 0; if (inetaton(net, &a)) { ircd_res.sort_list[nsort].addr = a; if (ISSORTMASK(n)) { *cp++ = n; net = cp; while (*cp && *cp != ';' && isascii(*cp) && !isspace(*cp)) cp++; n = *cp; *cp = 0; if (inetaton(net, &a)) { ircd_res.sort_list[nsort].mask = a.s_addr; } else { ircd_res.sort_list[nsort].mask = ircd_net_mask(ircd_res.sort_list[nsort].addr); } } else { ircd_res.sort_list[nsort].mask = ircd_net_mask(ircd_res.sort_list[nsort].addr); } nsort++; } *cp = n; } continue; } #endif if (MATCH(buf, "options")) { ircd_res_setoptions(buf + sizeof("options") - 1, "conf"); continue; } } if (nserv > 1) ircd_res.nscount = nserv; #ifdef RESOLVSORT ircd_res.nsort = nsort; #endif (void) fclose(fp); } if (ircd_res.defdname[0] == 0 && gethostname(buf, sizeof(ircd_res.defdname) - 1) == 0 && (cp = strchr(buf, '.')) != NULL) strcpy(ircd_res.defdname, cp + 1); /* find components of local domain that might be searched */ if (havesearch == 0) { pp = ircd_res.dnsrch; *pp++ = ircd_res.defdname; *pp = NULL; #ifndef RFC1535 dots = 0; for (cp = ircd_res.defdname; *cp; cp++) dots += (*cp == '.'); cp = ircd_res.defdname; while (pp < ircd_res.dnsrch + MAXDFLSRCH) { if (dots < LOCALDOMAINPARTS) break; cp = strchr(cp, '.') + 1; /* we know there is one */ *pp++ = cp; dots--; } *pp = NULL; #ifdef DEBUG if (ircd_res.options & RES_DEBUG) { printf(";; res_init()... default dnsrch list:\n"); for (pp = ircd_res.dnsrch; *pp; pp++) printf(";;\t%s\n", *pp); printf(";;\t..END..\n"); } #endif /* DEBUG */ #endif /* !RFC1535 */ } if ((cp = getenv("RES_OPTIONS")) != NULL) ircd_res_setoptions(cp, "env"); ircd_res.options |= RES_INIT; return (0); } static void ircd_res_setoptions(char *options, char *source) { char *cp = options; int i; #ifdef DEBUG if (ircd_res.options & RES_DEBUG) printf(";; ircd_res_setoptions(\"%s\", \"%s\")...\n", options, source); #endif while (*cp) { /* skip leading and inner runs of spaces */ while (*cp == ' ' || *cp == '\t') cp++; /* search for and process individual options */ if (!strncmp(cp, "ndots:", sizeof("ndots:") - 1)) { i = atoi(cp + sizeof("ndots:") - 1); if (i <= RES_MAXNDOTS) ircd_res.ndots = i; else ircd_res.ndots = RES_MAXNDOTS; #ifdef DEBUG if (ircd_res.options & RES_DEBUG) printf(";;\tndots=%d\n", ircd_res.ndots); #endif } else if (!strncmp(cp, "debug", sizeof("debug") - 1)) { #ifdef DEBUG if (!(ircd_res.options & RES_DEBUG)) { printf(";; ircd_res_setoptions(\"%s\", \"%s\")..\n", options, source); ircd_res.options |= RES_DEBUG; } printf(";;\tdebug\n"); #endif } else if (!strncmp(cp, "inet6", sizeof("inet6") - 1)) { #ifndef HAVE_GETIPNODEBYNAME ircd_res.options |= RES_USE_INET6; #endif } else { /* XXX - print a warning here? */ } /* skip to next run of spaces */ while (*cp && *cp != ' ' && *cp != '\t') cp++; } } #ifdef RESOLVSORT /* XXX - should really support CIDR which means explicit masks always. */ /* XXX - should really use system's version of this */ static u_int32_t ircd_net_mask(struct in_addr in) { register u_int32_t i = ntohl(in.s_addr); if (IN_CLASSA(i)) return (htonl(IN_CLASSA_NET)); else if (IN_CLASSB(i)) return (htonl(IN_CLASSB_NET)); return (htonl(IN_CLASSC_NET)); } #endif #ifdef NEXT static int ircd_netinfo_res_init(int *haveenv, int *havesearch) { register int n; void *domain, *parent; ni_id dir; ni_status status; ni_namelist nl; int nserv = 0; #ifdef RESOLVSORT int nsort = 0; #endif status = ni_open(NULL, ".", &domain); if (status == NI_OK) { ni_setreadtimeout(domain, NI_TIMEOUT); ni_setabort(domain, 1); /* climb the NetInfo hierarchy to find a resolver directory */ while (status == NI_OK) { status = ni_pathsearch(domain, &dir, NI_PATH_RESCONF); if (status == NI_OK) { /* found a resolver directory */ if (*haveenv == 0) { /* get the default domain name */ status = ni_lookupprop(domain, &dir, "domain", &nl); if (status == NI_OK && nl.ni_namelist_len > 0) { (void)strncpy(ircd_res.defdname, nl.ni_namelist_val[0], sizeof(ircd_res.defdname) - 1); ircd_res.defdname[sizeof(ircd_res.defdname) - 1] = '\0'; ni_namelist_free(&nl); *havesearch = 0; } /* get search list */ status = ni_lookupprop(domain, &dir, "search", &nl); if (status == NI_OK && nl.ni_namelist_len > 0) { (void)strncpy(ircd_res.defdname, nl.ni_namelist_val[0], sizeof(ircd_res.defdname) - 1); ircd_res.defdname[sizeof(ircd_res.defdname) - 1] = '\0'; /* copy */ for (n = 0; n < nl.ni_namelist_len && n < MAXDNSRCH; n++) { /* duplicate up to MAXDNSRCH servers */ char *cp = nl.ni_namelist_val[n]; ircd_res.dnsrch[n] = strcpy((char *)malloc(strlen(cp) + 1), cp); } ni_namelist_free(&nl); *havesearch = 1; } } /* get list of nameservers */ status = ni_lookupprop(domain, &dir, "nameserver", &nl); if (status == NI_OK && nl.ni_namelist_len > 0) { /* copy up to MAXNS servers */ for (n = 0; n < nl.ni_namelist_len && nserv < MAXNS; n++) { struct in_addr a; if (inetaton(nl.ni_namelist_val[n], &a)) { ircd_res.nsaddr_list[nserv].sin_addr = a; ircd_res.nsaddr_list[nserv].sin_family = AF_INET; ircd_res.nsaddr_list[nserv].sin_port = htons(NAMESERVER_PORT); nserv++; } } ni_namelist_free(&nl); } if (nserv > 1) ircd_res.nscount = nserv; #ifdef RESOLVSORT /* get sort order */ status = ni_lookupprop(domain, &dir, "sortlist", &nl); if (status == NI_OK && nl.ni_namelist_len > 0) { /* copy up to MAXRESOLVSORT address/netmask pairs */ for (n = 0; n < nl.ni_namelist_len && nsort < MAXRESOLVSORT; n++) { char ch; char *cp; const char *sp; struct in_addr a; cp = NULL; for (sp = sort_mask; *sp; sp++) { char *cp1; cp1 = strchr(nl.ni_namelist_val[n], *sp); if (cp && cp1) cp = (cp < cp1)? cp : cp1; else if (cp1) cp = cp1; } if (cp != NULL) { ch = *cp; *cp = '\0'; break; } if (inetaton(nl.ni_namelist_val[n], &a)) { ircd_res.sort_list[nsort].addr = a; if (*cp && ISSORTMASK(ch)) { *cp++ = ch; if (inetaton(cp, &a)) { ircd_res.sort_list[nsort].mask = a.s_addr; } else { ircd_res.sort_list[nsort].mask = ircd_net_mask(ircd_res.sort_list[nsort].addr); } } else { ircd_res.sort_list[nsort].mask = ircd_net_mask(ircd_res.sort_list[nsort].addr); } nsort++; } } ni_namelist_free(&nl); } ircd_res.nsort = nsort; #endif /* get resolver options */ status = ni_lookupprop(domain, &dir, "options", &nl); if (status == NI_OK && nl.ni_namelist_len > 0) { ircd_res_setoptions(nl.ni_namelist_val[0], "conf"); ni_namelist_free(&nl); } ni_free(domain); return(1); /* using DNS configuration from NetInfo */ } status = ni_open(domain, "..", &parent); ni_free(domain); if (status == NI_OK) domain = parent; } } return(0); /* if not using DNS configuration from NetInfo */ } #endif /* NEXT */ u_int ircd_res_randomid(void) { struct timeval now; gettimeofday(&now, NULL); return (0xffff & (now.tv_sec ^ now.tv_usec ^ getpid())); } irc2.11.2p3/ircd/nameser_def.h0000644000175000017500000003251510166301003013672 0ustar kkkk/* * ++Copyright++ 1983, 1989, 1993 * - * Copyright (c) 1983, 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Portions Copyright (c) 1993 by Digital Equipment Corporation. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies, and that * the name of Digital Equipment Corporation not be used in advertising or * publicity pertaining to distribution of the document or software without * specific, written prior permission. * * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * - * Portions Copyright (c) 1995 by International Business Machines, Inc. * * International Business Machines, Inc. (hereinafter called IBM) grants * permission under its copyrights to use, copy, modify, and distribute this * Software with or without fee, provided that the above copyright notice and * all paragraphs of this notice appear in all copies, and that the name of IBM * not be used in connection with the marketing of any product incorporating * the Software or modifications thereof, without specific, written prior * permission. * * To the extent it has a right to do so, IBM grants an immunity from suit * under its patents, if any, for the use, sale or manufacture of products to * the extent that such products are used for performing Domain Name System * dynamic updates in TCP/IP networks by means of the Software. No immunity is * granted for any product per se or for any other function of any product. * * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. * --Copyright-- */ /* * @(#)nameser.h 8.1 (Berkeley) 6/2/93 * $Id: nameser_def.h,v 1.5 2005/01/03 17:33:55 q Exp $ */ /* * revision information. this is the release date in YYYYMMDD format. * it can change every day so the right thing to do with it is use it * in preprocessor commands such as "#if (__BIND > 19931104)". do not * compare for equality; rather, use it to determine whether your resolver * is new enough to contain a certain feature. */ #define __BIND 19960801 /* interface version stamp */ /* * Define constants based on rfc883 */ #define PACKETSZ 512 /* maximum packet size */ #define MAXDNAME 1025 /* maximum presentation domain name */ #define MAXCDNAME 255 /* maximum compressed domain name */ #define MAXLABEL 63 /* maximum length of domain label */ #define HFIXEDSZ 12 /* #/bytes of fixed data in header */ #define QFIXEDSZ 4 /* #/bytes of fixed data in query */ #define RRFIXEDSZ 10 /* #/bytes of fixed data in r record */ #define INT32SZ 4 /* for systems without 32-bit ints */ #define INT16SZ 2 /* for systems without 16-bit ints */ #define INADDRSZ 4 /* IPv4 T_A */ #define IN6ADDRSZ 16 /* IPv6 T_AAAA */ /* * Internet nameserver port number */ #define NAMESERVER_PORT 53 /* * Currently defined opcodes */ #define QUERY 0x0 /* standard query */ #define IQUERY 0x1 /* inverse query */ #define STATUS 0x2 /* nameserver status query */ /*#define xxx 0x3*/ /* 0x3 reserved */ #define NS_NOTIFY_OP 0x4 /* notify secondary of SOA change */ /* * Currently defined response codes */ #define NOERROR 0 /* no error */ #define FORMERR 1 /* format error */ #define SERVFAIL 2 /* server failure */ #define NXDOMAIN 3 /* non existent domain */ #define NOTIMP 4 /* not implemented */ #define REFUSED 5 /* query refused */ /* * Type values for resources and queries */ #define T_A 1 /* host address */ #define T_NS 2 /* authoritative server */ #define T_MD 3 /* mail destination */ #define T_MF 4 /* mail forwarder */ #define T_CNAME 5 /* canonical name */ #define T_SOA 6 /* start of authority zone */ #define T_MB 7 /* mailbox domain name */ #define T_MG 8 /* mail group member */ #define T_MR 9 /* mail rename name */ #define T_NULL 10 /* null resource record */ #define T_WKS 11 /* well known service */ #define T_PTR 12 /* domain name pointer */ #define T_HINFO 13 /* host information */ #define T_MINFO 14 /* mailbox information */ #define T_MX 15 /* mail routing information */ #define T_TXT 16 /* text strings */ #define T_RP 17 /* responsible person */ #define T_AFSDB 18 /* AFS cell database */ #define T_X25 19 /* X_25 calling address */ #define T_ISDN 20 /* ISDN calling address */ #define T_RT 21 /* router */ #define T_NSAP 22 /* NSAP address */ #define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */ #define T_SIG 24 /* security signature */ #define T_KEY 25 /* security key */ #define T_PX 26 /* X.400 mail mapping */ #define T_GPOS 27 /* geographical position (withdrawn) */ #define T_AAAA 28 /* IP6 Address */ #define T_LOC 29 /* Location Information */ #define T_NXT 30 /* Next Valid Name in Zone */ #define T_EID 31 /* Endpoint identifier */ #define T_NIMLOC 32 /* Nimrod locator */ #define T_SRV 33 /* Server selection */ #define T_ATMA 34 /* ATM Address */ #define T_NAPTR 35 /* Naming Authority PoinTeR */ /* non standard */ #define T_UINFO 100 /* user (finger) information */ #define T_UID 101 /* user ID */ #define T_GID 102 /* group ID */ #define T_UNSPEC 103 /* Unspecified format (binary data) */ /* Query type values which do not appear in resource records */ #define T_IXFR 251 /* incremental zone transfer */ #define T_AXFR 252 /* transfer zone of authority */ #define T_MAILB 253 /* transfer mailbox records */ #define T_MAILA 254 /* transfer mail agent records */ #define T_ANY 255 /* wildcard match */ /* * Values for class field */ #define C_IN 1 /* the arpa internet */ #define C_CHAOS 3 /* for chaos net (MIT) */ #define C_HS 4 /* for Hesiod name server (MIT) (XXX) */ /* Query class values which do not appear in resource records */ #define C_ANY 255 /* wildcard match */ /* * Flags field of the KEY RR rdata */ #define KEYFLAG_TYPEMASK 0xC000 /* Mask for "type" bits */ #define KEYFLAG_TYPE_AUTH_CONF 0x0000 /* Key usable for both */ #define KEYFLAG_TYPE_CONF_ONLY 0x8000 /* Key usable for confidentiality */ #define KEYFLAG_TYPE_AUTH_ONLY 0x4000 /* Key usable for authentication */ #define KEYFLAG_TYPE_NO_KEY 0xC000 /* No key usable for either; no key */ /* The type bits can also be interpreted independently, as single bits: */ #define KEYFLAG_NO_AUTH 0x8000 /* Key not usable for authentication */ #define KEYFLAG_NO_CONF 0x4000 /* Key not usable for confidentiality */ #define KEYFLAG_EXPERIMENTAL 0x2000 /* Security is *mandatory* if bit=0 */ #define KEYFLAG_RESERVED3 0x1000 /* reserved - must be zero */ #define KEYFLAG_RESERVED4 0x0800 /* reserved - must be zero */ #define KEYFLAG_USERACCOUNT 0x0400 /* key is assoc. with a user acct */ #define KEYFLAG_ENTITY 0x0200 /* key is assoc. with entity eg host */ #define KEYFLAG_ZONEKEY 0x0100 /* key is zone key for the zone named */ #define KEYFLAG_IPSEC 0x0080 /* key is for IPSEC use (host or user)*/ #define KEYFLAG_EMAIL 0x0040 /* key is for email (MIME security) */ #define KEYFLAG_RESERVED10 0x0020 /* reserved - must be zero */ #define KEYFLAG_RESERVED11 0x0010 /* reserved - must be zero */ #define KEYFLAG_SIGNATORYMASK 0x000F /* key can sign DNS RR's of same name */ #define KEYFLAG_RESERVED_BITMASK ( KEYFLAG_RESERVED3 | \ KEYFLAG_RESERVED4 | \ KEYFLAG_RESERVED10| KEYFLAG_RESERVED11) /* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */ #define ALGORITHM_MD5RSA 1 /* MD5 with RSA */ #define ALGORITHM_EXPIRE_ONLY 253 /* No alg, no security */ #define ALGORITHM_PRIVATE_OID 254 /* Key begins with OID indicating alg */ /* Signatures */ /* Size of a mod or exp in bits */ #define MIN_MD5RSA_KEY_PART_BITS 512 #define MAX_MD5RSA_KEY_PART_BITS 2552 /* Total of binary mod and exp, bytes */ #define MAX_MD5RSA_KEY_BYTES ((MAX_MD5RSA_KEY_PART_BITS+7/8)*2+3) /* Max length of text sig block */ #define MAX_KEY_BASE64 (((MAX_MD5RSA_KEY_BYTES+2)/3)*4) /* * Status return codes for T_UNSPEC conversion routines */ #define CONV_SUCCESS 0 #define CONV_OVERFLOW (-1) #define CONV_BADFMT (-2) #define CONV_BADCKSUM (-3) #define CONV_BADBUFLEN (-4) /* * Structure for query header. The order of the fields is machine- and * compiler-dependent, depending on the byte/bit order and the layout * of bit fields. We use bit fields only in int variables, as this * is all ANSI requires. This requires a somewhat confusing rearrangement. */ typedef struct { unsigned id :16; /* query identification number */ #ifdef WORDS_BIGENDIAN /* fields in third byte */ unsigned qr: 1; /* response flag */ unsigned opcode: 4; /* purpose of message */ unsigned aa: 1; /* authoritive answer */ unsigned tc: 1; /* truncated message */ unsigned rd: 1; /* recursion desired */ /* fields in fourth byte */ unsigned ra: 1; /* recursion available */ unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ unsigned ad: 1; /* authentic data from named */ unsigned cd: 1; /* checking disabled by resolver */ unsigned rcode :4; /* response code */ #else /* WORDS_BIGENDIAN */ /* fields in third byte */ unsigned rd :1; /* recursion desired */ unsigned tc :1; /* truncated message */ unsigned aa :1; /* authoritive answer */ unsigned opcode :4; /* purpose of message */ unsigned qr :1; /* response flag */ /* fields in fourth byte */ unsigned rcode :4; /* response code */ unsigned cd: 1; /* checking disabled by resolver */ unsigned ad: 1; /* authentic data from named */ unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ unsigned ra :1; /* recursion available */ #endif /* WORDS_BIGENDIAN */ /* remaining bytes */ unsigned qdcount :16; /* number of question entries */ unsigned ancount :16; /* number of answer entries */ unsigned nscount :16; /* number of authority entries */ unsigned arcount :16; /* number of resource entries */ } HEADER; /* * Defines for handling compressed domain names */ #define INDIR_MASK 0xc0 /* * Inline versions of get/put short/long. Pointer is advanced. * * These macros demonstrate the property of C whereby it can be * portable or it can be elegant but rarely both. */ #define GETSHORT(s, cp) { \ register const u_char *t_cp = (const u_char *)(cp); \ (s) = ((u_int16_t)t_cp[0] << 8) \ | ((u_int16_t)t_cp[1]) \ ; \ (cp) += INT16SZ; \ } #define GETLONG(l, cp) { \ register const u_char *t_cp = (const u_char *)(cp); \ (l) = ((u_int32_t)t_cp[0] << 24) \ | ((u_int32_t)t_cp[1] << 16) \ | ((u_int32_t)t_cp[2] << 8) \ | ((u_int32_t)t_cp[3]) \ ; \ (cp) += INT32SZ; \ } #define PUTSHORT(s, cp) { \ register u_int16_t t_s = (u_int16_t)(s); \ register u_char *t_cp = (u_char *)(cp); \ *t_cp++ = t_s >> 8; \ *t_cp = t_s; \ (cp) += INT16SZ; \ } #define PUTLONG(l, cp) { \ register u_int32_t t_l = (u_int32_t)(l); \ register u_char *t_cp = (u_char *)(cp); \ *t_cp++ = t_l >> 24; \ *t_cp++ = t_l >> 16; \ *t_cp++ = t_l >> 8; \ *t_cp = t_l; \ (cp) += INT32SZ; \ } irc2.11.2p3/ircd/fileio.h0000644000175000017500000000543110204445171012676 0ustar kkkk/* * ircd-ratbox: A slightly useful ircd. * fileio.h: The file input/output header. * * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center * Copyright (C) 1996-2002 Hybrid Development Team * Copyright (C) 2002-2004 ircd-ratbox development team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA * * $Id: fileio.h,v 1.1 2005/02/15 19:16:09 chopin Exp $ */ #ifndef INCLUDED_fileio_h #define INCLUDED_fileio_h #define FB_EOF 0x01 #define FB_FAIL 0x02 struct FileBuf { int fd; /* file descriptor */ char *endp; /* one past the end */ char *ptr; /* current read pos */ char *pbptr; /* pointer to push back char */ int flags; /* file state */ char buf[BUFSIZ]; /* buffer */ char pbuf[BUFSIZ + 1]; /* push back buffer */ }; /* XXX This shouldn't be here */ struct Client; /* * FileBuf is a mirror of the ANSI FILE struct, but it works for any * file descriptor. FileBufs are allocated when a file is opened with * fbopen, and they are freed when the file is closed using fbclose. */ typedef struct FileBuf FBFILE; /* * open a file and return a FBFILE*, see fopen(3) */ extern FBFILE *fbopen(const char *filename, const char *mode); /* * associate a file descriptor with a FBFILE* * if a FBFILE* is associated here it MUST be closed using fbclose * see fdopen(3) */ extern FBFILE *fdbopen(int fd, const char *mode); /* * close a file opened with fbopen, see fclose(3) */ extern void fbclose(FBFILE * fb); /* * return the next character from the file, EOF on end of file * see fgetc(3) */ extern int fbgetc(FBFILE * fb); /* * return next string in a file up to and including the newline character * see fgets(3) */ extern char *fbgets(char *buf, size_t len, FBFILE * fb); /* * ungets c to fb see ungetc(3) */ extern void fbungetc(char c, FBFILE * fb); /* * write a null terminated string to a file, see fputs(3) */ extern int fbputs(const char *str, FBFILE * fb); /* * return the status of the file associated with fb, see fstat(3) */ extern int fbstat(struct stat *sb, FBFILE * fb); /* * popen a file. */ extern FBFILE *fbpopen(const char *, const char *); #endif /* INCLUDED_fileio_h */ irc2.11.2p3/ircd/chkconf.c0000644000175000017500000006626211176147424013057 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/chkconf.c * Copyright (C) 1993 Darren Reed * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: chkconf.c,v 1.52 2009/04/29 22:05:08 chopin Exp $"; #endif #include "os.h" #include "s_defines.h" #define CHKCONF_C #include "match_ext.h" #undef CHKCONF_C #define mystrdup(x) strdup(x) #ifdef MyMalloc #undef MyMalloc #endif #define MyMalloc(x) malloc(x) /*#define MyFree(x) free(x)*/ static char *configfile = IRCDCONF_PATH; #include "config_read.c" #ifdef CONFIG_DIRECTIVE_INCLUDE #define CK_FILE filelist->file #define CK_LINE filelist->linenum static aConfig *findConfLineNumber(int); static aConfig *files; #else #define CK_FILE filelist->filename #define CK_LINE nr - filelist->min static struct wordcount *findConfLineNumber(int); static struct wordcount *files; struct wordcount { char *filename; int min; int max; struct wordcount *next; }; static void mywc(void); #ifdef M4_PREPROC static char * mystrinclude(char *, int); static int simulateM4Include(struct wordcount *, int, char *, int); #endif static int dgets(int, char *, int); #endif static void new_class(int); static char *getfield(char *), confchar(u_int); static int openconf(void); static void validate(aConfItem *); static aClass *get_class(int, int); static aConfItem *initconf(void); static void showconf(void); static int checkSID(char *, int); static int numclasses = 0, *classarr = (int *)NULL, debugflag = 0; static char nullfield[] = ""; static char maxsendq[12]; #define SHOWSTR(x) ((x) ? (x) : "*") int main(int argc, char *argv[]) { aConfItem *result; int showflag = 0; if (argc > 1 && !strncmp(argv[1], "-h", 2)) { (void)printf("Usage: %s [-h | -s | -d[#]] [ircd.conf]\n", argv[0]); (void)printf("\t-h\tthis help\n"); (void)printf("\t-s\tshows preprocessed config file (after " "includes and/or M4)\n"); (void)printf("\t-d[#]\tthe bigger number, the more verbose " "chkconf is in its checks\n"); (void)printf("\tDefault ircd.conf = %s\n", IRCDCONF_PATH); exit(0); } new_class(0); if (argc > 1 && !strncmp(argv[1], "-d", 2)) { debugflag = 1; if (argv[1][2]) debugflag = atoi(argv[1]+2); argc--; argv++; } if (argc > 1 && !strncmp(argv[1], "-s", 2)) { showflag = 1; argc--; argv++; } if (argc > 1) configfile = argv[1]; if (showflag) { showconf(); return 0; } #ifndef CONFIG_DIRECTIVE_INCLUDE /* Initialize counters to be able to print line number even with m4 */ mywc(); # ifdef DEBUGMODE { struct wordcount *filelist; for(filelist = files; filelist->next; filelist = filelist->next) fprintf(stderr, "%s: Min %d - Max %d\n", filelist->filename, filelist->min, filelist->max); } # endif #endif /* If I do not use result as temporary return value * I get loops when M4_PREPROC is defined - Babar */ result = initconf(); validate(result); #if defined(CONFIG_DIRECTIVE_INCLUDE) config_free(files); #endif return 0; } /* * openconf * * returns -1 on any error or else the fd opened from which to read the * configuration file from. This may either be th4 file direct or one end * of a pipe from m4. */ static int openconf(void) { #ifdef M4_PREPROC int pi[2]; #ifdef HAVE_GNU_M4 char *includedir, *includedirptr; includedir = strdup(IRCDM4_PATH); includedirptr = strrchr(includedir, '/'); if (includedirptr) *includedirptr = '\0'; #endif /* ircd.m4 with full path now! Kratz */ if (access(IRCDM4_PATH, R_OK) == -1) { (void)fprintf(stderr, "%s missing.\n", IRCDM4_PATH); return -1; } if (pipe(pi) == -1) return -1; switch(fork()) { case -1: return -1; case 0: (void)close(pi[0]); (void)close(2); if (pi[1] != 1) { (void)close(1); (void)dup2(pi[1], 1); (void)close(pi[1]); } (void)dup2(1,2); /* * m4 maybe anywhere, use execvp to find it. Any error * goes out with report_error. Could be dangerous, * two servers running with the same fd's >:-) -avalon */ (void)execlp(M4_PATH, "m4", #ifdef HAVE_GNU_M4 #ifdef USE_M4_PREFIXES "-P", #endif "-I", includedir, #endif #ifdef INET6 "-DINET6", #endif IRCDM4_PATH, configfile, (char *) NULL); perror("m4"); exit(-1); default : (void)close(pi[1]); return pi[0]; } #else return open(configfile, O_RDONLY); #endif } /* show config as ircd would see it before starting to parse it */ static void showconf(void) { #if defined(CONFIG_DIRECTIVE_INCLUDE) aConfig *p, *p2; int etclen = 0; FILE *fdn; #else int dh; char line[512], c[80], *tmp; #endif int fd; fprintf(stderr, "showconf(): %s\n", configfile); if ((fd = openconf()) == -1) { #ifdef M4_PREPROC (void)wait(0); #endif return; } #if defined(CONFIG_DIRECTIVE_INCLUDE) if (debugflag) { etclen = strlen(IRCDCONF_DIR); } fdn = fdopen(fd, "r"); p2 = config_read(fdn, 0, new_config_file(configfile, NULL, 0)); for(p = p2; p; p = p->next) { if (debugflag) printf("%s:%d:", p->file->filename + (strncmp(p->file->filename, IRCDCONF_DIR, etclen) == 0 ? etclen : 0), p->linenum); printf("%s\n", p->line); } config_free(p2); (void)fclose(fdn); #else (void)dgets(-1, NULL, 0); /* make sure buffer is at empty pos */ while ((dh = dgets(fd, line, sizeof(line) - 1)) > 0) { if ((tmp = (char *)index(line, '\n'))) *tmp = 0; else while(dgets(fd, c, sizeof(c) - 1)) if ((tmp = (char *)index(c, '\n'))) { *tmp = 0; break; } printf("%s\n", line); } (void)close(fd); #endif #ifdef M4_PREPROC (void)wait(0); #endif return; } /* ** initconf() ** Read configuration file. ** ** returns a pointer to the config items chain if successful ** NULL if config is invalid (some mandatory fields missing) */ static aConfItem *initconf(void) { int fd; char *tmp, *tmp3 = NULL, *s; int ccount = 0, ncount = 0, flags = 0, nr = 0; aConfItem *aconf = NULL, *ctop = NULL; int mandatory_found = 0, valid = 1; #if defined(CONFIG_DIRECTIVE_INCLUDE) char *line; aConfig *ConfigTop, *filelist; aFile *ftop; FILE *fdn; #else int dh; struct wordcount *filelist = files; char line[512], c[80], *ftop; #endif (void)fprintf(stderr, "initconf(): ircd.conf = %s\n", configfile); if ((fd = openconf()) == -1) { #ifdef M4_PREPROC (void)wait(0); #endif return NULL; } #if defined(CONFIG_DIRECTIVE_INCLUDE) ftop = new_config_file(configfile, NULL, 0); fdn = fdopen(fd, "r"); files = ConfigTop = config_read(fdn, 0, ftop); for(filelist = ConfigTop; filelist; filelist = filelist->next) #else ftop = configfile; (void)dgets(-1, NULL, 0); /* make sure buffer is at empty pos */ while ((dh = dgets(fd, line, sizeof(line) - 1)) > 0) #endif { if (aconf) { if (aconf->host && (aconf->host != nullfield)) (void)free(aconf->host); if (aconf->passwd && (aconf->passwd != nullfield)) (void)free(aconf->passwd); if (aconf->name && (aconf->name != nullfield)) (void)free(aconf->name); } else aconf = (aConfItem *)malloc(sizeof(*aconf)); aconf->host = (char *)NULL; aconf->passwd = (char *)NULL; aconf->name = (char *)NULL; aconf->class = (aClass *)NULL; /* abusing clients to store ircd.conf line number */ aconf->clients = ++nr; #if defined(CONFIG_DIRECTIVE_INCLUDE) line = filelist->line; #else while (filelist->next && (filelist->max < nr)) filelist = filelist->next; if ((tmp = (char *)index(line, '\n'))) *tmp = 0; else while(dgets(fd, c, sizeof(c) - 1)) if ((tmp = (char *)index(c, '\n'))) { *tmp = 0; break; } #endif /* * Do quoting of characters and # detection. */ for (tmp = line; *tmp; tmp++) { if (*tmp == '\\') { switch (*(tmp+1)) { case 'n' : *tmp = '\n'; break; case 'r' : *tmp = '\r'; break; case 't' : *tmp = '\t'; break; case '0' : *tmp = '\0'; break; default : *tmp = *(tmp+1); break; } if (!*(tmp+1)) break; else for (s = tmp; (*s = *(s+1)); s++) ; tmp++; } else if (*tmp == '#') *tmp = '\0'; } if (!*line || *line == '#' || *line == '\n' || *line == ' ' || *line == '\t') continue; if (line[1] != IRCDCONF_DELIMITER) { config_error(CF_ERR, CK_FILE, CK_LINE, "wrong delimiter in line (%s)", line); continue; } if (debugflag) config_error(CF_NONE, CK_FILE, CK_LINE, "%s", line); tmp = getfield(line); if (!tmp) { config_error(CF_ERR, CK_FILE, CK_LINE, "no field found"); continue; } aconf->status = CONF_ILLEGAL; aconf->flags = 0L; switch (*tmp) { case 'A': /* Name, e-mail address of administrator */ case 'a': /* of this server. */ aconf->status = CONF_ADMIN; mandatory_found |= CONF_ADMIN; break; case 'B': /* bounce line */ case 'b': aconf->status = CONF_BOUNCE; break; case 'C': /* Server where I should try to connect */ /* in case of lp failures */ ccount++; aconf->status = CONF_CONNECT_SERVER; break; case 'c': ccount++; aconf->status = CONF_ZCONNECT_SERVER; break; case 'D': /* auto connect restrictions */ case 'd': aconf->status = CONF_DENY; break; case 'H': /* Hub server line */ case 'h': aconf->status = CONF_HUB; break; case 'i' : /* Restricted client */ aconf->flags |= CFLAG_RESTRICTED; case 'I': aconf->status = CONF_CLIENT; mandatory_found |= CONF_CLIENT; break; case 'K': /* Kill user line on irc.conf */ aconf->status = CONF_KILL; break; case 'k': aconf->status = CONF_OTHERKILL; break; /* Operator. Line should contain at least */ /* password and host where connection is */ case 'L': /* guaranteed leaf server */ case 'l': aconf->status = CONF_LEAF; break; /* Me. Host field is name used for this host */ /* and port number is the number of the port */ case 'M': case 'm': aconf->status = CONF_ME; mandatory_found |= CONF_ME; break; case 'N': /* Server where I should NOT try to */ case 'n': /* connect in case of lp failures */ /* but which tries to connect ME */ ++ncount; aconf->status = CONF_NOCONNECT_SERVER; break; case 'o': case 'O': aconf->status = CONF_OPERATOR; break; case 'P': /* listen port line */ case 'p': aconf->status = CONF_LISTEN_PORT; mandatory_found |= CONF_LISTEN_PORT; break; case 'Q': /* a server that you don't want in your */ case 'q': /* network. USE WITH CAUTION! */ aconf->status = CONF_QUARANTINED_SERVER; break; case 'S': /* Service. Same semantics as */ case 's': /* CONF_OPERATOR */ aconf->status = CONF_SERVICE; break; case 'V': aconf->status = CONF_VER; break; case 'Y': case 'y': aconf->status = CONF_CLASS; break; #ifdef XLINE case 'X': aconf->status = CONF_XLINE; break; #endif default: config_error(CF_WARN, CK_FILE, CK_LINE, "unknown conf line letter (%c)\n", *tmp); break; } if (IsIllegal(aconf)) continue; do { if ((tmp = getfield(NULL)) == NULL) break; DupString(aconf->host, tmp); if ((tmp = getfield(NULL)) == NULL) break; DupString(aconf->passwd, tmp); if ((tmp = getfield(NULL)) == NULL) break; DupString(aconf->name, tmp); if ((tmp = getfield(NULL)) == NULL) break; aconf->port = atoi(tmp); if ((tmp = getfield(NULL)) == NULL) break; if (aconf->status & CONF_CLIENT_MASK) { if (!*tmp) config_error(CF_WARN, CK_FILE, CK_LINE, "no class, default 0"); aconf->class = get_class(atoi(tmp), nr); } tmp3 = getfield(NULL); } while (0); /* to use break without compiler warnings */ if ((aconf->status & CONF_CLIENT) && tmp3) { /* Parse I-line flags */ for(s = tmp3; *s; ++s) { switch (*s) { #ifdef XLINE case 'e': #endif case 'R': case 'D': case 'I': case 'E': case 'N': case 'M': case 'F': break; case ' ': case '\t': /* so there's no weird warnings */ break; default: config_error(CF_WARN, CK_FILE, CK_LINE, "unknown I-line flag: %c", *s); } } } if ((aconf->status & CONF_OPERATOR) && tmp3) { /* Parse O-line flags */ for(s = tmp3; *s; ++s) { switch (*s) { case 'A': case 'L': case 'K': case 'k': case 'S': case 's': case 'C': case 'c': case 'l': case 'h': case 'd': case 'r': case 'R': case 'D': case 'e': case 'T': #ifdef CLIENTS_CHANNEL case '&': #endif case 'p': case 'P': case 't': break; case ' ': case '\t': /* so there's no weird warnings */ break; default: config_error(CF_WARN, CK_FILE, CK_LINE, "unknown O-line flag: %c", *s); } } } /* ** If conf line is a class definition, create a class entry ** for it and make the conf_line illegal and delete it. */ if (aconf->status & CONF_CLASS) { if (!aconf->host) { config_error(CF_ERR, CK_FILE, CK_LINE, "no class #"); continue; } if (!tmp) { config_error(CF_WARN, CK_FILE, CK_LINE, "missing sendq field, " "assuming default %d", QUEUELEN); (void)sprintf(maxsendq, "%d", QUEUELEN); } else (void)sprintf(maxsendq, "%d", atoi(tmp)); new_class(atoi(aconf->host)); aconf->class = get_class(atoi(aconf->host), nr); goto print_confline; } if (aconf->status & CONF_LISTEN_PORT) { if (!aconf->host) config_error(CF_ERR, CK_FILE, CK_LINE, "null host field in P-line"); #ifdef UNIXPORT else if (index(aconf->host, '/')) { struct stat sb; if (stat(aconf->host, &sb) == -1) { config_error(CF_ERR, CK_FILE, CK_LINE, "error in stat(%s)", aconf->host); } else if ((sb.st_mode & S_IFMT) != S_IFDIR) config_error(CF_ERR, CK_FILE, CK_LINE, "%s not directory", aconf->host); } #else else if (index(aconf->host, '/')) { config_error(CF_WARN, CK_FILE, CK_LINE, "/ present in P-line but UNIXPORT " "undefined"); } #endif aconf->class = get_class(0, nr); goto print_confline; } if (aconf->status & CONF_SERVER_MASK && (!aconf->host || index(aconf->host, '*') || index(aconf->host, '?'))) { config_error(CF_ERR, CK_FILE, CK_LINE, "bad host field"); continue; } if (aconf->status & CONF_SERVER_MASK && BadPtr(aconf->passwd)) { config_error(CF_ERR, CK_FILE, CK_LINE, "empty/no password field"); continue; } if (aconf->status & CONF_SERVER_MASK && !aconf->name) { config_error(CF_ERR, CK_FILE, CK_LINE, "bad name field"); continue; } if (aconf->status & (CONF_SERVER_MASK|CONF_OPS)) if (!index(aconf->host, '@')) { char *newhost; int len = 3; /* *@\0 = 3 */ len += strlen(aconf->host); newhost = (char *)MyMalloc(len); (void)sprintf(newhost, "*@%s", aconf->host); (void)free(aconf->host); aconf->host = newhost; } if (!aconf->class) aconf->class = get_class(0, nr); (void)sprintf(maxsendq, "%d", aconf->class->class); if (!aconf->name) aconf->name = nullfield; if (!aconf->passwd) aconf->passwd = nullfield; if (!aconf->host) aconf->host = nullfield; if (aconf->status & CONF_ME) { if (flags & aconf->status) config_error(CF_ERR, CK_FILE, CK_LINE, "multiple M-lines"); else flags |= aconf->status; if (tmp && *tmp) { /* Check for SID at the end of M: line */ if (debugflag > 2) (void)printf("SID is set to: %s\n", tmp); if (checkSID(tmp, nr)) config_error(CF_ERR, CK_FILE, CK_LINE, "SID invalid"); } else config_error(CF_ERR, CK_FILE, CK_LINE, "no SID in M-line"); } if (aconf->status & CONF_ADMIN) { if (flags & aconf->status) config_error(CF_ERR, CK_FILE, CK_LINE, "multiple A-lines"); else flags |= aconf->status; if (tmp && *tmp) { /* Check for Network at the end of A: line */ if (debugflag > 2) (void)printf("Network is set to: %s\n", tmp); } else config_error(CF_ERR, CK_FILE, CK_LINE, "no network in A-line"); } if (aconf->status & CONF_VER) { if (*aconf->host && !index(aconf->host, '/')) config_error(CF_WARN, CK_FILE, CK_LINE, "no / in V line"); else if (*aconf->passwd && !index(aconf->passwd, '/')) config_error(CF_WARN, CK_FILE, CK_LINE, "no / in V line"); } print_confline: if (debugflag > 8) { (void)printf("(%d) (%s) (%s) (%s) (%d) (%s)\n", aconf->status, aconf->host, aconf->passwd, aconf->name, aconf->port, maxsendq); } (void)fflush(stdout); if (aconf->status & (CONF_SERVER_MASK|CONF_HUB|CONF_LEAF)) { aconf->next = ctop; ctop = aconf; aconf = NULL; } } #if defined(CONFIG_DIRECTIVE_INCLUDE) (void)fclose(fdn); #else (void)close(fd); #endif #ifdef M4_PREPROC (void)wait(0); #endif if (!(mandatory_found & CONF_ME)) { config_error(CF_ERR, ftop, 0, "no M-line found (mandatory)"); valid = 0; } if (!(mandatory_found & CONF_ADMIN)) { config_error(CF_ERR, ftop, 0, "no A-line found (mandatory)"); valid = 0; } if (!(mandatory_found & CONF_LISTEN_PORT)) { config_error(CF_ERR, ftop, 0, "no P-line found (mandatory)"); valid = 0; } if (!(mandatory_found & CONF_CLIENT)) { config_error(CF_ERR, ftop, 0, "no I-line found (mandatory)"); valid = 0; } if (valid) { return ctop; } return NULL; } static aClass *get_class(int cn, int nr) { static aClass cls; int i = numclasses - 1; #ifdef CONFIG_DIRECTIVE_INCLUDE aConfig *filelist; #else struct wordcount *filelist; #endif cls.class = -1; for (; i >= 0; i--) if (classarr[i] == cn) { cls.class = cn; break; } if (i == -1) { filelist = findConfLineNumber(nr); config_error(CF_WARN, CK_FILE, CK_LINE, "class %d not found", cn); } return &cls; } static void new_class(int cn) { numclasses++; if (classarr) classarr = (int *)realloc(classarr, sizeof(int) * numclasses); else classarr = (int *)malloc(sizeof(int)); classarr[numclasses-1] = cn; } /* * field breakup for ircd.conf file. */ static char *getfield(char *irc_newline) { static char *line = NULL; char *end, *field; if (irc_newline) line = irc_newline; if (line == NULL) return(NULL); field = line; if ((end = (char *)index(line, IRCDCONF_DELIMITER)) == NULL) { line = NULL; if ((end = (char *)index(field,'\n')) == NULL) end = field + strlen(field); } else line = end + 1; *end = '\0'; return(field); } #ifndef CONFIG_DIRECTIVE_INCLUDE /* ** read a string terminated by \r or \n in from a fd ** ** Created: Sat Dec 12 06:29:58 EST 1992 by avalon ** Returns: ** 0 - EOF ** -1 - error on read ** >0 - number of bytes returned (<=num) ** After opening a fd, it is necessary to init dgets() by calling it as ** dgets(x,y,0); ** to mark the buffer as being empty. */ static int dgets(int fd, char *buf, int num) { static char dgbuf[8192]; static char *head = dgbuf, *tail = dgbuf; register char *s, *t; register int n, nr; /* ** Sanity checks. */ if (head == tail) *head = '\0'; if (!num) { head = tail = dgbuf; *head = '\0'; return 0; } if (num > sizeof(dgbuf) - 1) num = sizeof(dgbuf) - 1; dgetsagain: if (head > dgbuf) { for (nr = tail - head, s = head, t = dgbuf; nr > 0; nr--) *t++ = *s++; tail = t; head = dgbuf; } /* ** check input buffer for EOL and if present return string. */ if (head < tail && ((s = index(head, '\n')) || (s = index(head, '\r'))) && s < tail) { n = MIN(s - head + 1, num); /* at least 1 byte */ dgetsreturnbuf: bcopy(head, buf, n); head += n; if (head == tail) head = tail = dgbuf; return n; } if (tail - head >= num) /* dgets buf is big enough */ { n = num; goto dgetsreturnbuf; } n = sizeof(dgbuf) - (tail - dgbuf) - 1; nr = read(fd, tail, n); if (nr == -1) { head = tail = dgbuf; return -1; } if (!nr) { if (head < tail) { n = MIN(tail - head, num); /* File hasn't got a final new line */ goto dgetsreturnbuf; } head = tail = dgbuf; return 0; } tail += nr; *tail = '\0'; for (t = head; (s = index(t, '\n')); ) { if ((s > head) && (s > dgbuf)) { t = s-1; for (nr = 0; *t == '\\'; nr++) t--; if (nr & 1) { t = s+1; s--; nr = tail - t; while (nr--) *s++ = *t++; tail -= 2; *tail = '\0'; } else s++; } else s++; t = s; } *tail = '\0'; goto dgetsagain; } #endif static void validate(aConfItem *top) { Reg aConfItem *aconf, *bconf; u_int otype = 0, valid = 0; int nr; #ifdef CONFIG_DIRECTIVE_INCLUDE aConfig *filelist; #else struct wordcount *filelist; #endif if (!top) return; for (aconf = top; aconf; aconf = aconf->next) { if (aconf->status & CONF_MATCH) continue; if (aconf->status & CONF_SERVER_MASK) { if (aconf->status & (CONF_CONNECT_SERVER|CONF_ZCONNECT_SERVER)) otype = CONF_NOCONNECT_SERVER; else if (aconf->status & CONF_NOCONNECT_SERVER) otype = CONF_CONNECT_SERVER; for (bconf = top; bconf; bconf = bconf->next) { if (bconf == aconf || !(bconf->status & otype)) continue; if (bconf->class == aconf->class && !mycmp(bconf->name, aconf->name) && !mycmp(bconf->host, aconf->host)) { aconf->status |= CONF_MATCH; bconf->status |= CONF_MATCH; break; } } } else for (bconf = top; bconf; bconf = bconf->next) { if ((bconf == aconf) || !(bconf->status & CONF_SERVER_MASK)) continue; if (!mycmp(bconf->name, aconf->name)) { aconf->status |= CONF_MATCH; break; } } } for (aconf = top; aconf; aconf = aconf->next) if (aconf->status & CONF_MATCH) valid++; else { nr = aconf->clients; filelist = findConfLineNumber(nr); config_error(CF_WARN, CK_FILE, CK_LINE, "unmatched %c%c%s%c%s%c%s", confchar(aconf->status), IRCDCONF_DELIMITER, aconf->host, IRCDCONF_DELIMITER, SHOWSTR(aconf->passwd), IRCDCONF_DELIMITER, aconf->name); } return; } #ifdef M4_PREPROC static int simulateM4Include(struct wordcount *filelist, int nr, char *filename, int fnrmin) { int fd, dh, fnr = 0, finalnewline = 0; char line[512]; struct wordcount *listnew; #ifdef M4_PREPROC char *inc; #endif listnew = (struct wordcount *)malloc(sizeof(struct wordcount)); filelist->next = listnew; filelist = filelist->next; filelist->min = nr - fnrmin; filelist->filename = strdup(filename); filelist->max = 0; filelist->next = NULL; if ((fd = open(filename, O_RDONLY)) == -1) { perror(filename); return nr; } (void)dgets(-1, NULL, 0); while ((dh = dgets(fd, line, sizeof(line) - 1)) > 0) { if (dh != sizeof(line) - 1) { fnr++; if (fnr > fnrmin) { nr++; if (line[dh - 1] != '\n') { config_error(CF_WARN, CK_FILE, CK_LINE, "no final new line"); finalnewline = 0; } else finalnewline = 1; line[dh - 1] = 0; #ifdef M4_PREPROC inc = mystrinclude(line, nr); if (inc) { filelist->max = --nr; nr = simulateM4Include(filelist, nr, inc, 0); while (filelist->next) filelist = filelist->next; nr = simulateM4Include(filelist, nr, filename, fnr); break; } #endif } } else if (fnr > fnrmin) { line[dh - 1] = 0; config_error(CF_WARN, CK_FILE, CK_LINE, "line (%s) too long, maxlen %d", line, sizeof(line)); } } (void)close(fd); #ifdef M4_PREPROC (void)wait(0); #endif nr += finalnewline; if (!filelist->max) filelist->max = nr; return nr; } #endif #ifndef CONFIG_DIRECTIVE_INCLUDE static void mywc(void) { int fd, dh, nr = 0; char line[512]; struct wordcount *listtmp; #ifdef M4_PREPROC char *inc; #endif /* Dealing with ircd.m4 */ files = listtmp = (struct wordcount *)malloc(sizeof(struct wordcount)); listtmp->min = 0; #ifdef M4_PREPROC listtmp->filename = strdup(IRCDM4_PATH); inc = configfile; configfile = 0; /* used to have openconf launch only m4 ircd.m4 */ #else listtmp->filename = strdup("ircd.conf"); #endif if ((fd = openconf()) == -1) { (void)wait(0); return; } (void)dgets(-1, NULL, 0); /* We only count lines. No include in ircd.m4 if M4 defined */ while ((dh = dgets(fd, line, sizeof(line) - 1)) > 0) if (dh != sizeof(line) - 1) nr++; listtmp->max = nr; (void)close(fd); #ifdef M4_PREPROC (void)wait(0); configfile = inc; nr = simulateM4Include(listtmp, nr, configfile, 0); #endif } #endif /* CONFIG_DIRECTIVE_INCLUDE */ static char confchar(u_int status) { static char letrs[] = "QIicNCoOMKARYSLPHV"; char *s = letrs; status &= ~(CONF_MATCH|CONF_ILLEGAL); for (; *s; s++, status >>= 1) if (status & 1) return *s; return '-'; } static int checkSID(char *sid, int nr) { char *s = sid; int len = 0, rc = 0; #ifdef CONFIG_DIRECTIVE_INCLUDE aConfig *filelist; #else struct wordcount *filelist; #endif /* First SID char shall be numeric, rest must be alpha */ filelist = findConfLineNumber(nr); if (!isdigit(*s)) { config_error(CF_ERR, CK_FILE, CK_LINE, "SID %s invalid: 1st character must be number", sid); ++rc; } ++s; ++len; for (; *s; ++s, ++len) if (!isalnum(*s)) { config_error(CF_ERR, CK_FILE, CK_LINE, "SID %s invalid: wrong character (%c)", sid, *s); ++rc; } if (!(len == SIDLEN)) { config_error(CF_ERR, CK_FILE, CK_LINE, "SID %s invalid: wrong size (%d should be %d)", sid, len, SIDLEN); ++rc; } return rc; } #ifdef M4_PREPROC /* Do: s/include\((.*)\)/\1/ * and checks that it's not "commented out" */ static char * mystrinclude(char *s, int nr) { int off; struct wordcount *filelist; char *match = strstr(s, "include("); if (!match) return 0; off = match - s; for(; s < match; ++s) if (!isspace(*s)) return 0; s += 8; /* length("include(") */ for(; match && *match != ')'; ++match); *match = '\0'; if (off > 0) { filelist = findConfLineNumber(nr); config_error(CF_WARN, CK_FILE, CK_LINE, "spaces before include(%s): first line of included " "file will be shifted", s); } return s; } #endif #ifdef CONFIG_DIRECTIVE_INCLUDE static aConfig *findConfLineNumber(int nr) { int mynr = 1; aConfig *p = files; for( ; p->next && mynr < nr; p = p->next) mynr++; return p; } #else /* Locates file and line number of a config line */ static struct wordcount * findConfLineNumber(int nr) { struct wordcount *filelist = files; for(; filelist->next && (filelist->max < nr); filelist = filelist->next); return filelist; } #endif irc2.11.2p3/ircd/s_conf.c0000644000175000017500000017402311430555403012677 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/s_conf.c * Copyright (C) 1990 Jarkko Oikarinen and * University of Oulu, Computing Center * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* -- avalon -- 20 Feb 1992 * Reversed the order of the params for attach_conf(). * detach_conf() and attach_conf() are now the same: * function_conf(aClient *, aConfItem *) */ /* -- Jto -- 20 Jun 1990 * Added gruner's overnight fix.. */ /* -- Jto -- 16 Jun 1990 * Moved matches to ../common/match.c */ /* -- Jto -- 03 Jun 1990 * Added Kill fixes from gruner@lan.informatik.tu-muenchen.de * Added jarlek's msgbase fix (I still don't understand it... -- Jto) */ /* -- Jto -- 13 May 1990 * Added fixes from msa: * Comments and return value to init_conf() */ /* * -- Jto -- 12 May 1990 * Added close() into configuration file (was forgotten...) */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: s_conf.c,v 1.195 2010/08/11 17:16:51 bif Exp $"; #endif #include "os.h" #include "s_defines.h" #define S_CONF_C #include "s_externs.h" #undef S_CONF_C #ifdef ENABLE_CIDR_LIMITS #include "patricia_ext.h" #endif #ifdef TIMEDKLINES static int check_time_interval (char *, char *); #endif static int lookup_confhost (aConfItem *); #ifdef CONFIG_DIRECTIVE_INCLUDE #include "config_read.c" #endif aConfItem *conf = NULL; aConfItem *kconf = NULL; char *networkname = NULL; #ifdef TKLINE aConfItem *tkconf = NULL; #endif /* Parse I-lines flags from string. * D - Restricted, if no DNS. * I - Restricted, if no ident. * R - Restricted. * E - Kline exempt. * N - Do not resolve hostnames (show as IP). * F - Fallthrough to next I:line when password not matched */ long iline_flags_parse(char *string) { long tmp = 0; if (!string) { return 0; } if (index(string,'D')) { tmp |= CFLAG_RNODNS; } if (index(string,'I')) { tmp |= CFLAG_RNOIDENT; } if (index(string,'R')) { tmp |= CFLAG_RESTRICTED; } if (index(string,'E')) { tmp |= CFLAG_KEXEMPT; } #ifdef XLINE if (index(string,'e')) { tmp |= CFLAG_XEXEMPT; } #endif if (index(string,'N')) { tmp |= CFLAG_NORESOLVE; } if (index(string,'M')) { tmp |= CFLAG_NORESOLVEMATCH; } if (index(string,'F')) { tmp |= CFLAG_FALL; } return tmp; } /* convert iline flags to human readable string */ char *iline_flags_to_string(long flags) { static char ifsbuf[BUFSIZE]; char *s = ifsbuf; if (flags & CFLAG_RNODNS) { *s++ = 'D'; } if (flags & CFLAG_RNOIDENT) { *s++ = 'I'; } if (flags & CFLAG_RESTRICTED) { *s++ = 'R'; } if (flags & CFLAG_KEXEMPT) { *s++ = 'E'; } #ifdef XLINE if (flags & CFLAG_XEXEMPT) { *s++ = 'e'; } #endif if (flags & CFLAG_NORESOLVE) { *s++ = 'N'; } if (flags & CFLAG_NORESOLVEMATCH) { *s++ = 'M'; } if (flags & CFLAG_FALL) { *s++ = 'F'; } if (s == ifsbuf) { *s++ = '-'; } *s++ = '\0'; return ifsbuf; } /* Convert P-line flags from string * D - delayed port * S - server only port */ long pline_flags_parse(char *string) { long tmp = 0; if (index(string, 'D')) { tmp |= PFLAG_DELAYED; } if (index(string, 'S')) { tmp |= PFLAG_SERVERONLY; } return tmp; } /* Convert P-line flags from integer to string */ char *pline_flags_to_string(long flags) { static char pfsbuf[BUFSIZE]; char *s = pfsbuf; if (flags & PFLAG_DELAYED) { *s++ = 'D'; } if (flags & PFLAG_SERVERONLY) { *s++ = 'S'; } if (s == pfsbuf) { *s++ = '-'; } *s++ = '\0'; return pfsbuf; } /* convert oline flags to human readable string */ char *oline_flags_to_string(long flags) { static char ofsbuf[BUFSIZE]; char *s = ofsbuf; if (flags & ACL_LOCOP) *s++ = 'L'; if (flags & ACL_KILLREMOTE) *s++ = 'K'; else if (flags & ACL_KILLLOCAL) *s++ = 'k'; if (flags & ACL_SQUITREMOTE) *s++ ='S'; else if (flags & ACL_SQUITLOCAL) *s++ ='s'; if (flags & ACL_CONNECTREMOTE) *s++ ='C'; else if (flags & ACL_CONNECTLOCAL) *s++ ='c'; if (flags & ACL_CLOSE) *s++ ='l'; if (flags & ACL_HAZH) *s++ ='h'; if (flags & ACL_DNS) *s++ ='d'; if (flags & ACL_REHASH) *s++ ='r'; if (flags & ACL_RESTART) *s++ ='R'; if (flags & ACL_DIE) *s++ ='D'; if (flags & ACL_SET) *s++ ='e'; if (flags & ACL_TKLINE) *s++ ='T'; if (flags & ACL_KLINE) *s++ ='q'; #ifdef CLIENTS_CHANNEL if (flags & ACL_CLIENTS) *s++ ='&'; #endif if (flags & ACL_NOPENALTY) *s++ = 'P'; if (flags & ACL_CANFLOOD) *s++ = 'p'; if (flags & ACL_TRACE) *s++ = 't'; #ifdef ENABLE_SIDTRACE if (flags & ACL_SIDTRACE) *s++ = 'v'; #endif if (s == ofsbuf) *s++ = '-'; *s++ = '\0'; return ofsbuf; } /* convert string from config to flags */ long oline_flags_parse(char *string) { long tmp = 0; char *s; for (s = string; *s; s++) { switch(*s) { case 'L': tmp |= ACL_LOCOP; break; case 'A': tmp |= (ACL_ALL & ~(ACL_LOCOP|ACL_CLIENTS|ACL_NOPENALTY|ACL_CANFLOOD)); break; case 'K': tmp |= ACL_KILL; break; case 'k': tmp |= ACL_KILLLOCAL; break; case 'S': tmp |= ACL_SQUIT; break; case 's': tmp |= ACL_SQUITLOCAL; break; case 'C': tmp |= ACL_CONNECT; break; case 'c': tmp |= ACL_CONNECTLOCAL; break; case 'l': tmp |= ACL_CLOSE; break; case 'h': tmp |= ACL_HAZH; break; case 'd': tmp |= ACL_DNS; break; case 'r': tmp |= ACL_REHASH; break; case 'R': tmp |= ACL_RESTART; break; case 'D': tmp |= ACL_DIE; break; case 'e': tmp |= ACL_SET; break; case 'T': tmp |= ACL_TKLINE; break; case 'q': tmp |= ACL_KLINE; break; #ifdef CLIENTS_CHANNEL case '&': tmp |= ACL_CLIENTS; break; #endif case 'P': tmp |= ACL_NOPENALTY; break; case 'p': tmp |= ACL_CANFLOOD; break; case 't': tmp |= ACL_TRACE; break; #ifdef ENABLE_SIDTRACE case 'v': tmp |= ACL_SIDTRACE; break; #endif } } if (tmp & ACL_LOCOP) tmp &= ~ACL_ALL_REMOTE; #ifdef OPER_KILL # ifndef OPER_KILL_REMOTE tmp &= ~ACL_KILLREMOTE; # endif #else tmp &= ~ACL_KILL; #endif #ifndef OPER_REHASH tmp &= ~ACL_REHASH; #endif #ifndef OPER_SQUIT tmp &= ~ACL_SQUIT; #endif #ifndef OPER_SQUIT_REMOTE tmp &= ~ACL_SQUITREMOTE; #endif #ifndef OPER_CONNECT tmp &= ~ACL_CONNECT; #endif #ifndef OPER_RESTART tmp &= ~ACL_RESTART; #endif #ifndef OPER_DIE tmp &= ~ACL_DIE; #endif #ifndef OPER_SET tmp &= ~ACL_SET; #endif #ifndef OPER_TKLINE tmp &= ~ACL_TKLINE; #endif #ifndef OPER_KLINE tmp &= ~ACL_KLINE; #endif return tmp; } /* * remove all conf entries from the client except those which match * the status field mask. */ void det_confs_butmask(aClient *cptr, int mask) { Reg Link *tmp, *tmp2; for (tmp = cptr->confs; tmp; tmp = tmp2) { tmp2 = tmp->next; if ((tmp->value.aconf->status & mask) == 0) (void)detach_conf(cptr, tmp->value.aconf); } } /* * Match address by #IP bitmask (10.11.12.128/27) * Now should work for IPv6 too. * returns -1 on error, 0 on match, 1 when NO match. */ int match_ipmask(char *mask, aClient *cptr, int maskwithusername) { int m; char *p; struct IN_ADDR addr; char dummy[128]; char *omask; u_long lmask; #ifdef INET6 int j; #endif omask = mask; strncpyzt(dummy, mask, sizeof(dummy)); mask = dummy; if (maskwithusername && (p = index(mask, '@'))) { *p = '\0'; if (match(mask, cptr->username)) return 1; mask = p + 1; } if (!(p = index(mask, '/'))) goto badmask; *p = '\0'; if (sscanf(p + 1, "%d", &m) != 1) { goto badmask; } if (!m) return 0; /* x.x.x.x/0 always matches */ #ifndef INET6 if (m < 0 || m > 32) goto badmask; lmask = htonl((u_long)0xffffffffL << (32 - m)); addr.s_addr = inetaddr(mask); return ((addr.s_addr ^ cptr->ip.s_addr) & lmask) ? 1 : 0; #else if (m < 0 || m > 128) goto badmask; if (inetpton(AF_INET6, mask, (void *)addr.s6_addr) != 1) { return -1; } /* Make sure that the ipv4 notation still works. */ if (IN6_IS_ADDR_V4MAPPED(&addr)) { if (m <= 32) m += 96; if (m <= 96) goto badmask; } j = m & 0x1F; /* number not mutliple of 32 bits */ m >>= 5; /* number of 32 bits */ if (m && memcmp((void *)(addr.s6_addr), (void *)(cptr->ip.s6_addr), m << 2)) return 1; if (j) { lmask = htonl((u_long)0xffffffffL << (32 - j)); if ((((u_int32_t *)(addr.s6_addr))[m] ^ ((u_int32_t *)(cptr->ip.s6_addr))[m]) & lmask) return 1; } return 0; #endif badmask: if (maskwithusername) sendto_flag(SCH_ERROR, "Ignoring bad mask: %s", omask); return -1; } /* * find the first (best) I line to attach. */ #define UHConfMatch(x, y, z) (match((x), (index((x), '@') ? (y) : (y)+(z)))) int attach_Iline(aClient *cptr, struct hostent *hp, char *sockhost) { Reg aConfItem *aconf; char uhost[HOSTLEN+USERLEN+2]; char uaddr[HOSTLEN+USERLEN+2]; int ulen = strlen(cptr->username) + 1; /* for '@' */ int retval = -2; /* EXITC_NOILINE in register_user() */ /* We fill uaddr and uhost now, before aconf loop. */ sprintf(uaddr, "%s@%s", cptr->username, sockhost); if (hp) { char fullname[HOSTLEN+1]; /* If not for add_local_domain, I wouldn't need this ** fullname. Can't we add_local_domain somewhere in ** dns code? --B. */ strncpyzt(fullname, hp->h_name, sizeof(fullname)); add_local_domain(fullname, HOSTLEN - strlen(fullname)); Debug((DEBUG_DNS, "a_il: %s->%s", sockhost, fullname)); sprintf(uhost, "%s@%s", cptr->username, fullname); } /* all uses of uhost are guarded by if (hp), so no need to zero it. */ for (aconf = conf; aconf; aconf = aconf->next) { if ((aconf->status != CONF_CLIENT)) { continue; } if (aconf->port && aconf->port != cptr->acpt->port) { continue; } /* aconf->name can be NULL with wrong I:line in the config ** (without all required fields). If aconf->host can be NULL, ** I don't know. Anyway, this is an error! --B. */ if (!aconf->host || !aconf->name) { /* Try another I:line. */ continue; } /* If anything in aconf->name... */ if (*aconf->name) { int namematched = 0; if (hp) { if (!UHConfMatch(aconf->name, uhost, ulen)) { namematched = 1; } } /* Note: here we could do else (!hp) and try to ** check if aconf->name is '*' or '*@*' and ** if so, allow the client. But not doing so ** gives us nice opportunity to distinguish ** between '*' in aconf->name (requires DNS) ** and empty aconf->name (matches any). --B. */ /* Require name to match before checking addr fields. */ if (namematched == 0) { /* Try another I:line. */ continue; } } /* else empty aconf->name, match any hostname. */ if (*aconf->host) { #ifdef UNIXPORT if (IsUnixSocket(cptr) && aconf->host[0] == '/') { if (match(aconf->host, uaddr+ulen)) { /* Try another I:line. */ continue; } } else #endif if (strchr(aconf->host, '/')) /* 1.2.3.0/24 */ { /* match_ipmask takes care of checking ** possible username if aconf->host has '@' */ if (match_ipmask(aconf->host, cptr, 1)) { /* Try another I:line. */ continue; } } else /* 1.2.3.* */ { if (UHConfMatch(aconf->host, uaddr, ulen)) { /* Try another I:line. */ continue; } } } /* else empty aconf->host, match any ipaddr */ /* Password check, if I:line has it. If 'F' flag, try another ** I:line, otherwise bail out and reject client. */ if (!BadPtr(aconf->passwd) && !StrEq(cptr->passwd, aconf->passwd)) { if (IsConfFallThrough(aconf)) { continue; } else { sendto_one(cptr, replies[ERR_PASSWDMISMATCH], ME, BadTo(cptr->name)); retval = -8; /* EXITC_BADPASS */ break; } } /* Various cases of +r. */ if (IsConfRestricted(aconf) || (!hp && IsConfRNoDNS(aconf)) || (!(cptr->flags & FLAGS_GOTID) && IsConfRNoIdent(aconf))) { SetRestricted(cptr); } if (IsConfKlineExempt(aconf)) { SetKlineExempt(cptr); } #ifdef XLINE if (IsConfXlineExempt(aconf)) { ClearXlined(cptr); } #endif /* Copy uhost (hostname) over sockhost, if conf flag permits. */ if (hp && !IsConfNoResolve(aconf)) { get_sockhost(cptr, uhost+ulen); } /* Note that attach_conf() should not return -2. */ if ((retval = attach_conf(cptr, aconf)) < -1) { find_bounce(cptr, ConfClass(aconf), -1); } break; } if (retval == -2) { find_bounce(cptr, 0, -2); } return retval; } /* * Find the single N line and return pointer to it (from list). * If more than one then return NULL pointer. */ aConfItem *count_cnlines(Link *lp) { Reg aConfItem *aconf, *cline = NULL, *nline = NULL; for (; lp; lp = lp->next) { aconf = lp->value.aconf; if (!(aconf->status & CONF_SERVER_MASK)) continue; if ((aconf->status == CONF_CONNECT_SERVER || aconf->status == CONF_ZCONNECT_SERVER) && !cline) cline = aconf; else if (aconf->status == CONF_NOCONNECT_SERVER && !nline) nline = aconf; } return nline; } #ifdef ENABLE_CIDR_LIMITS static int add_cidr_limit(aClient *cptr, aConfItem *aconf) { patricia_node_t *pnode; if(aconf->class->cidr_amount == 0 || aconf->class->cidr_len == 0) return -1; pnode = patricia_match_ip(ConfCidrTree(aconf), &cptr->ip); /* doesnt exist, create and then allow */ if(pnode == NULL) { pnode = patricia_make_and_lookup_ip(ConfCidrTree(aconf), &cptr->ip, aconf->class->cidr_len); if(pnode == NULL) return -1; pnode->data++; return 1; } if((long)pnode->data >= aconf->class->cidr_amount) return 0; pnode->data++; return 1; } static void remove_cidr_limit(aClient *cptr, aConfItem *aconf) { patricia_node_t *pnode; if(ConfMaxCidrAmount(aconf) == 0 || ConfCidrLen(aconf) == 0) return; pnode = patricia_match_ip(ConfCidrTree(aconf), &cptr->ip); if(pnode == NULL) return; pnode->data--; if(((unsigned long) pnode->data) == 0) patricia_remove(ConfCidrTree(aconf), pnode); } #endif /* ENABLE_CIDR_LIMITS */ /* ** detach_conf ** Disassociate configuration from the client. ** Also removes a class from the list if marked for deleting. */ int detach_conf(aClient *cptr, aConfItem *aconf) { Reg Link **lp, *tmp; aConfItem **aconf2,*aconf3; lp = &(cptr->confs); while (*lp) { if ((*lp)->value.aconf == aconf) { if ((aconf) && (Class(aconf))) { if (aconf->status & CONF_CLIENT_MASK) { if (ConfLinks(aconf) > 0) --ConfLinks(aconf); #ifdef ENABLE_CIDR_LIMITS if ((aconf->status & CONF_CLIENT)) remove_cidr_limit(cptr, aconf); #endif } if (ConfMaxLinks(aconf) == -1 && ConfLinks(aconf) == 0) { free_class(Class(aconf)); Class(aconf) = NULL; } } if (aconf && --aconf->clients <= 0 && IsIllegal(aconf)) { /* Remove the conf entry from the Conf linked list */ for (aconf2 = &conf; (aconf3 = *aconf2); ) { if (aconf3 == aconf) { *aconf2 = aconf3->next; aconf3->next = NULL; free_conf(aconf); } else { aconf2 = &aconf3->next; } } } tmp = *lp; *lp = tmp->next; free_link(tmp); istat.is_conflink--; return 0; } else lp = &((*lp)->next); } return -1; } static int is_attached(aConfItem *aconf, aClient *cptr) { Reg Link *lp; for (lp = cptr->confs; lp; lp = lp->next) if (lp->value.aconf == aconf) break; return (lp) ? 1 : 0; } /* ** attach_conf ** Associate a specific configuration entry to a *local* ** client (this is the one which used in accepting the ** connection). Note, that this automaticly changes the ** attachment if there was an old one... ** Non-zero return value is used in register_user(). */ int attach_conf(aClient *cptr, aConfItem *aconf) { Reg Link *lp; if (is_attached(aconf, cptr)) return 1; if (IsIllegal(aconf)) return -1; /* EXITC_FAILURE, hmm */ if ((aconf->status & (CONF_OPERATOR | CONF_CLIENT ))) { if ( #ifdef YLINE_LIMITS_OLD_BEHAVIOUR aconf->clients >= ConfMaxLinks(aconf) #else ConfLinks(aconf) >= ConfMaxLinks(aconf) #endif && ConfMaxLinks(aconf) > 0) return -3; /* EXITC_YLINEMAX */ } if ((aconf->status & CONF_CLIENT)) { int hcnt = 0, ucnt = 0; int ghcnt = 0, gucnt = 0; anUser *user = NULL; /* check on local/global limits per host and per user@host */ #ifdef ENABLE_CIDR_LIMITS if(!add_cidr_limit(cptr, aconf)) return -4; /* EXITC_LHMAX */ #endif /* ** local limits first to save CPU if any is hit. ** host check is done on the IP address. ** user check is done on the IDENT reply. */ if (ConfMaxHLocal(aconf) > 0 || ConfMaxUHLocal(aconf) > 0 || ConfMaxHGlobal(aconf) > 0 || ConfMaxUHGlobal(aconf) > 0 ) { #ifdef YLINE_LIMITS_IPHASH for ((user = hash_find_ip(cptr->user->sip, NULL)); user; user = user->iphnext) if (!mycmp(cptr->user->sip, user->sip)) #else for ((user = hash_find_hostname(cptr->sockhost, NULL)); user; user = user->hhnext) if (!mycmp(cptr->sockhost, user->host)) #endif { ghcnt++; if (ConfMaxHGlobal(aconf) > 0 && ghcnt >= ConfMaxHGlobal(aconf)) { return -6; /* EXITC_GHMAX */ } if (MyConnect(user->bcptr)) { hcnt++; if (ConfMaxHLocal(aconf) > 0 && hcnt >= ConfMaxHLocal(aconf)) { return -4; /* EXITC_LHMAX */ } if (!mycmp(user->bcptr->auth, cptr->auth)) { ucnt++; gucnt++; } } else { if (!mycmp(user->username, cptr->user->username )) { gucnt++; } } if (ConfMaxUHLocal(aconf) > 0 && ucnt >= ConfMaxUHLocal(aconf)) { return -5; /* EXITC_LUHMAX */ } if (ConfMaxUHGlobal(aconf) > 0 && gucnt >= ConfMaxUHGlobal(aconf)) { return -7; /* EXITC_GUHMAX */ } } } } lp = make_link(); istat.is_conflink++; lp->next = cptr->confs; lp->value.aconf = aconf; cptr->confs = lp; cptr->ping = get_client_ping(cptr); aconf->clients++; if (aconf->status & CONF_CLIENT_MASK) ConfLinks(aconf)++; return 0; } aConfItem *find_admin(void) { Reg aConfItem *aconf; for (aconf = conf; aconf; aconf = aconf->next) if (aconf->status & CONF_ADMIN) break; return (aconf); } aConfItem *find_me(void) { Reg aConfItem *aconf; for (aconf = conf; aconf; aconf = aconf->next) if (aconf->status & CONF_ME) break; return (aconf); } /* * attach_confs * Attach a CONF line to a client if the name passed matches that for * the conf file (for non-C/N lines) or is an exact match (C/N lines * only). The difference in behaviour is to stop C:*::* and N:*::*. */ aConfItem *attach_confs(aClient *cptr, char *name, int statmask) { Reg aConfItem *tmp; aConfItem *first = NULL; int len = strlen(name); if (!name || len > HOSTLEN) return NULL; for (tmp = conf; tmp; tmp = tmp->next) { if ((tmp->status & statmask) && !IsIllegal(tmp) && ((tmp->status & (CONF_SERVER_MASK|CONF_HUB)) == 0) && tmp->name && !match(tmp->name, name)) { if (!attach_conf(cptr, tmp) && !first) first = tmp; } else if ((tmp->status & statmask) && !IsIllegal(tmp) && (tmp->status & (CONF_SERVER_MASK|CONF_HUB)) && tmp->name && !mycmp(tmp->name, name)) { if (!attach_conf(cptr, tmp) && !first) first = tmp; } } return (first); } /* * Added for new access check meLazy */ aConfItem *attach_confs_host(aClient *cptr, char *host, int statmask) { Reg aConfItem *tmp; aConfItem *first = NULL; int len = strlen(host); if (!host || len > HOSTLEN) return NULL; for (tmp = conf; tmp; tmp = tmp->next) { if ((tmp->status & statmask) && !IsIllegal(tmp) && (tmp->status & CONF_SERVER_MASK) == 0 && (!tmp->host || match(tmp->host, host) == 0)) { if (!attach_conf(cptr, tmp) && !first) first = tmp; } else if ((tmp->status & statmask) && !IsIllegal(tmp) && (tmp->status & CONF_SERVER_MASK) && (tmp->host && mycmp(tmp->host, host) == 0)) { if (!attach_conf(cptr, tmp) && !first) first = tmp; } } return (first); } /* * find a conf entry which matches the hostname and has the same name. */ aConfItem *find_conf_exact(char *name, char *user, char *host, int statmask) { Reg aConfItem *tmp; char userhost[USERLEN+HOSTLEN+3]; sprintf(userhost, "%s@%s", user, host); for (tmp = conf; tmp; tmp = tmp->next) { if (!(tmp->status & statmask) || !tmp->name || !tmp->host || mycmp(tmp->name, name)) continue; /* ** Accept if the *real* hostname (usually sockecthost) ** socket host) matches *either* host or name field ** of the configuration. */ if (match(tmp->host, userhost)) continue; if (tmp->status & CONF_OPERATOR) { if (tmp->clients < MaxLinks(Class(tmp))) return tmp; else continue; } else return tmp; } return NULL; } /* * find an O-line which matches the hostname and has the same "name". */ aConfItem *find_Oline(char *name, aClient *cptr) { Reg aConfItem *tmp, *tmp2 = NULL; char userhost[USERLEN+HOSTLEN+3]; char userip[USERLEN+HOSTLEN+3]; sprintf(userhost, "%s@%s", cptr->username, cptr->sockhost); sprintf(userip, "%s@%s", cptr->username, cptr->user->sip); for (tmp = conf; tmp; tmp = tmp->next) { if (!(tmp->status & (CONF_OPS)) || !tmp->name || !tmp->host || mycmp(tmp->name, name)) continue; /* ** Accept if the *real* hostname matches the host field or ** the ip does. */ if (match(tmp->host, userhost) && match(tmp->host, userip) && (!strchr(tmp->host, '/') || match_ipmask(tmp->host, cptr, 1))) continue; if (tmp->clients < MaxLinks(Class(tmp))) return tmp; else tmp2 = tmp; } return tmp2; } aConfItem *find_conf_name(char *name, int statmask) { Reg aConfItem *tmp; for (tmp = conf; tmp; tmp = tmp->next) { /* ** Accept if the hostname matches name field ** of the configuration. */ if ((tmp->status & statmask) && (!tmp->name || match(tmp->name, name) == 0)) return tmp; } return NULL; } aConfItem *find_conf(Link *lp, char *name, int statmask) { Reg aConfItem *tmp; int namelen = name ? strlen(name) : 0; if (namelen > HOSTLEN) return (aConfItem *) 0; for (; lp; lp = lp->next) { tmp = lp->value.aconf; if ((tmp->status & statmask) && (((tmp->status & (CONF_SERVER_MASK|CONF_HUB)) && tmp->name && !mycmp(tmp->name, name)) || ((tmp->status & (CONF_SERVER_MASK|CONF_HUB)) == 0 && tmp->name && !match(tmp->name, name)))) return tmp; } return NULL; } /* * Added for new access check meLazy */ aConfItem *find_conf_host(Link *lp, char *host, int statmask) { Reg aConfItem *tmp; int hostlen = host ? strlen(host) : 0; if (hostlen > HOSTLEN || BadPtr(host)) return (aConfItem *)NULL; for (; lp; lp = lp->next) { tmp = lp->value.aconf; if (tmp->status & statmask && (!(tmp->status & CONF_SERVER_MASK || tmp->host) || (tmp->host && !match(tmp->host, host)))) return tmp; } return NULL; } aConfItem *find_conf_host_sid(Link *lp, char *host, char *sid, int statmask) { Reg aConfItem *tmp; int hostlen = host ? strlen(host) : 0; if (hostlen > HOSTLEN || BadPtr(host)) return (aConfItem *)NULL; for (; lp; lp = lp->next) { tmp = lp->value.aconf; if (tmp->status & statmask && (!(tmp->status & CONF_SERVER_MASK || tmp->host) || (tmp->host && !match(tmp->host, host))) && (!tmp->passwd || !tmp->passwd[0] || !match(tmp->passwd, sid)) ) { return tmp; } } return NULL; } /* * find_conf_ip * * Find a conf line using the IP# stored in it to search upon. * Added 1/8/92 by Avalon. */ aConfItem *find_conf_ip(Link *lp, char *ip, char *user, int statmask) { Reg aConfItem *tmp; Reg char *s; for (; lp; lp = lp->next) { tmp = lp->value.aconf; if (!(tmp->status & statmask)) continue; s = index(tmp->host, '@'); *s = '\0'; if (match(tmp->host, user)) { *s = '@'; continue; } *s = '@'; if (!bcmp((char *)&tmp->ipnum, ip, sizeof(struct IN_ADDR))) return tmp; } return NULL; } /* * find_conf_entry * * - looks for a match on all given fields. */ aConfItem *find_conf_entry(aConfItem *aconf, u_int mask) { Reg aConfItem *bconf; for (bconf = conf, mask &= ~CONF_ILLEGAL; bconf; bconf = bconf->next) { if (!(bconf->status & mask) || (bconf->port != aconf->port)) continue; if ((BadPtr(bconf->host) && !BadPtr(aconf->host)) || (BadPtr(aconf->host) && !BadPtr(bconf->host))) continue; if (!BadPtr(bconf->host) && mycmp(bconf->host, aconf->host)) continue; if ((BadPtr(bconf->passwd) && !BadPtr(aconf->passwd)) || (BadPtr(aconf->passwd) && !BadPtr(bconf->passwd))) continue; if (!BadPtr(bconf->passwd) && mycmp(bconf->passwd, aconf->passwd)) continue; if ((BadPtr(bconf->name) && !BadPtr(aconf->name)) || (BadPtr(aconf->name) && !BadPtr(bconf->name))) continue; if (!BadPtr(bconf->name) && mycmp(bconf->name, aconf->name)) continue; break; } return bconf; } /* * rehash * * Actual REHASH service routine. Called with sig == 0 if it has been called * as a result of an operator issuing this command, else assume it has been * called as a result of the server receiving a HUP signal. */ int rehash(aClient *cptr, aClient *sptr, int sig) { Reg aConfItem **tmp = &conf, *tmp2 = NULL; Reg aClass *cltmp; Reg aClient *acptr; Reg int i; int ret = 0; if (sig == 1) { sendto_flag(SCH_NOTICE, "Got signal SIGHUP, reloading ircd.conf file"); logfiles_close(); logfiles_open(); #ifdef ULTRIX if (fork() > 0) exit(0); write_pidfile(); #endif } for (i = 0; i <= highest_fd; i++) if ((acptr = local[i]) && !IsMe(acptr)) { /* * Nullify any references from client structures to * this host structure which is about to be freed. * Could always keep reference counts instead of * this....-avalon */ acptr->hostp = NULL; } while ((tmp2 = *tmp)) if (tmp2->clients || tmp2->status & CONF_LISTEN_PORT) { /* ** Configuration entry is still in use by some ** local clients, cannot delete it--mark it so ** that it will be deleted when the last client ** exits... */ if (!(tmp2->status & (CONF_LISTEN_PORT|CONF_CLIENT))) { *tmp = tmp2->next; tmp2->next = NULL; } else tmp = &tmp2->next; tmp2->status |= CONF_ILLEGAL; } else { *tmp = tmp2->next; free_conf(tmp2); } tmp = &kconf; while ((tmp2 = *tmp)) { *tmp = tmp2->next; free_conf(tmp2); } /* * We don't delete the class table, rather mark all entries * for deletion. The table is cleaned up by check_class. - avalon */ for (cltmp = NextClass(FirstClass()); cltmp; cltmp = NextClass(cltmp)) MaxLinks(cltmp) = -1; if (sig == 'a') start_iauth(2); /* 2 means kill iauth first */ if (sig == 'd') { flush_cache(); close(resfd); resfd = init_resolver(0x1f); } #ifdef TKLINE if (sig == 't') tkline_expire(1); #endif (void) initconf(0); close_listeners(); reopen_listeners(); /* * Flush *unused* config entries. */ for (tmp = &conf; (tmp2 = *tmp); ) if (!(tmp2->status & CONF_ILLEGAL) || (tmp2->clients > 0)) tmp = &tmp2->next; else { *tmp = tmp2->next; tmp2->next = NULL; free_conf(tmp2); } read_motd(IRCDMOTD_PATH); if (rehashed == 1) { /* queue another rehash for later */ rehashed = 2; } else if (rehashed == 0) { rehashed = 1; } mysrand(timeofday); return ret; } /* * openconf * * returns -1 on any error or else the fd opened from which to read the * configuration file from. This may either be the file direct or one end * of a pipe from m4. */ int openconf(void) { #ifdef M4_PREPROC int pi[2], i; # ifdef HAVE_GNU_M4 char *includedir, *includedirptr; includedir = strdup(IRCDM4_PATH); includedirptr = strrchr(includedir, '/'); if (includedirptr) *includedirptr = '\0'; # endif #else int ret; #endif #ifdef M4_PREPROC if (pipe(pi) == -1) return -1; switch(vfork()) { case -1 : if (serverbooting) { fprintf(stderr, "Fatal Error: Unable to fork() m4 (%s)", strerror(errno)); } return -1; case 0 : (void)close(pi[0]); if (pi[1] != 1) { (void)dup2(pi[1], 1); (void)close(pi[1]); } /* If the server is booting, stderr is still open and * user should receive error message */ if (!serverbooting) { (void)dup2(1,2); } for (i = 3; i < MAXCONNECTIONS; i++) if (local[i]) (void) close(i); /* * m4 maybe anywhere, use execvp to find it. Any error * goes out with report_error. Could be dangerous, * two servers running with the same fd's >:-) -avalon */ (void)execlp(M4_PATH, "m4", #ifdef HAVE_GNU_M4 #ifdef USE_M4_PREFIXES "-P", #endif "-I", includedir, #endif #ifdef INET6 "-DINET6", #endif IRCDM4_PATH, configfile, (char *) NULL); if (serverbooting) { fprintf(stderr,"Fatal Error: Error executing m4 (%s)", strerror(errno)); } report_error("Error executing m4 %s:%s", &me); _exit(-1); default : (void)close(pi[1]); return pi[0]; } #else if ((ret = open(configfile, O_RDONLY)) == -1) { if (serverbooting) { fprintf(stderr, "Fatal Error: Can not open configuration file %s (%s)\n", configfile,strerror(errno)); } } return ret; #endif } /* ** char *ipv6_convert(char *orig) ** converts the original ip address to an standard form ** returns a pointer to a string. */ #ifdef INET6 char *ipv6_convert(char *orig) { char *s, *t, *buf = NULL; int i, j; int len = 1; /* for the '\0' in case of no @ */ struct in6_addr addr; if ((s = strchr(orig, '@'))) { *s = '\0'; len = strlen(orig) + 2; /* +2 for '@' and '\0' */ buf = (char *)MyMalloc(len); (void *)strcpy(buf, orig); buf[len - 2] = '@'; buf[len - 1] = '\0'; *s = '@'; orig = s + 1; } if ((s = strchr(orig, '/'))) { *s = '\0'; s++; } i = inetpton(AF_INET6, orig, addr.s6_addr); if (i > 0) { t = inetntop(AF_INET6, addr.s6_addr, ipv6string, sizeof(ipv6string)); } j = len - 1; if (!((i > 0) && t)) t = orig; len += strlen(t); buf = (char *)MyRealloc(buf, len); strcpy(buf + j, t); if (s) { *(s-1) = '/'; /* put the '/' back, not sure it's needed tho */ j = len; len += strlen(s) + 1; buf = (char *)MyRealloc(buf, len); buf[j - 1] = '/'; strcpy(buf + j, s); } return buf; } #endif /* ** initconf() ** Read configuration file. ** ** returns -1, if file cannot be opened ** 0, if file opened */ #define MAXCONFLINKS 150 int initconf(int opt) { static char quotes[9][2] = {{'b', '\b'}, {'f', '\f'}, {'n', '\n'}, {'r', '\r'}, {'t', '\t'}, {'v', '\v'}, {'\\', '\\'}, { 0, 0}}; Reg char *tmp, *s; int fd, i; char *tmp2 = NULL, *tmp3 = NULL, *tmp4 = NULL; #ifdef ENABLE_CIDR_LIMITS char *tmp5 = NULL; #endif int ccount = 0, ncount = 0; aConfItem *aconf = NULL; #if defined(CONFIG_DIRECTIVE_INCLUDE) char *line; aConfig *ConfigTop, *p; FILE *fdn; #else char line[512], c[80]; #endif Debug((DEBUG_DEBUG, "initconf(): ircd.conf = %s", configfile)); if ((fd = openconf()) == -1) { #if defined(M4_PREPROC) && !defined(USE_IAUTH) (void)wait(0); #endif return -1; } #if defined(CONFIG_DIRECTIVE_INCLUDE) fdn = fdopen(fd, "r"); if (fdn == NULL) { if (serverbooting) { fprintf(stderr, "Fatal Error: Can not open configuration file %s (%s)\n", configfile,strerror(errno)); } return -1; } ConfigTop = config_read(fdn, 0, new_config_file(configfile, NULL, 0)); for(p = ConfigTop; p; p = p->next) #else (void)dgets(-1, NULL, 0); /* make sure buffer is at empty pos */ while ((i = dgets(fd, line, sizeof(line) - 1)) > 0) #endif { #if defined(CONFIG_DIRECTIVE_INCLUDE) line = p->line; #else line[i] = '\0'; if ((tmp = (char *)index(line, '\n'))) *tmp = 0; else while(dgets(fd, c, sizeof(c) - 1) > 0) if ((tmp = (char *)index(c, '\n'))) { *tmp = 0; break; } #endif /* * Do quoting of characters and # detection. */ for (tmp = line; *tmp; tmp++) { if (*tmp == '\\') { for (i = 0; quotes[i][0]; i++) if (quotes[i][0] == *(tmp+1)) { *tmp = quotes[i][1]; break; } if (!quotes[i][0]) *tmp = *(tmp+1); if (!*(tmp+1)) break; else for (s = tmp; (*s = *(s+1)); s++) ; } else if (*tmp == '#') { *tmp = '\0'; break; /* Ignore the rest of the line */ } } if (!*line || line[0] == '#' || line[0] == '\n' || line[0] == ' ' || line[0] == '\t') continue; /* Could we test if it's conf line at all? -Vesa */ if (line[1] != IRCDCONF_DELIMITER) { Debug((DEBUG_ERROR, "Bad config line: %s", line)); continue; } if (aconf) free_conf(aconf); aconf = make_conf(); if (tmp2) MyFree(tmp2); tmp3 = tmp4 = NULL; #ifdef ENABLE_CIDR_LIMITS tmp5 = NULL; #endif tmp = getfield(line); if (!tmp) continue; switch (*tmp) { case 'A': /* Name, e-mail address of administrator */ case 'a': /* of this server. */ aconf->status = CONF_ADMIN; break; case 'B': /* Name of alternate servers */ case 'b': aconf->status = CONF_BOUNCE; break; case 'C': /* Server where I should try to connect */ /* in case of lp failures */ ccount++; aconf->status = CONF_CONNECT_SERVER; break; case 'c': ccount++; aconf->status = CONF_ZCONNECT_SERVER; break; case 'D': /* auto connect restrictions */ case 'd': aconf->status = CONF_DENY; break; case 'H': /* Hub server line */ case 'h': aconf->status = CONF_HUB; break; case 'i' : /* Restricted client */ aconf->flags |= CFLAG_RESTRICTED; case 'I': aconf->status = CONF_CLIENT; break; case 'K': /* Kill user line on irc.conf */ aconf->status = CONF_KILL; break; case 'k': aconf->status = CONF_OTHERKILL; break; /* Operator. Line should contain at least */ /* password and host where connection is */ case 'L': /* guaranteed leaf server */ case 'l': aconf->status = CONF_LEAF; break; /* Me. Host field is name used for this host */ /* and port number is the number of the port */ case 'M': case 'm': aconf->status = CONF_ME; break; case 'N': /* Server where I should NOT try to */ case 'n': /* connect in case of lp failures */ /* but which tries to connect ME */ ++ncount; aconf->status = CONF_NOCONNECT_SERVER; break; case 'o': aconf->flags |= ACL_LOCOP; case 'O': aconf->status = CONF_OPERATOR; break; case 'P': /* listen port line */ case 'p': aconf->status = CONF_LISTEN_PORT; break; case 'Q': /* a server that you don't want in your */ case 'q': /* network. USE WITH CAUTION! */ aconf->status = CONF_QUARANTINED_SERVER; break; case 'S': /* Service. Same semantics as */ case 's': /* CONF_OPERATOR */ aconf->status = CONF_SERVICE; break; case 'V': /* Server link version requirements */ aconf->status = CONF_VER; break; case 'Y': case 'y': aconf->status = CONF_CLASS; break; #ifdef XLINE case 'X': aconf->status = CONF_XLINE; break; #endif default: Debug((DEBUG_ERROR, "Error in config file: %s", line)); break; } if (IsIllegal(aconf)) continue; do { if ((tmp = getfield(NULL)) == NULL) break; #ifdef INET6 if (aconf->status & (CONF_CONNECT_SERVER|CONF_ZCONNECT_SERVER |CONF_CLIENT|CONF_KILL |CONF_OTHERKILL|CONF_NOCONNECT_SERVER |CONF_OPERATOR|CONF_LISTEN_PORT |CONF_SERVICE)) aconf->host = ipv6_convert(tmp); else DupString(aconf->host, tmp); #else DupString(aconf->host, tmp); #endif if ((tmp = getfield(NULL)) == NULL) break; DupString(aconf->passwd, tmp); if ((tmp = getfield(NULL)) == NULL) break; DupString(aconf->name, tmp); if ((tmp = getfield(NULL)) == NULL) break; #ifdef XLINE if (aconf->status == CONF_XLINE) { DupString(aconf->name2, tmp); if ((tmp = getfield(NULL)) == NULL) break; DupString(aconf->name3, tmp); if ((tmp = getfield(NULL)) == NULL) break; DupString(aconf->source_ip, tmp); break; } #endif aconf->port = 0; if (sscanf(tmp, "0x%x", &aconf->port) != 1 || aconf->port == 0) aconf->port = atoi(tmp); if (aconf->status == CONF_CONNECT_SERVER) DupString(tmp2, tmp); if (aconf->status == CONF_ZCONNECT_SERVER) DupString(tmp2, tmp); if ((tmp = getfield(NULL)) == NULL) break; Class(aconf) = find_class(atoi(tmp)); /* used in Y: local limits and I: and P: flags */ if ((tmp3 = getfield(NULL)) == NULL) break; /* used in Y: global limits */ if((tmp4 = getfield(NULL)) == NULL) break; #ifdef ENABLE_CIDR_LIMITS tmp5 = getfield(NULL); #endif } while (0); /* to use break without compiler warnings */ istat.is_confmem += aconf->host ? strlen(aconf->host)+1 : 0; istat.is_confmem += aconf->passwd ? strlen(aconf->passwd)+1 :0; istat.is_confmem += aconf->name ? strlen(aconf->name)+1 : 0; istat.is_confmem += aconf->name2 ? strlen(aconf->name2)+1 : 0; #ifdef XLINE istat.is_confmem += aconf->name3 ? strlen(aconf->name3)+1 : 0; #endif istat.is_confmem += aconf->source_ip ? strlen(aconf->source_ip)+1 : 0; /* ** Bounce line fields are mandatory */ if (aconf->status == CONF_BOUNCE && aconf->port == 0) continue; /* ** If conf line is a class definition, create a class entry ** for it and make the conf_line illegal and delete it. */ if (aconf->status & CONF_CLASS) { if (atoi(aconf->host) >= 0) add_class(atoi(aconf->host), atoi(aconf->passwd), atoi(aconf->name), aconf->port, tmp ? atoi(tmp) : 0, (tmp && index(tmp, '.')) ? atoi(index(tmp, '.') + 1) : 0, tmp3 ? atoi(tmp3) : 1, (tmp3 && index(tmp3, '.')) ? atoi(index(tmp3, '.') + 1) : 1, tmp4 ? atoi(tmp4) : 1, (tmp4 && index(tmp4, '.')) ? atoi(index(tmp4, '.') + 1) : 1 #ifdef ENABLE_CIDR_LIMITS , tmp5 #endif ); continue; } /* ** associate each conf line with a class by using a pointer ** to the correct class record. -avalon */ if (aconf->status & (CONF_CLIENT_MASK|CONF_LISTEN_PORT)) { if (Class(aconf) == 0) Class(aconf) = find_class(0); if (MaxLinks(Class(aconf)) < 0) Class(aconf) = find_class(0); } if (aconf->status & (CONF_LISTEN_PORT|CONF_CLIENT)) { aConfItem *bconf; /* any flags in this line? */ if (tmp3) { aconf->flags |= ((aconf->status == CONF_CLIENT) ? iline_flags_parse(tmp3) : pline_flags_parse(tmp3)); } /* trying to find exact conf line in already existing * conf, so we don't delete old one, just update it */ if ( #ifdef FASTER_ILINE_REHASH (aconf->status & CONF_LISTEN_PORT) && #endif (bconf = find_conf_entry(aconf, aconf->status))) { /* we remove bconf (already existing) from conf * so that we can add it back uniformly at the * end of while(dgets) loop. --B. */ delist_conf(bconf); bconf->status &= ~CONF_ILLEGAL; /* aconf is a new item, it can contain +r flag * (from lowercase i:lines). In any case we * don't want old flags to remain. --B. */ bconf->flags = aconf->flags; /* in case class was changed */ if (aconf->status == CONF_CLIENT && aconf->class != bconf->class) { bconf->class->links -= bconf->clients; bconf->class = aconf->class; bconf->class->links += bconf->clients; } /* free new one, assign old one to aconf */ free_conf(aconf); aconf = bconf; } else /* no such conf line was found */ { if (aconf->host && aconf->status == CONF_LISTEN_PORT) { (void)add_listener(aconf); } } } if (aconf->status & CONF_SERVICE) aconf->port &= SERVICE_MASK_ALL; if (aconf->status & (CONF_SERVER_MASK|CONF_SERVICE)) { char *hostptr = NULL; /* since it's u@h syntax, let's ignore user part in checks below --B. */ hostptr = index(aconf->host, '@'); if (hostptr != NULL) hostptr++; /* move ptr after '@' */ else hostptr = aconf->host; if (ncount > MAXCONFLINKS || ccount > MAXCONFLINKS || !hostptr || index(hostptr, '*') || index(hostptr,'?') || !aconf->name) continue; /* next config line */ } if (aconf->status & (CONF_SERVER_MASK|CONF_OPERATOR|CONF_SERVICE)) if (!index(aconf->host, '@') && *aconf->host != '/') { char *newhost; int len = 3; /* *@\0 = 3 */ len += strlen(aconf->host); newhost = (char *)MyMalloc(len); sprintf(newhost, "*@%s", aconf->host); MyFree(aconf->host); aconf->host = newhost; istat.is_confmem += 2; } if (tmp3 && (aconf->status & CONF_OPERATOR)) { aconf->flags |= oline_flags_parse(tmp3); /* remove this when removing o: lines --B. */ if (aconf->flags & ACL_LOCOP) aconf->flags &= ~ACL_ALL_REMOTE; } if (aconf->status & CONF_SERVER_MASK) { if (BadPtr(aconf->passwd)) continue; else if (!(opt & BOOT_QUICK)) (void)lookup_confhost(aconf); } if (aconf->status & (CONF_CONNECT_SERVER | CONF_ZCONNECT_SERVER)) { aconf->ping = (aCPing *)MyMalloc(sizeof(aCPing)); bzero((char *)aconf->ping, sizeof(*aconf->ping)); istat.is_confmem += sizeof(*aconf->ping); if (tmp2 && index(tmp2, '.')) aconf->ping->port = atoi(index(tmp2, '.') + 1); else aconf->ping->port = aconf->port; if (tmp2) { MyFree(tmp2); tmp2 = NULL; } if (tmp3) { DupString(aconf->source_ip, tmp3); } } /* ** Name cannot be changed after the startup. ** (or could be allowed, but only if all links are closed ** first). ** Configuration info does not override the name and port ** if previously defined. Note, that "info"-field can be ** changed by "/rehash". */ if (aconf->status == CONF_ME) { if (me.info != DefInfo) MyFree(me.info); me.info = MyMalloc(REALLEN+1); strncpyzt(me.info, aconf->name, REALLEN+1); if (me.serv->namebuf[0] == '\0' && aconf->host[0]) strncpyzt(me.serv->namebuf, aconf->host, sizeof(me.serv->namebuf)); if (me.serv->sid[0] == '\0' && tmp && *tmp) { for(i = 0; i < sizeof(me.serv->sid); i++) me.serv->sid[i] = toupper(tmp[i]); } if (aconf->port) setup_ping(aconf); } if (aconf->status == CONF_ADMIN) { if (!networkname && tmp && *tmp) { if (strlen(tmp) < HOSTLEN) { DupString(networkname,tmp); } } } (void)collapse(aconf->host); (void)collapse(aconf->name); Debug((DEBUG_NOTICE, "Read Init: (%d) (%s) (%s) (%s) (%d) (%d)", aconf->status, aconf->host, aconf->passwd, aconf->name, aconf->port, aconf->class ? ConfClass(aconf) : 0)); if (aconf->status & (CONF_KILL|CONF_OTHERKILL)) { aconf->next = kconf; kconf = aconf; } else { aconf->next = conf; conf = aconf; } aconf = NULL; } #if defined(CONFIG_DIRECTIVE_INCLUDE) config_free(ConfigTop); #endif if (aconf) free_conf(aconf); (void)dgets(-1, NULL, 0); /* make sure buffer is at empty pos */ #if defined(CONFIG_DIRECTIVE_INCLUDE) (void)fclose(fdn); #else (void)close(fd); #endif #if defined(M4_PREPROC) && !defined(USE_IAUTH) (void)wait(0); #endif check_class(); nextping = nextconnect = timeofday; return 0; } /* * lookup_confhost * Do (start) DNS lookups of all hostnames in the conf line and convert * an IP addresses in a.b.c.d number for to IP#s. */ static int lookup_confhost(aConfItem *aconf) { Reg char *s; Reg struct hostent *hp; Link ln; if (BadPtr(aconf->host) || BadPtr(aconf->name)) goto badlookup; if ((s = index(aconf->host, '@'))) s++; else s = aconf->host; /* ** Do name lookup now on hostnames given and store the ** ip numbers in conf structure. */ if (!isalpha(*s) && !isdigit(*s)) goto badlookup; /* ** Prepare structure in case we have to wait for a ** reply which we get later and store away. */ ln.value.aconf = aconf; ln.flags = ASYNC_CONF; #ifdef INET6 if(inetpton(AF_INET6, s, aconf->ipnum.s6_addr)) ; #else if (isdigit(*s)) aconf->ipnum.s_addr = inetaddr(s); #endif else if ((hp = gethost_byname(s, &ln))) bcopy(hp->h_addr, (char *)&(aconf->ipnum), sizeof(struct IN_ADDR)); #ifdef INET6 else { bcopy(minus_one, aconf->ipnum.s6_addr, IN6ADDRSZ); goto badlookup; } #else if (aconf->ipnum.s_addr == -1) goto badlookup; #endif return 0; badlookup: #ifdef INET6 if (AND16(aconf->ipnum.s6_addr) == 255) #else if (aconf->ipnum.s_addr == -1) #endif bzero((char *)&aconf->ipnum, sizeof(struct IN_ADDR)); Debug((DEBUG_ERROR,"Host/server name error: (%s) (%s)", aconf->host, aconf->name)); return -1; } int find_kill(aClient *cptr, int timedklines, char **comment) { #ifdef TIMEDKLINES static char reply[256]; int now = 0; #endif char *host, *ip, *name, *ident, *check; aConfItem *tmp; #ifdef TKLINE int tklines = 1; #endif if (!cptr->user) return 0; if (IsKlineExempt(cptr)) { return 0; } host = cptr->sockhost; #ifdef INET6 ip = (char *) inetntop(AF_INET6, (char *)&cptr->ip, ipv6string, sizeof(ipv6string)); #else ip = (char *) inetntoa((char *)&cptr->ip); #endif if (!strcmp(host, ip)) ip = NULL; /* we don't have a name for the ip# */ name = cptr->user->username; if (IsRestricted(cptr) && name[0] == '+') { /* ** since we added '+' at the begining of valid ** ident response, remove it here for kline ** comparison --Beeth */ name++; } ident = cptr->auth; if (strlen(host) > (size_t) HOSTLEN || (name ? strlen(name) : 0) > (size_t) HOSTLEN) return (0); #ifdef TIMEDKLINES *reply = '\0'; #endif findkline: tmp = #ifdef TKLINE tklines ? tkconf : #endif kconf; for (; tmp; tmp = tmp->next) { #ifdef TIMEDKLINES if (timedklines && (BadPtr(tmp->passwd) || !isdigit(*tmp->passwd))) continue; #endif if (!(tmp->status & ( #ifdef TKLINE tklines ? (CONF_TKILL | CONF_TOTHERKILL) : #endif (CONF_KILL | CONF_OTHERKILL)))) continue; /* should never happen with kconf */ if (!tmp->host || !tmp->name) continue; #ifdef TKLINE /* this TK already expired */ if (tklines && tmp->hold < timeofday) continue; #endif if (tmp->status == ( #ifdef TKLINE tklines ? CONF_TKILL : #endif CONF_KILL)) check = name; else check = ident; /* host & IP matching.. */ if (!ip) /* unresolved */ { if (strchr(tmp->host, '/')) { if (match_ipmask((*tmp->host == '=') ? tmp->host+1: tmp->host, cptr, 1)) continue; } else if (match((*tmp->host == '=') ? tmp->host+1 : tmp->host, host)) continue; } else if (*tmp->host == '=') /* numeric only */ continue; else /* resolved */ if (strchr(tmp->host, '/')) { if (match_ipmask(tmp->host, cptr, 1)) continue; } else if (match(tmp->host, ip) && match(tmp->host, host)) continue; /* user & port matching */ if ((!check || match(tmp->name, check) == 0) && (!tmp->port || (tmp->port == cptr->acpt->port))) { #ifdef TIMEDKLINES now = 0; if (!BadPtr(tmp->passwd) && isdigit(*tmp->passwd) && !(now = check_time_interval(tmp->passwd, reply))) continue; if (now == ERR_YOUWILLBEBANNED) tmp = NULL; #endif break; } } #ifdef TKLINE if (!tmp && tklines) { tklines = 0; goto findkline; } #endif if (tmp && !BadPtr(tmp->passwd)) { *comment = tmp->passwd; } else { *comment = NULL; } #ifdef TIMEDKLINES if (*reply) { sendto_one(cptr, reply, ME, now, cptr->name); } else #endif if (tmp) { sendto_one(cptr, replies[ERR_YOUREBANNEDCREEP], ME, cptr->name, BadPtr(tmp->name) ? "*" : tmp->name, BadPtr(tmp->host) ? "*" : tmp->host, *comment ? ": " : "", *comment ? *comment : ""); } return (tmp ? -1 : 0); } /* * For type stat, check if both name and host masks match. * Return -1 for match, 0 for no-match. */ int find_two_masks(char *name, char *host, int stat) { aConfItem *tmp; for (tmp = conf; tmp; tmp = tmp->next) if ((tmp->status == stat) && tmp->host && tmp->name && (match(tmp->host, host) == 0) && (match(tmp->name, name) == 0)) break; return (tmp ? -1 : 0); } /* * For type stat, check if name matches and any char from key matches * to chars in passwd field. * Return -1 for match, 0 for no-match. */ int find_conf_flags(char *name, char *key, int stat) { aConfItem *tmp; int l; if (index(key, '/') == NULL) return 0; l = ((char *)index(key, '/') - key) + 1; for (tmp = conf; tmp; tmp = tmp->next) if ((tmp->status == stat) && tmp->passwd && tmp->name && (strncasecmp(key, tmp->passwd, l) == 0) && (match(tmp->name, name) == 0) && (strpbrk(key + l, tmp->passwd + l))) break; return (tmp ? -1 : 0); } #ifdef TIMEDKLINES /* ** check against a set of time intervals */ static int check_time_interval(char *interval, char *reply) { struct tm *tptr; char *p; int perm_min_hours, perm_min_minutes, perm_max_hours, perm_max_minutes; int now, perm_min, perm_max; tptr = localtime(&timeofday); now = tptr->tm_hour * 60 + tptr->tm_min; while (interval) { p = (char *)index(interval, ','); if (p) *p = '\0'; if (sscanf(interval, "%2d%2d-%2d%2d", &perm_min_hours, &perm_min_minutes, &perm_max_hours, &perm_max_minutes) != 4) { if (p) *p = ','; return(0); } if (p) *(p++) = ','; perm_min = 60 * perm_min_hours + perm_min_minutes; perm_max = 60 * perm_max_hours + perm_max_minutes; /* ** The following check allows intervals over midnight ... */ if ((perm_min < perm_max) ? (perm_min <= now && now <= perm_max) : (perm_min <= now || now <= perm_max)) { (void)sprintf(reply, ":%%s %%d %%s :%s %d:%02d to %d:%02d.", "You are not allowed to connect from", perm_min_hours, perm_min_minutes, perm_max_hours, perm_max_minutes); return(ERR_YOUREBANNEDCREEP); } if ((perm_min < perm_max) ? (perm_min <= now + 5 && now + 5 <= perm_max) : (perm_min <= now + 5 || now + 5 <= perm_max)) { (void)sprintf(reply, ":%%s %%d %%s :%d minute%s%s", perm_min-now,(perm_min-now)>1?"s ":" ", "and you will be denied for further access"); return(ERR_YOUWILLBEBANNED); } interval = p; } return(0); } #endif /* TIMEDKLINES */ /* ** find_bounce ** send a bounce numeric to a client. ** fd is optional, and only makes sense if positive and when cptr is NULL ** fd == -1 : not fd, class is a class number. ** fd == -2 : not fd, class isn't a class number. */ void find_bounce(aClient *cptr, int class, int fd) { Reg aConfItem *aconf; if (fd < 0 && cptr == NULL) { /* nowhere to send error to */ return; } for (aconf = conf; aconf; aconf = aconf->next) { if (aconf->status != CONF_BOUNCE) { continue; } if (fd >= 0) { /* ** early rejection, ** connection class and hostname are unknown */ if (*aconf->host == '\0') { char rpl[BUFSIZE]; sprintf(rpl, replies[RPL_BOUNCE], ME, "unknown", aconf->name, aconf->port); strcat(rpl, "\r\n"); #ifdef INET6 sendto(fd, rpl, strlen(rpl), 0, 0, 0); #else send(fd, rpl, strlen(rpl), 0); #endif return; } else { continue; } } /* fd < 0 */ /* ** "too many" type rejection, class is known. ** check if B line is for a class #, ** and if it is for a hostname. */ if (fd != -2 && !strchr(aconf->host, '.') && (isdigit(*aconf->host) || *aconf->host == '-')) { if (class != atoi(aconf->host)) { continue; } } else { if (strchr(aconf->host, '/')) { if (match_ipmask(aconf->host, cptr, 1)) continue; } else if (match(aconf->host, cptr->sockhost)) { continue; } } sendto_one(cptr, replies[RPL_BOUNCE], ME, BadTo(cptr->name), aconf->name, aconf->port); return; } } /* ** find_denied ** for a given server name, make sure no D line matches any of the ** servers currently present on the net. */ aConfItem *find_denied(char *name, int class) { aConfItem *aconf; for (aconf = conf; aconf; aconf = aconf->next) { if (aconf->status != CONF_DENY) continue; if (!aconf->name) continue; if (match(aconf->name, name) && aconf->port != class) continue; if (isdigit(*aconf->passwd)) { aConfItem *aconf2; int ck = atoi(aconf->passwd); for (aconf2 = conf; aconf2; aconf2 = aconf2->next) { if (aconf2->status != CONF_NOCONNECT_SERVER) continue; if (!aconf2->class || ConfClass(aconf2) != ck) continue; if (find_client(aconf2->name, NULL)) return aconf2; } } if (aconf->host) { aServer *asptr; char *host = aconf->host; int reversed = 0; if (*host == '!') { host++; reversed = 1; } for (asptr = svrtop; asptr; asptr = asptr->nexts) if (!match(host, asptr->bcptr->name)) break; if (!reversed && asptr) return aconf; if (reversed && !asptr) /* anything but NULL; tho using it may give ** funny results in calling function */ return conf; } } return NULL; } #ifdef TKLINE /* * Parses 0w1d2h3m4s timeformat, filling in output variable in seconds. * Returns 0 if everything went ok. */ int wdhms2sec(char *input, time_t *output) { #ifndef TKLINE_MULTIPLIER #define TKLINE_MULTIPLIER 60 #endif int multi; int tmp = 0; char *s; *output = 0; if (!input) return 0; s = input; while (*s) { switch(tolower(*s)) { case 'w': multi = 604800; break; case 'd': multi = 86400; break; case 'h': multi = 3600; break; case 'm': multi = 60; break; case 's': multi = 1; break; default: if (isdigit(*s)) { tmp = atoi(s); while (isdigit(*s)) s++; if (!*s) { *output += TKLINE_MULTIPLIER * tmp; } continue; } else return -1; } *output += multi * tmp; s++; } return 0; } #endif #if defined(TKLINE) || defined(KLINE) /* * Adds t/kline to t/kconf. * If tkline already existed, its expire time is updated. * * Returns created tkline expire time. */ void do_kline(int tkline, char *who, time_t time, char *user, char *host, char *reason, int status) { char buff[BUFSIZE]; aClient *acptr; aConfItem *aconf; int i, count = 0; buff[0] = '\0'; /* Check if such u@h already exists in tkconf. */ for (aconf = tkline?tkconf:kconf; aconf; aconf = aconf->next) { if (0==strcasecmp(aconf->host, host) && 0==strcasecmp(aconf->name, user)) { aconf->hold = timeofday + time; break; } } if (aconf == NULL) { aconf = make_conf(); aconf->next = NULL; aconf->status = status; aconf->hold = timeofday + time; aconf->port = 0; Class(aconf) = find_class(0); DupString(aconf->name, BadTo(user)); DupString(aconf->host, BadTo(host)); DupString(aconf->passwd, reason); istat.is_confmem += strlen(aconf->name) + 1; istat.is_confmem += strlen(aconf->host) + 1; istat.is_confmem += strlen(aconf->passwd) + 1; /* put on top of t/kconf */ if (tkline) { if (tkconf) { aconf->next = tkconf; } tkconf = aconf; sendto_flag(SCH_TKILL, "TKLINE %s@%s (%u) by %s :%s", aconf->name, aconf->host, time, who, reason); } else { if (kconf) { aconf->next = kconf; } kconf = aconf; sendto_flag(SCH_TKILL, "KLINE %s@%s by %s :%s", aconf->name, aconf->host, who, reason); } } /* get rid of klined clients */ for (i = highest_fd; i >= 0; i--) { if (!(acptr = local[i]) || !IsPerson(acptr) || IsKlineExempt(acptr)) { continue; } if (!strcmp(acptr->sockhost, acptr->user->sip)) { /* unresolved */ if (strchr(aconf->host, '/')) { if (match_ipmask(*aconf->host == '=' ? aconf->host + 1 : aconf->host, acptr, 1)) { continue; } } else { if (match(*aconf->host == '=' ? aconf->host + 1 : aconf->host, acptr->sockhost)) { continue; } } } else { /* resolved */ if (*aconf->host == '=') { /* IP only */ continue; } if (strchr(aconf->host, '/')) { if (match_ipmask(aconf->host, acptr, 1)) { continue; } } else { if (match(aconf->host, acptr->user->sip) && match(aconf->host, acptr->user->host)) { continue; } } } if (match(aconf->name, aconf->status == CONF_TOTHERKILL ? acptr->auth : (IsRestricted(acptr) && acptr->user->username[0] == '+' ? acptr->user->username+1 : acptr->user->username)) == 0) { count++; sendto_one(acptr, replies[ERR_YOUREBANNEDCREEP], ME, acptr->name, aconf->name, aconf->host, ": ", aconf->passwd); sendto_flag(SCH_TKILL, "%sKill line active for %s", tkline?"T":"", get_client_name(acptr, FALSE)); if (buff[0] == '\0') { sprintf(buff, "Kill line active: %.80s", aconf->passwd); } acptr->exitc = tkline ? EXITC_TKLINE : EXITC_KLINE; (void) exit_client(acptr, acptr, &me, buff); } } if (count > 4) { sendto_flag(SCH_TKILL, "%sKline reaped %d souls", tkline?"T":"", count); } #ifdef TKLINE /* do next tkexpire, but not more often than once a minute */ if (!nexttkexpire || nexttkexpire > aconf->hold) { nexttkexpire = MAX(timeofday + 60, aconf->hold); } #endif return; } int prep_kline(int tkline, aClient *cptr, aClient *sptr, int parc, char **parv) { int status = tkline ? CONF_TKILL : CONF_KILL; time_t time; char *user, *host, *reason; int err = 0; /* sanity checks */ if (tkline) { err = wdhms2sec(parv[1], &time); #ifdef TKLINE_MAXTIME if (time > TKLINE_MAXTIME) time = TKLINE_MAXTIME; if (time < 0) /* overflown, must have wanted bignum :) */ time = TKLINE_MAXTIME; #endif user = parv[2]; reason = parv[3]; } else { user = parv[1]; reason = parv[2]; } host = strchr(user, '@'); if (strlen(user) > USERLEN+HOSTLEN+1) { err = 1; } if (host) { *host++ = '\0'; } if (!user || !host || *user == '\0' || *host == '\0' || (!strcmp("*", user) && !strcmp("*", host))) { /* disallow all forms of bad u@h format and block *@* too */ err = 1; } if (!err && host && strchr(host, '/') && match_ipmask(host, sptr, 0) == -1) { /* check validity of 1.2.3.0/24 or it will be spewing errors ** for every connecting client. */ err = 1; } #ifdef KLINE badkline: #endif if (err) { /* error */ if (!IsPerson(sptr)) { sendto_one(sptr, ":%s NOTICE %s " ":T/KLINE: Incorrect format", ME, parv[0]); return exit_client(cptr, cptr, &me, "T/KLINE: Incorrect format"); } sendto_one(sptr, ":%s NOTICE %s :%sKLINE: Incorrect format", ME, parv[0], tkline?"T":""); return 2; } /* All seems fine. */ if (*user == '=') { status = tkline ? CONF_TOTHERKILL : CONF_OTHERKILL; user++; } #ifdef INET6 host = ipv6_convert(host); #endif if (strlen(reason) > TOPICLEN) { reason[TOPICLEN] = '\0'; } #ifdef KLINE if (!tkline) { int kfd, ksize, kret; char kbuf[2*BUFSIZE]; char *utmp, *htmp, *rtmp; if (!strcmp(KLINE_PATH, IRCDCONF_PATH)) { sendto_flag(SCH_ERROR, "Invalid kline configuration file."); return MAXPENALTY; } utmp = strchr(user, IRCDCONF_DELIMITER); htmp = strchr(host, IRCDCONF_DELIMITER); rtmp = strchr(reason, IRCDCONF_DELIMITER); if (utmp || htmp || rtmp) { /* Too lazy to copy it here. --B. */ err = 1; goto badkline; } kfd = open(KLINE_PATH, O_WRONLY|O_APPEND|O_NDELAY); if (kfd < 0) { sendto_flag(SCH_ERROR, "Cannot open kline configuration file."); return MAXPENALTY; } ksize = snprintf(kbuf, sizeof(kbuf), "%c%c%s%c%s%c%s%c0%c #%s%s%s%s%s#%d\n", (status == CONF_OTHERKILL ? 'k' : 'K'), IRCDCONF_DELIMITER, host, IRCDCONF_DELIMITER, reason, IRCDCONF_DELIMITER, user, IRCDCONF_DELIMITER, IRCDCONF_DELIMITER, sptr->name, sptr->user ? "!" : "", sptr->user ? sptr->user->username : "", sptr->user ? "@" : "", sptr->user ? sptr->user->host : "", (int)timeofday); kret = write(kfd, kbuf, ksize); close(kfd); if (kret != ksize) { sendto_flag(SCH_ERROR, "Error writing (%d!=%d) " "to kline configuration file.", kret, ksize); sendto_one(sptr, ":%s NOTICE %s :KLINE: error writing " "(%d!=%d) to kline configuration file", ME, parv[0], kret, ksize); return MAXPENALTY; } } #endif /* KLINE */ /* All parameters are now sane. Do the stuff. */ do_kline(tkline, parv[0], time, user, host, reason, status); return 1; } #endif /* TKLINE || KLINE */ #ifdef KLINE int m_kline(aClient *cptr, aClient *sptr, int parc, char **parv) { if (!is_allowed(sptr, ACL_KLINE)) return m_nopriv(cptr, sptr, parc, parv); return prep_kline(0, cptr, sptr, parc, parv); } #endif #ifdef TKLINE int m_tkline(aClient *cptr, aClient *sptr, int parc, char **parv) { if (!is_allowed(sptr, ACL_TKLINE)) return m_nopriv(cptr, sptr, parc, parv); return prep_kline(1, cptr, sptr, parc, parv); } int m_untkline(aClient *cptr, aClient *sptr, int parc, char **parv) { aConfItem *tmp, *prev; char *user, *host; int deleted = 0; if (!is_allowed(sptr, ACL_UNTKLINE)) return m_nopriv(cptr, sptr, parc, parv); user = parv[1]; host = strchr(user, '@'); if (!host) { /* error */ if (!IsPerson(sptr)) { sendto_one(sptr, ":%s NOTICE %s " ":UNTKLINE: Incorrect format", ME, parv[0]); return exit_client(cptr, cptr, &me, "UNTKLINE: Incorrect format"); } sendto_one(sptr, ":%s NOTICE %s :UNTKLINE: Incorrect format", ME, parv[0]); return 2; } if (*user == '=') { user++; } *host++ = '\0'; for (prev = tkconf, tmp = tkconf; tmp; tmp = tmp->next) { if (0==strcasecmp(tmp->host, host) && 0==strcasecmp(tmp->name, user)) { if (tmp == tkconf) tkconf = tmp->next; else prev->next = tmp->next; free_conf(tmp); deleted = 1; break; } prev = tmp; } if (deleted) { sendto_flag(SCH_TKILL, "UNTKLINE %s@%s by %s", user, host, parv[0]); } return 1; } time_t tkline_expire(int all) { aConfItem *tmp = NULL, *tmp2 = tkconf, *prev = tkconf; time_t min = 0; while ((tmp = tmp2)) { tmp2 = tmp->next; if (all || tmp->hold <= timeofday) { if (tmp == tkconf) tkconf = tmp->next; else prev->next = tmp->next; free_conf(tmp); continue; } if (min == 0 || tmp->hold < min) { min = tmp->hold; } prev = tmp; } if (min && min < nexttkexpire + 60) min = nexttkexpire + 60; return min; } #endif /* TKLINE */ irc2.11.2p3/ircd/s_service.c0000644000175000017500000004567311430644562013427 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/s_service.c * Copyright (C) 1990 Jarkko Oikarinen and * University of Oulu, Computing Center * * See file AUTHORS in IRC package for additional names of * the programmers. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: s_service.c,v 1.69 2010/08/12 01:08:02 bif Exp $"; #endif #include "os.h" #include "s_defines.h" #define S_SERVICE_C #include "s_externs.h" #undef S_SERVICE_C aService *svctop = NULL; aService *make_service(aClient *cptr) { Reg aService *svc = cptr->service; if (svc) return svc; cptr->service = svc = (aService *)MyMalloc(sizeof(*svc)); bzero((char *)svc, sizeof(*svc)); cptr->name = svc->namebuf; svc->bcptr = cptr; if (svctop) svctop->prevs = svc; svc->nexts = svctop; svc->prevs = NULL; /* useless */ svctop = svc; return svc; } void free_service(aClient *cptr) { aService *serv; if ((serv = cptr->service)) { if (serv->nexts) serv->nexts->prevs = serv->prevs; if (serv->prevs) serv->prevs->nexts = serv->nexts; if (svctop == serv) svctop = serv->nexts; /* It's just the pointer, not even allocated in m_service. * Why would someone want to destroy that struct here? * So far commenting it out. --B. if (serv->servp) free_server(serv->servp, cptr); */ /* this is ok, ->server is a string. */ if (serv->server) MyFree(serv->server); MyFree(serv); cptr->service = NULL; } } static aClient *best_service(char *name, aClient *cptr) { Reg aClient *acptr = NULL; Reg aClient *bcptr; Reg aService *sp; int len = strlen(name); if (!index(name, '@') || !(acptr = find_service(name, cptr))) for (sp = svctop; sp; sp = sp->nexts) if ((bcptr = sp->bcptr) && !myncmp(name, bcptr->name, len)) { if (!acptr || bcptr->hopcount < acptr->hopcount) { acptr = bcptr; } } return (acptr ? acptr : cptr); } #ifdef USE_SERVICES /* ** check_services_butone ** check all local services except `cptr', and send `fmt' according to: ** action type on notice ** server origin */ void check_services_butone(long action, aServer *servp, aClient *cptr, char *fmt, ...) /* shouldn't cptr be named sptr? */ { char nbuf[NICKLEN + USERLEN + HOSTLEN + 3]; Reg aService *sp; *nbuf = '\0'; for (sp = svctop; sp; sp = sp->nexts) { if (!MyConnect(sp->bcptr) || (cptr && sp->bcptr == cptr->from)) { continue; } /* ** found a (local) service, check if action matches what's ** wanted AND if it comes from a server matching the dist */ if ((sp->wants & action) && (!servp || !match(sp->dist, servp->bcptr->name) || !match(sp->dist, servp->sid))) { if ((sp->wants & (SERVICE_WANT_PREFIX|SERVICE_WANT_UID)) && cptr && IsRegisteredUser(cptr) && (action & SERVICE_MASK_PREFIX)) { char buf[2048]; va_list va; va_start(va, fmt); (void)va_arg(va, char *); vsprintf(buf, fmt+3, va); va_end(va); if ((sp->wants & SERVICE_WANT_UID)) sendto_one(sp->bcptr, ":%s%s", cptr->user ? cptr->user->uid : cptr->name, buf); else sendto_one(sp->bcptr, ":%s!%s@%s%s", cptr->name, cptr->user->username, cptr->user->host, buf); } else { va_list va; va_start(va, fmt); vsendto_one(sp->bcptr, fmt, va); va_end(va); } } } return; } /* ** sendnum_toone ** send the NICK + USER + UMODE for sptr to cptr according to wants */ static void sendnum_toone(aClient *cptr, int wants, aClient *sptr, char *umode) { if (!*umode) umode = "+"; if ((wants & SERVICE_WANT_UID) && sptr->user) sendto_one(cptr, ":%s UNICK %s %s %s %s %s %s :%s", sptr->user->servp->sid, (wants & SERVICE_WANT_NICK) ? sptr->name : ".", sptr->user->uid, (wants & SERVICE_WANT_USER) ? sptr->user->username : ".", (wants & SERVICE_WANT_USER) ? sptr->user->host : ".", (wants & SERVICE_WANT_USER) ? sptr->user->sip : ".", (wants & (SERVICE_WANT_UMODE|SERVICE_WANT_OPER)) ? umode : "+", (wants & SERVICE_WANT_USER) ? sptr->info : ""); else if (wants & SERVICE_WANT_EXTNICK) /* extended NICK syntax */ sendto_one(cptr, "NICK %s %d %s %s %s %s :%s", (wants & SERVICE_WANT_NICK) ? sptr->name : ".", sptr->hopcount + 1, (wants & SERVICE_WANT_USER) ? sptr->user->username : ".", (wants & SERVICE_WANT_USER) ? sptr->user->host :".", (wants & SERVICE_WANT_USER) ? ((wants & SERVICE_WANT_SID) ? sptr->user->servp->sid : sptr->user->server) : ".", (wants & (SERVICE_WANT_UMODE|SERVICE_WANT_OPER)) ? umode : "+", (wants & SERVICE_WANT_USER) ? sptr->info : ""); else /* old style NICK + USER + UMODE */ { char nbuf[NICKLEN + USERLEN + HOSTLEN + 3]; char *prefix; if (wants & SERVICE_WANT_PREFIX) { sprintf(nbuf, "%s!%s@%s", sptr->name, sptr->user->username, sptr->user->host); prefix = nbuf; } else prefix = sptr->name; if (wants & SERVICE_WANT_NICK) sendto_one(cptr, "NICK %s :%d", sptr->name, sptr->hopcount+1); if (wants & SERVICE_WANT_USER) sendto_one(cptr, ":%s USER %s %s %s :%s", prefix, sptr->user->username, sptr->user->host, (wants & SERVICE_WANT_SID)? sptr->user->servp->sid : sptr->user->server, sptr->info); if (wants & (SERVICE_WANT_UMODE|SERVICE_WANT_OPER)) sendto_one(cptr, ":%s MODE %s %s", prefix, sptr->name, umode); } } /* ** check_services_num ** check all local services to eventually send NICK + USER + UMODE ** for new client sptr */ void check_services_num(aClient *sptr, char *umode) { Reg aService *sp; for (sp = svctop; sp; sp = sp->nexts) { if (!MyConnect(sp->bcptr)) { continue; } /* ** found a (local) service, check if action matches what's ** wanted AND if it comes from a server matching the dist */ if ((sp->wants & SERVICE_MASK_NUM) && (!match(sp->dist, sptr->user->server) || !match(sp->dist, sptr->user->servp->sid))) { sendnum_toone(sp->bcptr, sp->wants, sptr, umode); } } } aConfItem *find_conf_service(aClient *cptr, int type, aConfItem *aconf) { static char uhost[HOSTLEN+USERLEN+3]; Reg aConfItem *tmp; char *s; struct hostent *hp; int i; for (tmp = conf; tmp; tmp = tmp->next) { /* ** Accept if the *real* hostname (usually sockethost) ** matches host field of the configuration, the name field ** is the same, the type match is correct and nobody else ** is using this S-line. */ if (!(tmp->status & CONF_SERVICE)) continue; Debug((DEBUG_INFO,"service: cl=%d host (%s) name (%s) port=%d", tmp->clients, tmp->host, tmp->name, tmp->port)); Debug((DEBUG_INFO,"service: host (%s) name (%s) type=%d", cptr->sockhost, cptr->name, type)); if (tmp->clients || (type && tmp->port != type) || mycmp(tmp->name, cptr->name)) continue; if ((hp = cptr->hostp)) for (s = hp->h_name, i = 0; s; s = hp->h_aliases[i++]) { sprintf(uhost, "%s@%s", cptr->username, s); if (match(tmp->host, uhost) == 0) return tmp; } sprintf(uhost, "%s@%s", cptr->username, cptr->sockhost); if (match(tmp->host, uhost) == 0) return tmp; } return aconf; } #endif /* ** m_service ** ** <= 2.10 protocol: ** parv[0] = sender prefix ** parv[1] = service name ** parv[2] = server token (unused on pure 2.11 network) ** parv[3] = distribution code ** parv[4] = service type ** parv[5] = hopcount ** parv[6] = info ** ** 2.11 protocol ** parv[0] = sender prefix ** parv[1] = service name ** parv[2] = distribution mask ** parv[3] = service type ** parv[4] = info ** */ int m_service(aClient *cptr, aClient *sptr, int parc, char *parv[]) { aClient *acptr = NULL, *bcptr = NULL; aService *svc; #ifdef USE_SERVICES aConfItem *aconf; #endif aServer *sp = NULL; char *dist, *server = NULL, *info; int type, i; if (sptr->user) { sendto_one(sptr, replies[ERR_ALREADYREGISTRED], ME, BadTo(parv[0])); return 1; } if (parc < 5) { sendto_one(cptr, replies[ERR_NEEDMOREPARAMS], ME, BadTo(parv[0]), "SERVICE"); return 1; } /* Copy parameters into better documenting variables */ dist = parv[2]; type = strtol(parv[3], NULL, 0); info = parv[4]; /* * Change the sender's origin. */ if (IsServer(cptr)) { acptr = make_client(cptr); svc = make_service(acptr); add_client_to_list(acptr); strncpyzt(acptr->service->namebuf, parv[1], sizeof(acptr->service->namebuf)); /* 2.11 protocol - :SID SERVICE .. * - we know that the sptr contains the correct server */ acptr->hopcount = sptr->hopcount; sp = sptr->serv; if (sp == NULL) { sendto_flag(SCH_ERROR, "ERROR: SERVICE:%s without SERVER:%s from %s", acptr->name, server, get_client_name(cptr, FALSE)); return exit_client(NULL, acptr, &me, "No Such Server"); } if (match(dist, ME) && match(dist, me.serv->sid)) { sendto_flag(SCH_ERROR, "ERROR: SERVICE:%s DIST:%s from %s", acptr->name, dist, get_client_name(cptr, FALSE)); return exit_client(NULL, acptr, &me, "Distribution code mismatch"); } } #ifndef USE_SERVICES else { sendto_one(cptr, "ERROR :Server doesn't support services"); return 1; } #endif #ifdef USE_SERVICES if (!IsServer(cptr)) { char **isup = isupport; svc = make_service(sptr); sptr->hopcount = 0; server = ME; sp = me.serv; if (!do_nick_name(parv[1], 0)) { sendto_one(sptr, replies[ERR_ERRONEOUSNICKNAME], ME, BadTo(parv[0]), parv[1]); return 1; } if (strlen(parv[1]) + strlen(server) + 2 >= (size_t) HOSTLEN) { sendto_one(acptr, "ERROR :Servicename is too long."); sendto_flag(SCH_ERROR, "Access for service %d (%s) denied (%s)", type, parv[1], "servicename too long"); return exit_client(cptr, sptr, &me, "Name too long"); } strncpyzt(sptr->service->namebuf, parv[1], sizeof(sptr->service->namebuf)); if (!(aconf = find_conf_service(sptr, type, NULL))) { sendto_one(sptr, "ERROR :Access denied (service %d) %s", type, get_client_name(sptr, TRUE)); sendto_flag(SCH_ERROR, "Access denied (service %d) %s", type, get_client_name(sptr, TRUE)); return exit_client(cptr, sptr, &me, "Not enabled"); } if (!BadPtr(aconf->passwd) && !StrEq(aconf->passwd, sptr->passwd)) { sendto_flag(SCH_ERROR, "Access denied: (passwd mismatch) %s", get_client_name(sptr, TRUE)); return exit_client(cptr, sptr, &me, "Bad Password"); } (void)strcat(sptr->name, "@"), strcat(sptr->name, server); if (find_service(sptr->name, NULL)) { sendto_flag(SCH_ERROR, "Service %s already exists", get_client_name(sptr, TRUE)); return exit_client(cptr, sptr, &me, "Service Exists"); } attach_conf(sptr, aconf); sendto_one(sptr, replies[RPL_YOURESERVICE], ME, BadTo(sptr->name), sptr->name); sendto_one(sptr, replies[RPL_YOURHOST], ME, BadTo(sptr->name), get_client_name(&me, FALSE), version); while (*isup) { sendto_one(sptr,replies[RPL_ISUPPORT], ME, BadTo(sptr->name), *isup); isup++; } sendto_one(sptr, replies[RPL_MYINFO], ME, BadTo(sptr->name), ME, version); sendto_flag(SCH_NOTICE, "Service %s connected", get_client_name(sptr, TRUE)); istat.is_unknown--; istat.is_myservice++; if (istat.is_myservice > istat.is_m_myservice) istat.is_m_myservice = istat.is_myservice; /* local service, assign to acptr so we can use it later*/ acptr = sptr; } #endif istat.is_service++; if (istat.is_service > istat.is_m_service) istat.is_m_service = istat.is_service; SetService(acptr); svc->servp = sp; sp->refcnt++; svc->server = mystrdup(sp->bcptr->name); strncpyzt(svc->dist, dist, HOSTLEN); if (acptr->info != DefInfo) MyFree(acptr->info); if (strlen(info) > REALLEN) info[REALLEN] = '\0'; acptr->info = mystrdup(info); svc->wants = 0; svc->type = type; reorder_client_in_list(acptr); (void)add_to_client_hash_table(acptr->name, acptr); #ifdef USE_SERVICES check_services_butone(SERVICE_WANT_SERVICE, NULL, acptr, ":%s SERVICE %s %s %d :%s", sp->sid, acptr->name, dist, type, info); #endif sendto_flag(SCH_SERVICE, "Received SERVICE %s from %s via %s (%s %d %s)", acptr->name, sptr->name, get_client_name(cptr, TRUE), dist, acptr->hopcount, info); for (i = fdas.highest; i >= 0; i--) { if (!(bcptr = local[fdas.fd[i]]) || !IsServer(bcptr) || bcptr == cptr) continue; if (match(dist, bcptr->name) && match(dist, bcptr->serv->sid)) continue; sendto_one(bcptr, ":%s SERVICE %s %s %d :%s", sp->sid, acptr->name, dist, type, info); } return 0; } /* ** Returns list of all matching services. ** parv[1] - string to match names against ** parv[2] - type of service */ int m_servlist(aClient *cptr, aClient *sptr, int parc, char *parv[]) { Reg aService *sp; Reg aClient *acptr; char *mask = BadPtr(parv[1]) ? "*" : parv[1]; int type = 0; if (parc > 2) type = BadPtr(parv[2]) ? 0 : strtol(parv[2], NULL, 0); for (sp = svctop; sp; sp = sp->nexts) if ((acptr = sp->bcptr) && (!type || type == sp->type) && (match(mask, acptr->name) == 0)) sendto_one(sptr, replies[RPL_SERVLIST], ME, BadTo(parv[0]), acptr->name, sp->server, sp->dist, sp->type, acptr->hopcount, acptr->info); sendto_one(sptr, replies[RPL_SERVLISTEND], ME, BadTo(parv[0]), mask, type); return 2; } #ifdef USE_SERVICES /* ** m_servset ** ** parv[0] = sender prefix ** parv[1] = data requested ** parv[2] = burst requested (optional) */ int m_servset(aClient *cptr, aClient *sptr, int parc, char *parv[]) { aClient *acptr; int burst = 0; if (!MyConnect(sptr)) { sendto_flag(SCH_ERROR, "%s issued a SERVSET (from %s)", sptr->name, get_client_name(cptr, TRUE)); return 1; } if (!IsService(sptr) || (IsService(sptr) && sptr->service->wants)) { sendto_one(sptr, replies[ERR_NOPRIVILEGES], ME, BadTo(parv[0])); return 1; } if (sptr->service->wants) return 1; /* check against configuration */ sptr->service->wants = strtol(parv[1], NULL, 0) & sptr->service->type; /* check that service is global for some requests */ if (strcmp(sptr->service->dist, "*")) sptr->service->wants &= ~SERVICE_MASK_GLOBAL; /* allow options */ sptr->service->wants |= (strtol(parv[1], NULL, 0) & ~SERVICE_MASK_ALL); /* send accepted SERVSET */ sendto_one(sptr, ":%s SERVSET %s :%d", sptr->name, sptr->name, sptr->service->wants); if (parc < 3 || ((burst = sptr->service->wants & strtol(parv[2], NULL, 0)) == 0)) return 0; /* ** services can request a connect burst. ** it is optional, because most services should not need it, ** so let's save some bandwidth. ** ** tokens are NOT used. (2.8.x like burst) ** distribution code is respected. ** service type also respected. */ cptr->flags |= FLAGS_CBURST; if (burst & SERVICE_WANT_SERVER) { int split; for (acptr = &me; acptr; acptr = acptr->prev) { if (!IsServer(acptr) && !IsMe(acptr)) continue; if (match(sptr->service->dist, acptr->name) && match(sptr->service->dist, acptr->serv->sid)) continue; split = (MyConnect(acptr) && mycmp(acptr->name, acptr->sockhost)); sendto_one(sptr, ":%s SERVER %s %d %s :%s", acptr->serv->up->name, acptr->name, acptr->hopcount+1, acptr->serv->sid, acptr->info); } } if (burst & (SERVICE_WANT_NICK|SERVICE_WANT_USER|SERVICE_WANT_SERVICE)) { char buf[BUFSIZE] = "+"; for (acptr = &me; acptr; acptr = acptr->prev) { /* acptr->from == acptr for acptr == cptr */ if (acptr->from == cptr) continue; if (IsPerson(acptr)) { if (match(sptr->service->dist, acptr->user->server) && match(sptr->service->dist, acptr->user->servp->sid)) continue; if (burst & SERVICE_WANT_UMODE) send_umode(NULL, acptr, 0, SEND_UMODES, buf); else if (burst & SERVICE_WANT_OPER) send_umode(NULL, acptr, 0, FLAGS_OPER, buf); sendnum_toone(sptr, burst, acptr, buf); } else if (IsService(acptr)) { if (!(burst & SERVICE_WANT_SERVICE)) continue; if (match(sptr->service->dist, acptr->service->server) && match(sptr->service->dist, acptr->service->servp->sid)) continue; sendto_one(sptr, "SERVICE %s %s %s %d %d :%s", acptr->name, acptr->service->server, acptr->service->dist, acptr->service->type, acptr->hopcount + 1, acptr->info); } } } if (burst & (SERVICE_WANT_CHANNEL|SERVICE_WANT_VCHANNEL|SERVICE_WANT_MODE|SERVICE_WANT_TOPIC)) { char modebuf[MODEBUFLEN], parabuf[MODEBUFLEN]; aChannel *chptr; for (chptr = channel; chptr; chptr = chptr->nextch) { if (chptr->users == 0) continue; if (burst&(SERVICE_WANT_CHANNEL|SERVICE_WANT_VCHANNEL)) sendto_one(sptr, "CHANNEL %s %d", chptr->chname, chptr->users); if (burst & SERVICE_WANT_MODE) { *modebuf = *parabuf = '\0'; modebuf[1] = '\0'; channel_modes(&me, modebuf, parabuf, chptr); sendto_one(sptr, "MODE %s %s", chptr->chname, modebuf); } if ((burst & SERVICE_WANT_TOPIC) && *chptr->topic) sendto_one(sptr, "TOPIC %s :%s", chptr->chname, chptr->topic); } } sendto_one(sptr, "EOB"); cptr->flags ^= FLAGS_CBURST; return 0; } #endif /* ** Send query to service. ** parv[1] - string to match name against ** parv[2] - string to send to service */ int m_squery(aClient *cptr, aClient *sptr, int parc, char *parv[]) { aClient *acptr; if (parc <= 2) { if (parc == 1) sendto_one(sptr, replies[ERR_NORECIPIENT], ME, BadTo(parv[0]), "SQUERY"); else if (parc == 2 || BadPtr(parv[1])) sendto_one(sptr, replies[ERR_NOTEXTTOSEND], ME, BadTo(parv[0])); return 1; } if ((acptr = best_service(parv[1], NULL))) if (MyConnect(acptr) && (acptr->service->wants & SERVICE_WANT_PREFIX)) sendto_one(acptr, ":%s!%s@%s SQUERY %s :%s", parv[0], sptr->user->username, sptr->user->host, acptr->name, parv[2]); else if (MyConnect(acptr) && (acptr->service->wants & SERVICE_WANT_UID)) sendto_one(acptr, ":%s SQUERY %s :%s", sptr->user->uid, acptr->name, parv[2]); else sendto_one(acptr, ":%s SQUERY %s :%s", parv[0], acptr->name, parv[2]); else sendto_one(sptr, replies[ERR_NOSUCHSERVICE], ME, BadTo(parv[0]), parv[1]); return 2; } irc2.11.2p3/ircd/hash_def.h0000644000175000017500000000261611023575375013204 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/hash_def.h * Copyright (C) 1991 Darren Reed * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ typedef struct hashentry { int hits; int links; void *list; } aHashEntry; /* * it is not important for these to be "big" as ircd will make them grow * as required. */ #define HASHSIZE ((int)((float)MAXCONNECTIONS*1.75)) #define CHANNELHASHSIZE ((int)(((float)MAXCONNECTIONS*1.75)/2.0)) #define SIDSIZE (MAXCONNECTIONS/10) #ifdef USE_HOSTHASH #define HOSTNAMEHASHSIZE ((int)((float)MAXCONNECTIONS*1.75)) #endif #ifdef USE_IPHASH #define IPHASHSIZE ((int)((float)MAXCONNECTIONS*1.75)) #endif #define UIDSIZE ((int)((float)MAXCONNECTIONS*1.75)) irc2.11.2p3/ircd/res_mkquery.c0000644000175000017500000001350410127336166013777 0ustar kkkk/* * ++Copyright++ 1985, 1993 * - * Copyright (c) 1985, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Portions Copyright (c) 1993 by Digital Equipment Corporation. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies, and that * the name of Digital Equipment Corporation not be used in advertising or * publicity pertaining to distribution of the document or software without * specific, written prior permission. * * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * - * --Copyright-- */ #if defined(LIBC_SCCS) && !defined(lint) static const volatile char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93"; static const volatile char rcsid[] = "$Id: res_mkquery.c,v 1.8 2004/10/01 20:22:14 chopin Exp $"; #endif /* LIBC_SCCS and not lint */ #include "os.h" #include "s_defines.h" #define RES_MKQUERY_C #include "s_externs.h" #undef RES_MKQUERY_C /* * Form all types of queries. * Returns the size of the result or -1. * * Parameters: * int op; opcode of query * const char *dname; domain name * int class, type; class and type of query * const u_char *data; resource record data * int datalen; length of data * const u_char *newrr_in; new rr for modify or append * u_char *buf; buffer to put query * int buflen; size of buffer */ int ircd_res_mkquery(int op, const char *dname, int class, int type, const u_char *data, int datalen, const u_char *newrr_in, u_char *buf, int buflen) { register HEADER *hp; register u_char *cp; register int n; u_char *dnptrs[20], **dpp, **lastdnptr; if ((ircd_res.options & RES_INIT) == 0 && ircd_res_init() == -1) { h_errno = NETDB_INTERNAL; return (-1); } #ifdef DEBUG if (ircd_res.options & RES_DEBUG) printf(";; res_mkquery(%d, %s, %d, %d)\n", op, dname, class, type); #endif /* * Initialize header fields. */ if ((buf == NULL) || (buflen < HFIXEDSZ)) return (-1); bzero(buf, HFIXEDSZ); hp = (HEADER *) buf; hp->id = htons(++ircd_res.id); hp->opcode = op; hp->rd = (ircd_res.options & RES_RECURSE) != 0; hp->rcode = NOERROR; cp = buf + HFIXEDSZ; buflen -= HFIXEDSZ; dpp = dnptrs; *dpp++ = buf; *dpp++ = NULL; lastdnptr = dnptrs + sizeof dnptrs / sizeof dnptrs[0]; /* * perform opcode specific processing */ switch (op) { case QUERY: /*FALLTHROUGH*/ case NS_NOTIFY_OP: if ((buflen -= QFIXEDSZ) < 0) return (-1); if ((n = ircd_dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0) return (-1); cp += n; buflen -= n; ircd__putshort(type, cp); cp += INT16SZ; ircd__putshort(class, cp); cp += INT16SZ; hp->qdcount = htons(1); if (op == QUERY || data == NULL) break; /* * Make an additional record for completion domain. */ buflen -= RRFIXEDSZ; n = ircd_dn_comp((const char *) data, cp, buflen, dnptrs, lastdnptr); if (n < 0) return (-1); cp += n; buflen -= n; ircd__putshort(T_NULL, cp); cp += INT16SZ; ircd__putshort(class, cp); cp += INT16SZ; ircd__putlong(0, cp); cp += INT32SZ; ircd__putshort(0, cp); cp += INT16SZ; hp->arcount = htons(1); break; case IQUERY: /* * Initialize answer section */ if (buflen < 1 + RRFIXEDSZ + datalen) return (-1); *cp++ = '\0'; /* no domain name */ ircd__putshort(type, cp); cp += INT16SZ; ircd__putshort(class, cp); cp += INT16SZ; ircd__putlong(0, cp); cp += INT32SZ; ircd__putshort(datalen, cp); cp += INT16SZ; if (datalen) { bcopy(data, cp, datalen); cp += datalen; } hp->ancount = htons(1); break; default: return (-1); } return (cp - buf); } irc2.11.2p3/ircd/res.c0000644000175000017500000012444111157051520012215 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/res.c * Copyright (C) 1992 Darren Reed * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "os.h" #include "s_defines.h" #define RES_C #include "s_externs.h" #undef RES_C #ifndef lint static const volatile char rcsid[] = "@(#)$Id: res.c,v 1.53 2009/03/15 01:01:04 chopin Exp $"; #endif /* because there is a lot of debug code in here :-) */ /* #undef DEBUG */ static char hostbuf[HOSTLEN+1+100]; /* +100 for INET6 */ static char dot[] = "."; static int incache = 0; static CacheTable hashtable[ARES_CACSIZE]; static aCache *cachetop = NULL; static ResRQ *last, *first; static void rem_cache (aCache *); static void rem_request (ResRQ *); static int do_query_name (Link *, char *, ResRQ *, int); static int do_query_number (Link *, struct IN_ADDR *, ResRQ *); static void resend_query (ResRQ *); static int proc_answer (ResRQ *, HEADER *, char *, char *); static int query_name (char *, int, int, ResRQ *); static aCache *make_cache (ResRQ *), *rem_list (aCache *); static aCache *find_cache_name (ResRQ *, char *, int); static aCache *find_cache_number (ResRQ *, char *); static int add_request (ResRQ *); static ResRQ *make_request (Link *); static int send_res_msg (char *, int, int); static ResRQ *find_id (int); static int hash_number (unsigned char *); static void update_list (ResRQ *, aCache *); static int hash_name (char *); static int bad_hostname (char *, 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; int init_resolver(int op) { int ret = 0; #ifdef LRAND48 srand48(time(NULL)); #endif if (op & RES_INITLIST) { bzero((char *)&reinfo, sizeof(reinfo)); first = last = NULL; } if (op & RES_CALLINIT) { ret = ircd_res_init(); if (!ircd_res.nscount) { ircd_res.nscount = 1; #ifdef INET6 if (!inetpton(AF_INET6, "::1", &ircd_res.nsaddr_list[0].sin6_addr.s6_addr)) { bcopy(minus_one, ircd_res.nsaddr_list[0].sin6_addr.s6_addr, IN6ADDRSZ); } #else ircd_res.nsaddr_list[0].sin_addr.s_addr = inetaddr("127.0.0.1"); #endif } } if (op & RES_INITSOCK) { int on = 0; ret = resfd = socket(AFINET, SOCK_DGRAM, 0); (void) SETSOCKOPT(ret, SOL_SOCKET, SO_BROADCAST, &on, on); /* The following frame is a hack to allow resolving * in FreeBSD jail(). As it is harmless elsewhere, it is * not #ifdef-ed. * Note that currently IPv6 within jail() is not * supported by the FreeBSD. */ { struct SOCKADDR_IN res_addr; memset(&res_addr, 0, sizeof(res_addr)); res_addr.SIN_FAMILY = AFINET; #ifdef INET6 res_addr.sin6_addr = in6addr_any; #else res_addr.sin_addr.s_addr = htonl(INADDR_ANY); #endif bind(resfd, (SAP) &res_addr, sizeof(res_addr)); } } #ifdef DEBUG if (op & RES_INITDEBG); ircd_res.options |= RES_DEBUG; #endif if (op & RES_INITCACH) { bzero((char *)&cainfo, sizeof(cainfo)); bzero((char *)hashtable, sizeof(hashtable)); } if (op == 0) ret = resfd; return ret; } static int add_request(ResRQ *new) { if (!new) return -1; if (!first) first = last = new; else { last->next = new; last = new; } new->next = NULL; reinfo.re_requests++; return 0; } /* * 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(ResRQ *old) { Reg ResRQ **rptr, *r2ptr = NULL; Reg int i; Reg char *s; if (!old) return; for (rptr = &first; *rptr; r2ptr = *rptr, rptr = &(*rptr)->next) { if (*rptr == old) { *rptr = old->next; if (last == old) last = r2ptr; break; } } #ifdef DEBUG Debug((DEBUG_INFO,"rem_request:Remove %#x at %#x %#x", old, *rptr, r2ptr)); #endif r2ptr = old; if (r2ptr->he.h_name) MyFree(r2ptr->he.h_name); for (i = 0; i < MAXALIASES; i++) if ((s = r2ptr->he.h_aliases[i])) MyFree(s); if (r2ptr->name) MyFree(r2ptr->name); MyFree(r2ptr); return; } /* * Create a DNS request record for the server. */ static ResRQ *make_request(Link *lp) { Reg ResRQ *nreq; nreq = (ResRQ *)MyMalloc(sizeof(ResRQ)); bzero((char *)nreq, sizeof(ResRQ)); nreq->next = NULL; /* where NULL is non-zero ;) */ nreq->sentat = timeofday; nreq->retries = 3; nreq->resend = 1; nreq->srch = -1; if (lp) bcopy((char *)lp, (char *)&nreq->cinfo, sizeof(Link)); else bzero((char *)&nreq->cinfo, sizeof(Link)); nreq->timeout = 4; /* start at 4 and exponential inc. */ nreq->he.h_addrtype = AFINET; nreq->he.h_name = NULL; nreq->he.h_aliases[0] = NULL; (void)add_request(nreq); return nreq; } /* * Remove queries from the list which have been there too long without * being resolved. */ time_t timeout_query_list(time_t now) { Reg ResRQ *rptr, *r2ptr; Reg time_t next = 0, tout; aClient *cptr; Debug((DEBUG_DNS,"timeout_query_list at %s",myctime(now))); for (rptr = first; rptr; rptr = r2ptr) { r2ptr = rptr->next; tout = rptr->sentat + rptr->timeout; if (now >= tout) { if (--rptr->retries <= 0) { #ifdef DEBUG Debug((DEBUG_ERROR,"timeout %x now %d cptr %x", rptr, now, rptr->cinfo.value.cptr)); #endif reinfo.re_timeouts++; cptr = rptr->cinfo.value.cptr; switch (rptr->cinfo.flags) { case ASYNC_CLIENT : #if defined(USE_IAUTH) sendto_iauth("%d d", cptr->fd); #endif ClearDNS(cptr); break; case ASYNC_CONNECT : sendto_flag(SCH_ERROR, "Host %s unknown", rptr->name); break; } rem_request(rptr); continue; } else { rptr->sentat = now; rptr->timeout += rptr->timeout; resend_query(rptr); tout = now + rptr->timeout; #ifdef DEBUG Debug((DEBUG_INFO,"r %x now %d retry %d c %x", rptr, now, rptr->retries, rptr->cinfo.value.cptr)); #endif } } if (!next || tout < next) { next = tout; } } return (next > now) ? next : (now + AR_TTL); } /* * del_queries - called by the server to cleanup outstanding queries for * which there no longer exist clients or conf lines. */ void del_queries(char *cp) { Reg ResRQ *rptr, *r2ptr; for (rptr = first; rptr; rptr = r2ptr) { r2ptr = rptr->next; if (cp == rptr->cinfo.value.cp) rem_request(rptr); } } /* * sends msg to all nameservers found in the "ircd_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(char *msg, int len, int rcount) { Reg int i; int sent = 0, max; if (!msg) return -1; max = MIN(ircd_res.nscount, rcount); if (ircd_res.options & RES_PRIMARY) max = 1; if (!max) max = 1; for (i = 0; i < max; i++) { ircd_res.nsaddr_list[i].SIN_FAMILY = AFINET; if (sendto(resfd, msg, len, 0, (struct sockaddr *)&(ircd_res.nsaddr_list[i]), sizeof(struct SOCKADDR_IN)) == len) { reinfo.re_sent++; sent++; } else Debug((DEBUG_ERROR,"s_r_m:sendto: %d on %d", errno, resfd)); } return (sent) ? sent : -1; } /* * find a dns request id (id is determined by dn_mkquery) */ static ResRQ *find_id(int id) { Reg ResRQ *rptr; for (rptr = first; rptr; rptr = rptr->next) if (rptr->id == id) return rptr; return NULL; } /* * Get a host address of type type, by it's name. * lp contains the client info. * returns the host info if found in cache, or NULL when it doesn't * know it yet. */ struct hostent *gethost_byname_type(char *name, Link *lp, int type) { Reg aCache *cp; reinfo.re_na_look++; if (type != T_A #ifdef INET6 && type != T_AAAA #endif ) return NULL; if ((cp = find_cache_name(NULL, name, #ifdef INET6 (type == T_AAAA) ? FLG_AAAA_VALID : #endif FLG_A_VALID))) return (struct hostent *)&(cp->he); if (!lp) return NULL; (void)do_query_name(lp, name, NULL, type); return NULL; } /* * Get a host address by it's name. * For IPv6, this will first try T_AAAA, and if that fails tries T_A, * inside get_res(). * IPv4 is always T_A. * It returns a pointer to the host info, or NULL if it didn't find * it yet. */ struct hostent *gethost_byname(char *name, Link *lp) { return gethost_byname_type(name, lp, #ifdef INET6 T_AAAA #else T_A #endif ); } struct hostent *gethost_byaddr(char *addr, Link *lp) { aCache *cp; reinfo.re_nu_look++; if ((cp = find_cache_number(NULL, addr))) return (struct hostent *)&(cp->he); if (!lp) return NULL; (void)do_query_number(lp, (struct IN_ADDR *)addr, NULL); return NULL; } static int do_query_name(Link *lp, char *name, ResRQ *rptr, int type) { char hname[HOSTLEN+1]; int len; strncpyzt(hname, name, sizeof(hname)); len = strlen(hname); if (rptr && !index(hname, '.') && ircd_res.options & RES_DEFNAMES) { if (sizeof(hname) - 1 /* ending \0 */ < strlen(hname) + 1 /* dot */ + strlen(ircd_res.defdname)) { /* or some other retval? */ return -1; } (void)strncat(hname, dot, sizeof(hname) - len - 1); len++; (void)strncat(hname, ircd_res.defdname, sizeof(hname) - len -1); } /* * Store the name passed as the one to lookup and generate other host * names to pass onto the nameserver(s) for lookups. */ if (!rptr) { rptr = make_request(lp); rptr->type = type; rptr->name = (char *)MyMalloc(strlen(name) + 1); (void)strcpy(rptr->name, name); } Debug((DEBUG_DNS,"do_query_name(): %s ", hname)); return query_name(hname, C_IN, type, rptr); } /* * Use this to do reverse IP# lookups. */ static int do_query_number(Link *lp, struct IN_ADDR *numb, ResRQ *rptr) { char ipbuf[128]; Reg u_char *cp; #ifdef INET6 cp = (u_char *)numb->s6_addr; if (cp[0]==0 && cp[1]==0 && cp[2]==0 && cp[3]==0 && cp[4]==0 && cp[5]==0 && cp[6]==0 && cp[7]==0 && cp[8]==0 && cp[9]==0 && ((cp[10]==0 && cp[11]==0) || (cp[10]==0xff && cp[11]==0xff))) { (void)sprintf(ipbuf, "%u.%u.%u.%u.in-addr.arpa.", (u_int)(cp[15]), (u_int)(cp[14]), (u_int)(cp[13]), (u_int)(cp[12])); } else { (void)sprintf(ipbuf, "%x.%x.%x.%x.%x.%x.%x.%x." "%x.%x.%x.%x.%x.%x.%x.%x." "%x.%x.%x.%x.%x.%x.%x.%x." "%x.%x.%x.%x.%x.%x.%x.%x.ip6.arpa.", (u_int)(cp[15]&0xf), (u_int)(cp[15]>>4), (u_int)(cp[14]&0xf), (u_int)(cp[14]>>4), (u_int)(cp[13]&0xf), (u_int)(cp[13]>>4), (u_int)(cp[12]&0xf), (u_int)(cp[12]>>4), (u_int)(cp[11]&0xf), (u_int)(cp[11]>>4), (u_int)(cp[10]&0xf), (u_int)(cp[10]>>4), (u_int)(cp[9]&0xf), (u_int)(cp[9]>>4), (u_int)(cp[8]&0xf), (u_int)(cp[8]>>4), (u_int)(cp[7]&0xf), (u_int)(cp[7]>>4), (u_int)(cp[6]&0xf), (u_int)(cp[6]>>4), (u_int)(cp[5]&0xf), (u_int)(cp[5]>>4), (u_int)(cp[4]&0xf), (u_int)(cp[4]>>4), (u_int)(cp[3]&0xf), (u_int)(cp[3]>>4), (u_int)(cp[2]&0xf), (u_int)(cp[2]>>4), (u_int)(cp[1]&0xf), (u_int)(cp[1]>>4), (u_int)(cp[0]&0xf), (u_int)(cp[0]>>4)); } #else cp = (u_char *)&numb->s_addr; (void)sprintf(ipbuf, "%u.%u.%u.%u.in-addr.arpa.", (u_int)(cp[3]), (u_int)(cp[2]), (u_int)(cp[1]), (u_int)(cp[0])); #endif if (!rptr) { rptr = make_request(lp); rptr->type = T_PTR; #ifdef INET6 bcopy(numb->s6_addr, rptr->addr.s6_addr, IN6ADDRSZ); bcopy((char *)numb->s6_addr, (char *)&rptr->he.h_addr, sizeof(struct in6_addr)); #else rptr->addr.s_addr = numb->s_addr; bcopy((char *)&numb->s_addr, (char *)&rptr->he.h_addr, sizeof(struct in_addr)); #endif rptr->he.h_length = sizeof(struct IN_ADDR); } return (query_name(ipbuf, C_IN, T_PTR, rptr)); } /* * generate a query based on class, type and name. */ static int query_name(char *name, int class, int type, ResRQ *rptr) { char buf[MAXPACKET]; int r,s,k = 0; HEADER *hptr; #ifndef LRAND48 struct timeval tv; (void) gettimeofday(&tv, NULL); #endif bzero(buf, sizeof(buf)); r = ircd_res_mkquery(QUERY, name, class, type, NULL, 0, NULL, (u_char *)buf, sizeof(buf)); if (r <= 0) { h_errno = NO_RECOVERY; return r; } hptr = (HEADER *)buf; do { u_short nstmp; nstmp = ntohs(hptr->id) + k; #ifndef LRAND48 nstmp += (u_short)(tv.tv_usec & 0xffff); #else nstmp += lrand48() & 0xffff; #endif hptr->id = htons(nstmp); k++; } while (find_id(ntohs(hptr->id))); rptr->id = ntohs(hptr->id); rptr->sends++; s = send_res_msg(buf, r, rptr->sends); if (s == -1) { h_errno = TRY_AGAIN; return -1; } else rptr->sent += s; return 0; } static void resend_query(ResRQ *rptr) { if (rptr->resend == 0) return; reinfo.re_resends++; switch(rptr->type) { case T_PTR: (void)do_query_number(NULL, &rptr->addr, rptr); break; #ifdef INET6 case T_AAAA: #endif case T_A: (void)do_query_name(NULL, rptr->name, rptr, rptr->type); break; default: break; } return; } /* * process name server reply. */ static int proc_answer(ResRQ *rptr, HEADER *hptr, char *buf, char *eob) { Reg char *cp, **alias; Reg struct hent *hp; int class, type, dlen, len, ans = 0, n; struct IN_ADDR dr, *adr; cp = buf + sizeof(HEADER); hp = (struct hent *)&(rptr->he); adr = &hp->h_addr; while (WHOSTENTP(adr->S_ADDR)) adr++; alias = hp->h_aliases; while (*alias) alias++; #if defined(SOLARIS_2) && !defined(__GNUC__) /* brain damaged compiler it seems */ for (; hptr->qdcount > 0; hptr->qdcount--) #else while (hptr->qdcount-- > 0) #endif if ((n = __ircd_dn_skipname((u_char *)cp, (u_char *)eob)) == -1) break; else cp += (n + QFIXEDSZ); /* * proccess each answer sent to us blech. */ while (hptr->ancount-- > 0 && cp && cp < eob) { n = ircd_dn_expand((u_char *)buf, (u_char *)eob, (u_char *)cp, hostbuf, sizeof(hostbuf)); if (n <= 0) break; cp += n; type = (int)ircd_getshort((u_char *)cp); cp += 2; /* INT16SZ */ class = (int)ircd_getshort((u_char *)cp); cp += 2; /* INT16SZ */ rptr->ttl = ircd_getlong((u_char *)cp); cp += 4; /* INT32SZ */ dlen = (int)ircd_getshort((u_char *)cp); cp += 2; /* INT16SZ */ len = strlen(hostbuf); /* name server never returns with trailing '.' */ if (!index(hostbuf,'.') && (ircd_res.options & RES_DEFNAMES)) { int tmplen = strlen(ircd_res.defdname); if (len + 1 /* dot */ + tmplen + 1 /* \0 */ >= sizeof(hostbuf)) { /* some SCH_ERROR perhaps? */ return -1; } if (len) { /* probably will never happen */ hostbuf[len++] = '.'; } strcpy(hostbuf + len, ircd_res.defdname); len += strlen(ircd_res.defdname); } /* Check that it's a possible reply to the request we send. */ if (rptr->type != type && type != T_CNAME) { sendto_flag(SCH_ERROR, "Wrong reply type looking up %s. " "Got: %d, expected %d.", hostbuf, type, rptr->type); cp += dlen; continue; } switch(type) { #ifdef INET6 case T_AAAA : #endif case T_A : if (dlen != ( #ifdef INET6 (type == T_AAAA) ? sizeof(struct in6_addr) : #endif sizeof(struct in_addr))) { sendto_flag(SCH_ERROR, "Bad IP length (%d) returned for %s", dlen, hostbuf); Debug((DEBUG_DNS, "Bad IP length (%d) returned for %s", dlen, hostbuf)); return -2; } hp->h_length = dlen; if (ans == 1) hp->h_addrtype = (class == C_IN) ? AFINET: AF_UNSPEC; #ifdef INET6 if (type == T_AAAA) bcopy(cp, (char *)&dr, dlen); else { /* ugly hack */ memset(dr.s6_addr, 0, 10); dr.s6_addr[10] = dr.s6_addr[11] = 0xff; memcpy(dr.s6_addr+12, cp, 4); } bcopy(dr.s6_addr, adr->s6_addr, IN6ADDRSZ); #else bcopy(cp, (char *)&dr, dlen); adr->s_addr = dr.s_addr; #endif #ifdef INET6 Debug((DEBUG_INFO,"got ip # %s for %s", inet_ntop(AF_INET6, (char *)adr, ipv6string, sizeof(ipv6string)), hostbuf)); #else Debug((DEBUG_INFO,"got ip # %s for %s", inetntoa((char *)adr), hostbuf)); #endif if (len < HOSTLEN) { /* if we have no hostname currently, * now we have one, else we have just * another alias. -- BitKoenig */ if (!hp->h_name) { hp->h_name = (char *)MyMalloc(len+1); (void)strcpy(hp->h_name, hostbuf); } else /* don't keep it if we already have it */ if (strcasecmp(hp->h_name, hostbuf) && alias < &(hp->h_aliases[MAXALIASES-1])) { *alias = (char *)MyMalloc(len + 1); (void)strcpy(*alias++, hostbuf); *alias = NULL; } } ans++; adr++; cp += dlen; break; case T_PTR : if ((n = ircd_dn_expand((u_char *)buf, (u_char *)eob, (u_char *)cp, hostbuf, sizeof(hostbuf) )) < 0) { cp = NULL; break; } cp += n; len = strlen(hostbuf); if (len > HOSTLEN) { return -1; } Debug((DEBUG_INFO, "got host %s (%d vs %d)", hostbuf, len, strlen(hostbuf))); if (bad_hostname(hostbuf, len)) return -1; /* * copy the returned hostname into the host name * or alias field if there is a known hostname * already. */ if (hp->h_name) { Debug((DEBUG_INFO, "duplicate PTR ignored")); } else { aCache *cachep = NULL; hp->h_name = (char *)MyMalloc(len + 1); (void)strcpy(hp->h_name, hostbuf); /* Got a good PTR record back, cache entry can be used also for reverse lookups. --fiction */ cachep = find_cache_name(NULL, hostbuf, (FLG_A_VALID #ifdef INET6 |FLG_AAAA_VALID #endif )); if (cachep != NULL) { if ((cachep->flags & FLG_PTR_PEND_FWD) != 0) { cachep->flags |= FLG_PTR_VALID; cachep->flags &= ~FLG_PTR_PEND; } else { cachep->flags |= FLG_PTR_PEND_REV; } } } ans++; break; case T_CNAME : cp += dlen; if (len > HOSTLEN) { return -1; } Debug((DEBUG_INFO,"got cname %s",hostbuf)); #if 0 /* This is overcautious (we do not use CNAME in any other way than follow it to get the PTR) and breaks RFC2317 (we do not allow '/' in PTRs). */ if (bad_hostname(hostbuf, len)) return -1; /* a break would be enough here */ #endif if (alias >= &(hp->h_aliases[MAXALIASES-1])) break; /* if we already have this alias as hostname, * don't keep it twice --BitKoenig */ if (hp->h_name && strcasecmp(hp->h_name, hostbuf)) { *alias = (char *)MyMalloc(len + 1); (void)strcpy(*alias++, hostbuf); *alias = NULL; } ans++; break; default : cp += dlen; #ifdef DEBUG Debug((DEBUG_INFO,"proc_answer: type:%d for:%s", type,hostbuf)); #endif break; } } return ans; } /* * read a dns reply from the nameserver and process it. */ struct hostent *get_res(char *lp) { static char buf[sizeof(HEADER) + MAXPACKET]; Reg HEADER *hptr; Reg ResRQ *rptr = NULL; aCache *cp = NULL; struct SOCKADDR_IN sin; int rc, a, max; SOCK_LEN_TYPE len = sizeof(sin); char buffer[512]; (void)alarm((unsigned)4); rc = recvfrom(resfd, buf, sizeof(buf), 0, (struct sockaddr *)&sin, &len); (void)alarm((unsigned)0); if (rc <= sizeof(HEADER)) goto getres_err; /* * convert DNS reply reader from Network byte order to CPU byte order. */ hptr = (HEADER *)buf; hptr->id = ntohs(hptr->id); hptr->ancount = ntohs(hptr->ancount); hptr->qdcount = ntohs(hptr->qdcount); hptr->nscount = ntohs(hptr->nscount); hptr->arcount = ntohs(hptr->arcount); #ifdef DEBUG Debug((DEBUG_NOTICE, "get_res:id = %d rcode = %d ancount = %d", hptr->id, hptr->rcode, hptr->ancount)); #endif reinfo.re_replies++; /* * response for an id which we have already received an answer for * just ignore this response. */ rptr = find_id(hptr->id); if (!rptr) goto getres_err; /* * check against possibly fake replies */ max = MIN(ircd_res.nscount, rptr->sends); if (!max) max = 1; for (a = 0; a < max; a++) if (!ircd_res.nsaddr_list[a].SIN_ADDR.S_ADDR || !bcmp((char *)&sin.SIN_ADDR, (char *)&ircd_res.nsaddr_list[a].SIN_ADDR, sizeof(struct IN_ADDR))) break; if (a == max) { reinfo.re_unkrep++; goto getres_err; } if ((hptr->rcode != NOERROR) || (hptr->ancount == 0)) { switch (hptr->rcode) { case NXDOMAIN: h_errno = TRY_AGAIN; break; case SERVFAIL: h_errno = TRY_AGAIN; break; case NOERROR: h_errno = NO_DATA; break; case FORMERR: case NOTIMP: case REFUSED: default: h_errno = NO_RECOVERY; break; } reinfo.re_errors++; /* ** If a bad error was returned, we stop here and dont send ** send any more (no retries granted). */ if (h_errno != TRY_AGAIN) { Debug((DEBUG_DNS, "Fatal DNS error %d for %d", h_errno, hptr->rcode)); rptr->resend = 0; rptr->retries = 0; } goto getres_err; } a = proc_answer(rptr, hptr, buf, buf+rc); if (a == -1) { sprintf(buffer, "Bad hostname returned for %s", #ifdef INET6 inetntop(AF_INET6, rptr->he.h_addr.s6_addr, ipv6string, sizeof(ipv6string)) #else inetntoa((char *)&rptr->he.h_addr) #endif ); sendto_flag(SCH_ERROR, "%s", buffer); Debug((DEBUG_DNS, "%s", buffer)); } #ifdef DEBUG Debug((DEBUG_INFO,"get_res:Proc answer = %d",a)); #endif if (a > 0 && rptr->type == T_PTR) { struct hostent *hp2 = NULL; int type; if (BadPtr(rptr->he.h_name)) /* Kludge! 960907/Vesa */ goto getres_err; #ifdef INET6 Debug((DEBUG_DNS, "relookup %s <-> %s", rptr->he.h_name, inet_ntop(AF_INET6, (char *)&rptr->he.h_addr, ipv6string, sizeof(ipv6string)) )); #else Debug((DEBUG_DNS, "relookup %s <-> %s", rptr->he.h_name, inetntoa((char *)&rptr->he.h_addr) )); #endif /* * Lookup the 'authoritative' name that we were given for the * ip#. By using this call rather than regenerating the * type we automatically gain the use of the cache with no * extra kludges. */ #ifdef INET6 if (!IN6_IS_ADDR_V4MAPPED(&rptr->he.h_addr)) type = T_AAAA; else #endif type = T_A; hp2 = gethost_byname_type(rptr->he.h_name, &rptr->cinfo, type); if (hp2 && lp) bcopy((char *)&rptr->cinfo, lp, sizeof(Link)); /* * If name wasn't found, a request has been queued and it will * be the last one queued. This is rather nasty way to keep * a host alias with the query. -avalon * We also need 'authoritative' name to be kept --BitKoenig */ if (!hp2) { last->he.h_name = rptr->he.h_name; rptr->he.h_name = NULL; for (a = 0; rptr->he.h_aliases[a]; a++) { Debug((DEBUG_DNS, "Copied CNAME %s for %s", rptr->he.h_aliases[a], rptr->he.h_name)); last->he.h_aliases[a] = rptr->he.h_aliases[a]; rptr->he.h_aliases[a] = NULL; } } rem_request(rptr); return hp2; } if (a > 0) { if (lp) bcopy((char *)&rptr->cinfo, lp, sizeof(Link)); cp = make_cache(rptr); #ifdef DEBUG Debug((DEBUG_INFO,"get_res:cp=%#x rptr=%#x (made)",cp,rptr)); #endif rem_request(rptr); } else if (!rptr->sent) rem_request(rptr); return cp ? (struct hostent *)&cp->he : NULL; getres_err: /* * Reprocess an error if the nameserver didnt tell us to "TRY_AGAIN". */ if (rptr) { if (h_errno != TRY_AGAIN) { /* * If we havent tried with the default domain and its * set, then give it a try next. */ if (ircd_res.options & RES_DEFNAMES && ++rptr->srch == 0) { rptr->retries = ircd_res.retry; rptr->sends = 0; rptr->resend = 1; } #ifdef INET6 /* Comment out this ifdef to get names like ::ffff:a.b.c.d */ /* We always want to query for both IN A and IN AAAA */ if (rptr->type == T_AAAA) { rptr->type = T_A; query_name(rptr->name, C_IN, T_A, rptr); Debug((DEBUG_DNS,"getres_err: didn't work " "with T_AAAA, now also trying with " "T_A for %s", rptr->name)); } #endif resend_query(rptr); } else if (lp) bcopy((char *)&rptr->cinfo, lp, sizeof(Link)); } return (struct hostent *)NULL; } static int hash_number(u_char *ip) { Reg u_int hashv = 0; /* could use loop but slower */ hashv += (int)*ip++; hashv += hashv + (int)*ip++; hashv += hashv + (int)*ip++; #ifdef INET6 hashv += hashv + (int)*ip++; hashv += hashv + (int)*ip++; hashv += hashv + (int)*ip++; hashv += hashv + (int)*ip++; hashv += hashv + (int)*ip++; hashv += hashv + (int)*ip++; hashv += hashv + (int)*ip++; hashv += hashv + (int)*ip++; hashv += hashv + (int)*ip++; hashv += hashv + (int)*ip++; hashv += hashv + (int)*ip++; hashv += hashv + (int)*ip++; #endif hashv += hashv + (int)*ip; hashv %= ARES_CACSIZE; return (hashv); } static int hash_name(char *name) { Reg u_int hashv = 0; for (; *name && *name != '.'; name++) hashv += *name; hashv %= ARES_CACSIZE; return (hashv); } /* ** Add a new cache item to the queue and hash table. */ static aCache *add_to_cache(aCache *ocp) { Reg aCache *cp = NULL; Reg int hashv; #ifdef DEBUG Debug((DEBUG_INFO, "add_to_cache:ocp %#x he %#x name %#x addrl %#x 0 %#x", ocp, &ocp->he, ocp->he.h_name, ocp->he.h_addr_list, ocp->he.h_addr_list[0])); #endif ocp->list_next = cachetop; cachetop = ocp; hashv = hash_name(ocp->he.h_name); ocp->hname_next = hashtable[hashv].name_list; hashtable[hashv].name_list = ocp; hashv = hash_number((u_char *)ocp->he.h_addr); ocp->hnum_next = hashtable[hashv].num_list; hashtable[hashv].num_list = ocp; #ifdef DEBUG # ifdef INET6 inetntop(AF_INET6, ocp->he.h_addr_list, ipv6string, sizeof(ipv6string)); Debug((DEBUG_INFO,"add_to_cache:added %s[%s] cache %#x.", ocp->he.h_name, ipv6string, ocp)); # else Debug((DEBUG_INFO, "add_to_cache:added %s[%08x] cache %#x.", ocp->he.h_name, ocp->he.h_addr_list[0], ocp)); # endif Debug((DEBUG_INFO, "add_to_cache:h1 %d h2 %x lnext %#x namnext %#x numnext %#x", hash_name(ocp->he.h_name), hashv, ocp->list_next, ocp->hname_next, ocp->hnum_next)); #endif /* * LRU deletion of excessive cache entries. */ if (++incache > MAXCACHED) { for (cp = cachetop; cp->list_next; cp = cp->list_next) ; rem_cache(cp); } cainfo.ca_adds++; return ocp; } /* ** update_list does not alter the cache structure passed. It is assumed that ** it already contains the correct expire time, if it is a new entry. Old ** entries have the expirey time updated. ** ** Actually expiry time is not touched at all, what this function does is: ** a.) Reorder the cache linked list so cachep gets first. ** b.) If we have a rptr, data from rptr->he is used to update the cache ** entry cachep. ** An important thing was added. Based on rptr->type we can determine which ** part of the nameserver reply is authoritative and update only that part ** (if the reply is for an "A?" we sent, update IP list, if it is for a ** "PTR?" request, update names - aliases). --fiction */ static void update_list(ResRQ *rptr, aCache *cachep) { Reg aCache **cpp, *cp = cachep; Reg char *s, *t, **base; Reg int i, j; int addrcount; /* ** search for the new cache item in the cache list by hostname. ** If found, move the entry to the top of the list and return. */ cainfo.ca_updates++; for (cpp = &cachetop; *cpp; cpp = &((*cpp)->list_next)) if (cp == *cpp) break; if (!*cpp) return; *cpp = cp->list_next; cp->list_next = cachetop; cachetop = cp; if (!rptr) return; #ifdef DEBUG Debug((DEBUG_DEBUG,"u_l:cp %#x na %#x al %#x ad %#x", cp,cp->he.h_name,cp->he.h_aliases,cp->he.h_addr)); Debug((DEBUG_DEBUG,"u_l:rptr %#x h_n %#x", rptr, rptr->he.h_name)); #endif if (rptr->type == T_PTR) { /* * Compare the cache entry against the new record. Add any * previously missing names for this entry. */ for (i = 0; cp->he.h_aliases[i]; i++) ; addrcount = i; for (i = 0, s = rptr->he.h_name; s && i < MAXALIASES; s = rptr->he.h_aliases[i++]) { for (j = 0, t = cp->he.h_name; t && j < MAXALIASES; t = cp->he.h_aliases[j++]) { if (!mycmp(t, s)) break; } if (!t && j < MAXALIASES-1) { base = cp->he.h_aliases; addrcount++; base = (char **)MyRealloc((char *)base, sizeof(char *) * (addrcount + 1)); cp->he.h_aliases = base; #ifdef DEBUG Debug((DEBUG_DNS,"u_l:add name %s hal %x ac %d", s, cp->he.h_aliases, addrcount)); #endif base[addrcount-1] = mystrdup(s); base[addrcount] = NULL; } } } if (rptr->type == T_A #ifdef INET6 || rptr->type == T_AAAA #endif ) { for (i = 0; cp->he.h_addr_list[i]; i++) ; addrcount = i; /* * Do the same again for IP#'s. */ for (j = 0; WHOSTENTP(rptr->he.h_addr_list[j].S_ADDR); j++) { #ifdef INET6 s = (char *)rptr->he.h_addr_list[j].S_ADDR; #else s = (char *)&rptr->he.h_addr_list[j].S_ADDR; #endif for (i = 0; (t = cp->he.h_addr_list[i]); i++) if (!bcmp(s, t, sizeof(struct IN_ADDR))) break; if (i >= MAXADDRS || addrcount >= MAXADDRS) break; /* * Oh man this is bad...I *HATE* it. -avalon * * Whats it do ? Reallocate two arrays, one of pointers * to "char *" and the other of IP addresses. Contents of * the IP array *MUST* be preserved and the pointers into * it recalculated. */ if (!t) { struct IN_ADDR **ab; ab = (struct IN_ADDR **)cp->he.h_addr_list; addrcount++; t = (char *)MyRealloc((char *)*ab, addrcount * sizeof(struct IN_ADDR)); base = (char **)MyRealloc((char *)ab, (addrcount + 1) * sizeof(*ab)); cp->he.h_addr_list = base; ab = (struct IN_ADDR **)base; #ifdef DEBUG # ifdef INET6 Debug((DEBUG_DNS,"u_l:add IP %s hal %x ac %d", inetntop(AF_INET6, (char *)((struct in6_addr *)s)->s6_addr, ipv6string, sizeof(ipv6string)), cp->he.h_addr_list, addrcount)); # else Debug((DEBUG_DNS,"u_l:add IP %x hal %x ac %d", ntohl(((struct in_addr *)s)->s_addr), cp->he.h_addr_list, addrcount)); # endif #endif for (i = addrcount; i; i--) { *ab++ = (struct IN_ADDR *)t; t += sizeof(struct IN_ADDR); } *ab = NULL; bcopy(s, (char *)*--ab, sizeof(struct IN_ADDR)); } } /* Here addrcount is the number of IPs in the cache entry --fiction */ if (addrcount > 1) { /* Do not trust that cache entry for reverse lookups */ cp->flags &= ~(FLG_PTR_PEND_FWD|FLG_PTR_VALID); } else { if ((cp->flags & FLG_PTR_PEND_REV) != 0) { cp->flags |= FLG_PTR_VALID; cp->flags &= ~(FLG_PTR_PEND); } else { cp->flags |= FLG_PTR_PEND_FWD; } } } return; } static aCache *find_cache_name(ResRQ *rptr, char *name, int flags) { Reg aCache *cp; Reg char *s; Reg int hashv, i; hashv = hash_name(name); cp = hashtable[hashv].name_list; #ifdef DEBUG Debug((DEBUG_DNS,"find_cache_name:find %s : hashv = %d",name,hashv)); #endif for (; cp; cp = cp->hname_next) { if ((cp->flags & flags) == 0) { continue; } for (i = 0, s = cp->he.h_name; s; s = cp->he.h_aliases[i++]) if (mycmp(s, name) == 0) { cainfo.ca_na_hits++; update_list(rptr, cp); return cp; } } for (cp = cachetop; cp; cp = cp->list_next) { if ((cp->flags & flags) == 0) { continue; } /* * if no aliases or the hash value matches, we've already * done this entry and all possiblilities concerning it. */ if (!*cp->he.h_aliases) continue; if (hashv == hash_name(cp->he.h_name)) continue; for (i = 0, s = cp->he.h_aliases[i]; s && i < MAXALIASES; i++) if (!mycmp(name, s)) { cainfo.ca_na_hits++; update_list(rptr, cp); return cp; } } return NULL; } /* * find a cache entry by ip# and update its expire time */ static aCache *find_cache_number(ResRQ *rptr, char *numb) { Reg aCache *cp; Reg int hashv,i; hashv = hash_number((u_char *)numb); cp = hashtable[hashv].num_list; #ifdef DEBUG # ifdef INET6 Debug((DEBUG_DNS, "find_cache_number:find %s: hashv = %d", inet_ntop(AF_INET6, numb, ipv6string, sizeof(ipv6string)), hashv)); # else Debug((DEBUG_DNS,"find_cache_number:find %s[%08x]: hashv = %d", inetntoa(numb), ntohl(((struct in_addr *)numb)->s_addr), hashv)); # endif #endif for (; cp; cp = cp->hnum_next) { if ((cp->flags & FLG_PTR_VALID) == 0) { continue; } for (i = 0; cp->he.h_addr_list[i]; i++) { if (!bcmp(cp->he.h_addr_list[i], numb, sizeof(struct IN_ADDR))) { cainfo.ca_nu_hits++; update_list(rptr, cp); return cp; } } } for (cp = cachetop; cp; cp = cp->list_next) { if ((cp->flags & FLG_PTR_VALID) == 0) { continue; } if (!cp->he.h_addr_list && !cp->he.h_aliases) { cp = rem_list(cp); continue; } /* * single address entry...would have been done by hashed * search above... */ if (!cp->he.h_addr_list[1]) continue; /* * if the first IP# has the same hashnumber as the IP# we * are looking for, its been done already. */ if (hashv == hash_number((u_char *)cp->he.h_addr_list[0])) continue; for (i = 1; cp->he.h_addr_list[i]; i++) { if (!bcmp(cp->he.h_addr_list[i], numb, sizeof(struct IN_ADDR))) { cainfo.ca_nu_hits++; update_list(rptr, cp); return cp; } } } return NULL; } static aCache *make_cache(ResRQ *rptr) { Reg aCache *cp; Reg int i, n; Reg struct hostent *hp; Reg char *s, **t; /* ** shouldn't happen but it just might... */ if (!rptr->he.h_name || !WHOSTENTP(rptr->he.h_addr.S_ADDR)) return NULL; /* ** Make cache entry. First check to see if the cache already exists ** and if so, return a pointer to it. */ /* * Notice that find_* will also call update_list() and thus update the * cache entry according to our new rptr->he. However do not worry * anymore as update_list() has additional new checks too. --fiction */ if (rptr->type == T_PTR) { /* * Search cache by IP. * Idea is that IP is already known and trusted (and can be * used for search) when the reply is for a PTR request. * The "new" thing we get with PTR is the hostname. --fiction */ for (i = 0; WHOSTENTP(rptr->he.h_addr_list[i].S_ADDR); i++) { if ((cp = find_cache_number(rptr, #ifdef INET6 (char *)(rptr->he.h_addr_list[i].S_ADDR) #else (char *)&(rptr->he.h_addr_list[i].S_ADDR) #endif ))) return cp; } } else if (rptr->type == T_A #ifdef INET6 || rptr->type == T_AAAA #endif ) { /* * Search cache by name in case of A/AAAA reply. * Problem could be if the reply contained a CNAME and that * would make it into he.h_name. But as we assume CNAMEs can * end up ONLY in aliases everything should be fine. --fiction */ if ((cp = find_cache_name(rptr, rptr->he.h_name, #ifdef INET6 (rptr->type == T_AAAA) ? FLG_AAAA_VALID : #endif FLG_A_VALID))) { return cp; } } /* ** a matching entry wasnt found in the cache so go and make one up. */ cp = (aCache *)MyMalloc(sizeof(aCache)); bzero((char *)cp, sizeof(aCache)); hp = &cp->he; for (i = 0; i < MAXADDRS - 1; i++) if (!WHOSTENTP(rptr->he.h_addr_list[i].S_ADDR)) break; /* ** build two arrays, one for IP#'s, another of pointers to them. */ t = hp->h_addr_list = (char **)MyMalloc(sizeof(char *) * (i+1)); bzero((char *)t, sizeof(char *) * (i+1)); s = (char *)MyMalloc(sizeof(struct IN_ADDR) * i); bzero(s, sizeof(struct IN_ADDR) * i); for (n = 0; n < i; n++, s += sizeof(struct IN_ADDR)) { *t++ = s; bcopy((char *)&rptr->he.h_addr_list[n], s, sizeof(struct IN_ADDR)); } *t = (char *)NULL; /* ** an array of pointers to CNAMEs. */ for (i = 0; i < MAXALIASES - 1; i++) if (!rptr->he.h_aliases[i]) break; i++; t = hp->h_aliases = (char **)MyMalloc(sizeof(char *) * i); for (n = 0; n < i; n++, t++) { *t = rptr->he.h_aliases[n]; rptr->he.h_aliases[n] = NULL; } hp->h_addrtype = rptr->he.h_addrtype; hp->h_length = rptr->he.h_length; hp->h_name = rptr->he.h_name; if (rptr->ttl < 600) { reinfo.re_shortttl++; cp->ttl = 600; } else cp->ttl = rptr->ttl; cp->expireat = timeofday + cp->ttl; rptr->he.h_name = NULL; #ifdef DEBUG Debug((DEBUG_INFO,"make_cache:made cache %#x", cp)); #endif cp->flags = 0; switch (rptr->type) { case T_A: cp->flags |= FLG_A_VALID; break; #ifdef INET6 case T_AAAA: cp->flags |= FLG_AAAA_VALID; break; #endif } return add_to_cache(cp); } /* * rem_list */ static aCache *rem_list(aCache *cp) { aCache **cpp, *cr = cp->list_next; /* * remove cache entry from linked list */ for (cpp = &cachetop; *cpp; cpp = &((*cpp)->list_next)) { if (*cpp == cp) { *cpp = cp->list_next; MyFree(cp); break; } } return cr; } /* * rem_cache * delete a cache entry from the cache structures and lists and return * all memory used for the cache back to the memory pool. */ static void rem_cache(aCache *ocp) { Reg aCache **cp; Reg struct hostent *hp = &ocp->he; Reg int hashv; Reg aClient *cptr; #ifdef DEBUG Debug((DEBUG_DNS, "rem_cache: ocp %#x hp %#x l_n %#x aliases %#x", ocp, hp, ocp->list_next, hp->h_aliases)); #endif /* ** Cleanup any references to this structure by destroying the ** pointer. */ for (hashv = highest_fd; hashv >= 0; hashv--) if ((cptr = local[hashv]) && (cptr->hostp == hp)) cptr->hostp = NULL; /* * remove cache entry from linked list */ for (cp = &cachetop; *cp; cp = &((*cp)->list_next)) { if (*cp == ocp) { *cp = ocp->list_next; break; } } /* * remove cache entry from hashed name lists */ hashv = hash_name(hp->h_name); #ifdef DEBUG Debug((DEBUG_DEBUG,"rem_cache: h_name %s hashv %d next %#x first %#x", hp->h_name, hashv, ocp->hname_next, hashtable[hashv].name_list)); #endif for (cp = &hashtable[hashv].name_list; *cp; cp = &((*cp)->hname_next)) { if (*cp == ocp) { *cp = ocp->hname_next; break; } } /* * remove cache entry from hashed number list */ hashv = hash_number((u_char *)hp->h_addr); #ifdef DEBUG Debug((DEBUG_DEBUG,"rem_cache: h_addr %s hashv %d next %#x first %#x", # ifdef INET6 inet_ntop(AF_INET6, hp->h_addr, ipv6string, sizeof(ipv6string)), # else inetntoa(hp->h_addr), # endif hashv, ocp->hnum_next, hashtable[hashv].num_list)); #endif for (cp = &hashtable[hashv].num_list; *cp; cp = &((*cp)->hnum_next)) { if (*cp == ocp) { *cp = ocp->hnum_next; break; } } /* * free memory used to hold the various host names and the array * of alias pointers. */ if (hp->h_name) MyFree(hp->h_name); if (hp->h_aliases) { for (hashv = 0; hp->h_aliases[hashv]; hashv++) MyFree(hp->h_aliases[hashv]); MyFree(hp->h_aliases); } /* * free memory used to hold ip numbers and the array of them. */ if (hp->h_addr_list) { if (*hp->h_addr_list) MyFree(*hp->h_addr_list); MyFree(hp->h_addr_list); } MyFree(ocp); incache--; cainfo.ca_dels++; return; } /* * removes entries from the cache which are older than their expirey times. * returns the time at which the server should next poll the cache. */ time_t expire_cache(time_t now) { Reg aCache *cp, *cp2; Reg time_t next = 0; for (cp = cachetop; cp; cp = cp2) { cp2 = cp->list_next; if (now >= cp->expireat) { cainfo.ca_expires++; rem_cache(cp); } else if (!next || next > cp->expireat) next = cp->expireat; } return (next > now) ? next : (now + AR_TTL); } /* * remove all dns cache entries. */ void flush_cache(void) { Reg aCache *cp; while ((cp = cachetop)) rem_cache(cp); } int m_dns(aClient *cptr, aClient *sptr, int parc, char *parv[]) { Reg aCache *cp; Reg int i; if (!is_allowed(sptr, ACL_DNS)) return m_nopriv(cptr, sptr, parc, parv); if (parv[1] && *parv[1] == 'l') { for(cp = cachetop; cp; cp = cp->list_next) { sendto_one(sptr, "NOTICE %s :Ex %d ttl %d host %s(%s) %d", parv[0], cp->expireat - timeofday, cp->ttl, cp->he.h_name, #ifdef INET6 inetntop(AF_INET6, cp->he.h_addr, ipv6string, sizeof(ipv6string)) #else inetntoa(cp->he.h_addr) #endif , cp->flags); for (i = 0; cp->he.h_aliases[i]; i++) { sendto_one(sptr,"NOTICE %s : %s = %s (CN)", parv[0], cp->he.h_name, cp->he.h_aliases[i]); } for (i = 1; cp->he.h_addr_list[i]; i++) { sendto_one(sptr,"NOTICE %s : %s = %s (IP)", parv[0], cp->he.h_name, #ifdef INET6 inetntop(AF_INET6, cp->he.h_addr_list[i], ipv6string, sizeof(ipv6string)) #else inetntoa(cp->he.h_addr_list[i]) #endif ); } } return 2; } sendto_one(sptr,"NOTICE %s :Ca %d Cd %d Ce %d Cl %d Ch %d:%d Cu %d", sptr->name, cainfo.ca_adds, cainfo.ca_dels, cainfo.ca_expires, cainfo.ca_lookups, cainfo.ca_na_hits, cainfo.ca_nu_hits, cainfo.ca_updates); sendto_one(sptr,"NOTICE %s :Re %d Rl %d/%d Rp %d Rq %d", sptr->name, reinfo.re_errors, reinfo.re_nu_look, reinfo.re_na_look, reinfo.re_replies, reinfo.re_requests); sendto_one(sptr,"NOTICE %s :Ru %d Rsh %d Rs %d(%d) Rt %d", sptr->name, reinfo.re_unkrep, reinfo.re_shortttl, reinfo.re_sent, reinfo.re_resends, reinfo.re_timeouts); return 2; } u_long cres_mem(aClient *sptr, char *nick) { register aCache *c = cachetop; register struct hostent *h; register int i; u_long nm = 0, im = 0, sm = 0, ts = 0; for ( ;c ; c = c->list_next) { sm += sizeof(*c); h = &c->he; for (i = 0; h->h_addr_list[i]; i++) { im += sizeof(char *); im += sizeof(struct IN_ADDR); } im += sizeof(char *); for (i = 0; h->h_aliases[i]; i++) { nm += sizeof(char *); nm += strlen(h->h_aliases[i]); } nm += i - 1; nm += sizeof(char *); if (h->h_name) nm += strlen(h->h_name); } ts = ARES_CACSIZE * sizeof(CacheTable); sendto_one(sptr, ":%s %d %s :RES table %d", me.name, RPL_STATSDEBUG, nick, ts); sendto_one(sptr, ":%s %d %s :Structs %d IP storage %d Name storage %d", me.name, RPL_STATSDEBUG, nick, sm, im, nm); return ts + sm + im + nm; } static int bad_hostname(char *name, int len) { char *s, c; for (s = name; (c = *s) && len; s++, len--) #ifdef RESTRICT_HOSTNAMES { /* basic character set */ if (isalnum(c)) continue; /* special case: hyphen */ if ((c == '-') && /* we accept '-' only if... */ (s != name) && /* not "-aaa.bbb" */ (s[-1] != '.') && /* not "aaa.-bbb" */ (len != 1) && /* not "aaa.bbb-" */ (s[1] != '.')) /* not "aaa-.bbb" */ continue; /* start of a new component */ if ((c == '.') && /* we accept '.' only if... */ (s != name) && /* not ".aaa.bbb" */ (s[-1] != '.')) /* not "aaa..bbb" */ continue; #ifdef HOSTNAMES_UNDERSCORE /* ignore underscore in certain circumstances */ if (c == '_') continue; #endif /* HOSTNAMES_UNDERSCORE */ return -1; } #else /* RESTRICT_HOSTNAMES */ if (isspace(c) || (c == 0x7) || (c == ':') || (c == '*') || (c == '?')) return -1; #endif /* RESTRICT_HOSTNAMES */ return 0; } irc2.11.2p3/ircd/s_err.c0000644000175000017500000007657111431020077012546 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/s_err.c * Copyright (C) 1992 Darren Reed * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: s_err.c,v 1.71 2010/08/12 16:24:31 bif Exp $"; #endif #include "os.h" #include "s_defines.h" #define S_ERR_C #include "s_externs.h" #undef S_ERR_C char * replies[] = { /* 000 */ (char *)NULL, /* 001 RPL_WELCOME */ ":%s 001 %s :Welcome to the Internet Relay Network %s", /* 002 RPL_YOURHOST */ ":%s 002 %s :Your host is %s, running version %s", /* 003 RPL_CREATED */ ":%s 003 %s :This server was created %s", /* 004 RPL_MYINFO */ ":%s 004 %s %s %s aoOirw abeiIklmnoOpqrRstv", /* 005 RPL_ISUPPORT */ ":%s 005 %s %s :are supported by this server", /* 006 */ (char *)NULL, /* 007 */ (char *)NULL, /* 008 */ (char *)NULL, /* 009 */ (char *)NULL, /* 010 RPL_BOUNCE */ ":%s 010 %s %s %d :Please use this Server/Port instead", /* 011 */ (char *)NULL, /* 012 */ (char *)NULL, /* 013 */ (char *)NULL, /* 014 */ (char *)NULL, /* 015 RPL_MAP */ ":%s 015 %s :%s", /* 016 */ (char *)NULL, /* 017 RPL_MAPEND */ ":%s 017 %s :End of MAP", /* 018 RPL_MAPSTART */ ":%s 018 %s :%s", /* 019 */ (char *)NULL, /* 020 RPL_HELLO */ ":%s 020 * :%s", /* 021 */ (char *)NULL, /* 022 */ (char *)NULL, /* 023 */ (char *)NULL, /* 024 */ (char *)NULL, /* 025 */ (char *)NULL, /* 026 */ (char *)NULL, /* 027 */ (char *)NULL, /* 028 */ (char *)NULL, /* 029 */ (char *)NULL, /* 030 */ (char *)NULL, /* 031 */ (char *)NULL, /* 032 */ (char *)NULL, /* 033 */ (char *)NULL, /* 034 */ (char *)NULL, /* 035 */ (char *)NULL, /* 036 */ (char *)NULL, /* 037 */ (char *)NULL, /* 038 */ (char *)NULL, /* 039 */ (char *)NULL, /* 040 */ (char *)NULL, /* 041 */ (char *)NULL, /* 042 RPL_YOURID */ ":%s 042 %s %s :your unique ID", /* 043 RPL_SAVENICK */ ":%s 043 %s %s :nickname collision, forcing nick change to your unique ID.", /* 044 */ (char *)NULL, /* 045 */ (char *)NULL, /* 046 */ (char *)NULL, /* 047 */ (char *)NULL, /* 048 */ (char *)NULL, /* 049 */ (char *)NULL, /* 050 */ (char *)NULL, /* 051 */ (char *)NULL, /* 052 */ (char *)NULL, /* 053 */ (char *)NULL, /* 054 */ (char *)NULL, /* 055 */ (char *)NULL, /* 056 */ (char *)NULL, /* 057 */ (char *)NULL, /* 058 */ (char *)NULL, /* 059 */ (char *)NULL, /* 060 */ (char *)NULL, /* 061 */ (char *)NULL, /* 062 */ (char *)NULL, /* 063 */ (char *)NULL, /* 064 */ (char *)NULL, /* 065 */ (char *)NULL, /* 066 */ (char *)NULL, /* 067 */ (char *)NULL, /* 068 */ (char *)NULL, /* 069 */ (char *)NULL, /* 070 */ (char *)NULL, /* 071 */ (char *)NULL, /* 072 */ (char *)NULL, /* 073 */ (char *)NULL, /* 074 */ (char *)NULL, /* 075 */ (char *)NULL, /* 076 */ (char *)NULL, /* 077 */ (char *)NULL, /* 078 */ (char *)NULL, /* 079 */ (char *)NULL, /* 080 */ (char *)NULL, /* 081 */ (char *)NULL, /* 082 */ (char *)NULL, /* 083 */ (char *)NULL, /* 084 */ (char *)NULL, /* 085 */ (char *)NULL, /* 086 */ (char *)NULL, /* 087 */ (char *)NULL, /* 088 */ (char *)NULL, /* 089 */ (char *)NULL, /* 090 */ (char *)NULL, /* 091 */ (char *)NULL, /* 092 */ (char *)NULL, /* 093 */ (char *)NULL, /* 094 */ (char *)NULL, /* 095 */ (char *)NULL, /* 096 */ (char *)NULL, /* 097 */ (char *)NULL, /* 098 */ (char *)NULL, /* 099 */ (char *)NULL, /* 100 */ (char *)NULL, /* 101 */ (char *)NULL, /* 102 */ (char *)NULL, /* 103 */ (char *)NULL, /* 104 */ (char *)NULL, /* 105 */ (char *)NULL, /* 106 */ (char *)NULL, /* 107 */ (char *)NULL, /* 108 */ (char *)NULL, /* 109 */ (char *)NULL, /* 110 */ (char *)NULL, /* 111 */ (char *)NULL, /* 112 */ (char *)NULL, /* 113 */ (char *)NULL, /* 114 */ (char *)NULL, /* 115 */ (char *)NULL, /* 116 */ (char *)NULL, /* 117 */ (char *)NULL, /* 118 */ (char *)NULL, /* 119 */ (char *)NULL, /* 120 */ (char *)NULL, /* 121 */ (char *)NULL, /* 122 */ (char *)NULL, /* 123 */ (char *)NULL, /* 124 */ (char *)NULL, /* 125 */ (char *)NULL, /* 126 */ (char *)NULL, /* 127 */ (char *)NULL, /* 128 */ (char *)NULL, /* 129 */ (char *)NULL, /* 130 */ (char *)NULL, /* 131 */ (char *)NULL, /* 132 */ (char *)NULL, /* 133 */ (char *)NULL, /* 134 */ (char *)NULL, /* 135 */ (char *)NULL, /* 136 */ (char *)NULL, /* 137 */ (char *)NULL, /* 138 */ (char *)NULL, /* 139 */ (char *)NULL, /* 140 */ (char *)NULL, /* 141 */ (char *)NULL, /* 142 */ (char *)NULL, /* 143 */ (char *)NULL, /* 144 */ (char *)NULL, /* 145 */ (char *)NULL, /* 146 */ (char *)NULL, /* 147 */ (char *)NULL, /* 148 */ (char *)NULL, /* 149 */ (char *)NULL, /* 150 */ (char *)NULL, /* 151 */ (char *)NULL, /* 152 */ (char *)NULL, /* 153 */ (char *)NULL, /* 154 */ (char *)NULL, /* 155 */ (char *)NULL, /* 156 */ (char *)NULL, /* 157 */ (char *)NULL, /* 158 */ (char *)NULL, /* 159 */ (char *)NULL, /* 160 */ (char *)NULL, /* 161 */ (char *)NULL, /* 162 */ (char *)NULL, /* 163 */ (char *)NULL, /* 164 */ (char *)NULL, /* 165 */ (char *)NULL, /* 166 */ (char *)NULL, /* 167 */ (char *)NULL, /* 168 */ (char *)NULL, /* 169 */ (char *)NULL, /* 170 */ (char *)NULL, /* 171 */ (char *)NULL, /* 172 */ (char *)NULL, /* 173 */ (char *)NULL, /* 174 */ (char *)NULL, /* 175 */ (char *)NULL, /* 176 */ (char *)NULL, /* 177 */ (char *)NULL, /* 178 */ (char *)NULL, /* 179 */ (char *)NULL, /* 180 */ (char *)NULL, /* 181 */ (char *)NULL, /* 182 */ (char *)NULL, /* 183 */ (char *)NULL, /* 184 */ (char *)NULL, /* 185 */ (char *)NULL, /* 186 */ (char *)NULL, /* 187 */ (char *)NULL, /* 188 */ (char *)NULL, /* 189 */ (char *)NULL, /* 190 */ (char *)NULL, /* 191 */ (char *)NULL, /* 192 */ (char *)NULL, /* 193 */ (char *)NULL, /* 194 */ (char *)NULL, /* 195 */ (char *)NULL, /* 196 */ (char *)NULL, /* 197 */ (char *)NULL, /* 198 */ (char *)NULL, /* 199 */ (char *)NULL, /* 200 RPL_TRACELINK */ ":%s 200 %s Link %s%s %s %s V%X%s %d %d %d", /* 201 RPL_TRACECONNECTING */ ":%s 201 %s Try. %d %s", /* 202 RPL_TRACEHANDSHAKE */ ":%s 202 %s H.S. %d %s", /* 203 RPL_TRACEUNKNOWN */ ":%s 203 %s ???? %d %s", /* 204 RPL_TRACEOPERATOR */ ":%s 204 %s Oper %d %s", /* 205 RPL_TRACEUSER */ ":%s 205 %s User %d %s", /* 206 RPL_TRACESERVER */ ":%s 206 %s Serv %d %dS %dC %s %s!%s@%s V%X%s", /* 207 RPL_TRACESERVICE */ ":%s 207 %s Service %d %s 0x%X 0x%X", /* 208 RPL_TRACENEWTYPE */ ":%s 208 %s 0 %s", /* 209 */ NULL, /* 210 */ NULL, /* 211 RPL_STATSLINKINFO */ (char *)NULL, /* 212 RPL_STATSCOMMANDS */ ":%s 212 %s %s %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u", /* 213 RPL_STATSCLINE */ ":%s 213 %s %c %s %s %s %d %d", /* 214 RPL_STATSNLINE */ ":%s 214 %s %c %s %s %s %d %d", /* 215 RPL_STATSILINE */ ":%s 215 %s %c %s %s %s %d %d %s", /* 216 RPL_STATSKLINE */ ":%s 216 %s %c %s %s %s %d %d", /* 217 RPL_STATSQLINE */ ":%s 217 %s %c %s %s %s %d %d", /* 218 RPL_STATSYLINE */ ":%s 218 %s %c %d %d %d %d %d.%d %d.%d %d.%d %d%s", /* 219 RPL_ENDOFSTATS */ ":%s 219 %s %c :End of STATS report", /* 220 */ (char *)NULL, /* 221 RPL_UMODEIS */ ":%s 221 %s %s", /* 222 */ (char *)NULL, /* 223 */ (char *)NULL, /* 224 */ (char *)NULL, /* 225 */ (char *)NULL, /* 226 */ (char *)NULL, /* 227 */ (char *)NULL, /* 228 */ (char *)NULL, /* 229 */ (char *)NULL, /* 230 */ (char *)NULL, /* 231 RPL_SERVICEINFO */ (char *)NULL, /* 232 RPL_ENDOFSERVICES */ (char *)NULL, /* 233 RPL_SERVICE */ (char *)NULL, /* 234 RPL_SERVLIST */ ":%s 234 %s %s %s %s 0x%X %d :%s", /* 235 RPL_SERVLISTEND */ ":%s 235 %s %s %d :End of service listing", /* 236 */ (char *)NULL, /* 237 */ (char *)NULL, /* 238 */ (char *)NULL, /* 239 */ (char *)NULL, /* 240 RPL_STATSVLINE */ ":%s 240 %s %c %s %s %s %d %d", /* 241 RPL_STATSLLINE */ ":%s 241 %s %c %s %s %s %d %d", /* 242 RPL_STATSUPTIME */ ":%s 242 %s :Server Up %d days, %d:%02d:%02d", /* 243 RPL_STATSOLINE */ ":%s 243 %s %c %s %s %s %d %d %s", /* 244 RPL_STATSHLINE */ ":%s 244 %s %c %s %s %s %d %d", /* 245 RPL_STATSSLINE */ ":%s 245 %s %c %s %s %s 0x%X %d", /* 246 RPL_STATSPING */ ":%s 246 %s %s %d %d %d %d", /* 247 RPL_STATSBLINE */ ":%s 247 %s %c %s %s %s %d %d", /* 248 RPL_STATSDEFINE */ (char *)NULL, /* 249 RPL_STATSDEBUG */ (char *)NULL, /* 250 RPL_STATSDLINE */ ":%s 250 %s %c %s %s %s %d %d", /* 251 RPL_LUSERCLIENT */ ":%s 251 %s :There are %d users and %d services on %d servers", /* 252 RPL_LUSEROP */ ":%s 252 %s %d :operators online", /* 253 RPL_LUSERUNKNOWN */ ":%s 253 %s %d :unknown connections", /* 254 RPL_LUSERCHANNELS */ ":%s 254 %s %d :channels formed", /* 255 RPL_LUSERME */ ":%s 255 %s :I have %d users, %d services and %d servers", /* 256 RPL_ADMINME */ ":%s 256 %s :Administrative info about %s", /* 257 RPL_ADMINLOC1 */ ":%s 257 %s :%s", /* 258 RPL_ADMINLOC2 */ ":%s 258 %s :%s", /* 259 RPL_ADMINEMAIL */ ":%s 259 %s :%s", /* 260 */ (char *)NULL, /* 261 */ (char *)NULL, /* 262 RPL_TRACEEND */ ":%s 262 %s %s %s.%s :End of TRACE", /* 263 RPL_TRYAGAIN */ ":%s 263 %s %s :Please wait a while and try again.", /* 264 */ (char *)NULL, /* 265 RPL_LOCALUSERS */ ":%s 265 %s %d %d :Current local users %d, max %d", /* 266 RPL_GLOBALUSERS */ ":%s 266 %s %d %d :Current global users %d, max %d", /* 267 */ (char *)NULL, /* 268 */ (char *)NULL, /* 269 */ (char *)NULL, /* 270 */ (char *)NULL, /* 271 */ (char *)NULL, /* 272 */ (char *)NULL, /* 273 */ (char *)NULL, /* 274 */ (char *)NULL, /* 275 */ (char *)NULL, /* 276 */ (char *)NULL, /* 277 */ (char *)NULL, /* 278 */ (char *)NULL, /* 279 */ (char *)NULL, /* 280 */ (char *)NULL, /* 281 */ (char *)NULL, /* 282 */ (char *)NULL, /* 283 */ (char *)NULL, /* 284 */ (char *)NULL, /* 285 */ (char *)NULL, /* 286 */ (char *)NULL, /* 287 */ (char *)NULL, /* 288 */ (char *)NULL, /* 289 */ (char *)NULL, /* 290 */ (char *)NULL, /* 291 */ (char *)NULL, /* 292 */ (char *)NULL, /* 293 */ (char *)NULL, /* 294 */ (char *)NULL, /* 295 */ (char *)NULL, /* 296 */ (char *)NULL, /* 297 */ (char *)NULL, /* 298 */ (char *)NULL, /* 299 */ (char *)NULL, /* 300 RPL_NONE */ (char *)NULL, /* 301 RPL_AWAY */ ":%s 301 %s %s :%s", /* 302 RPL_USERHOST */ ":%s 302 %s :", /* 303 RPL_ISON */ ":%s 303 %s :", /* 304 RPL_TEXT */ (char *)NULL, /* 305 RPL_UNAWAY */ ":%s 305 %s :You are no longer marked as being away", /* 306 RPL_NOWAWAY */ ":%s 306 %s :You have been marked as being away", /* 307 */ (char *)NULL, /* 308 */ (char *)NULL, /* 309 */ (char *)NULL, /* 310 */ (char *)NULL, /* 311 RPL_WHOISUSER */ ":%s 311 %s %s %s %s * :%s", /* 312 RPL_WHOISSERVER */ ":%s 312 %s %s %s :%s", /* 313 RPL_WHOISOPERATOR */ ":%s 313 %s %s :is an IRC Operator", /* 314 RPL_WHOWASUSER */ ":%s 314 %s %s %s %s * :%s", /* 315 RPL_ENDOFWHO */ ":%s 315 %s %s :End of WHO list.", /* 316 RPL_WHOISCHANOP */ (char *)NULL, #ifdef WHOIS_SIGNON_TIME /* 317 RPL_WHOISIDLE */ ":%s 317 %s %s %ld %ld :seconds idle, signon time", #else /* 317 RPL_WHOISIDLE */ ":%s 317 %s %s %ld :seconds idle", #endif /* 318 RPL_ENDOFWHOIS */ ":%s 318 %s %s :End of WHOIS list.", /* 319 RPL_WHOISCHANNELS */ ":%s 319 %s %s :%s", /* 320 */ (char *)NULL, /* 321 RPL_LISTSTART */ ":%s 321 %s Channel :Users Name", /* 322 RPL_LIST */ ":%s 322 %s %s %d :%s", /* 323 RPL_LISTEND */ ":%s 323 %s :End of LIST", /* 324 RPL_CHANNELMODEIS */ ":%s 324 %s %s %s %s", /* 325 RPL_UNIQOPIS */ ":%s 325 %s %s %s", /* 326 */ (char *)NULL, /* 327 */ (char *)NULL, /* 328 */ (char *)NULL, /* 329 */ (char *)NULL, /* 330 */ (char *)NULL, /* 331 RPL_NOTOPIC */ ":%s 331 %s %s :No topic is set.", /* 332 RPL_TOPIC */ ":%s 332 %s %s :%s", /* 333 RPL_TOPIC_WHO_TIME */ ":%s 333 %s %s %s %lu", /* 334 */ (char *)NULL, /* 335 */ (char *)NULL, /* 336 */ (char *)NULL, /* 337 */ (char *)NULL, /* 338 */ (char *)NULL, /* 339 */ (char *)NULL, /* 340 */ (char *)NULL, /* 341 RPL_INVITING */ ":%s 341 %s %s %s", /* 342 RPL_SUMMONING */ ":%s 342 %s %s :User summoned to irc", /* 343 */ (char *)NULL, /* 344 RPL_REOPLIST */ ":%s 344 %s %s %s!%s@%s", /* 345 RPL_ENDOFREOPLIST */ ":%s 345 %s %s :End of Channel Reop List", /* 346 RPL_INVITELIST */ ":%s 346 %s %s %s!%s@%s", /* 347 RPL_ENDOFINVITELIST */ ":%s 347 %s %s :End of Channel Invite List", /* 348 RPL_EXCEPTLIST */ ":%s 348 %s %s %s!%s@%s", /* 349 RPL_ENDOFEXCEPTLIST */ ":%s 349 %s %s :End of Channel Exception List", /* 350 */ (char *)NULL, /* 351 RPL_VERSION */ ":%s 351 %s %s.%s %s %s :%s", /* 352 RPL_WHOREPLY */ ":%s 352 %s %s %s %s %s %s %s :%d %s %s", /* 353 RPL_NAMREPLY */ ":%s 353 %s %s", /* 354 */ (char *)NULL, /* 355 */ (char *)NULL, /* 356 */ (char *)NULL, /* 357 */ (char *)NULL, /* 358 */ (char *)NULL, /* 359 */ (char *)NULL, /* 360 */ (char *)NULL, /* 361 RPL_KILLDONE */ (char *)NULL, /* 362 RPL_CLOSING */ ":%s 362 %s %s :Closed. Status = %d", /* 363 RPL_CLOSEEND */ ":%s 363 %s %d: Connections Closed", /* 364 RPL_LINKS */ ":%s 364 %s %s %s :%d %s %s", /* 365 RPL_ENDOFLINKS */ ":%s 365 %s %s :End of LINKS list.", /* 366 RPL_ENDOFNAMES */ ":%s 366 %s %s :End of NAMES list.", /* 367 RPL_BANLIST */ ":%s 367 %s %s %s!%s@%s", /* 368 RPL_ENDOFBANLIST */ ":%s 368 %s %s :End of Channel Ban List", /* 369 RPL_ENDOFWHOWAS */ ":%s 369 %s %s :End of WHOWAS", /* 370 */ (char *)NULL, /* 371 RPL_INFO */ ":%s 371 %s :%s", /* 372 RPL_MOTD */ ":%s 372 %s :- %s", /* 373 RPL_INFOSTART */ ":%s 373 %s :Server INFO", /* 374 RPL_ENDOFINFO */ ":%s 374 %s :End of INFO list.", /* 375 RPL_MOTDSTART */ ":%s 375 %s :- %s Message of the Day - ", /* 376 RPL_ENDOFMOTD */ ":%s 376 %s :End of MOTD command.", /* 377 */ (char *)NULL, /* 378 */ (char *)NULL, /* 379 */ (char *)NULL, /* 380 */ (char *)NULL, /* 381 RPL_YOUREOPER */ ":%s 381 %s :" TXT_YOUREOPER, /* 382 RPL_REHASHING */ ":%s 382 %s %s :Rehashing", /* 383 RPL_YOURESERVICE */ ":%s 383 %s :You are service %s", /* 384 RPL_MYPORTIS */ ":%s 384 %s %d :Port to local server is\r\n", /* 385 RPL_NOTOPERANYMORE */ (char *)NULL, /* 386 */ (char *)NULL, /* 387 */ (char *)NULL, /* 388 */ (char *)NULL, /* 389 */ (char *)NULL, /* 390 */ (char *)NULL, /* 391 RPL_TIME */ ":%s 391 %s %s :%s", #if defined(USERS_RFC1459) && defined(USERS_SHOWS_UTMP) /* 392 RPL_USERSSTART */ ":%s 392 %s :UserID Terminal Host", /* 393 RPL_USERS */ ":%s 393 %s :%-8s %-9s %-8s", /* 394 RPL_ENDOFUSERS */ ":%s 394 %s :End of Users", /* 395 RPL_NOUSERS */ ":%s 395 %s :Nobody logged in.", #else /* 392 */ (char *)NULL, /* 393 */ (char *)NULL, /* 394 */ (char *)NULL, /* 395 */ (char *)NULL, #endif /* 396 */ (char *)NULL, /* 397 */ (char *)NULL, /* 398 */ (char *)NULL, /* 399 */ (char *)NULL, /* 400 */ (char *)NULL, /* 401 ERR_NOSUCHNICK */ ":%s 401 %s %s :No such nick/channel", /* 402 ERR_NOSUCHSERVER */ ":%s 402 %s %s :No such server", /* 403 ERR_NOSUCHCHANNEL */ ":%s 403 %s %s :No such channel", /* 404 ERR_CANNOTSENDTOCHAN */ ":%s 404 %s %s :Cannot send to channel", /* 405 ERR_TOOMANYCHANNELS */ ":%s 405 %s %s :You have joined too many channels", /* 406 ERR_WASNOSUCHNICK */ ":%s 406 %s %s :There was no such nickname", /* 407 ERR_TOOMANYTARGETS */ ":%s 407 %s %s :%s recipients. %s", /* 408 ERR_NOSUCHSERVICE */ ":%s 408 %s %s :No such service", /* 409 ERR_NOORIGIN */ ":%s 409 %s :No origin specified", /* 410 */ (char *)NULL, /* 411 ERR_NORECIPIENT */ ":%s 411 %s :No recipient given (%s)", /* 412 ERR_NOTEXTTOSEND */ ":%s 412 %s :No text to send", /* 413 ERR_NOTOPLEVEL */ ":%s 413 %s %s :No toplevel domain specified", /* 414 ERR_WILDTOPLEVEL */ ":%s 414 %s %s :Wildcard in toplevel Domain", /* 415 ERR_BADMASK */ ":%s 415 %s %s :Bad Server/host mask", /* 416 ERR_TOOMANYMATCHES */ ":%s 416 %s %s :output too large, truncated", /* 417 */ (char *)NULL, /* 418 */ (char *)NULL, /* 419 */ (char *)NULL, /* 420 */ (char *)NULL, /* 421 ERR_UNKNOWNCOMMAND */ ":%s 421 %s %s :Unknown command", /* 422 ERR_NOMOTD */ ":%s 422 %s :MOTD File is missing", /* 423 ERR_NOADMININFO */ ":%s 423 %s %s :No administrative info available", /* 424 ERR_FILEERROR */ ":%s 424 %s :File error doing %s on %s", /* 425 */ (char *)NULL, /* 426 */ (char *)NULL, /* 427 */ (char *)NULL, /* 428 */ (char *)NULL, /* 429 */ (char *)NULL, /* 430 */ (char *)NULL, /* 431 ERR_NONICKNAMEGIVEN */ ":%s 431 %s :No nickname given", /* 432 ERR_ERRONEOUSNICKNAME */ ":%s 432 %s %s :Erroneous Nickname", /* 433 ERR_NICKNAMEINUSE */ ":%s 433 %s %s :Nickname is already in use.", /* 434 ERR_SERVICENAMEINUSE */ (char *)NULL, /* 435 ERR_SERVICECONFUSED */ (char *)NULL, /* 436 ERR_NICKCOLLISION */ ":%s 436 %s %s :Nickname collision KILL from %s@%s", /* 437 ERR_UNAVAILRESOURCE */ ":%s 437 %s %s :Nick/channel is temporarily unavailable", /* 438 */ (char *)NULL, /* 439 */ (char *)NULL, /* 440 */ (char *)NULL, /* 441 ERR_USERNOTINCHANNEL */ ":%s 441 %s %s %s :They aren't on that channel", /* 442 ERR_NOTONCHANNEL */ ":%s 442 %s %s :You're not on that channel", /* 443 ERR_USERONCHANNEL */ ":%s 443 %s %s %s :is already on channel", /* 444 ERR_NOLOGIN */ ":%s 444 %s %s :User not logged in", #ifndef ENABLE_SUMMON /* 445 ERR_SUMMONDISABLED */ ":%s 445 %s :SUMMON has been disabled", #else /* 445 */ (char *)NULL, #endif #if defined(USERS_RFC1459) && !defined(USERS_SHOWS_UTMP) /* 446 ERR_USERSDISABLED */ ":%s 446 %s :USERS has been disabled", #else /* 446 */ (char *)NULL, #endif /* 447 */ (char *)NULL, /* 448 */ (char *)NULL, /* 449 */ (char *)NULL, /* 450 */ (char *)NULL, /* 451 ERR_NOTREGISTERED */ ":%s 451 %s :You have not registered", /* 452 */ (char *)NULL, /* 453 */ (char *)NULL, /* 454 */ (char *)NULL, /* 455 */ (char *)NULL, /* 456 */ (char *)NULL, /* 457 */ (char *)NULL, /* 458 */ (char *)NULL, /* 459 */ (char *)NULL, /* 460 */ (char *)NULL, /* 461 ERR_NEEDMOREPARAMS */ ":%s 461 %s %s :Not enough parameters", /* 462 ERR_ALREADYREGISTRED */ ":%s 462 %s :Unauthorized command (already registered)", /* 463 ERR_NOPERMFORHOST */ ":%s 463 %s :Your host isn't among the privileged", /* 464 ERR_PASSWDMISMATCH */ ":%s 464 %s :Password Incorrect", /* 465 ERR_YOUREBANNEDCREEP */ ":%s 465 %s :You (%s@%s) are banned from this server%s%s", /* 466 ERR_YOUWILLBEBANNED */ (char *)NULL, /* 467 ERR_KEYSET */ ":%s 467 %s %s :Channel key already set", /* 468 */ (char *)NULL, /* 469 */ (char *)NULL, /* 470 */ (char *)NULL, /* 471 ERR_CHANNELISFULL */ ":%s 471 %s %s :Cannot join channel (+l)", /* 472 ERR_UNKNOWNMODE */ ":%s 472 %s %c :is unknown mode char to me for %s", /* 473 ERR_INVITEONLYCHAN */ ":%s 473 %s %s :Cannot join channel (+i)", /* 474 ERR_BANNEDFROMCHAN */ ":%s 474 %s %s :Cannot join channel (+b)", /* 475 ERR_BADCHANNELKEY */ ":%s 475 %s %s :Cannot join channel (+k)", /* 476 ERR_BADCHANMASK */ ":%s 476 %s %s :Bad Channel Mask", /* 477 ERR_NOCHANMODES */ ":%s 477 %s %s :Channel doesn't support modes", /* 478 ERR_BANLISTFULL */ ":%s 478 %s %s %s!%s@%s :Channel list is full", /* 479 */ (char *)NULL, /* 480 */ (char *)NULL, /* 481 ERR_NOPRIVILEGES */ ":%s 481 %s :Permission Denied", /* 482 ERR_CHANOPRIVSNEEDED */ ":%s 482 %s %s :You're not channel operator", /* 483 ERR_CANTKILLSERVER */ ":%s 483 %s %s :You can't kill a server!", /* 484 ERR_RESTRICTED */ ":%s 484 %s :Your connection is restricted!", /* 485 ERR_UNIQOPRIVSNEEDED */ ":%s 485 %s :You're not the original channel operator", /* 486 */ (char *)NULL, /* 487 */ (char *)NULL, /* 488 */ (char *)NULL, /* 489 */ (char *)NULL, /* 490 */ (char *)NULL, /* 491 ERR_NOOPERHOST */ ":%s 491 %s :No O-lines for your host", /* 492 ERR_NOSERVICEHOST */ (char *)NULL, /* 493 */ (char *)NULL, /* 494 */ (char *)NULL, /* 495 */ (char *)NULL, /* 496 */ (char *)NULL, /* 497 */ (char *)NULL, /* 498 */ (char *)NULL, #ifdef TXT_NOSTATSK /* 499 */ ":%s 499 %s :" TXT_NOSTATSK, #else /* 499 */ (char *)NULL, #endif /* 500 */ (char *)NULL, /* 501 ERR_UMODEUNKNOWNFLAG */ ":%s 501 %s :Unknown MODE flag", /* 502 ERR_USERSDONTMATCH */ ":%s 502 %s :Can't change mode for other users", /* 503 */ (char *)NULL, /* 504 */ (char *)NULL, /* 505 */ (char *)NULL, /* 506 */ (char *)NULL, /* 507 */ (char *)NULL, /* 508 */ (char *)NULL, /* 509 */ (char *)NULL, /* 510 */ (char *)NULL, /* 511 */ (char *)NULL, /* 512 */ (char *)NULL, /* 513 */ (char *)NULL, /* 514 */ (char *)NULL, /* 515 */ (char *)NULL, /* 516 */ (char *)NULL, /* 517 */ (char *)NULL, /* 518 */ (char *)NULL, /* 519 */ (char *)NULL, /* 520 */ (char *)NULL, /* 521 */ (char *)NULL, /* 522 */ (char *)NULL, /* 523 */ (char *)NULL, /* 524 */ (char *)NULL, /* 525 */ (char *)NULL, /* 526 */ (char *)NULL, /* 527 */ (char *)NULL, /* 528 */ (char *)NULL, /* 529 */ (char *)NULL, /* 530 */ (char *)NULL, /* 531 */ (char *)NULL, /* 532 */ (char *)NULL, /* 533 */ (char *)NULL, /* 534 */ (char *)NULL, /* 535 */ (char *)NULL, /* 536 */ (char *)NULL, /* 537 */ (char *)NULL, /* 538 */ (char *)NULL, /* 539 */ (char *)NULL, /* 540 */ (char *)NULL, /* 541 */ (char *)NULL, /* 542 */ (char *)NULL, /* 543 */ (char *)NULL, /* 544 */ (char *)NULL, /* 545 */ (char *)NULL, /* 546 */ (char *)NULL, /* 547 */ (char *)NULL, /* 548 */ (char *)NULL, /* 549 */ (char *)NULL, /* 550 */ (char *)NULL, /* 551 */ (char *)NULL, /* 552 */ (char *)NULL, /* 553 */ (char *)NULL, /* 554 */ (char *)NULL, /* 555 */ (char *)NULL, /* 556 */ (char *)NULL, /* 557 */ (char *)NULL, /* 558 */ (char *)NULL, /* 559 */ (char *)NULL, /* 560 */ (char *)NULL, /* 561 */ (char *)NULL, /* 562 */ (char *)NULL, /* 563 */ (char *)NULL, /* 564 */ (char *)NULL, /* 565 */ (char *)NULL, /* 566 */ (char *)NULL, /* 567 */ (char *)NULL, /* 568 */ (char *)NULL, /* 569 */ (char *)NULL, /* 570 */ (char *)NULL, /* 571 */ (char *)NULL, /* 572 */ (char *)NULL, /* 573 */ (char *)NULL, /* 574 */ (char *)NULL, /* 575 */ (char *)NULL, /* 576 */ (char *)NULL, /* 577 */ (char *)NULL, /* 578 */ (char *)NULL, /* 579 */ (char *)NULL, /* 580 */ (char *)NULL, /* 581 */ (char *)NULL, /* 582 */ (char *)NULL, /* 583 */ (char *)NULL, /* 584 */ (char *)NULL, /* 585 */ (char *)NULL, /* 586 */ (char *)NULL, /* 587 */ (char *)NULL, /* 588 */ (char *)NULL, /* 589 */ (char *)NULL, /* 590 */ (char *)NULL, /* 591 */ (char *)NULL, /* 592 */ (char *)NULL, /* 593 */ (char *)NULL, /* 594 */ (char *)NULL, /* 595 */ (char *)NULL, /* 596 */ (char *)NULL, /* 597 */ (char *)NULL, /* 598 */ (char *)NULL, /* 599 */ (char *)NULL, /* 600 */ (char *)NULL, /* 601 */ (char *)NULL, /* 602 */ (char *)NULL, /* 603 */ (char *)NULL, /* 604 */ (char *)NULL, /* 605 */ (char *)NULL, /* 606 */ (char *)NULL, /* 607 */ (char *)NULL, /* 608 */ (char *)NULL, /* 609 */ (char *)NULL, /* 610 */ (char *)NULL, /* 611 */ (char *)NULL, /* 612 */ (char *)NULL, /* 613 */ (char *)NULL, /* 614 */ (char *)NULL, /* 615 */ (char *)NULL, /* 616 */ (char *)NULL, /* 617 */ (char *)NULL, /* 618 */ (char *)NULL, /* 619 */ (char *)NULL, /* 620 */ (char *)NULL, /* 621 */ (char *)NULL, /* 622 */ (char *)NULL, /* 623 */ (char *)NULL, /* 624 */ (char *)NULL, /* 625 */ (char *)NULL, /* 626 */ (char *)NULL, /* 627 */ (char *)NULL, /* 628 */ (char *)NULL, /* 629 */ (char *)NULL, /* 630 */ (char *)NULL, /* 631 */ (char *)NULL, /* 632 */ (char *)NULL, /* 633 */ (char *)NULL, /* 634 */ (char *)NULL, /* 635 */ (char *)NULL, /* 636 */ (char *)NULL, /* 637 */ (char *)NULL, /* 638 */ (char *)NULL, /* 639 */ (char *)NULL, /* 640 */ (char *)NULL, /* 641 */ (char *)NULL, /* 642 */ (char *)NULL, /* 643 */ (char *)NULL, /* 644 */ (char *)NULL, /* 645 */ (char *)NULL, /* 646 */ (char *)NULL, /* 647 */ (char *)NULL, /* 648 */ (char *)NULL, /* 649 */ (char *)NULL, /* 650 */ (char *)NULL, /* 651 */ (char *)NULL, /* 652 */ (char *)NULL, /* 653 */ (char *)NULL, /* 654 */ (char *)NULL, /* 655 */ (char *)NULL, /* 656 */ (char *)NULL, /* 657 */ (char *)NULL, /* 658 */ (char *)NULL, /* 659 */ (char *)NULL, /* 660 */ (char *)NULL, /* 661 */ (char *)NULL, /* 662 */ (char *)NULL, /* 663 */ (char *)NULL, /* 664 */ (char *)NULL, /* 665 */ (char *)NULL, /* 666 */ (char *)NULL, /* 667 */ (char *)NULL, /* 668 */ (char *)NULL, /* 669 */ (char *)NULL, /* 670 */ (char *)NULL, /* 671 */ (char *)NULL, /* 672 */ (char *)NULL, /* 673 */ (char *)NULL, /* 674 */ (char *)NULL, /* 675 */ (char *)NULL, /* 676 */ (char *)NULL, /* 677 */ (char *)NULL, /* 678 */ (char *)NULL, /* 679 */ (char *)NULL, /* 680 */ (char *)NULL, /* 681 */ (char *)NULL, /* 682 */ (char *)NULL, /* 683 */ (char *)NULL, /* 684 */ (char *)NULL, /* 685 */ (char *)NULL, /* 686 */ (char *)NULL, /* 687 */ (char *)NULL, /* 688 */ (char *)NULL, /* 689 */ (char *)NULL, /* 690 */ (char *)NULL, /* 691 */ (char *)NULL, /* 692 */ (char *)NULL, /* 693 */ (char *)NULL, /* 694 */ (char *)NULL, /* 695 */ (char *)NULL, /* 696 */ (char *)NULL, /* 697 */ (char *)NULL, /* 698 */ (char *)NULL, /* 699 */ (char *)NULL, /* 700 */ (char *)NULL, /* 701 */ (char *)NULL, /* 702 */ (char *)NULL, /* 703 */ (char *)NULL, /* 704 */ (char *)NULL, /* 705 */ (char *)NULL, /* 706 */ (char *)NULL, /* 707 */ (char *)NULL, /* 708 RPL_ETRACEFULL */ ":%s 709 %s %s %d %s %s %s %s %s %s :%s", /* 709 */ (char *)NULL, /* 710 */ (char *)NULL, /* 711 */ (char *)NULL, /* 712 */ (char *)NULL, /* 713 */ (char *)NULL, /* 714 */ (char *)NULL, /* 715 */ (char *)NULL, /* 716 */ (char *)NULL, /* 717 */ (char *)NULL, /* 718 */ (char *)NULL, /* 719 */ (char *)NULL, /* 720 */ (char *)NULL, /* 721 */ (char *)NULL, /* 722 */ (char *)NULL, /* 723 */ (char *)NULL, /* 724 */ (char *)NULL, /* 725 */ (char *)NULL, /* 726 */ (char *)NULL, /* 727 */ (char *)NULL, /* 728 */ (char *)NULL, /* 729 */ (char *)NULL, /* 730 */ (char *)NULL, /* 731 */ (char *)NULL, /* 732 */ (char *)NULL, /* 733 */ (char *)NULL, /* 734 */ (char *)NULL, /* 735 */ (char *)NULL, /* 736 */ (char *)NULL, /* 737 */ (char *)NULL, /* 738 */ (char *)NULL, /* 739 */ (char *)NULL, /* 740 */ (char *)NULL, /* 741 */ (char *)NULL, /* 742 */ (char *)NULL, /* 743 */ (char *)NULL, /* 744 */ (char *)NULL, /* 745 */ (char *)NULL, /* 746 */ (char *)NULL, /* 747 */ (char *)NULL, /* 748 */ (char *)NULL, /* 749 */ (char *)NULL, /* 750 */ (char *)NULL, /* 751 */ (char *)NULL, /* 752 */ (char *)NULL, /* 753 */ (char *)NULL, /* 754 */ (char *)NULL, /* 755 */ (char *)NULL, /* 756 */ (char *)NULL, /* 757 */ (char *)NULL, /* 758 */ (char *)NULL, /* 759 RPL_ETRACEEND */ ":%s 759 %s %s %s.%s :End of ETRACE", /* 760 */ (char *)NULL, /* 761 */ (char *)NULL, /* 762 */ (char *)NULL, /* 763 */ (char *)NULL, /* 764 */ (char *)NULL, /* 765 */ (char *)NULL, /* 766 */ (char *)NULL, /* 767 */ (char *)NULL, /* 768 */ (char *)NULL, /* 769 */ (char *)NULL, /* 770 */ (char *)NULL, /* 771 */ (char *)NULL, /* 772 */ (char *)NULL, /* 773 */ (char *)NULL, /* 774 */ (char *)NULL, /* 775 */ (char *)NULL, /* 776 */ (char *)NULL, /* 777 */ (char *)NULL, /* 778 */ (char *)NULL, /* 779 */ (char *)NULL, /* 780 */ (char *)NULL, /* 781 */ (char *)NULL, /* 782 */ (char *)NULL, /* 783 */ (char *)NULL, /* 784 */ (char *)NULL, /* 785 */ (char *)NULL, /* 786 */ (char *)NULL, /* 787 */ (char *)NULL, /* 788 */ (char *)NULL, /* 789 */ (char *)NULL, /* 790 */ (char *)NULL, /* 791 */ (char *)NULL, /* 792 */ (char *)NULL, /* 793 */ (char *)NULL, /* 794 */ (char *)NULL, /* 795 */ (char *)NULL, /* 796 */ (char *)NULL, /* 797 */ (char *)NULL, /* 798 */ (char *)NULL, /* 799 */ (char *)NULL, /* 800 */ (char *)NULL, /* 801 */ (char *)NULL, /* 802 */ (char *)NULL, /* 803 */ (char *)NULL, /* 804 */ (char *)NULL, /* 805 */ (char *)NULL, /* 806 */ (char *)NULL, /* 807 */ (char *)NULL, /* 808 */ (char *)NULL, /* 809 */ (char *)NULL, /* 810 */ (char *)NULL, /* 811 */ (char *)NULL, /* 812 */ (char *)NULL, /* 813 */ (char *)NULL, /* 814 */ (char *)NULL, /* 815 */ (char *)NULL, /* 816 */ (char *)NULL, /* 817 */ (char *)NULL, /* 818 */ (char *)NULL, /* 819 */ (char *)NULL, /* 820 */ (char *)NULL, /* 821 */ (char *)NULL, /* 822 */ (char *)NULL, /* 823 */ (char *)NULL, /* 824 */ (char *)NULL, /* 825 */ (char *)NULL, /* 826 */ (char *)NULL, /* 827 */ (char *)NULL, /* 828 */ (char *)NULL, /* 829 */ (char *)NULL, /* 830 */ (char *)NULL, /* 831 */ (char *)NULL, /* 832 */ (char *)NULL, /* 833 */ (char *)NULL, /* 834 */ (char *)NULL, /* 835 */ (char *)NULL, /* 836 */ (char *)NULL, /* 837 */ (char *)NULL, /* 838 */ (char *)NULL, /* 839 */ (char *)NULL, /* 840 */ (char *)NULL, /* 841 */ (char *)NULL, /* 842 */ (char *)NULL, /* 843 */ (char *)NULL, /* 844 */ (char *)NULL, /* 845 */ (char *)NULL, /* 846 */ (char *)NULL, /* 847 */ (char *)NULL, /* 848 */ (char *)NULL, /* 849 */ (char *)NULL, /* 850 */ (char *)NULL, /* 851 */ (char *)NULL, /* 852 */ (char *)NULL, /* 853 */ (char *)NULL, /* 854 */ (char *)NULL, /* 855 */ (char *)NULL, /* 856 */ (char *)NULL, /* 857 */ (char *)NULL, /* 858 */ (char *)NULL, /* 859 */ (char *)NULL, /* 860 */ (char *)NULL, /* 861 */ (char *)NULL, /* 862 */ (char *)NULL, /* 863 */ (char *)NULL, /* 864 */ (char *)NULL, /* 865 */ (char *)NULL, /* 866 */ (char *)NULL, /* 867 */ (char *)NULL, /* 868 */ (char *)NULL, /* 869 */ (char *)NULL, /* 870 */ (char *)NULL, /* 871 */ (char *)NULL, /* 872 */ (char *)NULL, /* 873 */ (char *)NULL, /* 874 */ (char *)NULL, /* 875 */ (char *)NULL, /* 876 */ (char *)NULL, /* 877 */ (char *)NULL, /* 878 */ (char *)NULL, /* 879 */ (char *)NULL, /* 880 */ (char *)NULL, /* 881 */ (char *)NULL, /* 882 */ (char *)NULL, /* 883 */ (char *)NULL, /* 884 */ (char *)NULL, /* 885 */ (char *)NULL, /* 886 */ (char *)NULL, /* 887 */ (char *)NULL, /* 888 */ (char *)NULL, /* 889 */ (char *)NULL, /* 890 */ (char *)NULL, /* 891 */ (char *)NULL, /* 892 */ (char *)NULL, /* 893 */ (char *)NULL, /* 894 */ (char *)NULL, /* 895 */ (char *)NULL, /* 896 */ (char *)NULL, /* 897 */ (char *)NULL, /* 898 */ (char *)NULL, /* 899 */ (char *)NULL, /* 900 */ (char *)NULL, /* 901 */ (char *)NULL, /* 902 */ (char *)NULL, /* 903 */ (char *)NULL, /* 904 */ (char *)NULL, /* 905 */ (char *)NULL, /* 906 */ (char *)NULL, /* 907 */ (char *)NULL, /* 908 */ (char *)NULL, /* 909 */ (char *)NULL, /* 910 */ (char *)NULL, /* 911 */ (char *)NULL, /* 912 */ (char *)NULL, /* 913 */ (char *)NULL, /* 914 */ (char *)NULL, /* 915 */ (char *)NULL, /* 916 */ (char *)NULL, /* 917 */ (char *)NULL, /* 918 */ (char *)NULL, /* 919 */ (char *)NULL, /* 920 */ (char *)NULL, /* 921 */ (char *)NULL, /* 922 */ (char *)NULL, /* 923 */ (char *)NULL, /* 924 */ (char *)NULL, /* 925 */ (char *)NULL, /* 926 */ (char *)NULL, /* 927 */ (char *)NULL, /* 928 */ (char *)NULL, /* 929 */ (char *)NULL, /* 930 */ (char *)NULL, /* 931 */ (char *)NULL, /* 932 */ (char *)NULL, /* 933 */ (char *)NULL, /* 934 */ (char *)NULL, /* 935 */ (char *)NULL, /* 936 */ (char *)NULL, /* 937 */ (char *)NULL, /* 938 */ (char *)NULL, /* 939 */ (char *)NULL, /* 940 */ (char *)NULL, /* 941 */ (char *)NULL, /* 942 */ (char *)NULL, /* 943 */ (char *)NULL, /* 944 */ (char *)NULL, /* 945 */ (char *)NULL, /* 946 */ (char *)NULL, /* 947 */ (char *)NULL, /* 948 */ (char *)NULL, /* 949 */ (char *)NULL, /* 950 */ (char *)NULL, /* 951 */ (char *)NULL, /* 952 */ (char *)NULL, /* 953 */ (char *)NULL, /* 954 */ (char *)NULL, /* 955 */ (char *)NULL, /* 956 */ (char *)NULL, /* 957 */ (char *)NULL, /* 958 */ (char *)NULL, /* 959 */ (char *)NULL, /* 960 */ (char *)NULL, /* 961 */ (char *)NULL, /* 962 */ (char *)NULL, /* 963 */ (char *)NULL, /* 964 */ (char *)NULL, /* 965 */ (char *)NULL, /* 966 */ (char *)NULL, /* 967 */ (char *)NULL, /* 968 */ (char *)NULL, /* 969 */ (char *)NULL, /* 970 */ (char *)NULL, /* 971 */ (char *)NULL, /* 972 */ (char *)NULL, /* 973 */ (char *)NULL, /* 974 */ (char *)NULL, /* 975 */ (char *)NULL, /* 976 */ (char *)NULL, /* 977 */ (char *)NULL, /* 978 */ (char *)NULL, /* 979 */ (char *)NULL, /* 980 */ (char *)NULL, /* 981 */ (char *)NULL, /* 982 */ (char *)NULL, /* 983 */ (char *)NULL, /* 984 */ (char *)NULL, /* 985 */ (char *)NULL, /* 986 */ (char *)NULL, /* 987 */ (char *)NULL, /* 988 */ (char *)NULL, /* 989 */ (char *)NULL, /* 990 */ (char *)NULL, /* 991 */ (char *)NULL, /* 992 */ (char *)NULL, /* 993 */ (char *)NULL, /* 994 */ (char *)NULL, /* 995 */ (char *)NULL, /* 996 */ (char *)NULL, /* 997 */ (char *)NULL, /* 998 */ (char *)NULL, /* 999 */ (char *)NULL }; irc2.11.2p3/ircd/s_id_ext.h0000644000175000017500000000316410022664725013234 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/s_id_ext.h * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/s_id.c. */ /* External definitions for global variables. */ #ifndef S_ID_C /* none */ #endif /* S_ID_C */ /* External definitions for global functions. */ #ifndef S_ID_C #define EXTERN extern #else /* S_ID_C */ #define EXTERN #endif /* S_ID_C */ EXTERN char *get_chid (void); EXTERN int close_chid (char *); EXTERN void cache_chid (aChannel *); EXTERN int check_chid (char *); EXTERN void collect_chid (void); EXTERN void init_sid (char *); EXTERN char *next_uid (void); EXTERN int check_uid (char *, char *); EXTERN char *ltoid (long l, int n); EXTERN long idtol (char *id, int n); EXTERN int sid_valid (char *sid); EXTERN int cid_ok (char *name, int n); #undef EXTERN irc2.11.2p3/ircd/channel_ext.h0000644000175000017500000000551611157057061013730 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/channel_ext.h * Copyright (C) 1997 Alain Nissen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/channel.c. */ /* External definitions for global variables. */ #ifndef CHANNEL_C extern aChannel *channel; #endif /* CHANNEL_C */ /* External definitions for global functions. */ #ifndef CHANNEL_C #define EXTERN extern #else /* CHANNEL_C */ #define EXTERN #endif /* CHANNEL_C */ EXTERN void remove_user_from_channel (aClient *sptr, aChannel *chptr); EXTERN int is_chan_op (aClient *cptr, aChannel *chptr); EXTERN int has_voice (aClient *cptr, aChannel *chptr); EXTERN int can_send (aClient *cptr, aChannel *chptr); #ifdef JAPANESE EXTERN char *get_channelmask (char *); EXTERN int jp_valid (aClient *, aChannel *, char *); #else #define get_channelmask(x) rindex((x), ':') #endif EXTERN aChannel *find_channel (Reg char *chname, Reg aChannel *chptr); EXTERN void setup_server_channels (aClient *mp); EXTERN void channel_modes (aClient *cptr, Reg char *mbuf, Reg char *pbuf, aChannel *chptr); EXTERN void send_channel_modes (aClient *cptr, aChannel *chptr); EXTERN void send_channel_members (aClient *cptr, aChannel *chptr); EXTERN int m_mode (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int clean_channelname (Reg char *cn); EXTERN void del_invite (aClient *cptr, aChannel *chptr); EXTERN int m_join (Reg aClient *cptr, Reg aClient *sptr, int parc, char *parv[]); EXTERN int m_njoin (Reg aClient *cptr, Reg aClient *sptr, int parc, char *parv[]); EXTERN int m_part (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_kick (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_topic (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_invite (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_list (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_names (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN time_t collect_channel_garbage (time_t now); #undef EXTERN irc2.11.2p3/ircd/patricia_ext.h0000644000175000017500000001031111157044733014103 0ustar kkkk/* * Imported: Id: patricia.h 18598 2005-03-04 17:45:53Z androsyn * Dave Plonka * * This product includes software developed by the University of Michigan, * Merit Network, Inc., and their contributors. * * This file had been called "radix.h" in the MRT sources. * * I renamed it to "patricia.h" since it's not an implementation of a general * radix trie. Also, pulled in various requirements from "mrt.h" and added * some other things it could be used as a standalone API. */ #ifndef PATRICIA_C #define EXTERN extern #else /* PATRICIA_C */ #define EXTERN #endif /* PATRICIA_C */ #ifndef _PATRICIA_H #define _PATRICIA_H #include #include #include #include #include #include #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE !(FALSE) #endif #ifndef INET6_ADDRSTRLEN #define INET6_ADDRSTRLEN 46 #endif /* typedef unsigned int u_int; */ typedef void (*void_fn_t) (); #define prefix_touchar(prefix) ((u_char *)&(prefix)->add.sin) #define MAXLINE 1024 #define BIT_TEST(f, b) ((f) & (b)) #include #include typedef struct _prefix_t { u_short family; /* AF_INET | AF_INET6 */ u_short bitlen; /* same as mask? */ int ref_count; /* reference count */ union { struct in_addr sin; #ifdef INET6 struct in6_addr sin6; #endif /* IPV6 */ } add; } prefix_t; typedef struct _patricia_node_t { u_int bit; /* flag if this node used */ prefix_t *prefix; /* who we are in patricia tree */ struct _patricia_node_t *l, *r; /* left and right children */ struct _patricia_node_t *parent; /* may be used */ void *data; } patricia_node_t; typedef struct _patricia_tree_t { patricia_node_t *head; u_int maxbits; /* for IP, 32 bit addresses */ int num_active_node; /* for debug purpose */ } patricia_tree_t; EXTERN patricia_node_t *patricia_match_ip(patricia_tree_t *, struct IN_ADDR *); patricia_node_t *patricia_match_string(patricia_tree_t *, const char *); patricia_node_t *patricia_match_exact_string(patricia_tree_t *, const char *); patricia_node_t *patricia_search_exact(patricia_tree_t *, prefix_t *); patricia_node_t *patricia_search_best(patricia_tree_t *, prefix_t *); patricia_node_t *patricia_search_best2(patricia_tree_t *, prefix_t *, int); patricia_node_t *patricia_lookup(patricia_tree_t *, prefix_t *); EXTERN void patricia_remove(patricia_tree_t *, patricia_node_t *); EXTERN patricia_tree_t *patricia_new(int); void patricia_clear(patricia_tree_t *, void_fn_t); EXTERN void patricia_destroy(patricia_tree_t *, void_fn_t); void patricia_process(patricia_tree_t *, void_fn_t); void patricia_init(void); #if 0 prefix_t *ascii2prefix(int family, char *string); #endif patricia_node_t *patricia_make_and_lookup(patricia_tree_t *, const char *); EXTERN patricia_node_t *patricia_make_and_lookup_ip(patricia_tree_t *, struct IN_ADDR *, int); #define PATRICIA_MAXBITS 128 #define PATRICIA_NBIT(x) (0x80 >> ((x) & 0x7f)) #define PATRICIA_NBYTE(x) ((x) >> 3) #define PATRICIA_DATA_GET(node, type) (type *)((node)->data) #define PATRICIA_DATA_SET(node, value) ((node)->data = (void *)(value)) #define PATRICIA_WALK(Xhead, Xnode) \ do { \ patricia_node_t *Xstack[PATRICIA_MAXBITS+1]; \ patricia_node_t **Xsp = Xstack; \ patricia_node_t *Xrn = (Xhead); \ while ((Xnode = Xrn)) { \ if (Xnode->prefix) #define PATRICIA_WALK_ALL(Xhead, Xnode) \ do { \ patricia_node_t *Xstack[PATRICIA_MAXBITS+1]; \ patricia_node_t **Xsp = Xstack; \ patricia_node_t *Xrn = (Xhead); \ while ((Xnode = Xrn)) { \ if (1) #define PATRICIA_WALK_BREAK { \ if (Xsp != Xstack) { \ Xrn = *(--Xsp); \ } else { \ Xrn = (patricia_node_t *) 0; \ } \ continue; } #define PATRICIA_WALK_END \ if (Xrn->l) { \ if (Xrn->r) { \ *Xsp++ = Xrn->r; \ } \ Xrn = Xrn->l; \ } else if (Xrn->r) { \ Xrn = Xrn->r; \ } else if (Xsp != Xstack) { \ Xrn = *(--Xsp); \ } else { \ Xrn = (patricia_node_t *) 0; \ } \ } \ } while (0) #endif /* _PATRICIA_H */ irc2.11.2p3/ircd/ircd.c0000644000175000017500000011113711430560064012345 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/ircd.c * Copyright (C) 1990 Jarkko Oikarinen and * University of Oulu, Computing Center * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: ircd.c,v 1.165 2010/08/11 17:39:00 bif Exp $"; #endif #include "os.h" #include "s_defines.h" #define IRCD_C #include "s_externs.h" #undef IRCD_C aClient me; /* That's me */ aClient *client = &me; /* Pointer to beginning of Client list */ static void open_debugfile(void), setup_signals(void), io_loop(void); #if defined(USE_IAUTH) static RETSIGTYPE s_slave(int s); #endif istat_t istat; iconf_t iconf; char **myargv; int rehashed = 0; int portnum = -1; /* Server port number, listening this */ char *configfile = IRCDCONF_PATH; /* Server configuration file */ int debuglevel = -1; /* Server debug level */ int bootopt = BOOT_PROT|BOOT_STRICTPROT; /* Server boot option flags */ int serverbooting = 1; int firstrejoindone = 0; /* Server rejoined the network after start */ char *debugmode = ""; /* -"- -"- -"- -"- */ char *sbrk0; /* initial sbrk(0) */ char *tunefile = IRCDTUNE_PATH; volatile static int dorehash = 0, dorestart = 0, restart_iauth = 0; #ifdef DELAY_CLOSE time_t nextdelayclose = 0; /* time for next delayed close */ #endif time_t nextconnect = 1; /* time for next try_connections call */ time_t nextgarbage = 1; /* time for next collect_channel_garbage call*/ time_t nextping = 1; /* same as above for check_pings() */ time_t nextdnscheck = 0; /* next time to poll dns to force timeouts */ time_t nextexpire = 1; /* next expire run on the dns cache */ time_t nextiarestart = 1; /* next time to check if iauth is alive */ time_t nextpreference = 1; /* time for next calculate_preference call */ #ifdef TKLINE time_t nexttkexpire = 0; /* time for next tkline_expire call */ #endif aClient *ListenerLL = NULL; /* Listeners linked list */ RETSIGTYPE s_die(int s) { sendto_serv_v(NULL, SV_UID, ":%s SDIE", me.serv->sid); #ifdef USE_SYSLOG (void)syslog(LOG_CRIT, "Server Killed By SIGTERM"); (void)closelog(); #endif logfiles_close(); ircd_writetune(tunefile); flush_connections(me.fd); #ifdef UNIXPORT { aClient *acptr; char unixpath[256]; for (acptr = ListenerLL; acptr; acptr = acptr->next) { if (IsUnixSocket(acptr)) { sprintf(unixpath, "%s/%d", acptr->confs->value.aconf->host, acptr->confs->value.aconf->port); (void)unlink(unixpath); } } } #endif exit(-1); } #if defined(USE_IAUTH) static RETSIGTYPE s_slave(int s) { # if POSIX_SIGNALS struct sigaction act; act.sa_handler = s_slave; act.sa_flags = 0; (void)sigemptyset(&act.sa_mask); (void)sigaddset(&act.sa_mask, SIGUSR1); (void)sigaction(SIGUSR1, &act, NULL); # else (void)signal(SIGUSR1, s_slave); # endif restart_iauth = 1; } #endif static RETSIGTYPE s_rehash(int s) { #if POSIX_SIGNALS struct sigaction act; act.sa_handler = s_rehash; act.sa_flags = 0; (void)sigemptyset(&act.sa_mask); (void)sigaddset(&act.sa_mask, SIGHUP); (void)sigaction(SIGHUP, &act, NULL); #else (void)signal(SIGHUP, s_rehash); /* sysV -argv */ #endif if (dorehash >= 1) dorehash = 2; else dorehash = 1; } void restart(char *mesg) { #ifdef USE_SYSLOG (void)syslog(LOG_WARNING, "Restarting Server because: %s (%u)", mesg, (u_int)((char *)sbrk((size_t)0)-sbrk0)); #endif sendto_flag(SCH_NOTICE, "Restarting server because: %s (%u)", mesg, (u_int)((char *)sbrk((size_t)0)-sbrk0)); server_reboot(); } RETSIGTYPE s_restart(int s) { #if POSIX_SIGNALS struct sigaction act; act.sa_handler = s_restart; act.sa_flags = 0; (void)sigemptyset(&act.sa_mask); (void)sigaddset(&act.sa_mask, SIGINT); (void)sigaction(SIGINT, &act, NULL); #else (void)signal(SIGHUP, SIG_DFL); /* sysV -argv */ #endif if (bootopt & BOOT_TTY) { fprintf(stderr, "Caught SIGINT, terminating...\n"); exit(-1); } dorestart = 1; } void server_reboot(void) { Reg int i; sendto_flag(SCH_NOTICE, "Aieeeee!!! Restarting server... (%u)", (u_int)((char *)sbrk((size_t)0)-sbrk0)); Debug((DEBUG_NOTICE,"Restarting server...")); flush_connections(me.fd); /* ** fd 0 must be 'preserved' if either the -d or -i options have ** been passed to us before restarting. */ #ifdef USE_SYSLOG (void)closelog(); #endif logfiles_close(); for (i = 3; i < MAXCONNECTIONS; i++) (void)close(i); if (!(bootopt & (BOOT_TTY|BOOT_DEBUG))) { (void)close(2); (void)close(1); } if ((bootopt & BOOT_CONSOLE) || isatty(0)) (void)close(0); ircd_writetune(tunefile); if (!(bootopt & BOOT_INETD)) { (void)execv(IRCD_PATH, myargv); #ifdef USE_SYSLOG /* Have to reopen since it has been closed above */ openlog(mybasename(myargv[0]), LOG_PID|LOG_NDELAY, LOG_FACILITY); syslog(LOG_CRIT, "execv(%s,%s) failed: %m\n", IRCD_PATH, myargv[0]); closelog(); #endif Debug((DEBUG_FATAL,"Couldn't restart server: %s", strerror(errno))); } exit(-1); } /* ** try_connections ** ** Scan through configuration and try new connections. ** Returns the calendar time when the next call to this ** function should be made latest. (No harm done if this ** is called earlier or later...) */ static time_t try_connections(time_t currenttime) { Reg aConfItem *aconf; Reg aClient *cptr; aConfItem **pconf; int confrq; time_t next = 0; aClass *cltmp; aConfItem *con_conf = NULL; int allheld = 1; #ifdef DISABLE_DOUBLE_CONNECTS int i; #endif if ((bootopt & BOOT_STANDALONE)) return 0; Debug((DEBUG_NOTICE,"Connection check at : %s", myctime(currenttime))); for (aconf = conf; aconf; aconf = aconf->next ) { /* not a C-line */ if (!(aconf->status & (CONF_CONNECT_SERVER|CONF_ZCONNECT_SERVER))) continue; /* not a candidate for AC */ if (aconf->port <= 0) continue; cltmp = Class(aconf); /* not a candidate for AC */ if (MaxLinks(cltmp) == 0) continue; /* minimize next to lowest hold time of all AC-able C-lines */ if (next > aconf->hold || next == 0) next = aconf->hold; /* skip conf if the use of it is on hold until future. */ if (aconf->hold > currenttime) continue; /* at least one candidate not held for future, good */ allheld = 0; /* see if another link in this conf is allowed */ if (Links(cltmp) >= MaxLinks(cltmp)) continue; /* next possible check after connfreq secs for this C-line */ confrq = get_con_freq(cltmp); aconf->hold = currenttime + confrq; /* is this server already connected? */ cptr = find_name(aconf->name, (aClient *)NULL); if (!cptr) cptr = find_mask(aconf->name, (aClient *)NULL); /* matching client already exists, no AC to it */ if (cptr) continue; /* no such server, check D-lines */ if (find_denied(aconf->name, Class(cltmp))) continue; #ifdef DISABLE_DOUBLE_CONNECTS /* Much better would be traversing only unknown ** connections, but this requires another global ** variable, adding and removing from there in ** proper places etc. Some day. --B. */ for (i = highest_fd; i >= 0; i--) { if (!(cptr = local[i]) || cptr->status > STAT_UNKNOWN) { continue; } /* an unknown traveller we have */ if ( #ifndef INET6 cptr->ip.s_addr == aconf->ipnum.s_addr #else !memcmp(cptr->ip.s6_addr, aconf->ipnum.s6_addr, 16) #endif ) { /* IP the same. Coincidence? Maybe. ** Do not cause havoc with double connect. */ break; } cptr = NULL; } if (cptr) { sendto_flag(SCH_SERVER, "AC to %s postponed", aconf->name); continue; } #endif /* we have a candidate! */ /* choose the best. */ if (!con_conf || (con_conf->pref > aconf->pref && aconf->pref >= 0) || (con_conf->pref == -1 && Class(cltmp) > ConfClass(con_conf))) { con_conf = aconf; } /* above is my doubt: if we always choose best connection ** and it always fails connecting, we may never try another, ** even "worse"; what shall we do? --Beeth */ } if (con_conf) { if (con_conf->next) /* are we already last? */ { for (pconf = &conf; (aconf = *pconf); pconf = &(aconf->next)) /* put the current one at the end and * make sure we try all connections */ if (aconf == con_conf) *pconf = aconf->next; (*pconf = con_conf)->next = 0; } /* "Penalty" for being the best, so in next call of * try_connections() other servers have chance. --B. */ con_conf->hold += get_con_freq(Class(con_conf)); if (iconf.aconnect == 0 || iconf.aconnect == 2 && timeofday - iconf.split > DELAYCHASETIMELIMIT) { sendto_flag(SCH_NOTICE, "Connection to %s deferred. Autoconnect " "administratively disabled", con_conf->name); } else if (connect_server(con_conf, (aClient *)NULL, (struct hostent *)NULL) == 0) { sendto_flag(SCH_NOTICE, "Connection to %s[%s] activated.", con_conf->name, con_conf->host); } } else if (allheld == 0) /* disable AC only when some C: got checked */ { /* No suitable conf for AC was found, so why bother checking ** again? If some server quits, it'd get reenabled --B. */ next = 0; } Debug((DEBUG_NOTICE,"Next connection check : %s", myctime(next))); return (next); } /* * calculate preference value based on accumulated stats. */ time_t calculate_preference(time_t currenttime) { aConfItem *aconf; aCPing *cp; double f, f2; for (aconf = conf; aconf; aconf = aconf->next) { /* not a C-line */ if (!(aconf->status & (CONF_CONNECT_SERVER|CONF_ZCONNECT_SERVER))) continue; /* not a candidate for AC */ if (aconf->port <= 0) continue; /* send (udp) pings for all AC-able C-lines, we'll use it to ** calculate preferences */ send_ping(aconf); if (!(cp = aconf->ping) || !cp->seq || !cp->recvd) { aconf->pref = -1; } else { f = (double)cp->recvd / (double)cp->seq; f2 = pow(f, (double)20.0); if (f2 < (double)0.001) f = (double)0.001; else f = f2; f2 = (double)cp->ping / (double)cp->recvd; f = f2 / f; if (f > 100000.0) f = 100000.0; aconf->pref = (u_int) (f * (double)100.0); } } return currenttime + 60; } /* Checks all clients against KILL lines. (And remove them, if found.) ** Only MAXDELAYEDKILLS at a time or all, if not defined. ** Returns 1, if still work to do, 0 if finished. */ static int delayed_kills(time_t currenttime) { static time_t dk_rehashed = 0; /* time of last rehash we're processing */ static int dk_lastfd; /* fd we last checked */ static int dk_checked; /* # clients we checked */ static int dk_killed; /* # clients we killed */ Reg aClient *cptr; Reg int i, j; if (dk_rehashed == 0) { dk_rehashed = currenttime; dk_checked = 0; dk_killed = 0; dk_lastfd = highest_fd; } #ifdef MAXDELAYEDKILLS /* checking only this many clients each time */ j = dk_lastfd - MAXDELAYEDKILLS + 1; if (j < 0) #endif j = 0; for (i = dk_lastfd; i >= j; i--) { int kflag = 0; char *reason = NULL; if (!(cptr = local[i]) || !IsPerson(cptr)) { /* for K:lines we're interested only in local, ** fully registered clients */ if (j > 0) j--; continue; } dk_checked++; kflag = find_kill(cptr, 0, &reason); /* If the client is a user and a KILL line was found ** to be active, close this connection. */ if (kflag == -1) { char buf[100]; dk_killed++; sendto_flag(SCH_NOTICE, "Kill line active for %s", get_client_name(cptr, FALSE)); cptr->exitc = EXITC_KLINE; if (!BadPtr(reason)) sprintf(buf, "Kill line active: %.80s", reason); (void)exit_client(cptr, cptr, &me, (reason) ? buf : "Kill line active"); } } dk_lastfd = i; /* from which fd to start next time */ Debug((DEBUG_DEBUG, "DelayedKills killed %d and counting...", dk_killed)); if (dk_lastfd < 0) { sendto_flag(SCH_NOTICE, "DelayedKills checked %d killed %d " "in %d sec", dk_checked, dk_killed, currenttime - dk_rehashed); dk_rehashed = 0; if (rehashed == 2) { /* there was rehash queued, start again */ return 1; } return 0; } return rehashed; } static time_t check_pings(time_t currenttime) { #ifdef TIMEDKLINES static time_t lkill = 0; #endif Reg aClient *cptr; Reg int kflag = 0; aClient *bysptr = NULL; int ping = 0, i; time_t oldest = 0, timeout; char *reason = NULL; for (i = highest_fd; i >= 0; i--) { if (!(cptr = local[i]) || IsListener(cptr)) continue; #ifdef TIMEDKLINES kflag = 0; reason = NULL; /* ** Once per TIMEDKLINES seconds. ** (1 minute is minimum resolution in K-line field) */ if ((currenttime - lkill > TIMEDKLINES) && IsPerson(cptr) && !IsKlineExempt(cptr)) { kflag = find_kill(cptr, 1, &reason); } #endif ping = IsRegistered(cptr) ? cptr->ping : ACCEPTTIMEOUT; Debug((DEBUG_DEBUG, "c(%s) %d p %d k %d a %d", cptr->name, cptr->status, ping, kflag, currenttime - cptr->lasttime)); /* * Ok, so goto's are ugly and can be avoided here but this code * is already indented enough so I think its justified. -avalon */ if (!kflag && IsRegistered(cptr) && (ping >= currenttime - cptr->lasttime)) goto ping_timeout; /* * If the server hasnt talked to us in 2*ping seconds * and it has a ping time, then close its connection. * If the client is a user and a KILL line was found * to be active, close this connection too. */ if (kflag || ((currenttime - cptr->lasttime) >= (2 * ping) && (cptr->flags & FLAGS_PINGSENT)) || (!IsRegistered(cptr) && (currenttime - cptr->firsttime) >= ping)) { if (!IsRegistered(cptr) && (DoingDNS(cptr) || DoingAuth(cptr) || DoingXAuth(cptr))) { if (cptr->authfd >= 0) { (void)close(cptr->authfd); cptr->authfd = -1; cptr->count = 0; *cptr->buffer = '\0'; } Debug((DEBUG_NOTICE, "%s/%c%s timeout %s", (DoingDNS(cptr)) ? "DNS" : "dns", (DoingXAuth(cptr)) ? "X" : "x", (DoingAuth(cptr)) ? "AUTH" : "auth", get_client_name(cptr,TRUE))); del_queries((char *)cptr); ClearAuth(cptr); #if defined(USE_IAUTH) if (DoingDNS(cptr) || DoingXAuth(cptr)) { if (DoingDNS(cptr) && (iauth_options & XOPT_EXTWAIT)) { /* iauth wants more time */ sendto_iauth("%d d", cptr->fd); ClearDNS(cptr); cptr->lasttime = currenttime; continue; } if (DoingXAuth(cptr) && (iauth_options & XOPT_NOTIMEOUT)) { cptr->exitc = EXITC_AUTHTOUT; sendto_iauth("%d T", cptr->fd); exit_client(cptr, cptr, &me, "Authentication Timeout"); continue; } sendto_iauth("%d T", cptr->fd); SetDoneXAuth(cptr); } #endif ClearDNS(cptr); ClearXAuth(cptr); ClearWXAuth(cptr); cptr->firsttime = currenttime; cptr->lasttime = currenttime; continue; } if (IsServer(cptr) || IsConnecting(cptr) || IsHandshake(cptr)) { if (cptr->serv && cptr->serv->byuid[0]) { bysptr = find_uid(cptr->serv->byuid, NULL); } /* we are interested only in *remote* opers */ if (bysptr && !MyConnect(bysptr)) { sendto_one(bysptr, ":%s NOTICE %s :" "No response from %s, closing" " link", ME, bysptr->name, get_client_name(cptr, FALSE)); } sendto_flag(SCH_NOTICE, "No response from %s closing link", get_client_name(cptr, FALSE)); } /* * this is used for KILL lines with time restrictions * on them - send a message to the user being killed * first. */ if (kflag && IsPerson(cptr)) { char buf[100]; sendto_flag(SCH_NOTICE, "Kill line active for %s", get_client_name(cptr, FALSE)); cptr->exitc = EXITC_KLINE; if (!BadPtr(reason)) sprintf(buf, "Kill line active: %.80s", reason); (void)exit_client(cptr, cptr, &me, (reason) ? buf : "Kill line active"); } else { cptr->exitc = EXITC_PING; (void)exit_client(cptr, cptr, &me, "Ping timeout"); } continue; } else if (IsRegistered(cptr) && (cptr->flags & FLAGS_PINGSENT) == 0) { /* * if we havent PINGed the connection and we havent * heard from it in a while, PING it to make sure * it is still alive. */ cptr->flags |= FLAGS_PINGSENT; /* not nice but does the job */ cptr->lasttime = currenttime - ping; sendto_one(cptr, "PING :%s", me.name); } ping_timeout: timeout = cptr->lasttime + ping; while (timeout <= currenttime) timeout += ping; if (timeout < oldest || !oldest) oldest = timeout; } #ifdef TIMEDKLINES if (currenttime - lkill > 60) lkill = currenttime; #endif if (!oldest || oldest < currenttime) oldest = currenttime + PINGFREQUENCY; if (oldest < currenttime + 30) oldest += 30; Debug((DEBUG_NOTICE,"Next check_ping() call at: %s, %d %d %d", myctime(oldest), ping, oldest, currenttime)); return (oldest); } static void setup_me(aClient *mp) { struct passwd *p; p = getpwuid(getuid()); strncpyzt(mp->username, (p) ? p->pw_name : "unknown", sizeof(mp->username)); (void)get_my_name(mp, mp->sockhost, sizeof(mp->sockhost)-1); /* I think we need no hostp, especially fake one --B. */ mp->hostp = NULL; if (mp->serv->namebuf[0] == '\0') strncpyzt(mp->serv->namebuf, mp->sockhost, sizeof(mp->serv->namebuf)); if (me.info == DefInfo) me.info = mystrdup("IRCers United"); mp->lasttime = mp->since = mp->firsttime = time(NULL); mp->hopcount = 0; mp->authfd = -1; mp->auth = mp->username; mp->confs = NULL; mp->flags = 0; mp->acpt = mp->from = mp; mp->next = NULL; mp->user = NULL; mp->fd = -1; SetMe(mp); mp->serv->snum = find_server_num (ME); /* we don't fill our own IP -> 0 as ip lenght */ (void) make_user(mp,0); istat.is_users++; /* here, cptr->next is NULL, see make_user() */ mp->user->flags |= FLAGS_OPER; mp->serv->up = mp; mp->serv->maskedby = mp; mp->serv->version |= SV_UID; mp->user->server = find_server_string(mp->serv->snum); strncpyzt(mp->user->username, (p) ? p->pw_name : "unknown", sizeof(mp->user->username)); (void) strcpy(mp->user->host, mp->name); SetEOB(mp); istat.is_eobservers = 1; (void)add_to_client_hash_table(mp->name, mp); (void)add_to_sid_hash_table(mp->serv->sid, mp); strncpyzt(mp->serv->verstr, PATCHLEVEL, sizeof(mp->serv->verstr)); setup_server_channels(mp); } /* ** bad_command ** This is called when the commandline is not acceptable. ** Give error message and exit without starting anything. */ static void bad_command(void) { (void)printf( "Usage: ircd [-a] [-b] [-c]%s [-h servername] [-q] [-i]" "[-T [tunefile]] [-p (strict|on|off)] [-s] [-v] [-t] %s\n", #ifdef CMDLINE_CONFIG " [-f config]", #else "", #endif #ifdef DEBUGMODE " [-x loglevel]" #else "" #endif ); (void)printf("Server not started\n\n"); exit(-1); } int main(int argc, char *argv[]) { uid_t uid, euid; sbrk0 = (char *)sbrk((size_t)0); uid = getuid(); euid = geteuid(); #ifdef CHROOTDIR ircd_res_init(); if (chdir(ROOT_PATH)!=0) { perror("chdir"); (void)fprintf(stderr,"%s: Cannot chdir: %s.\n", IRCD_PATH, ROOT_PATH); exit(5); } if (chroot(ROOT_PATH)!=0) { perror("chroot"); (void)fprintf(stderr,"%s: Cannot chroot: %s.\n", IRCD_PATH, ROOT_PATH); exit(5); } #endif /*CHROOTDIR*/ #ifdef ZIP_LINKS if (zlib_version[0] == '0') { fprintf(stderr, "zlib version 1.0 or higher required\n"); exit(1); } if (zlib_version[0] != ZLIB_VERSION[0]) { fprintf(stderr, "incompatible zlib version\n"); exit(1); } if (strcmp(zlib_version, ZLIB_VERSION) != 0) { fprintf(stderr, "warning: different zlib version\n"); } #endif myargv = argv; (void)umask(077); /* better safe than sorry --SRB */ bzero((char *)&me, sizeof(me)); make_server(&me); register_server(&me); version = make_version(); /* Generate readable version string */ /* ** All command line parameters have the syntax "-fstring" ** or "-f string" (e.g. the space is optional). String may ** be empty. Flag characters cannot be concatenated (like ** "-fxyz"), it would conflict with the form "-fstring". */ while (--argc > 0 && (*++argv)[0] == '-') { char *p = argv[0]+1; int flag = *p++; if (flag == '\0' || *p == '\0') { if (argc > 1 && argv[1][0] != '-') { p = *++argv; argc -= 1; } else { p = ""; } } switch (flag) { case 'a': bootopt |= BOOT_AUTODIE; break; case 'b': bootopt |= BOOT_BADTUNE; break; case 'c': bootopt |= BOOT_CONSOLE; break; case 'q': bootopt |= BOOT_QUICK; break; #ifdef CMDLINE_CONFIG case 'f': (void)setuid((uid_t)uid); configfile = p; break; #endif case 'h': if (*p == '\0') bad_command(); strncpyzt(me.serv->namebuf, p, sizeof(me.serv->namebuf)); break; case 'i': bootopt |= BOOT_INETD|BOOT_AUTODIE; break; case 'p': if (!strcmp(p, "strict")) bootopt |= BOOT_PROT|BOOT_STRICTPROT; else if (!strcmp(p, "on")) bootopt |= BOOT_PROT; else if (!strcmp(p, "off")) bootopt &= ~(BOOT_PROT|BOOT_STRICTPROT); else if (!strcmp(p, "standalone")) bootopt |= BOOT_STANDALONE; else bad_command(); break; case 's': bootopt |= BOOT_NOIAUTH; break; case 't': #ifdef DEBUGMODE (void)setuid((uid_t)uid); #endif bootopt |= BOOT_TTY; break; case 'T': tunefile = p; break; case 'v': (void)printf("ircd %s %s\n\tzlib %s\n\tircd.conf delimiter %c\n\t%s #%s\n", version, serveropts, #ifndef ZIP_LINKS "not used", #else zlib_version, #endif IRCDCONF_DELIMITER, creation, generation); exit(0); case 'x': #ifdef DEBUGMODE (void)setuid((uid_t)uid); debuglevel = atoi(p); debugmode = *p ? p : "0"; bootopt |= BOOT_DEBUG; break; #else (void)fprintf(stderr, "%s: DEBUGMODE must be defined for -x y\n", myargv[0]); exit(0); #endif default: bad_command(); } } if (strlen(tunefile) > 1023 || strlen(mybasename(tunefile)) > 42) { fprintf(stderr, "Too long tune filename\n"); exit(-1); } if (argc > 0) bad_command(); /* This exits out */ #ifndef IRC_UID if ((uid != euid) && !euid) { (void)fprintf(stderr, "ERROR: do not run ircd setuid root. Make it setuid a\ normal user.\n"); exit(-1); } #endif #if !defined(CHROOTDIR) (void)setuid((uid_t)euid); # if defined(IRC_UID) && defined(IRC_GID) if ((int)getuid() == 0) { /* run as a specified user */ (void)fprintf(stderr,"WARNING: running ircd with uid = %d\n", IRC_UID); (void)fprintf(stderr," changing to gid %d.\n",IRC_GID); (void)setgid(IRC_GID); (void)setuid(IRC_UID); } # endif #endif /*CHROOTDIR/UID/GID*/ #if defined(USE_IAUTH) /* At this point, we just check whether iauth is there. Real start * is done in init_sys(). */ if ((bootopt & BOOT_NOIAUTH) == 0) switch (vfork()) { case -1: fprintf(stderr, "%s: Unable to fork!", myargv[0]); exit(-1); case 0: close(0); close(1); close(3); if (execl(IAUTH_PATH, IAUTH, "-X", NULL) < 0) _exit(-1); default: { int rc; (void)wait(&rc); if (rc != 0) { fprintf(stderr, "%s: error: unable to find \"%s\".\n", myargv[0], IAUTH_PATH); exit(-1); } } } #endif setup_signals(); /* didn't set debuglevel */ /* but asked for debugging output to tty */ #ifdef DEBUGMODE if ((debuglevel < 0) && (bootopt & BOOT_TTY)) { (void)fprintf(stderr, "you specified -t without -x. use -x \n"); exit(-1); } #endif timeofday = time(NULL); initanonymous(); initstats(); initruntimeconf(); ircd_readtune(tunefile); motd = NULL; read_motd(IRCDMOTD_PATH); inithashtables(); initlists(); initclass(); initwhowas(); timeofday = time(NULL); open_debugfile(); timeofday = time(NULL); (void)init_sys(); #ifdef USE_SYSLOG openlog(mybasename(myargv[0]), LOG_PID|LOG_NDELAY, LOG_FACILITY); #endif timeofday = time(NULL); if (initconf(bootopt) == -1) { Debug((DEBUG_FATAL, "Couldn't open configuration file %s", configfile)); (void)fprintf(stderr, "Couldn't open configuration file %s (%s)\n", configfile,strerror(errno)); exit(-1); } else { aClient *acptr = NULL; int i; for (i = 0; i <= highest_fd; i++) { if (!(acptr = local[i])) continue; if (IsListener(acptr)) break; acptr = NULL; } /* exit if there is nothing to listen to */ if (acptr == NULL && !(bootopt & BOOT_INETD)) { fprintf(stderr, "Fatal Error: No working P-line in ircd.conf\n"); exit(-1); } /* Is there an M-line? */ if (!find_me()) { fprintf(stderr, "Fatal Error: No M-line in ircd.conf.\n"); exit(-1); } if ((i=check_servername(ME))) { fprintf(stderr, "Fatal Error: %s.\n", check_servername_errors[i-1][1]); exit(-1); } if (!me.serv->sid) { fprintf(stderr, "Fatal Error: No SID specified in ircd.conf\n"); exit(-1); } if (!sid_valid(me.serv->sid)) { fprintf(stderr, "Fatal Error: Invalid sid %s specified in ircd.conf\n", me.serv->sid); exit(-1); } if (!networkname) { fprintf(stderr, "Warning: Network name is not set in ircd.conf\n"); } isupport = make_isupport(); /* Generate RPL_ISUPPORT (005) numerics */ } setup_me(&me); check_class(); ircd_writetune(tunefile); if (bootopt & BOOT_INETD) { aClient *tmp; aConfItem *aconf; tmp = make_client(NULL); make_server(tmp); register_server(tmp); tmp->fd = 0; tmp->flags = FLAGS_LISTEN; tmp->acpt = tmp; tmp->from = tmp; tmp->firsttime = time(NULL); SetMe(tmp); (void)strcpy(tmp->serv->namebuf, "*"); if (inetport(tmp, 0, "0.0.0.0", 0, 1)) tmp->fd = -1; if (tmp->fd == 0) { aconf = make_conf(); aconf->status = CONF_LISTEN_PORT; aconf->clients++; aconf->next = conf; conf = aconf; tmp->confs = make_link(); tmp->confs->next = NULL; tmp->confs->value.aconf = aconf; add_fd(tmp->fd, &fdas); add_fd(tmp->fd, &fdall); set_non_blocking(tmp->fd, tmp); } else exit(5); } Debug((DEBUG_NOTICE,"Server ready...")); #ifdef USE_SYSLOG syslog(LOG_NOTICE, "Server Ready: v%s (%s #%s)", version, creation, generation); #endif printf("Server %s (%s) version %s starting%s%s", ME, me.serv->sid, version, (bootopt & BOOT_TTY) ? " in foreground mode." : ".", #ifdef DEBUGMODE "(DEBUGMODE)\n" #else "\n" #endif ); timeofday = time(NULL); mysrand(timeofday); /* daemonize() closes 0,1,2 -- make sure you don't have any fd open */ daemonize(); logfiles_open(); write_pidfile(); dbuf_init(); serverbooting = 0; while (1) io_loop(); } static void io_loop(void) { static time_t delay = 0; int maxs = 4; if (timeofday >= nextpreference) nextpreference = calculate_preference(timeofday); /* ** We only want to connect if a connection is due, ** not every time through. Note, if there are no ** active C lines, this call to Tryconnections is ** made once only; it will return 0. - avalon */ if (nextconnect && timeofday >= nextconnect) nextconnect = try_connections(timeofday); #ifdef DELAY_CLOSE /* close all overdue delayed fds */ if (nextdelayclose && timeofday >= nextdelayclose) nextdelayclose = delay_close(-1); #endif #ifdef TKLINE /* expire tklines */ if (nexttkexpire && timeofday >= nexttkexpire) nexttkexpire = tkline_expire(0); #endif /* ** Every once in a while, hunt channel structures that ** can be freed. Reop channels while at it, too. */ if (timeofday >= nextgarbage) nextgarbage = collect_channel_garbage(timeofday); /* ** DNS checks. One to timeout queries, one for cache expiries. */ if (timeofday >= nextdnscheck) nextdnscheck = timeout_query_list(timeofday); if (timeofday >= nextexpire) nextexpire = expire_cache(timeofday); /* ** take the smaller of the two 'timed' event times as ** the time of next event (stops us being late :) - avalon ** WARNING - nextconnect can return 0! */ if (nextconnect) delay = MIN(nextping, nextconnect); else delay = nextping; #ifdef DELAY_CLOSE if (nextdelayclose) delay = MIN(nextdelayclose, delay); #endif delay = MIN(nextdnscheck, delay); delay = MIN(nextexpire, delay); delay = MIN(nextpreference, delay); delay -= timeofday; /* ** Adjust delay to something reasonable [ad hoc values] ** (one might think something more clever here... --msa) ** We don't really need to check that often and as long ** as we don't delay too long, everything should be ok. ** waiting too long can cause things to timeout... ** i.e. PINGS -> a disconnection :( ** - avalon */ if (delay < 1) delay = 1; else delay = MIN(delay, TIMESEC); /* ** First, try to drain traffic from servers and listening sockets. ** Give up either if there's no traffic or too many iterations. */ while (maxs--) if (read_message(0, &fdas, 0)) flush_fdary(&fdas); else break; Debug((DEBUG_DEBUG, "delay for %d", delay)); /* ** Second, deal with _all_ clients but only try to empty sendQ's for ** servers. Other clients are dealt with below.. */ if (read_message(1, &fdall, 1) == 0 && delay > 1) { /* ** Timed out (e.g. *NO* traffic at all). ** Try again but also check to empty sendQ's for all clients. */ (void)read_message(delay - 1, &fdall, 0); } timeofday = time(NULL); Debug((DEBUG_DEBUG ,"Got message(s)")); /* ** ...perhaps should not do these loops every time, ** but only if there is some chance of something ** happening (but, note that conf->hold times may ** be changed elsewhere--so precomputed next event ** time might be too far away... (similarly with ** ping times) --msa */ if (timeofday >= nextping) { nextping = check_pings(timeofday); if (rehashed > 0) { rehashed = delayed_kills(timeofday); } } if (dorestart) restart("Caught SIGINT"); if (dorehash > 0) { /* Only on signal, not on oper /rehash */ ircd_writetune(tunefile); (void)rehash(&me, &me, 1); dorehash--; } if (restart_iauth || timeofday >= nextiarestart) { start_iauth(restart_iauth); restart_iauth = 0; nextiarestart = timeofday + 15; } /* ** Flush output buffers on all connections now if they ** have data in them (or at least try to flush) ** -avalon */ flush_connections(me.fd); #ifdef DEBUGMODE checklists(); #endif } /* * open_debugfile * * If the -t option is not given on the command line when the server is * started, all debugging output is sent to the file set by IRCDDBG_PATH. * Here we just open that file and make sure it is opened to fd 2 so that * any fprintf's to stderr also goto the logfile. If the debuglevel is not * set from the command line by -x, use /dev/null as the dummy logfile as long * as DEBUGMODE has been defined, else don't waste the fd. */ static void open_debugfile(void) { #ifdef DEBUGMODE int fd; if (debuglevel >= 0) { (void)printf("isatty = %d ttyname = %#x\n", isatty(2), (u_int)ttyname(2)); if (!(bootopt & BOOT_TTY)) /* leave debugging output on fd 2 */ { (void)truncate(IRCDDBG_PATH, 0); if ((fd = open(IRCDDBG_PATH,O_WRONLY|O_CREAT,0600))<0) if ((fd = open("/dev/null", O_WRONLY)) < 0) exit(-1); if (fd != 2) { (void)dup2(fd, 2); (void)close(fd); } } Debug((DEBUG_FATAL, "Debug: File <%s> Level: %d at %s", ( (!(bootopt & BOOT_TTY)) ? IRCDDBG_PATH : (isatty(2) && ttyname(2)) ? ttyname(2) : "FD2-Pipe"), debuglevel, myctime(time(NULL)))); } #endif return; } static void setup_signals(void) { #if POSIX_SIGNALS struct sigaction act; act.sa_handler = SIG_IGN; act.sa_flags = 0; (void)sigemptyset(&act.sa_mask); (void)sigaddset(&act.sa_mask, SIGPIPE); (void)sigaddset(&act.sa_mask, SIGALRM); # ifdef SIGWINCH (void)sigaddset(&act.sa_mask, SIGWINCH); (void)sigaction(SIGWINCH, &act, NULL); # endif (void)sigaction(SIGPIPE, &act, NULL); act.sa_handler = dummy; (void)sigaction(SIGALRM, &act, NULL); act.sa_handler = s_rehash; (void)sigemptyset(&act.sa_mask); (void)sigaddset(&act.sa_mask, SIGHUP); (void)sigaction(SIGHUP, &act, NULL); act.sa_handler = s_restart; (void)sigaddset(&act.sa_mask, SIGINT); (void)sigaction(SIGINT, &act, NULL); act.sa_handler = s_die; (void)sigaddset(&act.sa_mask, SIGTERM); (void)sigaction(SIGTERM, &act, NULL); # if defined(USE_IAUTH) act.sa_handler = s_slave; # else act.sa_handler = SIG_IGN; # endif (void)sigaddset(&act.sa_mask, SIGUSR1); (void)sigaction(SIGUSR1, &act, NULL); # if defined(USE_IAUTH) act.sa_handler = SIG_IGN; # ifdef SA_NOCLDWAIT act.sa_flags = SA_NOCLDWAIT; # else act.sa_flags = 0; # endif (void)sigaddset(&act.sa_mask, SIGCHLD); (void)sigaction(SIGCHLD, &act, NULL); # endif # if defined(__FreeBSD__) /* Don't core after detaching from gdb on fbsd */ act.sa_handler = SIG_IGN; act.sa_flags = 0; (void)sigaddset(&act.sa_mask, SIGTRAP); (void)sigaction(SIGTRAP,&act,NULL); # endif /* __FreeBSD__ */ #else /* POSIX_SIGNALS */ # ifndef HAVE_RELIABLE_SIGNALS (void)signal(SIGPIPE, dummy); # ifdef SIGWINCH (void)signal(SIGWINCH, dummy); # endif # else /* HAVE_RELIABLE_SIGNALS */ # ifdef SIGWINCH (void)signal(SIGWINCH, SIG_IGN); # endif (void)signal(SIGPIPE, SIG_IGN); # endif /* HAVE_RELIABLE_SIGNALS */ (void)signal(SIGALRM, dummy); (void)signal(SIGHUP, s_rehash); (void)signal(SIGTERM, s_die); (void)signal(SIGINT, s_restart); # if defined(USE_IAUTH) (void)signal(SIGUSR1, s_slave); (void)signal(SIGCHLD, SIG_IGN); # else (void)signal(SIGUSR1, SIG_IGN); # endif # if defined(__FreeBSD__) /* don't core after detaching from gdb on fbsd */ (void)signal(SIGTRAP, SIG_IGN); # endif /* __FreeBSD__ */ #endif /* POSIX_SIGNAL */ #ifdef RESTARTING_SYSTEMCALLS /* ** At least on Apollo sr10.1 it seems continuing system calls ** after signal is the default. The following 'siginterrupt' ** should change that default to interrupting calls. */ (void)siginterrupt(SIGALRM, 1); #endif } /* * Called from bigger_hash_table(), s_die(), server_reboot(), * main(after initializations), grow_history(), rehash(io_loop) signal. */ void ircd_writetune(char *filename) { int fd; char buf[100]; if (!filename || !*filename) return; (void)truncate(filename, 0); if ((fd = open(filename, O_CREAT|O_WRONLY, 0600)) >= 0) { (void)sprintf(buf, "%d\n%d\n%d\n%d\n%d\n%d\n%d\n", ww_size, lk_size, _HASHSIZE, _CHANNELHASHSIZE, _SIDSIZE, poolsize, _UIDSIZE); if (write(fd, buf, strlen(buf)) == -1) sendto_flag(SCH_ERROR, "Failed (%d) to write tune file: %s.", errno, mybasename(filename)); else sendto_flag(SCH_NOTICE, "Updated %s.", mybasename(filename)); close(fd); } else sendto_flag(SCH_ERROR, "Failed (%d) to open tune file: %s.", errno, mybasename(filename)); } /* * Called only from main() at startup. */ void ircd_readtune(char *filename) { int fd, t_data[7]; char buf[100]; memset(buf, 0, sizeof(buf)); if ((fd = open(filename, O_RDONLY)) != -1) { read(fd, buf, 100); /* no panic if this fails.. */ if (sscanf(buf, "%d\n%d\n%d\n%d\n%d\n%d\n%d\n", &t_data[0], &t_data[1], &t_data[2], &t_data[3], &t_data[4], &t_data[5], &t_data[6]) != 7) { close(fd); if (bootopt & BOOT_BADTUNE) return; else { fprintf(stderr, "ircd tune file %s: bad format\n", filename); exit(1); } } /* ** Initiate the tune-values after successfully ** reading the tune-file. */ ww_size = t_data[0]; lk_size = t_data[1]; _HASHSIZE = t_data[2]; #ifdef USE_HOSTHASH _HOSTNAMEHASHSIZE = t_data[2]; /* hostname has always same size as the client hash */ #endif #ifdef USE_IPHASH _IPHASHSIZE = t_data[2]; #endif _CHANNELHASHSIZE = t_data[3]; _SIDSIZE = t_data[4]; poolsize = t_data[5]; _UIDSIZE = t_data[6]; /* ** the lock array only grows if the whowas array grows, ** I don't think it should be initialized with a lower ** size since it will never adjust unless whowas array does. */ if (lk_size < ww_size) lk_size = ww_size; close(fd); } } irc2.11.2p3/ircd/s_numeric_ext.h0000644000175000017500000000235507744057364014317 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/s_numeric_ext.h * Copyright (C) 1997 Alain Nissen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/s_numeric.c. */ /* External definitions for global functions. */ #ifndef S_NUMERIC_C #define EXTERN extern #else /* S_NUMERIC_C */ #define EXTERN #endif /* S_NUMERIC_C */ EXTERN int do_numeric (int numeric, aClient *cptr, aClient *sptr, int parc, char *parv[]); #undef EXTERN irc2.11.2p3/ircd/s_id.c0000644000175000017500000001713410202024057012335 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/s_id.c * Copyright (C) 1998 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: s_id.c,v 1.29 2005/02/08 02:47:11 chopin Exp $"; #endif #include "os.h" #include "s_defines.h" #define S_ID_C #include "s_externs.h" #undef S_ID_C static unsigned char id_alphabet[CHIDNB+1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; static signed int alphabet_id[256] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0 */ 26, /* 1 */ 27, /* 2 */ 28, /* 3 */ 29, /* 4 */ 30, /* 5 */ 31, /* 6 */ 32, /* 7 */ 33, /* 8 */ 34, /* 9 */ 35, -1, -1, -1, -1, -1, -1, -1, /* A */ 0, /* B */ 1, /* C */ 2, /* D */ 3, /* E */ 4, /* F */ 5, /* G */ 6, /* H */ 7, /* I */ 8, /* J */ 9, /* K */ 10, /* L */ 11, /* M */ 12, /* N */ 13, /* O */ 14, /* P */ 15, /* Q */ 16, /* R */ 17, /* S */ 18, /* T */ 19, /* U */ 20, /* V */ 21, /* W */ 22, /* X */ 23, /* Y */ 24, /* Z */ 25, -1, -1, -1, -1, -1, -1, /* a */ 0, /* b */ 1, /* c */ 2, /* d */ 3, /* e */ 4, /* f */ 5, /* g */ 6, /* h */ 7, /* i */ 8, /* j */ 9, /* k */ 10, /* l */ 11, /* m */ 12, /* n */ 13, /* o */ 14, /* p */ 15, /* q */ 16, /* r */ 17, /* s */ 18, /* t */ 19, /* u */ 20, /* v */ 21, /* w */ 22, /* x */ 23, /* y */ 24, /* z */ 25, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; /* ** ltoid(long l, int n) ** base 10 -> base 36 conversion ** Converts l, to a string of n chars, zero ('A') filled. The first chars are ** dropped if it's longer. ** Returns a pointer to a static string, or NULL. */ char *ltoid(long l, int n) { static char idrpl[UIDLEN+1]; /* Currently nothing longer should be used. */ int i = n - 1; if (n > sizeof(idrpl)) { /* This should not happen. */ return NULL; } idrpl[n] = '\0'; do { idrpl[i] = id_alphabet[l % CHIDNB]; l /= CHIDNB; } while (i-- > 0); return (char *) idrpl; } /* ** idtol(char *id, int n) ** base 36 -> base 10 conversion ** Converts the first n char from string id, to a number, and return that. */ long idtol(char *id, int n) { long l = 0; if (!id) { /* Whatever. */ return 0; } while (n-- && *id) { l = l * CHIDNB + alphabet_id[(unsigned char )*id++]; } return l; } /* get_chid: give the current id */ char *get_chid(void) { return ltoid((long)time(NULL), CHIDLEN); } /* close_chid: is the ID in the close future? (written for CHIDLEN == 5) */ int close_chid(char *id) { static time_t last = 0; static char current; char *curid; if (timeofday - last > 900 || id[0] == current) { last = timeofday; curid = get_chid(); current = curid[0]; } if (id_alphabet[1 + alphabet_id[(unsigned char)current]] == id[1]) return 1; if (id[0] == current && idtol(id, CHIDLEN) >= (timeofday % (u_int) pow(CHIDNB, CHIDLEN))) return 1; return 0; } aChannel *idcache = NULL; /* cache_chid: add a channel to the list of cached names */ void cache_chid(aChannel *chptr) { /* ** caching should be limited to the minimum, ** for memory reasons, but most importantly for ** user friendly-ness. ** Is the logic here right, tho? */ if (chptr->history == 0 || (timeofday - chptr->history) >LDELAYCHASETIMELIMIT+DELAYCHASETIMELIMIT) { MyFree(chptr); return; } chptr->nextch = idcache; idcache = chptr; istat.is_cchan++; istat.is_cchanmem += sizeof(aChannel) + strlen(chptr->chname); } /* check_chid: checks if a (short) channel name is in the cache * returns: 0 if not, 1 if yes */ int check_chid(char *name) { aChannel *chptr = idcache; while (chptr) { if (!strcasecmp(name, chptr->chname+1+CHIDLEN)) return 1; chptr = chptr->nextch; } return 0; } /* collect_chid: remove expired entries from the cache */ void collect_chid(void) { aChannel **chptr = &idcache, *del; while (*chptr) { if (close_chid((*chptr)->chname) == 0) { del = *chptr; *chptr = del->nextch; istat.is_cchan--; istat.is_cchanmem -= sizeof(aChannel) +strlen(del->chname); MyFree(del); } else chptr = &((*chptr)->nextch); } } /* ** checks wether the ID is valid ** It checks n chars of name to be a valid char for an ID. ** This skips the first char for now. It's used in !channels, where the first ** char is a '!', and for UID's, where the first char should be a number. ** returns 1 when it's valid, 0 when not. */ int cid_ok(char *name, int n) { int i; for (i = 1; i <= n; i++) { if (alphabet_id[(unsigned char)name[i]] == -1) { return 0; } } return 1; } /* * unique user IDs */ /* ** sid_valid(char *sid) ** ** Check that the sid is a valid sid. The first char should be a number in ** range of [0-9], the rest should be a char in the range of [0-9A-Z]. ** It returns 1 if it's a valid sid, 0 if not. */ int sid_valid(char *sid) { if (isdigit(sid[0]) && strlen(sid) == SIDLEN) { return cid_ok(sid, SIDLEN - 1); } return 0; } #if 0 /* we don't need it */ static char sid[SIDLEN+1]; void init_sid(char *conf) { if (!conf || (strlen(conf) != SIDLEN) || !sid_valid(conf)) { exit(0); /* ick.. -syrk */ } strcpy(sid, conf); } #endif char *next_uid(void) { static char uid[UIDLEN+1+5]; /* why +5? --Beeth */ static long curr_cid = 0; static int needfinduid = 0; do { sprintf(uid, "%s%s", me.serv->sid, ltoid(curr_cid, UIDLEN-SIDLEN)); curr_cid++; #if CHIDNB == 36 && UIDLEN == 9 && SIDLEN == 4 /* MAXCID = CHIDNB ^ (UIDLEN - SIDLEN) */ # define MAXCID 60466176 #else # error Fix MAXCID! #endif if (curr_cid > MAXCID) { /* ** We used all CIDs, restart from 0. ** At a rate of 1 client per second we have 700 days before ** reusing CID. ** Note: after we increase UIDLEN to 12 this uptime would ** have to be almost 90 thousands years! */ curr_cid = 0; needfinduid = 1; } } while (needfinduid && find_uid(uid, NULL) != NULL); return uid; } /* * check_uid * various sanity checks to ensure that a UID is valid. * returns 1 when it's valid, 0 when not. */ int check_uid(char *uid, char *sid) { int retval = 0; if (isdigit(uid[0]) && strlen(uid) == UIDLEN) { retval = cid_ok(uid, UIDLEN - 1); } if (retval == 1) { /* compare SID part of UID with source of message --B. */ retval = (strncasecmp(uid, sid, SIDLEN) == 0); } return retval; } irc2.11.2p3/ircd/s_auth.c0000644000175000017500000005171010731060550012705 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/s_auth.c * Copyright (C) 1992 Darren Reed * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: s_auth.c,v 1.55 2007/12/15 23:21:12 chopin Exp $"; #endif #include "os.h" #include "s_defines.h" #define S_AUTH_C #include "s_externs.h" #undef S_AUTH_C /* * set_clean_username * * As non OTHER type of usernames retrieved via ident lookup are forced as * usernames for the user, one has to be careful not to allow potentially * damaging characters in the username. * This procedure fills up cptr->username based on cptr->auth * Characters disallowed: * leading : for obvious reasons * spaces for obvious reasons * @ because of how get_sockhost() is implemented, * and because it's used from attached_Iline() * [ /trace parsing is impossible */ static void set_clean_username(aClient *cptr) { int i = 0, dirty = 0; char *s; if (cptr->auth == NULL) return; s = cptr->auth; if (index(cptr->auth, '[') || index(cptr->auth, '@') || strlen(cptr->auth) > USERLEN) dirty = 1; else if (cptr->auth[0] == ':') { dirty = 1; s += 1; } else { char *r = cptr->auth; while (*r) if (isspace(*(r++))) break; if (*r) dirty = 1; } if (dirty) cptr->username[i++] = '-'; while (i < USERLEN && *s) { if (*s != '@' && *s != '[' && !isspace(*s)) cptr->username[i++] = *s; s += 1; } cptr->username[i] = '\0'; if (!strcmp(cptr->username, cptr->auth)) { MyFree(cptr->auth); cptr->auth = cptr->username; } else { istat.is_authmem += strlen(cptr->auth) + 1; istat.is_auth += 1; } } #if defined(USE_IAUTH) u_char iauth_options = 0; u_int iauth_spawn = 0; char *iauth_version = NULL; static aExtCf *iauth_conf = NULL; static aExtData *iauth_stats = NULL; /* * sendto_iauth * * Send the buffer to the authentication slave process. * Return 0 if everything went well, -1 otherwise. */ int vsendto_iauth(char *pattern, va_list va) { static char abuf[BUFSIZ], *p; int i, len; if (adfd < 0) { return -1; } vsprintf(abuf, pattern, va); strcat(abuf, "\n"); p = abuf; len = strlen(p); do { i = write(adfd, abuf, len); if ( i == -1 ) { if (errno != EAGAIN && errno != EWOULDBLOCK) { sendto_flag(SCH_AUTH, "Aiiie! lost slave " "authentication process"); close(adfd); adfd = -1; start_iauth(0); return -1; } i = 0; } p += i; len -= i; } while (len > 0); return 0; } int sendto_iauth(char *pattern, ...) { int i; va_list va; va_start(va, pattern); i = vsendto_iauth(pattern, va); va_end(va); return i; } /* * read_iauth * * read and process data from the authentication slave process. */ void read_iauth(void) { static char obuf[READBUF_SIZE+1], last = '?'; static int olen = 0, ia_dbg = 0; char buf[READBUF_SIZE+1], *start, *end, tbuf[BUFSIZ]; aClient *cptr; int i; if (adfd == -1) { olen = 0; return; } while (1) { if (olen) bcopy(obuf, buf, olen); if ((i = recv(adfd, buf+olen, READBUF_SIZE-olen, 0)) <= 0) { if (errno != EAGAIN && errno != EWOULDBLOCK) { sendto_flag(SCH_AUTH, "Aiiie! lost slave authentication process (errno = %d)", errno); close(adfd); adfd = -1; olen = 0; start_iauth(0); } break; } olen += i; buf[olen] = '\0'; start = buf; while ((end = index(start, '\n'))) { *end++ = '\0'; last = *start; if (*start == '>') { sendto_flag(SCH_AUTH, "%s", start+1); start = end; continue; } if (*start == 'G') { ia_dbg = atoi(start+2); if (ia_dbg) sendto_flag(SCH_AUTH,"ia_dbg = %d",ia_dbg); start = end; continue; } if (*start == 'O') /* options */ { iauth_options = 0; if (strchr(start+2, 'A')) iauth_options |= XOPT_EARLYPARSE; if (strchr(start+2, 'R')) iauth_options |= XOPT_REQUIRED; if (strchr(start+2, 'T')) iauth_options |= XOPT_NOTIMEOUT; if (strchr(start+2, 'W')) iauth_options |= XOPT_EXTWAIT; if (iauth_options) sendto_flag(SCH_AUTH, "iauth options: %x", iauth_options); start = end; continue; } if (*start == 'V') /* version */ { if (iauth_version) MyFree(iauth_version); iauth_version = mystrdup(start+2); sendto_flag(SCH_AUTH, "iauth version %s running.", iauth_version); start = end; sendto_iauth("0 M %s", me.name); continue; } if (*start == 'a') { aExtCf *ectmp; while ((ectmp = iauth_conf)) { iauth_conf = iauth_conf->next; MyFree(ectmp->line); MyFree(ectmp); } /* little lie.. ;) */ sendto_flag(SCH_AUTH, "New iauth configuration."); start = end; continue; } if (*start == 'A') { aExtCf **ectmp = &iauth_conf; while (*ectmp) ectmp = &((*ectmp)->next); *ectmp = (aExtCf *) MyMalloc(sizeof(aExtCf)); (*ectmp)->line = mystrdup(start+2); (*ectmp)->next = NULL; start = end; continue; } if (*start == 's') { aExtData *ectmp; while ((ectmp = iauth_stats)) { iauth_stats = iauth_stats->next; MyFree(ectmp->line); MyFree(ectmp); } iauth_stats = (aExtData *) MyMalloc(sizeof(aExtData)); iauth_stats->line = MyMalloc(60); sprintf(iauth_stats->line, "iauth modules statistics (%s)", myctime(timeofday)); iauth_stats->next = (aExtData *) MyMalloc(sizeof(aExtData)); iauth_stats->next->line = MyMalloc(60); sprintf(iauth_stats->next->line, "spawned: %d, current options: %X (%.11s)", iauth_spawn, iauth_options, (iauth_version) ? iauth_version : "???"); iauth_stats->next->next = NULL; start = end; continue; } if (*start == 'S') { aExtData **ectmp = &iauth_stats; while (*ectmp) ectmp = &((*ectmp)->next); *ectmp = (aExtData *) MyMalloc(sizeof(aExtData)); (*ectmp)->line = mystrdup(start+2); (*ectmp)->next = NULL; start = end; continue; } if (*start != 'U' && *start != 'u' && *start != 'o' && *start != 'K' && *start != 'k' && *start != 'D') { sendto_flag(SCH_AUTH, "Garbage from iauth [%s]", start); sendto_iauth("-1 E Garbage [%s]", start); /* ** The above should never happen, but i've seen it ** occasionnally, so let's try to get more info ** about it! -kalt */ sendto_flag(SCH_AUTH, "last=%u start=%x end=%x buf=%x olen=%d i=%d", last, start, end, buf, olen, i); sendto_iauth( "-1 E last=%u start=%x end=%x buf=%x olen=%d i=%d", last, start, end, buf, olen, i); start = end; continue; } if ((cptr = local[i = atoi(start+2)]) == NULL) { /* this is fairly common and can be ignored */ if (ia_dbg) { sendto_flag(SCH_AUTH, "Client %d is gone.", i); sendto_iauth("%d E Gone [%s]", i, start); } start = end; continue; } #ifndef INET6 sprintf(tbuf, "%c %d %s %u ", start[0], i, inetntoa((char *)&cptr->ip), cptr->port); #else sprintf(tbuf, "%c %d %s %u ", start[0], i, inetntop(AF_INET6, (char *)&cptr->ip, ipv6string, sizeof(ipv6string)), cptr->port); #endif if (strncmp(tbuf, start, strlen(tbuf))) { /* this is fairly common and can be ignored */ if (ia_dbg) { sendto_flag(SCH_AUTH, "Client mismatch: %d [%s] != [%s]", i, start, tbuf); sendto_iauth("%d E Mismatch [%s] != [%s]", i, start, tbuf); } start = end; continue; } if (start[0] == 'U') { if (*(start+strlen(tbuf)) == '\0') { sendto_flag(SCH_AUTH, "Null U message! %d [%s]", i, start); sendto_iauth("%d E Null U [%s]", i, start); start = end; continue; } if (cptr->auth != cptr->username) { istat.is_authmem -= strlen(cptr->auth) + 1; istat.is_auth -= 1; MyFree(cptr->auth); } cptr->auth = mystrdup(start+strlen(tbuf)); set_clean_username(cptr); cptr->flags |= FLAGS_GOTID; } else if (start[0] == 'u') { if (*(start+strlen(tbuf)) == '\0') { sendto_flag(SCH_AUTH, "Null u message! %d [%s]", i, start); sendto_iauth("%d E Null u [%s]", i, start); start = end; continue; } if (cptr->auth != cptr->username) { istat.is_authmem -= strlen(cptr->auth) + 1; istat.is_auth -= 1; MyFree(cptr->auth); } cptr->auth = MyMalloc(strlen(start+strlen(tbuf)) + 2); *cptr->auth = '-'; strcpy(cptr->auth+1, start+strlen(tbuf)); set_clean_username(cptr); cptr->flags |= FLAGS_GOTID; } else if (start[0] == 'o') { if (!WaitingXAuth(cptr)) { sendto_flag(SCH_AUTH, "Early o message discarded!"); sendto_iauth("%d E Early o [%s]", i,start); start = end; continue; } if (cptr->user == NULL) { /* just to be safe */ sendto_flag(SCH_AUTH, "Ack! cptr->user is NULL"); start = end; continue; } strncpyzt(cptr->user->username, tbuf, USERLEN+1); } else if (start[0] == 'D') { /*authentication finished*/ ClearXAuth(cptr); SetDoneXAuth(cptr); if (WaitingXAuth(cptr)) { ClearWXAuth(cptr); register_user(cptr, cptr, cptr->name, cptr->user->username); } else ClearWXAuth(cptr); } else { char *reason; /* Copy kill reason received from iauth */ reason = strstr(start, " :"); if (reason && (reason + 2 != '\0')) { if (cptr->reason) { MyFree(cptr->reason); } cptr->reason = mystrdup(reason + 2); } /* ** mark for kill, because it cannot be killed ** yet: we don't even know if this is a server ** or a user connection! */ if (start[0] == 'K') cptr->exitc = EXITC_AREF; else cptr->exitc = EXITC_AREFQ; /* should also check to make sure it's still an unregistered client.. */ /* Finally, working after registration. --B. */ if (IsRegisteredUser(cptr)) { if (cptr->exitc == EXITC_AREF) { sendto_flag(SCH_LOCAL, "Denied after connection " "from %s.", get_client_host(cptr)); } (void) exit_client(cptr, cptr, &me, cptr->reason ? cptr->reason : "Denied access"); } } start = end; } olen -= start - buf; if (olen) memcpy(obuf, start, olen); } } /* * report_iauth_conf * * called from m_stats(), this is the reply to /stats a */ void report_iauth_conf(aClient *sptr, char *to) { aExtCf *ectmp = iauth_conf; if (adfd < 0) return; while (ectmp) { sendto_one(sptr, ":%s %d %s :%s", ME, RPL_STATSIAUTH, to, ectmp->line); ectmp = ectmp->next; } } /* * report_iauth_stats * * called from m_stats(), this is part of the reply to /stats t */ void report_iauth_stats(aClient *sptr, char *to) { aExtData *ectmp = iauth_stats; while (ectmp) { sendto_one(sptr, ":%s %d %s :%s", ME, RPL_STATSDEBUG, to, ectmp->line); ectmp = ectmp->next; } } #endif /* * start_auth * * Flag the client to show that an attempt to contact the ident server on * the client's host. The connect and subsequently the socket are all put * into 'non-blocking' mode. Should the connect or any later phase of the * identifing process fail, it is aborted and the user is given a username * of "unknown". */ void start_auth(aClient *cptr) { #ifndef NO_IDENT struct SOCKADDR_IN us, them; SOCK_LEN_TYPE ulen, tlen; # if defined(USE_IAUTH) if ((iauth_options & XOPT_REQUIRED) && adfd < 0) return; # endif Debug((DEBUG_NOTICE,"start_auth(%x) fd %d status %d", cptr, cptr->fd, cptr->status)); if ((cptr->authfd = socket(AFINET, SOCK_STREAM, 0)) == -1) { # ifdef USE_SYSLOG syslog(LOG_ERR, "Unable to create auth socket for %s:%m", get_client_name(cptr,TRUE)); # endif Debug((DEBUG_ERROR, "Unable to create auth socket for %s:%s", get_client_name(cptr, TRUE), strerror(get_sockerr(cptr)))); ircstp->is_abad++; return; } if (cptr->authfd >= (MAXCONNECTIONS - 2)) { sendto_flag(SCH_ERROR, "Can't allocate fd for auth on %s", get_client_name(cptr, TRUE)); (void)close(cptr->authfd); return; } set_non_blocking(cptr->authfd, cptr); /* get remote host peer - so that we get right interface -- jrg */ tlen = ulen = sizeof(us); if (getpeername(cptr->fd, (struct sockaddr *)&them, &tlen) < 0) { /* we probably don't need this error message -kalt */ report_error("getpeername for auth request %s:%s", cptr); close(cptr->authfd); cptr->authfd = -1; return; } them.SIN_FAMILY = AFINET; /* We must bind the local end to the interface that they connected to: The local system might have more than one network address, and RFC931 check only sends port numbers: server takes IP addresses from query socket -- jrg */ (void)getsockname(cptr->fd, (struct sockaddr *)&us, &ulen); us.SIN_FAMILY = AFINET; # if defined(USE_IAUTH) if (adfd >= 0) { char abuf[BUFSIZ]; # ifdef INET6 sprintf(abuf, "%d C %s %u ", cptr->fd, inetntop(AF_INET6, (char *)&them.sin6_addr, ipv6string, sizeof(ipv6string)), ntohs(them.SIN_PORT)); sprintf(abuf+strlen(abuf), "%s %u", inetntop(AF_INET6, (char *)&us.sin6_addr, ipv6string, sizeof(ipv6string)), ntohs(us.SIN_PORT)); # else sprintf(abuf, "%d C %s %u ", cptr->fd, inetntoa((char *)&them.sin_addr),ntohs(them.SIN_PORT)); sprintf(abuf+strlen(abuf), "%s %u", inetntoa((char *)&us.sin_addr), ntohs(us.SIN_PORT)); # endif if (sendto_iauth(abuf) == 0) { close(cptr->authfd); cptr->authfd = -1; cptr->flags |= FLAGS_XAUTH; return; } } # endif # ifdef INET6 Debug((DEBUG_NOTICE,"auth(%x) from %s %x %x", cptr, inet_ntop(AF_INET6, (char *)&us.sin6_addr, ipv6string, sizeof(ipv6string)), us.sin6_addr.s6_addr[14], us.sin6_addr.s6_addr[15])); # else Debug((DEBUG_NOTICE,"auth(%x) from %s", cptr, inetntoa((char *)&us.sin_addr))); # endif them.SIN_PORT = htons(113); us.SIN_PORT = htons(0); /* bind assigns us a port */ if (bind(cptr->authfd, (struct SOCKADDR *)&us, ulen) >= 0) { (void)getsockname(cptr->fd, (struct SOCKADDR *)&us, &ulen); # ifdef INET6 Debug((DEBUG_NOTICE,"auth(%x) to %s", cptr, inet_ntop(AF_INET6, (char *)&them.sin6_addr, ipv6string, sizeof(ipv6string)))); # else Debug((DEBUG_NOTICE,"auth(%x) to %s", cptr, inetntoa((char *)&them.sin_addr))); # endif (void)alarm((unsigned)4); if (connect(cptr->authfd, (struct SOCKADDR *)&them, tlen) == -1 && errno != EINPROGRESS) { # ifdef INET6 Debug((DEBUG_ERROR, "auth(%x) connect failed to %s - %d", cptr, inet_ntop(AF_INET6, (char *)&them.sin6_addr, ipv6string, sizeof(ipv6string)), errno)); # else Debug((DEBUG_ERROR, "auth(%x) connect failed to %s - %d", cptr, inetntoa((char *)&them.sin_addr), errno)); # endif ircstp->is_abad++; /* * No error report from this... */ (void)alarm((unsigned)0); (void)close(cptr->authfd); cptr->authfd = -1; return; } (void)alarm((unsigned)0); } else { report_error("binding stream socket for auth request %s:%s", cptr); # ifdef INET6 Debug((DEBUG_ERROR,"auth(%x) bind failed on %s port %d - %d", cptr, inet_ntop(AF_INET6, (char *)&us.sin6_addr, ipv6string, sizeof(ipv6string)), ntohs(us.SIN_PORT), errno)); # else Debug((DEBUG_ERROR,"auth(%x) bind failed on %s port %d - %d", cptr, inetntoa((char *)&us.sin_addr), ntohs(us.SIN_PORT), errno)); # endif } cptr->flags |= (FLAGS_WRAUTH|FLAGS_AUTH); if (cptr->authfd > highest_fd) highest_fd = cptr->authfd; #endif return; } /* * send_authports * * Send the ident server a query giving "theirport , ourport". * The write is only attempted *once* so it is deemed to be a fail if the * entire write doesn't write all the data given. This shouldnt be a * problem since the socket should have a write buffer far greater than * this message to store it in should problems arise. -avalon */ void send_authports(aClient *cptr) { struct SOCKADDR_IN us, them; char authbuf[32]; SOCK_LEN_TYPE ulen, tlen; Debug((DEBUG_NOTICE,"write_authports(%x) fd %d authfd %d stat %d", cptr, cptr->fd, cptr->authfd, cptr->status)); tlen = ulen = sizeof(us); if (getsockname(cptr->fd, (struct SOCKADDR *)&us, &ulen) || getpeername(cptr->fd, (struct SOCKADDR *)&them, &tlen)) { #ifdef USE_SYSLOG syslog(LOG_ERR, "auth get{sock,peer}name error for %s:%m", get_client_name(cptr, TRUE)); #endif goto authsenderr; } sprintf(authbuf, "%u , %u\r\n", (unsigned int)ntohs(them.SIN_PORT), (unsigned int)ntohs(us.SIN_PORT)); #ifdef INET6 Debug((DEBUG_SEND, "sending [%s] to auth port %s.113", authbuf, inet_ntop(AF_INET6, (char *)&them.sin6_addr, ipv6string, sizeof(ipv6string)))); #else Debug((DEBUG_SEND, "sending [%s] to auth port %s.113", authbuf, inetntoa((char *)&them.sin_addr))); #endif if (write(cptr->authfd, authbuf, strlen(authbuf)) != strlen(authbuf)) { authsenderr: ircstp->is_abad++; (void)close(cptr->authfd); if (cptr->authfd == highest_fd) while (!local[highest_fd]) highest_fd--; cptr->authfd = -1; cptr->flags &= ~(FLAGS_AUTH|FLAGS_WRAUTH); return; } cptr->flags &= ~FLAGS_WRAUTH; return; } /* * read_authports * * read the reply (if any) from the ident server we connected to. * The actual read processijng here is pretty weak - no handling of the reply * if it is fragmented by IP. */ void read_authports(aClient *cptr) { Reg char *s, *t; Reg int len; char ruser[513], system[8]; u_short remp = 0, locp = 0; *system = *ruser = '\0'; Debug((DEBUG_NOTICE,"read_authports(%x) fd %d authfd %d stat %d", cptr, cptr->fd, cptr->authfd, cptr->status)); /* * Nasty. Can't allow any other reads from client fd while we're * waiting on the authfd to return a full valid string. Use the * client's input buffer to buffer the authd reply. * Oh. this is needed because an authd reply may come back in more * than 1 read! -avalon */ if ((len = read(cptr->authfd, cptr->buffer + cptr->count, sizeof(cptr->buffer) - 1 - cptr->count)) >= 0) { cptr->count += len; cptr->buffer[cptr->count] = '\0'; } if ((len > 0) && (cptr->count != (sizeof(cptr->buffer) - 1)) && (sscanf(cptr->buffer, "%hd , %hd : USERID : %*[^:]: %512s", &remp, &locp, ruser) == 3)) { s = rindex(cptr->buffer, ':'); *s++ = '\0'; for (t = (rindex(cptr->buffer, ':') + 1); *t; t++) if (!isspace(*t)) break; strncpyzt(system, t, sizeof(system)); for (t = ruser; *s && (t < ruser + sizeof(ruser)); s++) if (!isspace(*s) && *s != ':') *t++ = *s; *t = '\0'; Debug((DEBUG_INFO,"auth reply ok [%s] [%s]", system, ruser)); } else if (len != 0) { if (!index(cptr->buffer, '\n') && !index(cptr->buffer, '\r')) return; Debug((DEBUG_ERROR,"local %d remote %d s %x", locp, remp, ruser)); Debug((DEBUG_ERROR,"bad auth reply in [%s]", cptr->buffer)); *ruser = '\0'; } (void)close(cptr->authfd); if (cptr->authfd == highest_fd) while (!local[highest_fd]) highest_fd--; cptr->count = 0; cptr->authfd = -1; ClearAuth(cptr); if (len > 0) Debug((DEBUG_INFO,"ident reply: [%s]", cptr->buffer)); if (!locp || !remp || !*ruser) { ircstp->is_abad++; return; } ircstp->is_asuc++; if (cptr->auth != cptr->username)/*impossible, but...*/ { istat.is_authmem -= strlen(cptr->auth) + 1; istat.is_auth -= 1; MyFree(cptr->auth); } if (!strncmp(system, "OTHER", 5)) { /* OTHER type of identifier */ cptr->auth = MyMalloc(strlen(ruser) + 2); *cptr->auth = '-'; strcpy(cptr->auth+1, ruser); } else cptr->auth = mystrdup(ruser); set_clean_username(cptr); cptr->flags |= FLAGS_GOTID; Debug((DEBUG_INFO, "got username [%s]", ruser)); return; } irc2.11.2p3/ircd/version_ext.h0000644000175000017500000000231307440514507014000 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/version_ext.h * Copyright (C) 1997 Alain Nissen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/version.c. */ /* External definitions for global variables. */ #ifndef VERSION_C extern char *generation; extern char *creation; extern char *version; extern char *pass_version; extern char *infotext[]; extern char **isupport; #endif /* VERSION_C */ irc2.11.2p3/ircd/channel_def.h0000644000175000017500000000210507440513716013661 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/channel_def.h * Copyright (C) 1990 Jarkko Oikarinen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define CREATE 1 /* whether a channel should be created or just tested for existance */ #define MODEBUFLEN 200 #define NullChn ((aChannel *)0) #define ChannelExists(n) (find_channel(n, NullChn) != NullChn) irc2.11.2p3/ircd/s_user_ext.h0000644000175000017500000000625610426176415013625 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/s_user_ext.h * Copyright (C) 1997 Alain Nissen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/s_user.c. */ /* External definitions for global functions. */ #ifndef S_USER_C #define EXTERN extern #else /* S_USER_C */ #define EXTERN #endif /* S_USER_C */ EXTERN aClient *next_client (Reg aClient *next, Reg char *ch); EXTERN int hunt_server (aClient *cptr, aClient *sptr, char *command, int server, int parc, char *parv[]); EXTERN int do_nick_name (char *nick, int server); EXTERN int register_user (aClient *, aClient *, char *, char *); EXTERN char *canonize (char *buffer); EXTERN int m_nick (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_unick (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_private (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_notice (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_who (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_whois (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_user (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_post (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_quit (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_kill (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_away (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_ping (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_pong (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_oper (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_pass (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_userhost (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_ison (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_umode (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN void send_umode (aClient *cptr, aClient *sptr, int old, int sendmask, char *umode_buf); EXTERN void send_umode_out (aClient *cptr, aClient *sptr, int old); EXTERN int m_save (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int is_allowed(aClient *, long); EXTERN char *oline_flags_to_string(long); EXTERN long oline_flags_parse(char *); EXTERN void send_away(aClient *, aClient *); #undef EXTERN irc2.11.2p3/ircd/version.c.SH.in0000644000175000017500000000767111431321766014043 0ustar kkkk#! /bin/sh echo "Building version.c..." if test -r version.c then generation=`sed -n 's/^char \*generation = \"\(.*\)\";/\1/p' < version.c` if test ! "$generation" ; then generation=0; fi else generation=0 fi generation=`expr $generation + 1` sumsserv="`(cd ../ircd; @SUM@ s_serv.c)`" sumsuser="`(cd ../ircd; @SUM@ s_user.c)`" sumchan="`(cd ../ircd; @SUM@ channel.c)`" sumsbsd="`(cd ../ircd; @SUM@ s_bsd.c)`" sumhash="`(cd ../ircd; @SUM@ hash.c)`" sumsmisc="`(cd ../ircd; @SUM@ s_misc.c)`" sumircd="`(cd ../ircd; @SUM@ ircd.c)`" creation=`date | \ awk '{if (NF == 6) \ { print $1 " " $2 " " $3 " " $6 " at " $4 " " $5 } \ else \ { print $1 " " $2 " " $3 " " $7 " at " $4 " " $5 " " $6 }}'` cat >version.c <= 0) && (level <= debuglevel)) { va_list va; va_start(va, form); (void)vsprintf(debugbuf, form, va); va_end(va); (void)fprintf(stderr, "%s\n", debugbuf); } errno = err; } #endif /* DEBUGMODE */ /* * This is part of the STATS replies. There is no offical numeric for this * since this isnt an official command, in much the same way as HASH isnt. * It is also possible that some systems wont support this call or have * different field names for "struct rusage". * -avalon */ void send_usage(aClient *cptr, char *nick) { #if HAVE_GETRUSAGE struct rusage rus; time_t secs, rup; #ifdef hz # define hzz hz #else # ifdef HZ # define hzz HZ # else int hzz = 1; # ifdef HPUX hzz = (int)sysconf(_SC_CLK_TCK); # endif # endif #endif if (getrusage(RUSAGE_SELF, &rus) == -1) { sendto_one(cptr,":%s NOTICE %s :Getruseage error: %s.", me.name, nick, strerror(errno)); return; } secs = rus.ru_utime.tv_sec + rus.ru_stime.tv_sec; rup = timeofday - me.since; if (secs == 0) secs = 1; sendto_one(cptr, ":%s %d %s :CPU Secs %lu:%lu User %lu:%lu System %lu:%lu", me.name, RPL_STATSDEBUG, nick, secs/60, secs%60, rus.ru_utime.tv_sec/60, rus.ru_utime.tv_sec%60, rus.ru_stime.tv_sec/60, rus.ru_stime.tv_sec%60); if (rup && hzz) sendto_one(cptr, ":%s %d %s :RSS %lu ShMem %lu Data %lu Stack %lu", me.name, RPL_STATSDEBUG, nick, rus.ru_maxrss, rus.ru_ixrss / (rup * hzz), rus.ru_idrss / (rup * hzz), rus.ru_isrss / (rup * hzz)); sendto_one(cptr, ":%s %d %s :Swaps %lu Reclaims %lu Faults %lu", me.name, RPL_STATSDEBUG, nick, rus.ru_nswap, rus.ru_minflt, rus.ru_majflt); sendto_one(cptr, ":%s %d %s :Block in %lu out %lu", me.name, RPL_STATSDEBUG, nick, rus.ru_inblock, rus.ru_oublock); sendto_one(cptr, ":%s %d %s :Msg Rcv %lu Send %lu", me.name, RPL_STATSDEBUG, nick, rus.ru_msgrcv, rus.ru_msgsnd); sendto_one(cptr, ":%s %d %s :Signals %lu Context Vol. %lu Invol %lu", me.name, RPL_STATSDEBUG, nick, rus.ru_nsignals, rus.ru_nvcsw, rus.ru_nivcsw); #else /* HAVE_GETRUSAGE */ # if HAVE_TIMES struct tms tmsbuf; time_t secs, mins; int hzz = 1, ticpermin; int umin, smin, usec, ssec; # ifdef HPUX hzz = sysconf(_SC_CLK_TCK); # endif ticpermin = hzz * 60; umin = tmsbuf.tms_utime / ticpermin; usec = (tmsbuf.tms_utime%ticpermin)/(float)hzz; smin = tmsbuf.tms_stime / ticpermin; ssec = (tmsbuf.tms_stime%ticpermin)/(float)hzz; secs = usec + ssec; mins = (secs/60) + umin + smin; secs %= hzz; if (times(&tmsbuf) == -1) { sendto_one(cptr, ":%s %d %s :times(2) error: %s.", me.name, RPL_STATSDEBUG, nick, strerror(errno)); return; } secs = tmsbuf.tms_utime + tmsbuf.tms_stime; sendto_one(cptr, ":%s %d %s :CPU Secs %lu:%lu User %lu:%lu System %lu:%lu", me.name, RPL_STATSDEBUG, nick, mins, secs, umin, usec, smin, ssec); # endif /* HAVE_TIMES */ #endif /* HAVE_GETRUSAGE */ sendto_one(cptr, ":%s %d %s :DBUF alloc %lu blocks %lu", me.name, RPL_STATSDEBUG, nick, istat.is_dbufuse, istat.is_dbufnow); #ifdef DEBUGMODE sendto_one(cptr, ":%s %d %s :Reads %lu Writes %lu", me.name, RPL_STATSDEBUG, nick, readcalls, writecalls); sendto_one(cptr, ":%s %d %s :Writes: <0 %d 0 %d <16 %d <32 %d <64 %d", me.name, RPL_STATSDEBUG, nick, writeb[0], writeb[1], writeb[2], writeb[3], writeb[4]); sendto_one(cptr, ":%s %d %s :<128 %d <256 %d <512 %d <1024 %d >1024 %d", me.name, RPL_STATSDEBUG, nick, writeb[5], writeb[6], writeb[7], writeb[8], writeb[9]); #endif return; } void send_defines(aClient *cptr, char *nick, char *extend) { sendto_one(cptr, ":%s %d %s :HUB:%s MS:%d", ME, RPL_STATSDEFINE, nick, #ifdef HUB "yes", #else "no", #endif MAXSERVERS); sendto_one(cptr, ":%s %d %s :LQ:%d MXC:%d TS:%d HRD:%d HGL:%d WWD:%d ATO:%d", ME, RPL_STATSDEFINE, nick, LISTENQUEUE, MAXCONNECTIONS, TIMESEC, HANGONRETRYDELAY, HANGONGOODLINK, WRITEWAITDELAY, ACCEPTTIMEOUT); sendto_one(cptr, ":%s %d %s :KCTL:%d DCTL:%d LDCTL:%d CF:%d MCPU:%d", ME, RPL_STATSDEFINE, nick, KILLCHASETIMELIMIT, DELAYCHASETIMELIMIT, LDELAYCHASETIMELIMIT, CLIENT_FLOOD, MAXCHANNELSPERUSER); sendto_one(cptr, ":%s %d %s :H:%d N:%d N0:%d D:%d U:%d R:%d T:%d C:%d P:%d K:%d", ME, RPL_STATSDEFINE, nick, HOSTLEN, LOCALNICKLEN, #ifdef MINLOCALNICKLEN MINLOCALNICKLEN, #else 1, #endif UIDLEN, USERLEN, REALLEN, TOPICLEN, CHANNELLEN, PASSWDLEN, KEYLEN); sendto_one(cptr, ":%s %d %s :BS:%d MXR:%d MXB:%d MXBL:%d PY:%d", ME, RPL_STATSDEFINE, nick, BUFSIZE, MAXRECIPIENTS, MAXBANS, MAXBANLENGTH, MAXPENALTY); sendto_one(cptr, ":%s %d %s :ZL:%d CM:%d CP:%d DC:%d", ME, RPL_STATSDEFINE, nick, #ifdef ZIP_LINKS ZIP_LEVEL, #else -1, #endif #ifdef CLONE_CHECK CLONE_MAX, CLONE_PERIOD, #else -1, -1, #endif #ifdef DELAY_CLOSE DELAY_CLOSE #else -1 #endif ); sendto_one(cptr, ":%s %d %s :AC:%d CA:%d S:%d SS:%d/%d/%d SU:%d/%d/%d", ME, RPL_STATSDEFINE, nick, iconf.aconnect, iconf.caccept, iconf.split, SPLIT_SERVERS, iconf.split_minservers, istat.is_eobservers, SPLIT_USERS, iconf.split_minusers, istat.is_user[0] + istat.is_user[1]); #ifdef CLIENTS_CHANNEL sendto_one(cptr, ":%s %d %s :CCL:0x%X", ME, RPL_STATSDEFINE, nick, CLIENTS_CHANNEL_LEVEL); #endif /* note that it's safe to check extend[1], it will at worst be null. ** if we ever need extend[2], check length first... --B. */ if (extend[1] == '5') { char **isup = isupport; while (*isup) { sendto_one(cptr, replies[RPL_ISUPPORT], ME, nick, *isup); isup++; } } } void count_memory(aClient *cptr, char *nick, int debug) { extern aChannel *channel; extern aClass *classes; extern aConfItem *conf; extern int _HASHSIZE, _CHANNELHASHSIZE; Reg aClient *acptr; Reg Link *link; Reg aChannel *chptr; Reg aConfItem *aconf; Reg aClass *cltmp; int lc = 0, d_lc = 0, /* local clients */ ch = 0, d_ch = 0, /* channels */ lcc = 0, d_lcc = 0, /* local client conf links */ rc = 0, d_rc = 0, /* remote clients */ us = 0, d_us = 0, /* user structs */ chu = 0, d_chu = 0, /* channel users */ chi = 0, d_chi = 0, /* channel invites */ chb = 0, d_chb = 0, /* channel bans */ chh = 0, d_chh = 0, /* channel in history */ wwu = 0, d_wwu = 0, /* whowas users */ cl = 0, d_cl = 0, /* classes */ co = 0, d_co = 0; /* conf lines */ int usi = 0, d_usi = 0, /* users invited */ usc = 0, d_usc = 0, /* users in channels */ aw = 0, d_aw = 0, /* aways set */ wwa = 0, d_wwa = 0, /* whowas aways */ wwuw = 0, d_wwuw = 0; /* whowas uwas */ u_long chm = 0, d_chm = 0, /* memory used by channels */ chhm = 0, d_chhm = 0, /* memory used by channel in history */ chbm = 0, d_chbm = 0, /* memory used by channel bans */ lcm = 0, d_lcm = 0, /* memory used by local clients */ rcm = 0, d_rcm = 0, /* memory used by remote clients */ awm = 0, d_awm = 0, /* memory used by aways */ wwam = 0, d_wwam = 0, /* whowas away memory used */ wwm = 0, d_wwm = 0, /* whowas array memory used */ dm = 0, d_dm = 0, /* delay array memory used */ com = 0, d_com = 0, /* memory used by conf lines */ db = 0, d_db = 0, /* memory used by dbufs */ rm = 0, d_rm = 0, /* res memory used */ totcl = 0, d_totcl = 0, totch = 0, d_totch = 0, totww = 0, d_totww = 0, tot = 0, d_tot = 0; time_t start = 0; if (debug) { start = time(NULL); count_whowas_memory(&d_wwu, &d_wwa, &d_wwam, &d_wwuw); d_wwm = sizeof(aName) * ww_size; d_dm = sizeof(aLock) * lk_size; } wwu = istat.is_wwusers; wwa = istat.is_wwaways; wwam = istat.is_wwawaysmem; wwuw = istat.is_wwuwas; wwm = sizeof(aName) * ww_size; dm = sizeof(aLock) * lk_size; /*lc = istat.is_unknown + istat.is_myclnt + istat.is_serv;*/ lc = istat.is_localc; lcc = istat.is_conflink; rc = istat.is_remc; us = istat.is_users; usi = istat.is_useri; usc = istat.is_userc; aw = istat.is_away; awm = istat.is_awaymem; if (debug) { for (acptr = client; acptr; acptr = acptr->next) { if (MyConnect(acptr)) { d_lc++; for (link = acptr->confs; link; link=link->next) { d_lcc++; } } else { d_rc++; } if (acptr->user) { invLink *ilink; d_us++; for (ilink = acptr->user->invited; ilink; ilink = ilink->next) { d_usi++; } d_usc += acptr->user->joined; if (acptr->user->away) { d_aw++; d_awm += (strlen(acptr->user->away)+1); } } } } lcm = lc * CLIENT_LOCAL_SIZE; rcm = rc * CLIENT_REMOTE_SIZE; d_lcm = d_lc * CLIENT_LOCAL_SIZE; d_rcm = d_rc * CLIENT_REMOTE_SIZE; ch = istat.is_chan; chm = istat.is_chanmem; chh = istat.is_hchan; chhm = istat.is_hchanmem; chi = istat.is_invite; chb = istat.is_bans; chbm = istat.is_banmem + chb * sizeof(Link); chu = istat.is_chanusers; if (debug) { for (chptr = channel; chptr; chptr = chptr->nextch) { if (chptr->users == 0) { d_chh++; d_chhm+=strlen(chptr->chname)+sizeof(aChannel); } else { d_ch++; d_chm += (strlen(chptr->chname) + sizeof(aChannel)); } for (link = chptr->members; link; link = link->next) { d_chu++; } for (link = chptr->invites; link; link = link->next) { d_chi++; } for (link = chptr->mlist; link; link = link->next) { d_chb++; d_chbm += strlen(link->value.cp) + 1; } } d_chbm += d_chb * sizeof(Link); } co = istat.is_conf; com = istat.is_confmem; cl = istat.is_class; if (debug) { for (aconf = conf; aconf; aconf = aconf->next) { d_co++; d_com += aconf->host ? strlen(aconf->host)+1 : 0; d_com += aconf->passwd ? strlen(aconf->passwd)+1 : 0; d_com += aconf->name ? strlen(aconf->name)+1 : 0; d_com += aconf->ping ? sizeof(*aconf->ping) : 0; d_com += sizeof(aConfItem); } for (cltmp = classes; cltmp; cltmp = cltmp->next) { d_cl++; } } if (debug) sendto_one(cptr, ":%s %d %s :Request processed in %u seconds", me.name, RPL_STATSDEBUG, nick, time(NULL) - start); sendto_one(cptr, ":%s %d %s :Client Local %d(%lu) Remote %d(%lu) Auth %d(%lu)", me.name, RPL_STATSDEBUG, nick, lc, lcm, rc, rcm, istat.is_auth, istat.is_authmem); if (debug && (lc != d_lc || lcm != d_lcm || rc != d_rc || rcm != d_rcm)) { sendto_one(cptr, ":%s %d %s :Client Local %d(%lu) Remote %d(%lu) [REAL]", me.name, RPL_STATSDEBUG, nick, d_lc, d_lcm, d_rc, d_rcm); } sendto_one(cptr, ":%s %d %s :Users %d in/visible %d/%d(%lu) Invites %d(%lu)", me.name, RPL_STATSDEBUG, nick, us, istat.is_user[1], istat.is_user[0], us*sizeof(anUser), usi, usi*sizeof(Link)); if (debug && (us != d_us || usi != d_usi)) { sendto_one(cptr, ":%s %d %s :Users %d(%lu) Invites %d(%lu) [REAL]", me.name, RPL_STATSDEBUG, nick, d_us, d_us*sizeof(anUser), d_usi, d_usi * sizeof(Link)); } sendto_one(cptr, ":%s %d %s :User channels %d(%lu) Aways %d(%lu)", me.name, RPL_STATSDEBUG, nick, usc, usc*sizeof(Link), aw, awm); if (debug && (usc != d_usc || aw != d_aw || awm != d_awm)) { sendto_one(cptr, ":%s %d %s :User channels %d(%lu) Aways %d(%lu) [REAL]", me.name, RPL_STATSDEBUG, nick, d_usc, d_usc*sizeof(Link), d_aw, d_awm); } sendto_one(cptr, ":%s %d %s :Attached confs %d(%lu)", me.name, RPL_STATSDEBUG, nick, lcc, lcc*sizeof(Link)); if (debug && lcc != d_lcc) { sendto_one(cptr, ":%s %d %s :Attached confs %d(%lu) [REAL]", me.name, RPL_STATSDEBUG, nick, d_lcc, d_lcc*sizeof(Link)); } totcl = lcm + rcm + us*sizeof(anUser) + usc*sizeof(Link) + awm; totcl += lcc*sizeof(Link) + usi*sizeof(Link); d_totcl = d_lcm + d_rcm + d_us*sizeof(anUser) + d_usc*sizeof(Link); d_totcl += d_awm + d_lcc*sizeof(Link) + d_usi*sizeof(Link); sendto_one(cptr, ":%s %d %s :Conflines %d(%lu)", me.name, RPL_STATSDEBUG, nick, co, com); if (debug && (co != d_co || com != d_com)) { sendto_one(cptr, ":%s %d %s :Conflines %d(%lu) [REAL]", me.name, RPL_STATSDEBUG, nick, d_co, d_com); } sendto_one(cptr, ":%s %d %s :Classes %d(%lu)", me.name, RPL_STATSDEBUG, nick, cl, cl*sizeof(aClass)); if (debug && cl != d_cl) { sendto_one(cptr, ":%s %d %s :Classes %d(%lu) [REAL]", me.name, RPL_STATSDEBUG, nick, d_cl, d_cl*sizeof(aClass)); } sendto_one(cptr, ":%s %d %s :Channels %d(%lu) Modes %d(%lu) History %d(%lu) Cache %d(%lu)", me.name, RPL_STATSDEBUG, nick, ch, chm, chb, chbm, chh, chhm, istat.is_cchan, istat.is_cchanmem); if (debug && (ch != d_ch || chm != d_chm || chb != d_chb || chbm != d_chbm || chh != d_chh || chhm != d_chhm)) { sendto_one(cptr, ":%s %d %s :Channels %d(%lu) Modes %d(%lu) History %d(%lu) [REAL]", me.name, RPL_STATSDEBUG, nick, d_ch, d_chm, d_chb, d_chbm, d_chh, d_chhm); } sendto_one(cptr, ":%s %d %s :Channel members %d(%lu) invite %d(%lu)", me.name, RPL_STATSDEBUG, nick, chu, chu*sizeof(Link), chi, chi*sizeof(Link)); if (debug && (chu != d_chu || chi != d_chi)) { sendto_one(cptr, ":%s %d %s :Channel members %d(%lu) invite %d(%lu) " "[REAL]", me.name, RPL_STATSDEBUG, nick, d_chu, d_chu*sizeof(Link), d_chi, d_chi*sizeof(Link)); } totch = chm + chhm + chbm + chu*sizeof(Link) + chi*sizeof(Link); d_totch = d_chm + d_chhm + d_chbm + d_chu*sizeof(Link) + d_chi*sizeof(Link); sendto_one(cptr, ":%s %d %s :Whowas users %d(%lu) away %d(%lu) links %d(%lu)", me.name, RPL_STATSDEBUG, nick, wwu, wwu*sizeof(anUser), wwa, wwam, wwuw, wwuw*sizeof(Link)); if (debug && (wwu != d_wwu || wwa != d_wwa || wwam != d_wwam || wwuw != d_wwuw)) { sendto_one(cptr, ":%s %d %s :Whowas users %d(%lu) away %d(%lu) " "links %d(%lu) [REAL]", me.name, RPL_STATSDEBUG, nick, d_wwu, d_wwu*sizeof(anUser), d_wwa, d_wwam, d_wwuw, d_wwuw*sizeof(Link)); } sendto_one(cptr, ":%s %d %s :Whowas array %d(%lu) Delay array %d(%lu)", me.name, RPL_STATSDEBUG, nick, ww_size, wwm, lk_size, dm); if (debug && (wwm != d_wwm || dm != d_dm)) { sendto_one(cptr, ":%s %d %s :Whowas array %d(%lu) Delay array %d(%lu) " "[REAL]", me.name, RPL_STATSDEBUG, nick, ww_size, d_wwm, lk_size, d_dm); } totww = wwu*sizeof(anUser) + wwam + wwm; d_totww = d_wwu*sizeof(anUser) + d_wwam + d_wwm; sendto_one(cptr, ":%s %d %s :Hash: client %d(%lu) chan %d(%lu)", me.name, RPL_STATSDEBUG, nick, _HASHSIZE, sizeof(aHashEntry) * _HASHSIZE, _CHANNELHASHSIZE, sizeof(aHashEntry) * _CHANNELHASHSIZE); d_db = db = istat.is_dbufnow * sizeof(dbufbuf); db = istat.is_dbufnow * sizeof(dbufbuf); sendto_one(cptr, ":%s %d %s :Dbuf blocks %lu(%lu) (> %lu [%lu]) (%lu < %lu) " "[%lu]", me.name, RPL_STATSDEBUG, nick, istat.is_dbufnow, db, istat.is_dbuf, (u_int) (((u_int)BUFFERPOOL) / ((u_int)sizeof(dbufbuf))), istat.is_dbufuse, istat.is_dbufmax, istat.is_dbufmore); d_rm = rm = cres_mem(cptr, nick); tot = totww + totch + totcl + com + cl*sizeof(aClass) + db + rm; tot += sizeof(aHashEntry) * _HASHSIZE; tot += sizeof(aHashEntry) * _CHANNELHASHSIZE; d_tot = d_totww + d_totch + d_totcl + d_com + d_cl*sizeof(aClass); d_tot += d_db + d_rm; d_tot += sizeof(aHashEntry) * _HASHSIZE; d_tot += sizeof(aHashEntry) * _CHANNELHASHSIZE; sendto_one(cptr, ":%s %d %s :Total: ww %lu ch %lu cl %lu co %lu db %lu", me.name, RPL_STATSDEBUG, nick, totww, totch, totcl, com,db); if (debug && tot != d_tot) { sendto_one(cptr, ":%s %d %s :Total: ww %lu ch %lu cl %lu co %lu " "db %lu [REAL]", me.name, RPL_STATSDEBUG, nick, d_totww, d_totch, d_totcl, d_com, d_db); sendto_one(cptr, ":%s %d %s :TOTAL: %lu [REAL]", me.name, RPL_STATSDEBUG, nick, d_tot); } sendto_one(cptr, ":%s %d %s :TOTAL: %d sbrk(0)-etext: %u", me.name, RPL_STATSDEBUG, nick, tot, (u_long)sbrk((size_t)0)-(u_long)sbrk0); return; } irc2.11.2p3/ircd/list.c0000644000175000017500000003777411157052667012430 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/list.c * Copyright (C) 1990 Jarkko Oikarinen and * University of Oulu, Finland * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: list.c,v 1.47 2009/03/15 01:11:19 chopin Exp $"; #endif #include "os.h" #include "s_defines.h" #define LIST_C #include "s_externs.h" #undef LIST_C char *DefInfo = "*Not On This Net*"; /* constant */ #ifdef DEBUGMODE static struct liststats { int inuse; } cloc, crem, users, servs, links, classs, aconfs; #endif aServer *svrtop = NULL; int numclients = 0; void initlists(void) { #ifdef DEBUGMODE bzero((char *)&cloc, sizeof(cloc)); bzero((char *)&crem, sizeof(crem)); bzero((char *)&users, sizeof(users)); bzero((char *)&servs, sizeof(servs)); bzero((char *)&links, sizeof(links)); bzero((char *)&classs, sizeof(classs)); bzero((char *)&aconfs, sizeof(aconfs)); #endif } void outofmemory(void) { if (serverbooting) { fprintf(stderr,"Fatal Error: Out of memory.\n"); exit(-1); } Debug((DEBUG_FATAL, "Out of memory: restarting server...")); sendto_flag(SCH_NOTICE, "Ouch!!! Out of memory..."); restart("Out of Memory"); } #ifdef DEBUGMODE void checklists() { aServer *sp; for (sp = svrtop; sp; sp = sp->nexts) if (sp->bcptr->serv != sp) Debug((DEBUG_ERROR, "svrtop: %#x->%#x->%#x != %#x", sp, sp->bcptr, sp->bcptr->serv, sp)); } #endif /* ** Create a new aClient structure and set it to initial state. ** ** from == NULL, create local client (a client connected ** to a socket). ** ** from, create remote client (behind a socket ** associated with the client defined by ** 'from'). ('from' is a local client!!). */ aClient *make_client(aClient *from) { Reg aClient *cptr = NULL; Reg unsigned size = CLIENT_REMOTE_SIZE; /* * Check freelists first to see if we can grab a client without * having to call malloc. */ if (!from) size = CLIENT_LOCAL_SIZE; cptr = (aClient *)MyMalloc(size); bzero((char *)cptr, (int)size); #ifdef DEBUGMODE if (size == CLIENT_LOCAL_SIZE) cloc.inuse++; else crem.inuse++; #endif /* Note: structure is zero (calloc) */ cptr->from = from ? from : cptr; /* 'from' of local client is self! */ cptr->next = NULL; /* For machines with NON-ZERO NULL pointers >;) */ cptr->prev = NULL; cptr->hnext = NULL; cptr->user = NULL; cptr->serv = NULL; cptr->name = cptr->namebuf; cptr->status = STAT_UNKNOWN; cptr->fd = -1; (void)strcpy(cptr->username, "unknown"); cptr->info = DefInfo; if (size == CLIENT_LOCAL_SIZE) { cptr->since = cptr->lasttime = cptr->firsttime = timeofday; cptr->confs = NULL; cptr->sockhost[0] = '\0'; cptr->buffer[0] = '\0'; cptr->authfd = -1; cptr->auth = cptr->username; cptr->exitc = EXITC_UNDEF; cptr->receiveB = cptr->sendB = cptr->receiveM = cptr->sendM = 0; #ifdef ZIP_LINKS cptr->zip = NULL; #endif #ifdef XLINE cptr->user2 = NULL; cptr->user3 = NULL; #endif } return (cptr); } void free_client(aClient *cptr) { if (cptr->info != DefInfo) MyFree(cptr->info); /* True only for local clients */ if (cptr->hopcount == 0 || (IsServer(cptr) && cptr->hopcount == 1)) { if (cptr->auth != cptr->username) { sendto_flag(SCH_ERROR, "Please report to ircd-bug@" "irc.org about cptr->auth allocated but not" " free()d!"); istat.is_authmem -= strlen(cptr->auth) + 1; istat.is_auth -= 1; MyFree(cptr->auth); } if (cptr->reason) { MyFree(cptr->reason); } #ifdef XLINE if (cptr->user2) MyFree(cptr->user2); if (cptr->user3) MyFree(cptr->user3); #endif } MyFree(cptr); } /* ** 'make_user' add's an User information block to a client ** if it was not previously allocated. ** iplen is lenght of the IP we want to allocate. */ anUser *make_user(aClient *cptr, int iplen) { Reg anUser *user; user = cptr->user; if (!user) { user = (anUser *)MyMalloc(sizeof(anUser) + iplen); memset(user, 0, sizeof(anUser) + iplen); #ifdef DEBUGMODE users.inuse++; #endif user->away = NULL; user->refcnt = 1; user->joined = 0; user->flags = 0; user->channel = NULL; user->invited = NULL; user->uwas = NULL; cptr->user = user; user->hashv = 0; user->uhnext = NULL; user->uid[0] = '\0'; user->servp = NULL; user->bcptr = cptr; if (cptr->next) /* the only cptr->next == NULL is me */ istat.is_users++; } return user; } aServer *make_server(aClient *cptr) { aServer *serv = cptr->serv; if (!serv) { serv = (aServer *)MyMalloc(sizeof(aServer)); memset(serv, 0, sizeof(aServer)); #ifdef DEBUGMODE servs.inuse++; #endif cptr->serv = serv; cptr->name = serv->namebuf; *serv->namebuf = '\0'; serv->user = NULL; serv->snum = -1; *serv->by = '\0'; serv->up = NULL; serv->refcnt = 1; serv->nexts = NULL; serv->prevs = NULL; serv->bcptr = cptr; serv->lastload = 0; } return cptr->serv; } /* ** free_user ** Decrease user reference count by one and release block, ** if count reaches 0 */ void free_user(anUser *user) { aServer *serv; aClient *cptr = user->bcptr; if (--user->refcnt <= 0) { /* Loop: This would be second deallocation of this structure. * XXX: Remove loop detection before 2.11.0 - jv */ if (user->refcnt == -211001) { sendto_flag(SCH_ERROR, "* %p free_user loop (%s!%s@%s) %p *", (void *)cptr, cptr ? cptr->name : "", user->username, user->host, user); return; } /* * sanity check */ if (user->joined || user->refcnt < 0 || user->invited || user->channel || user->uwas || user->bcptr) { char buf[512]; /*too many arguments for dumpcore() and sendto_flag()*/ sprintf(buf, "%p %p %p %p %d %d %p (%s)", (void *)user, (void *)user->invited, (void *)user->channel, (void *)user->uwas, user->joined, user->refcnt, (void *)user->bcptr, (user->bcptr) ? user->bcptr->name :"none"); #ifdef DEBUGMODE dumpcore("%p user (%s!%s@%s) %s", (void *)cptr, cptr ? cptr->name : "", user->username, user->host, buf); #else sendto_flag(SCH_ERROR, "* %p user (%s!%s@%s) %s *", (void *)cptr, cptr ? cptr->name : "", user->username, user->host, buf); #endif } if ((serv = user->servp)) { user->servp = NULL; /* to avoid some impossible loop */ user->refcnt = -211000; /* For loop detection */ free_server(serv); } if (user->away) { istat.is_away--; istat.is_awaymem -= (strlen(user->away) + 1); MyFree(user->away); } MyFree(user); #ifdef DEBUGMODE users.inuse--; #endif } } void free_server(aServer *serv) { aClient *cptr = serv->bcptr; /* decrement reference counter, and eventually free it */ if (--serv->refcnt <= 0) { if (serv->refcnt == -211001) { /* Loop detected, break it. * XXX: Remove loop detection before 2.11.0 - jv */ sendto_flag(SCH_DEBUG, "* %#x free_server loop %s *", serv, serv->namebuf); return; } /* Decrease (and possibly free) refcnt of the user struct * of who connected this server. */ if (serv->user) { int cnt = serv->refcnt; serv->refcnt = -211000; /* Loop detection */ free_user(serv->user); serv->user = NULL; serv->refcnt = cnt; } if (serv->refcnt < 0 || serv->prevs || serv->nexts || serv->bcptr || serv->user) { char buf[512]; sprintf(buf, "%d %p %p %p %p (%s)", serv->refcnt, (void *)serv->prevs, (void *)serv->nexts, (void *)serv->user, (void *)serv->bcptr, (serv->bcptr) ? serv->bcptr->name : "none"); #ifdef DEBUGMODE dumpcore("%#x server %s %s", cptr, cptr ? cptr->name : "", buf); servs.inuse--; #else sendto_flag(SCH_ERROR, "* %#x server %s %s *", cptr, cptr ? cptr->name : "", buf); #endif } MyFree(serv); } } /* * taken the code from ExitOneClient() for this and placed it here. * - avalon * remove client **AND** _related structures_ from lists, * *free* them too. -krys */ void remove_client_from_list(aClient *cptr) { checklist(); /* is there another way, at this point? */ /* servers directly connected have hopcount=1, but so do their * users, hence the check for IsServer --B. */ if (cptr->hopcount == 0 || (cptr->hopcount == 1 && IsServer(cptr))) istat.is_localc--; else istat.is_remc--; if (cptr->prev) cptr->prev->next = cptr->next; else { client = cptr->next; client->prev = NULL; } if (cptr->next) cptr->next->prev = cptr->prev; if (cptr->user) { istat.is_users--; /* decrement reference counter, and eventually free it */ cptr->user->bcptr = NULL; (void)free_user(cptr->user); } if (cptr->serv) { cptr->serv->bcptr = NULL; free_server(cptr->serv); } if (cptr->service) /* ** has to be removed from the list of aService structures, ** no reference counter for services, thus this part of the ** code can safely be included in free_service() */ free_service(cptr); #ifdef DEBUGMODE if (cptr->fd == -2) cloc.inuse--; else crem.inuse--; #endif (void)free_client(cptr); numclients--; return; } /* * move the client aClient struct before its server's */ void reorder_client_in_list(aClient *cptr) { if (cptr->user == NULL && cptr->service == NULL) return; /* update neighbours */ if (cptr->next) cptr->next->prev = cptr->prev; if (cptr->prev) cptr->prev->next = cptr->next; else client = cptr->next; /* re-insert */ if (cptr->user) { cptr->next = cptr->user->servp->bcptr; cptr->prev = cptr->user->servp->bcptr->prev; #ifdef DEBUGMODE sendto_flag(SCH_DEBUG, "%p [%s] moved before server: %p [%s]", cptr, cptr->name, cptr->user->servp->bcptr, cptr->user->servp->bcptr->name); #endif } else if (cptr->service) { cptr->next = cptr->service->servp->bcptr; cptr->prev = cptr->service->servp->bcptr->prev; } /* update new neighbours */ if (cptr->prev) cptr->prev->next = cptr; else client = cptr; cptr->next->prev = cptr; } /* * although only a small routine, it appears in a number of places * as a collection of a few lines...functions like this *should* be * in this file, shouldnt they ? after all, this is list.c, isnt it ? * -avalon */ void add_client_to_list(aClient *cptr) { /* * since we always insert new clients to the top of the list, * this should mean the "me" is the bottom most item in the list. */ if (cptr->from == cptr) istat.is_localc++; else istat.is_remc++; if (cptr->user) istat.is_users++; cptr->next = client; client = cptr; if (cptr->next) cptr->next->prev = cptr; numclients++; return; } /* * Look for ptr in the linked listed pointed to by link. */ Link *find_user_link(Link *lp, aClient *ptr) { if (ptr) for (; lp; lp = lp->next) if (lp->value.cptr == ptr) return (lp); return NULL; } Link *find_channel_link(Link *lp, aChannel *ptr) { if (ptr) for (; lp; lp = lp->next) if (lp->value.chptr == ptr) return (lp); return NULL; } Link *make_link(void) { Reg Link *lp; lp = (Link *)MyMalloc(sizeof(Link)); #ifdef DEBUGMODE links.inuse++; #endif lp->flags = 0; return lp; } invLink *make_invlink(void) { Reg invLink *lp; lp = (invLink *)MyMalloc(sizeof(invLink)); #ifdef DEBUGMODE links.inuse++; #endif lp->flags = 0; return lp; } void free_link(Link *lp) { MyFree(lp); #ifdef DEBUGMODE links.inuse--; #endif } void free_invlink(invLink *lp) { MyFree(lp); #ifdef DEBUGMODE links.inuse--; #endif } aClass *make_class(void) { Reg aClass *tmp; tmp = (aClass *)MyMalloc(sizeof(aClass)); #ifdef DEBUGMODE classs.inuse++; #endif return tmp; } void free_class(aClass *tmp) { #ifdef ENABLE_CIDR_LIMITS if (tmp->ip_limits) patricia_destroy(tmp->ip_limits, NULL); #endif MyFree(tmp); #ifdef DEBUGMODE classs.inuse--; #endif } aConfItem *make_conf(void) { Reg aConfItem *aconf; aconf = (struct ConfItem *)MyMalloc(sizeof(aConfItem)); #ifdef DEBUGMODE aconfs.inuse++; #endif istat.is_conf++; istat.is_confmem += sizeof(aConfItem); bzero((char *)&aconf->ipnum, sizeof(struct IN_ADDR)); aconf->clients = aconf->port = 0; aconf->next = NULL; aconf->host = aconf->passwd = aconf->name = aconf->name2 = NULL; #ifdef XLINE aconf->name3 = NULL; #endif aconf->ping = NULL; aconf->status = CONF_ILLEGAL; aconf->pref = -1; aconf->hold = time(NULL); aconf->source_ip = NULL; aconf->flags = 0L; Class(aconf) = NULL; return (aconf); } void delist_conf(aConfItem *aconf) { if (aconf == conf) conf = conf->next; else { aConfItem *bconf; for (bconf = conf; aconf != bconf->next; bconf = bconf->next) ; bconf->next = aconf->next; } aconf->next = NULL; } void free_conf(aConfItem *aconf) { del_queries((char *)aconf); istat.is_conf--; istat.is_confmem -= aconf->host ? strlen(aconf->host)+1 : 0; istat.is_confmem -= aconf->passwd ? strlen(aconf->passwd)+1 : 0; istat.is_confmem -= aconf->name ? strlen(aconf->name)+1 : 0; istat.is_confmem -= aconf->name2 ? strlen(aconf->name2)+1 : 0; #ifdef XLINE istat.is_confmem -= aconf->name3 ? strlen(aconf->name3)+1 : 0; #endif istat.is_confmem -= aconf->ping ? sizeof(*aconf->ping) : 0; istat.is_confmem -= aconf->source_ip ? strlen(aconf->source_ip)+1 : 0; istat.is_confmem -= sizeof(aConfItem); MyFree(aconf->host); if (aconf->passwd) bzero(aconf->passwd, strlen(aconf->passwd)); if (aconf->ping) MyFree(aconf->ping); if (aconf->source_ip) MyFree(aconf->source_ip); MyFree(aconf->passwd); MyFree(aconf->name); MyFree(aconf->name2); #ifdef XLINE if (aconf->name3) MyFree(aconf->name3); #endif MyFree(aconf); #ifdef DEBUGMODE aconfs.inuse--; #endif return; } #ifdef DEBUGMODE void send_listinfo(aClient *cptr, char *name) { int inuse = 0, mem = 0, tmp = 0; sendto_one(cptr, ":%s %d %s :Local: inuse: %d(%d)", me.name, RPL_STATSDEBUG, name, inuse += cloc.inuse, tmp = cloc.inuse * CLIENT_LOCAL_SIZE); mem += tmp; sendto_one(cptr, ":%s %d %s :Remote: inuse: %d(%d)", me.name, RPL_STATSDEBUG, name, crem.inuse, tmp = crem.inuse * CLIENT_REMOTE_SIZE); mem += tmp; inuse += crem.inuse; sendto_one(cptr, ":%s %d %s :Users: inuse: %d(%d)", me.name, RPL_STATSDEBUG, name, users.inuse, tmp = users.inuse * sizeof(anUser)); mem += tmp; inuse += users.inuse, sendto_one(cptr, ":%s %d %s :Servs: inuse: %d(%d)", me.name, RPL_STATSDEBUG, name, servs.inuse, tmp = servs.inuse * sizeof(aServer)); mem += tmp; inuse += servs.inuse, sendto_one(cptr, ":%s %d %s :Links: inuse: %d(%d)", me.name, RPL_STATSDEBUG, name, links.inuse, tmp = links.inuse * sizeof(Link)); mem += tmp; inuse += links.inuse, sendto_one(cptr, ":%s %d %s :Classes: inuse: %d(%d)", me.name, RPL_STATSDEBUG, name, classs.inuse, tmp = classs.inuse * sizeof(aClass)); mem += tmp; inuse += classs.inuse, sendto_one(cptr, ":%s %d %s :Confs: inuse: %d(%d)", me.name, RPL_STATSDEBUG, name, aconfs.inuse, tmp = aconfs.inuse * sizeof(aConfItem)); mem += tmp; inuse += aconfs.inuse, sendto_one(cptr, ":%s %d %s :Totals: inuse %d %d", me.name, RPL_STATSDEBUG, name, inuse, mem); } #endif void add_fd(int fd, FdAry *ary) { Debug((DEBUG_DEBUG,"add_fd(%d,%#x)", fd, ary)); if (fd >= 0) ary->fd[++(ary->highest)] = fd; } int del_fd(int fd, FdAry *ary) { int i; Debug((DEBUG_DEBUG,"del_fd(%d,%#x)", fd, ary)); if ((ary->highest == -1) || (fd < 0)) return -1; for (i = 0; i <= ary->highest; i++) if (ary->fd[i] == fd) break; if (i < ary->highest) { ary->fd[i] = ary->fd[ary->highest--]; return 0; } else if (i > ary->highest) return -1; ary->highest--; return 0; } irc2.11.2p3/ircd/s_debug_ext.h0000644000175000017500000000273411022774466013735 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/s_debug_ext.h * Copyright (C) 1997 Alain Nissen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/s_debug.c. */ /* External definitions for global variables. */ #ifndef S_DEBUG_C extern char serveropts[]; #endif /* S_DEBUG_C */ /* External definitions for global functions. */ #ifndef S_DEBUG_C #define EXTERN extern #else /* S_DEBUG_C */ #define EXTERN #endif /* S_DEBUG_C */ EXTERN void debug (int level, char *form, ...); EXTERN void send_usage (aClient *cptr, char *nick); EXTERN void send_defines (aClient *cptr, char *nick, char *); EXTERN void count_memory (aClient *cptr, char *nick, int debug); #undef EXTERN irc2.11.2p3/ircd/res_mkquery_ext.h0000644000175000017500000000250507744057363014675 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/res_mkquery_ext.h * Copyright (C) 1997 Alain Nissen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/res_mkquery.c. */ /* External definitions for global functions. */ #ifndef RES_MKQUERY_C #define EXTERN extern #else /* RES_MKQUERY_C */ #define EXTERN #endif /* RES_MKQUERY_C */ EXTERN int ircd_res_mkquery (int op, const char *dname, int class, int type, const u_char *data, int datalen, const u_char *newrr_in, u_char *buf, int buflen); #undef EXTERN irc2.11.2p3/ircd/s_send.c0000644000175000017500000001755410731140505012704 0ustar kkkk/* * IRC - Internet Relay Chat, ircd/s_send.c * Copyright (C) 1999 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: s_send.c,v 1.11 2007/12/16 06:10:13 chopin Exp $"; #endif #include "os.h" #include "s_defines.h" #define S_SEND_C #include "s_externs.h" #undef S_SEND_C static char oldprefixbuf[512]; /* old style server-server prefix */ static char newprefixbuf[512]; /* new style server-server prefix */ static char prefixbuf[512]; /* server-client prefix */ static char suffixbuf[2048]; /* suffix */ static int oldplen, newplen, plen, slen; /* length of the above buffers */ static int maxplen, lastmax; #define CLEAR_LENGTHS oldplen = newplen = plen = slen = maxplen = lastmax =0; /* ** esend_message ** Wrapper for send_message() that deals with the multiple buffers ** we now have to deal with UIDs. */ static void esend_message(aClient *to) { if (maxplen != lastmax) { if (maxplen + slen > 512) { slen = 510 - maxplen; suffixbuf[slen++] = '\r'; suffixbuf[slen++] = '\n'; suffixbuf[slen] = '0'; } lastmax = maxplen; } if (/*ST_UID*/IsServer(to) && newplen > 0) { send_message(to, newprefixbuf, newplen); if (slen) { send_message(to, suffixbuf, slen); } } else { if (IsServer(to)) { send_message(to, oldprefixbuf, oldplen); } else { send_message(to, prefixbuf, plen); } if (slen) { send_message(to, suffixbuf, slen); } } } /* ** build_old_prefix ** function responsible for filling oldprefixbuf using pre-UID conventions */ static void build_old_prefix(aClient *orig, char *imsg, aClient *dest, char *dname) { if (oldplen != 0) { return; } if (dname == NULL) { dname = dest->name; } oldplen = sprintf(oldprefixbuf, ":%s %s %s", orig->name, imsg, dname); if (oldplen > maxplen) { maxplen = oldplen; } } /* ** build_new_prefix ** function responsible for filling oldprefixbuf with the origin and/or ** destination's UID if they exist. */ static void build_new_prefix(aClient *orig, char *imsg, aClient *dest, char *dname) { char *oname = NULL; if (newplen != 0) { return; } if (IsRegisteredUser(orig) && orig->user->uid[0]) { oname = orig->user->uid; } if (dname == NULL) { if (IsRegisteredUser(dest) && dest->user->uid[0]) { dname = dest->user->uid; } else if (oname) { dname = dest->name; } else { newplen = -1; return; /* no uid anywhere, bail out */ } } newplen = sprintf(newprefixbuf, ":%s %s %s", oname, imsg, dname); if (newplen > maxplen) { maxplen = newplen; } } #if 0 /* seems unused */ /* ** build_prefix ** function responsible for filling prefixbuf */ static void build_prefix(aClient *orig, char *imsg, aClient *dest, char *dname) { char *cp = prefixbuf, *ch; if (plen != 0) { return; } if (dname == NULL) { dname = dest->name; } if (IsPerson(orig)) { *cp++ = ':'; ch = orig->name; while (*ch) *cp++ = *ch++; *cp++ = '!'; ch = orig->user->username; while (*ch) *cp++ = *ch++; *cp++ = '@'; ch = orig->user->host; while (*ch) *cp++ = *ch++; *cp++ = ' '; while (*imsg) *cp++ = *imsg++; *cp++ = ' '; ch = (dname) ? dname : dest->name; while (*ch) *cp++ = *ch++; *cp++ = ' '; *cp = '0'; plen = cp - prefixbuf; } else { if (dname == NULL) { dname = dest->name; } plen = sprintf(prefixbuf, ":%s %s %s", orig->name, imsg, dname); } if (plen > maxplen) { maxplen = plen; } } #endif /* ** build_suffix ** function responsible for filling suffixbuf. */ static void build_suffix(char *format, va_list va) { if (slen) { return; } slen = vsprintf(suffixbuf, format, va); suffixbuf[slen++] = '\r'; suffixbuf[slen++] = '\n'; suffixbuf[slen] = '0'; } /* ** ALL the esendto_*() functions follow about the same parameter order: ** ** origin (remote when applicable) ** destination (remote when applicable, eventually NULL) ** destination name (if not aClient) ** IRC message ** but one (exception to multiple destinations) ** eventual extra delivery related arguments ** ** suffix format ** suffix parameters */ /* ** esendto_one() ** send a message to a single client */ void esendto_one(aClient *orig, aClient *dest, char *imsg, char *fmt, ...) { va_list va; CLEAR_LENGTHS; if (/*ST_UID*/IsServer(dest->from)) { build_new_prefix(orig, imsg, dest, NULL); } if (newplen <= 0) { build_old_prefix(orig, imsg, dest, NULL); } va_start(va, fmt); build_suffix(fmt, va); va_end(va); esend_message(dest->from); } /* ** esendto_serv_butone ** send message to all connected servers except 'one' */ void esendto_serv_butone(aClient *orig, aClient *dest, char *dname, char *imsg, aClient *one, char *fmt, ...) { int i; aClient *acptr; CLEAR_LENGTHS; for (i = fdas.highest; i >= 0; i--) { if ((acptr = local[fdas.fd[i]]) && (!one || acptr != one->from) && !IsMe(acptr)) { if (newplen == 0 && /*ST_UID*/IsServer(acptr)) build_new_prefix(orig, imsg, dest, dname); if (oldplen == 0 && (/*ST_NOTUID*/0 || newplen <= 0)) build_old_prefix(orig, imsg, dest, dname); if (slen == 0) { va_list va; va_start(va, fmt); build_suffix(fmt, va); va_end(va); } esend_message(acptr); } } } /* ** esendto_channel_butone ** send message to all connected servers except 'one' */ void esendto_channel_butone(aClient *orig, char *imsg, aClient *one, aChannel *chptr, char *fmt, ...) { Link *lp; aClient *acptr; CLEAR_LENGTHS; for (lp = chptr->clist; lp; lp = lp->next) { acptr = lp->value.cptr; if (acptr->from == one || IsMe(acptr)) { continue; /* ...was the one I should skip */ } if (acptr == orig) { continue; } if (MyConnect(acptr) && IsRegisteredUser(acptr)) { /* to local users */ if (plen == 0) { plen = sprintf(prefixbuf, ":anonymous!anonymous@" "anonymous. %s %s", imsg, chptr->chname); } } else { /* to servers */ if (newplen == 0 && /*ST_UID*/IsServer(acptr)) { build_new_prefix(orig, imsg, NULL, chptr->chname); } if (oldplen == 0 && (/*ST_NOTUID*/0 || newplen <= 0)) { build_old_prefix(orig, imsg, NULL, chptr->chname); } } if (slen == 0) { va_list va; va_start(va, fmt); build_suffix(fmt, va); va_end(va); } esend_message(acptr); } } /* ** sendto_match_servs ** send to all servers which match the mask at the end of a channel name ** (if there is a mask present) or to all if no mask. */ void esendto_match_servs(aClient *orig, char *imsg, aChannel *chptr, char *fmt, ...) { int i; aClient *cptr; char *mask; CLEAR_LENGTHS; if (chptr) { if (*chptr->chname == '&') { return; } if ((mask = get_channelmask(chptr->chname))) { mask++; } } else { mask = NULL; } for (i = fdas.highest; i >= 0; i--) { if (!(cptr = local[fdas.fd[i]]) || (cptr == orig) || IsMe(cptr)) { continue; } if (!BadPtr(mask) && match(mask, cptr->name)) { continue; } if (newplen == 0 && /*ST_UID*/IsServer(cptr)) { build_new_prefix(orig, imsg, NULL, chptr->chname); } if (oldplen == 0 && (/*ST_NOTUID*/0 || newplen <= 0)) { build_old_prefix(orig, imsg, NULL, chptr->chname); } if (slen == 0) { va_list va; va_start(va, fmt); build_suffix(fmt, va); va_end(va); } esend_message(cptr); } } irc2.11.2p3/ircd/res_def.h0000644000175000017500000000314011030036010013013 0ustar kkkk/* * $Id: res_def.h,v 1.7 2008/06/24 00:12:56 chopin Exp $ * * ircd/res_def.h (C)opyright 1992 Darren Reed. */ #define RES_INITLIST 1 #define RES_CALLINIT 2 #define RES_INITSOCK 4 #define RES_INITDEBG 8 #define RES_INITCACH 16 #define MAXPACKET 1024 #define MAXALIASES 35 #define MAXADDRS 35 #define AR_TTL 600 /* TTL in seconds for dns cache entries */ #define FLG_A_VALID 1 #ifdef INET6 #define FLG_AAAA_VALID 2 #endif #define FLG_PTR_PEND_FWD 4 #define FLG_PTR_PEND_REV 8 #define FLG_PTR_PEND (FLG_PTR_PEND_FWD|FLG_PTR_PEND_REV) #define FLG_PTR_VALID 16 struct hent { char *h_name; /* official name of host */ char *h_aliases[MAXALIASES]; /* alias list */ int h_addrtype; /* host address type */ int h_length; /* length of address */ /* list of addresses from name server */ struct IN_ADDR h_addr_list[MAXADDRS]; #define h_addr h_addr_list[0] /* address, for backward compatiblity */ }; typedef struct reslist { int id; int sent; /* number of requests sent */ int srch; 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 reslist *next; Link cinfo; struct hent he; } ResRQ; typedef struct cache { time_t expireat; time_t ttl; int flags; struct hostent he; struct cache *hname_next, *hnum_next, *list_next; } aCache; typedef struct cachetable { aCache *num_list; aCache *name_list; } CacheTable; /* must be a prime */ #define ARES_CACSIZE 1009 /* should be around twice smaller */ #define MAXCACHED 512 irc2.11.2p3/ircd/s_send_ext.h0000644000175000017500000000305006771274266013600 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, common/send_ext.h * Copyright (C) 1999 Christophe Kalt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/s_send.c. */ /* External definitions for global functions. */ #ifndef S_SEND_C #define EXTERN extern #else /* S_SEND_C */ #define EXTERN #endif /* S_SEND_C */ EXTERN void esendto_one(aClient *orig, aClient *dest, char *imsg, char *fmt, ...); EXTERN void esendto_serv_butone(aClient *orig, aClient *dest, char *dname, char *imsg, aClient *one, char *fmt, ...); EXTERN void esendto_channel_butone(aClient *orig, char *imsg, aClient *one, aChannel *chptr, char *fmt, ...); EXTERN void esendto_match_servs(aClient *orig, char *imsg, aChannel *chptr, char *fmt, ...); #undef EXTERN irc2.11.2p3/ircd/s_zip_ext.h0000644000175000017500000000261007744057365013452 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/s_zip_ext.h * Copyright (C) 1997 Alain Nissen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/s_zip.c. */ /* External definitions for global functions. */ #ifndef S_ZIP_C #define EXTERN extern #else /* S_ZIP_C */ #define EXTERN #endif /* S_ZIP_C */ #ifdef ZIP_LINKS EXTERN int zip_init (aClient *cptr); EXTERN void zip_free (aClient *cptr); EXTERN char *unzip_packet (aClient *cptr, char *buffer, int *length); EXTERN char *zip_buffer (aClient *cptr, char *buffer, int *length, int flush); #endif /* ZIP_LINKS */ #undef EXTERN irc2.11.2p3/ircd/s_bsd.c0000644000175000017500000025324411431321766012531 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/s_bsd.c * Copyright (C) 1990 Jarkko Oikarinen and * University of Oulu, Computing Center * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* -- Jto -- 07 Jul 1990 * Added jlp@hamblin.byu.edu's debugtty fix */ /* -- Armin -- Jun 18 1990 * Added setdtablesize() for more socket connections * (sequent OS Dynix only) -- maybe select()-call must be changed ... */ /* -- Jto -- 13 May 1990 * Added several fixes from msa: * Better error messages * Changes in check_access * Added SO_REUSEADDR fix from zessel@informatik.uni-kl.de */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: s_bsd.c,v 1.187 2010/08/13 19:58:46 bif Exp $"; #endif #include "os.h" #include "s_defines.h" #define S_BSD_C #include "s_externs.h" #undef S_BSD_C #ifndef IN_LOOPBACKNET #define IN_LOOPBACKNET 0x7f #endif aClient *local[MAXCONNECTIONS]; FdAry fdas, fdall; int highest_fd = 0, readcalls = 0, udpfd = -1, resfd = -1, adfd = -1; time_t timeofday; static struct SOCKADDR_IN mysk; static void polludp(void); static struct SOCKADDR *connect_inet (aConfItem *, aClient *, int *); static int completed_connection (aClient *); static int check_init (aClient *, char *); static int check_ping (char *, int); static void do_dns_async (void); static int set_sock_opts (int, aClient *); #ifdef UNIXPORT static struct SOCKADDR *connect_unix (aConfItem *, aClient *, int *); static aClient *add_unixconnection (aClient *, int); static char unixpath[256]; #endif static char readbuf[READBUF_SIZE]; #define CFLAG (CONF_CONNECT_SERVER|CONF_ZCONNECT_SERVER) #define NFLAG CONF_NOCONNECT_SERVER /* * Try and find the correct name to use with getrlimit() for setting the max. * number of files allowed to be open by this process. */ #ifdef RLIMIT_FDMAX # define RLIMIT_FD_MAX RLIMIT_FDMAX #else # ifdef RLIMIT_NOFILE # define RLIMIT_FD_MAX RLIMIT_NOFILE # else # ifdef RLIMIT_OPEN_MAX # define RLIMIT_FD_MAX RLIMIT_OPEN_MAX # else # undef RLIMIT_FD_MAX # endif # endif #endif /* ** add_local_domain() ** Add the domain to hostname, if it is missing ** (as suggested by eps@TOASTER.SFSU.EDU) ** Note: size is the max we can append to hname! */ void add_local_domain(char *hname, size_t size) { #ifdef RES_INIT /* some return plain hostname with ending dot, whoops. */ if (hname[strlen(hname)-1] == '.') { hname[strlen(hname)-1] = '\0'; size++; } /* try to fix up unqualified names */ if (!index(hname, '.')) { if (!(ircd_res.options & RES_INIT)) { Debug((DEBUG_DNS,"ircd_res_init()")); ircd_res_init(); } /* Enough space in hname to append defdname? */ /* "2" is dot and ending \0 */ if (ircd_res.defdname[0] && strlen(ircd_res.defdname) + 2 <= size) { /* no need for strncat with above check */ (void)strcat(hname, "."); (void)strcat(hname, ircd_res.defdname); } } #endif return; } /* ** Cannot use perror() within daemon. stderr is closed in ** ircd and cannot be used. And, worse yet, it might have ** been reassigned to a normal connection... */ /* ** report_error ** This a replacement for perror(). Record error to log and ** also send a copy to all *LOCAL* opers online. ** ** text is a *format* string for outputting error. It must ** contain only two '%s', the first will be replaced ** by the sockhost from the cptr, and the latter will ** by strerror(errno). ** ** cptr if not NULL, is the *LOCAL* client associated with ** the error. */ void report_error(char *text, aClient *cptr) { Reg int errtmp = errno; /* debug may change 'errno' */ Reg char *host; int err; SOCK_LEN_TYPE len = sizeof(err); char fmbuf[BUFSIZE+1]; aClient *bysptr = NULL; extern char *strerror(int); host = (cptr) ? get_client_name(cptr, FALSE) : ""; Debug((DEBUG_ERROR, text, host, strerror(errtmp))); /* * Get the *real* error from the socket (well try to anyway..). * This may only work when SO_DEBUG is enabled but its worth the * gamble anyway. */ #ifdef SO_ERROR if (cptr && !IsMe(cptr) && cptr->fd >= 0) if (!GETSOCKOPT(cptr->fd, SOL_SOCKET, SO_ERROR, &err, &len)) if (err) errtmp = err; #endif sendto_flag(SCH_ERROR, text, host, strerror(errtmp)); if (cptr && (IsConnecting(cptr) || IsHandshake(cptr)) && cptr->serv && cptr->serv->byuid[0]) { bysptr = find_uid(cptr->serv->byuid, NULL); if (bysptr && !MyConnect(bysptr)) { fmbuf[0] = '\0'; strcpy(fmbuf, ":%s NOTICE %s :"); strncat(fmbuf, text, BUFSIZE-strlen(fmbuf)); sendto_one(bysptr, fmbuf, ME, bysptr->name, host, strerror(errtmp)); } } #ifdef USE_SYSLOG syslog(LOG_WARNING, text, host, strerror(errtmp)); #endif if (serverbooting) { fprintf(stderr,text,host,strerror(errtmp)); fprintf(stderr,"\n"); } return; } /* * inetport * * Create a socket in the AF_INET domain, bind it to the port given in * 'port' and listen to it. If 'ip' has a value, use it as vif to listen. * Connections are accepted to this socket depending on the IP# mask given * by 'ipmask'. Returns the fd of the socket created or -1 on error. */ int inetport(aClient *cptr, char *ip, char *ipmask, int port, int dolisten) { static struct SOCKADDR_IN server; int ad[4]; SOCK_LEN_TYPE len = sizeof(server); char ipname[20]; /* broken config? why allow such broken line to live? ** XXX: fix initconf()? --B. */ if (!ipmask) { sendto_flag(SCH_ERROR, "Invalid P-line"); return -1; } ad[0] = ad[1] = ad[2] = ad[3] = 0; /* * do it this way because building ip# from separate values for each * byte requires endian knowledge or some nasty messing. Also means * easy conversion of "*" to 0.0.0.0 or 134.* to 134.0.0.0 :-) */ (void)sscanf(ipmask, "%d.%d.%d.%d", &ad[0], &ad[1], &ad[2], &ad[3]); if (ad[0]>>8 || ad[1]>>8 || ad[2]>>8 || ad[3]>>8) { sendto_flag(SCH_ERROR, "Invalid ipmask %s", ipmask); return -1; } (void)sprintf(ipname, "%d.%d.%d.%d", ad[0], ad[1], ad[2], ad[3]); (void)sprintf(cptr->sockhost, "%-.42s.%u", ip ? ip : ME, (unsigned int)port); DupString(cptr->auth, ipname); /* * At first, open a new socket */ if (cptr->fd == -1) cptr->fd = socket(AFINET, SOCK_STREAM, 0); if (cptr->fd < 0) { report_error("opening stream socket %s:%s", cptr); return -1; } else if (cptr->fd >= MAXCLIENTS) { sendto_flag(SCH_ERROR, "No more connections allowed (%s)", cptr->name); (void)close(cptr->fd); return -1; } (void)set_sock_opts(cptr->fd, cptr); #if defined (__CYGWIN32__) /* Can anyone explain why setting nonblock here works and does not ** in add_listener after we return from inetport()? --B. */ (void)set_non_blocking(cptr->fd, cptr); #endif /* * Bind a port to listen for new connections if port is non-null, * else assume it is already open and try get something from it. */ if (port) { server.SIN_FAMILY = AFINET; #ifdef INET6 if (!ip || (!isxdigit(*ip) && *ip != ':')) server.sin6_addr = in6addr_any; else if(!inetpton(AF_INET6, ip, server.sin6_addr.s6_addr)) bcopy(minus_one, server.sin6_addr.s6_addr, IN6ADDRSZ); #else if (!ip || !isdigit(*ip)) server.sin_addr.s_addr = INADDR_ANY; else server.sin_addr.s_addr = inetaddr(ip); #endif server.SIN_PORT = htons(port); /* * Try 10 times to bind the socket with an interval of 20 * seconds. Do this so we don't have to keep trying manually * to bind. Why ? Because a port that has closed often lingers * around for a short time. * This used to be the case. Now it no longer is. * Could cause the server to hang for too long - avalon */ if (bind(cptr->fd, (SAP)&server, sizeof(server)) == -1) { report_error("binding stream socket %s:%s", cptr); (void)close(cptr->fd); return -1; } } if (getsockname(cptr->fd, (struct SOCKADDR *)&server, &len)) { report_error("getsockname failed for %s:%s",cptr); (void)close(cptr->fd); return -1; } if (cptr == &me) /* KLUDGE to get it work... */ { char buf[1024]; (void)sprintf(buf, replies[RPL_MYPORTIS], ME, "*", ntohs(server.SIN_PORT)); (void)write(0, buf, strlen(buf)); } if (cptr->fd > highest_fd) highest_fd = cptr->fd; #ifdef INET6 bcopy(server.sin6_addr.s6_addr, cptr->ip.s6_addr, IN6ADDRSZ); #else cptr->ip.s_addr = server.sin_addr.s_addr; /* broken on linux at least*/ #endif cptr->port = port; local[cptr->fd] = cptr; if (dolisten) { listen(cptr->fd, LISTENQUEUE); } return 0; } /* * add_listener * * Create a new client which is essentially the stub like 'me' to be used * for a socket that is passive (listen'ing for connections to be accepted). */ int add_listener(aConfItem *aconf) { aClient *cptr; cptr = make_client(NULL); cptr->flags = FLAGS_LISTEN; cptr->acpt = cptr; cptr->from = cptr; cptr->firsttime = time(NULL); cptr->name = ME; SetMe(cptr); cptr->confs = make_link(); cptr->confs->next = NULL; cptr->confs->value.aconf = aconf; open_listener(cptr); /* Add to linked list */ if (ListenerLL) { ListenerLL->prev = cptr; } cptr->next = ListenerLL; cptr->prev = NULL; ListenerLL = cptr; return 0; } #ifdef UNIXPORT /* * unixport * * Create a socket and bind it to a filename which is comprised of the path * (directory where file is placed) and port (actual filename created). * Set directory permissions as rwxr-xr-x so other users can connect to the * file which is 'forced' to rwxrwxrwx (different OS's have different need of * modes so users can connect to the socket). */ int unixport(aClient *cptr, char *path, int port) { struct sockaddr_un un; struct stat buf; if ((cptr->fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { report_error("error opening unix domain socket %s:%s", cptr); return -1; } else if (cptr->fd >= MAXCLIENTS) { sendto_flag(SCH_ERROR, "No more connections allowed (%s)", path); (void)close(cptr->fd); return -1; } un.sun_family = AF_UNIX; (void)mkdir(path, 0755); sprintf(unixpath, "%s/%d", path, port); get_sockhost(cptr, unixpath); if (stat(unixpath, &buf)==0) { report_error("unix domain socket %s:%s", cptr); (void)close(cptr->fd); return -1; } strncpyzt(un.sun_path, unixpath, sizeof(un.sun_path)); errno = 0; if (bind(cptr->fd, (SAP)&un, strlen(unixpath)+2) == -1) { report_error("error binding unix socket %s:%s", cptr); (void)close(cptr->fd); return -1; } if (cptr->fd > highest_fd) highest_fd = cptr->fd; (void)listen(cptr->fd, LISTENQUEUE); (void)chmod(path, 0755); (void)chmod(unixpath, 0777); SetUnixSock(cptr); cptr->port = 0; local[cptr->fd] = cptr; return 0; } #endif /* * close_listeners * * Close and free all clients which are marked as having their socket open * and in a state where they can accept connections. Unix sockets have * the path to the socket unlinked for cleanliness. */ void close_listeners(void) { aClient *acptr, *bcptr; aConfItem *aconf; /* * close all 'extra' listening ports we have and unlink the file * name if it was a unix socket. */ for (acptr = ListenerLL; acptr; acptr = bcptr) { aconf = acptr->confs->value.aconf; bcptr = acptr->next; /* might get deleted by close_connection */ if (IsIllegal(aconf)) { #ifdef UNIXPORT if (IsUnixSocket(acptr)) { sprintf(unixpath, "%s/%d", aconf->host, aconf->port); (void)unlink(unixpath); } #endif if (aconf->clients > 0) { close_client_fd(acptr); } else { close_connection(acptr); } } } } /* Opens listening socket on given listener */ void open_listener(aClient *cptr) { aConfItem *aconf; int dolisten = 1; aconf = cptr->confs->value.aconf; if (!IsListener(cptr) || cptr->fd > 0) { return; } #ifdef UNIXPORT if (*aconf->host == '/') { if (unixport(cptr, aconf->host, aconf->port)) { cptr->fd = -1; } } else #endif { if (IsConfDelayed(aconf) && !firstrejoindone) { dolisten = 0; SetListenerInactive(cptr); } if (inetport(cptr, aconf->host, aconf->name, aconf->port, dolisten)) { /* to allow further inetport calls */ cptr->fd = -1; } } if (cptr->fd >= 0) { add_fd(cptr->fd, &fdas); add_fd(cptr->fd, &fdall); set_non_blocking(cptr->fd, cptr); } } /* Reopens listening sockets on all listeners */ void reopen_listeners(void) { aClient *acptr; aConfItem *aconf; for (acptr = ListenerLL; acptr; acptr = acptr->next) { aconf = acptr->confs->value.aconf; if (!IsIllegal(aconf) && acptr->fd < 0) { open_listener(acptr); } } } void activate_delayed_listeners(void) { int cnt = 0; aClient *acptr; for (acptr = ListenerLL; acptr; acptr = acptr->next) { if (IsListenerInactive(acptr)) { listen(acptr->fd, LISTENQUEUE); ClearListenerInactive(acptr); cnt++; } } if (cnt > 0) { sendto_flag(SCH_NOTICE, "%d listeners activated", cnt); } } void start_iauth(int rcvdsig) { #if defined(USE_IAUTH) static time_t last = 0; static char first = 1; int sp[2], fd, val; static pid_t iauth_pid = 0; if ((bootopt & BOOT_NOIAUTH) != 0) return; if (rcvdsig == 2) { sendto_flag(SCH_AUTH, "Killing iauth..."); if (iauth_pid) kill(iauth_pid, SIGTERM); iauth_pid = 0; } else if (adfd >= 0) { if (rcvdsig) sendto_flag(SCH_AUTH, "iauth is already running, restart canceled"); return; } if ((time(NULL) - last) > 90 || rcvdsig) { sendto_flag(SCH_AUTH, "Starting iauth..."); last = time(NULL); read_iauth(); /* to reset olen */ iauth_spawn += 1; } else return; if (socketpair(AF_UNIX, SOCK_STREAM, 0, sp) < 0) { sendto_flag(SCH_ERROR, "socketpair() failed!"); sendto_flag(SCH_AUTH, "Failed to restart iauth!"); } adfd = sp[0]; set_non_blocking(sp[0], NULL); set_non_blocking(sp[1], NULL); /* less to worry about in iauth */ val = IAUTH_BUFFER; if (setsockopt(sp[0], SOL_SOCKET, SO_SNDBUF, (void *) &val, sizeof(val)) < 0) sendto_flag(SCH_AUTH, "IAUTH_BUFFER too big for sp0 sndbuf, using default"); if (setsockopt(sp[1], SOL_SOCKET, SO_SNDBUF, (void *) &val, sizeof(val)) < 0) sendto_flag(SCH_AUTH, "IAUTH_BUFFER too big for sp1 sndbuf, using default"); if (setsockopt(sp[0], SOL_SOCKET, SO_RCVBUF, (void *) &val, sizeof(val)) < 0) sendto_flag(SCH_AUTH, "IAUTH_BUFFER too big for sp0 rcvbuf, using default"); if (setsockopt(sp[1], SOL_SOCKET, SO_RCVBUF, (void *) &val, sizeof(val)) < 0) sendto_flag(SCH_AUTH, "IAUTH_BUFFER too big for sp1 rcvbuf, using default"); switch ((iauth_pid = vfork())) { case -1: sendto_flag(SCH_ERROR, "vfork() failed!"); sendto_flag(SCH_AUTH, "Failed to restart iauth!"); close(sp[0]); close(sp[1]); adfd = -1; return; case 0: for (fd = 0; fd < MAXCONNECTIONS; fd++) if (fd != sp[1]) (void)close(fd); if (sp[1] != 0) { (void)dup2(sp[1], 0); close(sp[1]); } if (execl(IAUTH_PATH, IAUTH, NULL) < 0) _exit(-1); /* should really not happen.. */ default: close(sp[1]); } if (first) first = 0; else { int i; aClient *cptr; char abuf[BUFSIZ]; /* size of abuf in vsendto_iauth */ /* 20 is biggest possible ending "%d O\n\0", which means ** 16-digit fd -- very unlikely :> */ char *e = abuf + BUFSIZ - 20; char *s = abuf; /* Build abuf to send big buffer once (or twice) to iauth, ** which goes faster than many consecutive small writes. ** BitKoenig claims it saves metadata overhead on Linux and ** does not harm other systems --B. */ for (i = 0; i <= highest_fd; i++) { if (!(cptr = local[i])) continue; if (IsServer(cptr) || IsService(cptr)) continue; /* if not enough room in abuf, send whatever we have ** now and start writing from begin of abuf again. */ if (s > e) { /* sendto_iauth() appends "\n", so we ** remove last one */ *(s - 1) = '\0'; sendto_iauth(abuf); s = abuf; } /* A little trick: we sprintf onto s and move s (which ** points inside abuf) forward, at the end of s (number ** of bytes returned by sprintf). This makes s always ** point to the end of things written on abuf, which ** allows both next sprintf at the end (no strcat!) and ** removing last \n when needed. */ s += sprintf(s, "%d O\n", i); } /* send the rest */ if (s != abuf) { *(s - 1) = '\0'; sendto_iauth(abuf); } } #endif } /* * init_sys */ void init_sys(void) { Reg int fd; #ifdef RLIMIT_FD_MAX struct rlimit limit; if (!getrlimit(RLIMIT_FD_MAX, &limit)) { if (limit.rlim_max < MAXCONNECTIONS) { (void)fprintf(stderr, "ircd fd table is too big\n"); (void)fprintf(stderr, "Hard Limit: %d IRC max: %d\n", (int) limit.rlim_max, MAXCONNECTIONS); (void)fprintf(stderr, "Fix MAXCONNECTIONS and recompile.\n"); exit(-1); } limit.rlim_cur = limit.rlim_max; /* make soft limit the max */ if (setrlimit(RLIMIT_FD_MAX, &limit) == -1) { (void)fprintf(stderr, "error setting max fd's to %d\n", (int) limit.rlim_cur); exit(-1); } } /* Let's assume that if it has define for fd limit, then it can do core limits, too. --B. */ if (!getrlimit(RLIMIT_CORE, &limit)) { limit.rlim_cur = limit.rlim_max; if (limit.rlim_cur != RLIM_INFINITY) { (void)fprintf(stderr, "warning: max core" " is not unlimited\n"); } if (setrlimit(RLIMIT_CORE, &limit) == -1) { (void)fprintf(stderr, "error setting max core to %d\n", (int) limit.rlim_cur); exit(-1); } } #endif #if !defined(USE_POLL) # ifdef sequent # ifndef DYNIXPTX int fd_limit; fd_limit = setdtablesize(MAXCONNECTIONS + 1); if (fd_limit < MAXCONNECTIONS) { (void)fprintf(stderr,"ircd fd table too big\n"); (void)fprintf(stderr,"Hard Limit: %d IRC max: %d\n", fd_limit, MAXCONNECTIONS); (void)fprintf(stderr,"Fix MAXCONNECTIONS\n"); exit(-1); } # endif # endif #endif /* USE_POLL */ #if defined(PCS) || defined(DYNIXPTX) || defined(SVR3) char logbuf[BUFSIZ]; (void)setvbuf(stderr,logbuf,_IOLBF,sizeof(logbuf)); #else # if defined(HPUX) (void)setvbuf(stderr, NULL, _IOLBF, 0); # else # if !defined(SVR4) (void)setlinebuf(stderr); # endif # endif #endif bzero((char *)&fdas, sizeof(fdas)); bzero((char *)&fdall, sizeof(fdall)); fdas.highest = fdall.highest = -1; /* we need stderr open, don't close() it, daemonize() will do it */ /* after ircdwatch restarts ircd, we no longer have stderr, FIXME */ local[0] = local[1] = local[2] = NULL; for (fd = 3; fd < MAXCONNECTIONS; fd++) { local[fd] = NULL; (void)close(fd); } } void daemonize(void) { #ifdef TIOCNOTTY int fd; #endif if (bootopt & BOOT_TTY) /* debugging is going to a tty */ goto init_dgram; (void)fclose(stdout); (void)close(1); if (!(bootopt & BOOT_DEBUG)) { (void)fclose(stderr); (void)close(2); } if (((bootopt & BOOT_CONSOLE) || isatty(0)) && !(bootopt & BOOT_INETD)) { if (fork()) exit(0); #ifdef TIOCNOTTY if ((fd = open("/dev/tty", O_RDWR)) >= 0) { (void)ioctl(fd, TIOCNOTTY, (char *)NULL); (void)close(fd); } #endif #if defined(HPUX) || defined(SVR4) || defined(DYNIXPTX) || \ defined(_POSIX_SOURCE) || defined(SGI) (void)setsid(); #elif defined (__CYGWIN32__) || defined(__APPLE__) (void)setpgrp(); #else (void)setpgrp(0, (int)getpid()); #endif (void)fclose(stdin); (void)close(0); } init_dgram: resfd = init_resolver(0x1f); start_iauth(0); } void write_pidfile(void) { int fd; char buff[20]; (void)truncate(IRCDPID_PATH, 0); if ((fd = open(IRCDPID_PATH, O_CREAT|O_WRONLY, 0600))>=0) { bzero(buff, sizeof(buff)); (void)sprintf(buff,"%5d\n", (int)getpid()); if (write(fd, buff, strlen(buff)) == -1) { Debug((DEBUG_NOTICE,"Error writing to pid file %s", IRCDPID_PATH)); } (void)close(fd); return; } # ifdef DEBUGMODE else Debug((DEBUG_NOTICE,"Error opening pid file %s", IRCDPID_PATH)); # endif } /* * Initialize the various name strings used to store hostnames. This is set * from either the server's sockhost (if client fd is a tty or localhost) * or from the ip# converted into a string. 0 = success, -1 = fail. */ static int check_init(aClient *cptr, char *sockn) { struct SOCKADDR_IN sk; SOCK_LEN_TYPE len = sizeof(struct SOCKADDR_IN); #ifdef UNIXPORT if (IsUnixSocket(cptr)) { strncpyzt(sockn, cptr->acpt->sockhost, HOSTLEN+1); get_sockhost(cptr, sockn); return 0; } #endif /* If descriptor is a tty, special checking... */ if (isatty(cptr->fd)) { strncpyzt(sockn, me.sockhost, HOSTLEN); bzero((char *)&sk, sizeof(struct SOCKADDR_IN)); } else if (getpeername(cptr->fd, (SAP)&sk, &len) == -1) { report_error("connect failure: %s %s", cptr); return -1; } #ifdef INET6 inetntop(AF_INET6, (char *)&sk.sin6_addr, sockn, INET6_ADDRSTRLEN); Debug((DEBUG_DNS,"sockn %x",sockn)); Debug((DEBUG_DNS,"sockn %s",sockn)); #else (void)strcpy(sockn, (char *)inetntoa((char *)&sk.sin_addr)); #endif bcopy((char *)&sk.SIN_ADDR, (char *)&cptr->ip, sizeof(struct IN_ADDR)); cptr->port = ntohs(sk.SIN_PORT); return 0; } /* * Ordinary client access check. Look for conf lines which have the same * status as the flags passed. * 0 = Success * -1 = Bad socket. * -2 = Access denied */ int check_client(aClient *cptr) { char sockname[HOSTLEN+1]; Reg struct hostent *hp = NULL; Reg int i; #ifdef INET6 Debug((DEBUG_DNS, "ch_cl: check access for %s[%s]", cptr->name, inet_ntop(AF_INET6, (char *)&cptr->ip, ipv6string, sizeof(ipv6string)))); #else Debug((DEBUG_DNS, "ch_cl: check access for %s[%s]", cptr->name, inetntoa((char *)&cptr->ip))); #endif if (check_init(cptr, sockname)) return -1; #ifdef UNIXPORT if (!IsUnixSocket(cptr)) #endif hp = cptr->hostp; /* * Verify that the host to ip mapping is correct both ways and that * the ip#(s) for the socket is listed for the host. */ if (hp) { for (i = 0; hp->h_addr_list[i]; i++) if (!bcmp(hp->h_addr_list[i], (char *)&cptr->ip, sizeof(struct IN_ADDR))) break; if (!hp->h_addr_list[i]) { #ifdef INET6 sendto_flag(SCH_ERROR, "IP# Mismatch: %s != %s[%08x%08x%08x%08x]", inetntop(AF_INET6, (char *)&cptr->ip, ipv6string,sizeof(ipv6string)), hp->h_name, ((unsigned long *)hp->h_addr)[0], ((unsigned long *)hp->h_addr)[1], ((unsigned long *)hp->h_addr)[2], ((unsigned long *)hp->h_addr)[3]); #else sendto_flag(SCH_ERROR, "IP# Mismatch: %s != %s[%08x]", inetntoa((char *)&cptr->ip), hp->h_name, *((unsigned long *)hp->h_addr)); #endif hp = NULL; cptr->hostp = NULL; } } if ((i = attach_Iline(cptr, hp, sockname))) { Debug((DEBUG_DNS,"ch_cl: access denied: %s[%s]", cptr->name, sockname)); return i; } Debug((DEBUG_DNS, "ch_cl: access ok: %s[%s]", cptr->name, sockname)); #ifdef NO_OPER_REMOTE if ( #ifdef UNIXPORT IsUnixSocket(cptr) || #endif #ifdef INET6 IN6_IS_ADDR_LOOPBACK(&cptr->ip) || /* If s6_addr32 was standard, we could just compare them, * not memcmp. --B. */ !memcmp(cptr->ip.s6_addr, mysk.sin6_addr.s6_addr, 16) #else inetnetof(cptr->ip) == IN_LOOPBACKNET || cptr->ip.S_ADDR == mysk.SIN_ADDR.S_ADDR #endif ) { ircstp->is_loc++; cptr->flags |= FLAGS_LOCAL; } #endif /* NO_OPER_REMOTE */ return 0; } /* * check_server_init(), check_server() * check access for a server given its name (passed in cptr struct). * Must check for all C/N lines which have a name which matches the * name given and a host which matches. A host alias which is the * same as the server name is also acceptable in the host field of a * C/N line. * 0 = Success * -1 = Access denied * -2 = Bad socket. */ int check_server_init(aClient *cptr) { Reg char *name; Reg aConfItem *c_conf = NULL, *n_conf = NULL; struct hostent *hp = NULL; Link *lp; name = cptr->name; Debug((DEBUG_DNS, "sv_cl: check access for %s[%s]", name, cptr->sockhost)); if (IsUnknown(cptr) && !attach_confs(cptr, name, CFLAG|NFLAG)) { Debug((DEBUG_DNS,"No C/N lines for %s", name)); return -1; } lp = cptr->confs; /* * We initiated this connection so the client should have a C and N * line already attached after passing through the connec_server() * function earlier. */ if (IsConnecting(cptr) || IsHandshake(cptr)) { c_conf = find_conf(lp, name, CFLAG); n_conf = find_conf(lp, name, NFLAG); if (!c_conf || !n_conf) { sendto_flag(SCH_ERROR, "Connecting Error: %s[%s]", name, cptr->sockhost); det_confs_butmask(cptr, 0); return -1; } } #ifdef UNIXPORT if (IsUnixSocket(cptr)) { if (!c_conf) c_conf = find_conf(lp, name, CFLAG); if (!n_conf) n_conf = find_conf(lp, name, NFLAG); } #endif /* ** If the servername is a hostname, either an alias (CNAME) or ** real name, then check with it as the host. Use gethostbyname() ** to check for servername as hostname. */ if (!cptr->hostp #ifdef UNIXPORT && !IsUnixSocket(cptr) #endif ) { Reg aConfItem *aconf; aconf = count_cnlines(lp); if (aconf) { Reg char *s; Link lin; /* ** Do a lookup for the CONF line *only* and not ** the server connection else we get stuck in a ** nasty state since it takes a SERVER message to ** get us here and we can't interrupt that very ** well. */ lin.value.aconf = aconf; lin.flags = ASYNC_CONF; nextdnscheck = 1; if ((s = index(aconf->host, '@'))) s++; else s = aconf->host; Debug((DEBUG_DNS,"sv_ci:cache lookup (%s)",s)); hp = gethost_byname(s, &lin); } } return check_server(cptr, hp, c_conf, n_conf); } int check_server(aClient *cptr, struct hostent *hp, aConfItem *c_conf, aConfItem *n_conf) { Reg char *name; char abuff[HOSTLEN+USERLEN+2]; char sockname[HOSTLEN+1], fullname[HOSTLEN+1]; Link *lp = cptr->confs; int i; if (check_init(cptr, sockname)) return -2; check_serverback: if (hp) { for (i = 0; hp->h_addr_list[i]; i++) if (!bcmp(hp->h_addr_list[i], (char *)&cptr->ip, sizeof(struct IN_ADDR))) break; if (!hp->h_addr_list[i]) { #ifdef INET6 sendto_flag(SCH_ERROR, "IP# Mismatch: %s != %s[%08x%08x%08x%08x]", inetntop(AF_INET6, (char *)&cptr->ip, ipv6string, sizeof(ipv6string)),hp->h_name, ((unsigned long *)hp->h_addr)[0], ((unsigned long *)hp->h_addr)[1], ((unsigned long *)hp->h_addr)[2], ((unsigned long *)hp->h_addr)[3]); #else sendto_flag(SCH_ERROR, "IP# Mismatch: %s != %s[%08x]", inetntoa((char *)&cptr->ip), hp->h_name, *((unsigned long *)hp->h_addr)); #endif hp = NULL; } } else if (cptr->hostp) { hp = cptr->hostp; goto check_serverback; } if (hp) /* * if we are missing a C or N line from above, search for * it under all known hostnames we have for this ip#. */ for (i=0,name = hp->h_name; name ; name = hp->h_aliases[i++]) { strncpyzt(fullname, name, sizeof(fullname)); add_local_domain(fullname, HOSTLEN-strlen(fullname)); Debug((DEBUG_DNS, "sv_cl: gethostbyaddr: %s->%s", sockname, fullname)); sprintf(abuff, "%s@%s", cptr->username, fullname); if (!c_conf) c_conf = find_conf_host(lp, abuff, CFLAG); if (!n_conf) n_conf = find_conf_host(lp, abuff, NFLAG); if (c_conf && n_conf) { get_sockhost(cptr, fullname); break; } } name = cptr->name; /* * Check for C and N lines with the hostname portion the ip number * of the host the server runs on. This also checks the case where * there is a server connecting from 'localhost'. */ if (IsUnknown(cptr) && (!c_conf || !n_conf)) { sprintf(abuff, "%s@%s", cptr->username, sockname); if (!c_conf) c_conf = find_conf_host(lp, abuff, CFLAG); if (!n_conf) n_conf = find_conf_host(lp, abuff, NFLAG); } /* * Attach by IP# only if all other checks have failed. * It is quite possible to get here with the strange things that can * happen when using DNS in the way the irc server does. -avalon */ if (!hp) { if (!c_conf) c_conf = find_conf_ip(lp, (char *)&cptr->ip, cptr->username, CFLAG); if (!n_conf) n_conf = find_conf_ip(lp, (char *)&cptr->ip, cptr->username, NFLAG); } else for (i = 0; hp->h_addr_list[i]; i++) { if (!c_conf) c_conf = find_conf_ip(lp, hp->h_addr_list[i], cptr->username, CFLAG); if (!n_conf) n_conf = find_conf_ip(lp, hp->h_addr_list[i], cptr->username, NFLAG); } /* * detach all conf lines that got attached by attach_confs() */ det_confs_butmask(cptr, 0); /* * if no C or no N lines, then deny access */ if (!c_conf || !n_conf) { get_sockhost(cptr, sockname); Debug((DEBUG_DNS, "sv_cl: access denied: %s[%s@%s] c %x n %x", name, cptr->auth, cptr->sockhost, c_conf, n_conf)); return -1; } /* * attach the C and N lines to the client structure for later use. */ (void)attach_confs(cptr, name, CONF_HUB|CONF_LEAF); (void)attach_conf(cptr, n_conf); (void)attach_conf(cptr, c_conf); if (IsIllegal(n_conf) || IsIllegal(c_conf)) { sendto_flag(SCH_DEBUG, "Illegal class!"); return -2; } if (!n_conf->host || !c_conf->host) { sendto_flag(SCH_DEBUG, "Null host in class!"); return -2; } if ( #ifdef INET6 AND16(c_conf->ipnum.s6_addr) == 255 #else c_conf->ipnum.s_addr == -1 #endif #ifdef UNIXPORT && !IsUnixSocket(cptr) #endif ) { bcopy((char *)&cptr->ip, (char *)&c_conf->ipnum, sizeof(struct IN_ADDR)); } #ifdef UNIXPORT if (!IsUnixSocket(cptr)) #endif get_sockhost(cptr, c_conf->host); Debug((DEBUG_DNS,"sv_cl: access ok: %s[%s]", name, cptr->sockhost)); return 0; } /* ** completed_connection ** Complete non-blocking connect()-sequence. Check access and ** terminate connection, if trouble detected. ** ** Return TRUE, if successfully completed ** FALSE, if failed and ClientExit */ static int completed_connection(aClient *cptr) { aConfItem *aconf; SetHandshake(cptr); aconf = find_conf(cptr->confs, cptr->name, CFLAG); if (!aconf) { sendto_flag(SCH_NOTICE, "Lost C-Line for %s", get_client_name(cptr,FALSE)); return -1; } if (!BadPtr(aconf->passwd)) sendto_one(cptr, "PASS %s %s IRC|%s %s%s%s", aconf->passwd, pass_version, serveropts, (bootopt & BOOT_STRICTPROT) ? "P" : "", #ifdef JAPANESE "j", #else "", #endif #ifdef ZIP_LINKS (aconf->status == CONF_ZCONNECT_SERVER) ? "Z" : #endif "" ); aconf = find_conf(cptr->confs, cptr->name, CONF_NOCONNECT_SERVER); if (!aconf) { sendto_flag(SCH_NOTICE, "Lost N-Line for %s", get_client_name(cptr,FALSE)); return -1; } sendto_one(cptr, "SERVER %s 1 %s :%s", my_name_for_link(ME, aconf->port), me.serv->sid, me.info); if (!IsDead(cptr)) { start_auth(cptr); #if defined(USE_IAUTH) /* ** This could become a bug.. but I don't think iauth needs the ** hostname/aliases in this case. -kalt */ sendto_iauth("%d d", cptr->fd); #endif } return (IsDead(cptr)) ? -1 : 0; } /* * Closes FD in aClient structures. */ void close_client_fd(aClient *cptr) { int i; #ifdef SO_LINGER struct linger sockling; sockling.l_onoff = 0; #endif if (cptr->authfd >= 0) { #ifdef SO_LINGER if (cptr->exitc == EXITC_PING) if (SETSOCKOPT(cptr->authfd, SOL_SOCKET, SO_LINGER, &sockling, sockling)) report_error("setsockopt(SO_LINGER) %s:%s", cptr); #endif (void)close(cptr->authfd); cptr->authfd = -1; } if ((i = cptr->fd) >= 0) { flush_connections(i); if (IsServer(cptr) || IsListener(cptr)) { del_fd(i, &fdas); #ifdef ZIP_LINKS /* ** the connection might have zip data (even if ** FLAGS_ZIP is not set) */ zip_free(cptr); #endif } else if (IsClient(cptr)) { #ifdef SO_LINGER if (cptr->exitc == EXITC_PING) if (SETSOCKOPT(i, SOL_SOCKET, SO_LINGER, &sockling, sockling)) report_error("setsockopt(SO_LINGER) %s:%s", cptr); #endif } del_fd(i, &fdall); local[i] = NULL; (void)close(i); cptr->fd = -1; DBufClear(&cptr->sendQ); DBufClear(&cptr->recvQ); bzero(cptr->passwd, sizeof(cptr->passwd)); } } /* ** close_connection ** Close the physical connection. This function must make ** MyConnect(cptr) == FALSE, and set cptr->from == NULL. */ void close_connection(aClient *cptr) { aConfItem *aconf; if (IsServer(cptr)) { ircstp->is_sv++; ircstp->is_sbs += cptr->sendB; ircstp->is_sbr += cptr->receiveB; ircstp->is_sti += timeofday - cptr->firsttime; } else if (IsClient(cptr)) { ircstp->is_cl++; ircstp->is_cbs += cptr->sendB; ircstp->is_cbr += cptr->receiveB; ircstp->is_cti += timeofday - cptr->firsttime; } else { ircstp->is_ni++; } /* * remove outstanding DNS queries. */ del_queries((char *)cptr); /* * If the server connection has been up for a long amount of time, * schedule a 'quick' reconnect, else reset the next-connect cycle. */ if (IsServer(cptr) && (aconf = find_conf_exact(cptr->name, cptr->username, cptr->sockhost, CFLAG))) { /* * Reschedule a faster reconnect, if this was a automatically * connected configuration entry. (Note that if we have had * a rehash in between, the status has been changed to * CONF_ILLEGAL). But only do this if it was a "good" link. */ aconf->hold = timeofday; aconf->hold += (aconf->hold - cptr->since > HANGONGOODLINK) ? HANGONRETRYDELAY : ConfConFreq(aconf); /* nextconnect could be 0 */ if (nextconnect > aconf->hold || nextconnect == 0) { nextconnect = aconf->hold; } } if (nextconnect == 0 && (IsHandshake(cptr) || IsConnecting(cptr))) { nextconnect = timeofday + HANGONRETRYDELAY; } if (cptr->fd >= 0) { #if defined(USE_IAUTH) if (!IsListener(cptr) && !IsConnecting(cptr)) { /* iauth doesn't know about listening FD nor * cancelled outgoing connections. */ sendto_iauth("%d D", cptr->fd); } #endif /* * clean up extra sockets from P-lines which have been * discarded. */ if ((cptr->acpt != &me) && !(IsListener(cptr))) { aconf = cptr->acpt->confs->value.aconf; if (aconf->clients > 0) { aconf->clients--; } if (!aconf->clients && IsIllegal(aconf)) { close_connection(cptr->acpt); } } } close_client_fd(cptr); /* Remove from Listener Linked list */ if (IsListener(cptr) && cptr->confs && cptr->confs->value.aconf && IsIllegal(cptr->confs->value.aconf) && cptr->confs->value.aconf->clients <= 0) { if (cptr->prev) { cptr->prev->next = cptr->next; } else { /* we were 1st */ ListenerLL = cptr->next; } if (cptr->next) { cptr->next->prev = cptr->prev; } } det_confs_butmask(cptr, 0); cptr->from = NULL; /* ...this should catch them! >:) --msa */ return; } /* ** set_sock_opts */ static int set_sock_opts(int fd, aClient *cptr) { int opt, ret = 0; #ifdef SO_REUSEADDR opt = 1; if (SETSOCKOPT(fd, SOL_SOCKET, SO_REUSEADDR, &opt, opt) < 0) report_error("setsockopt(SO_REUSEADDR) %s:%s", cptr); #endif #if defined(SO_DEBUG) && defined(DEBUGMODE) && 0 /* Solaris 2.x with SO_DEBUG writes to syslog by default */ #if !defined(SOLARIS_2) || defined(USE_SYSLOG) opt = 1; if (SETSOCKOPT(fd, SOL_SOCKET, SO_DEBUG, &opt, opt) < 0) report_error("setsockopt(SO_DEBUG) %s:%s", cptr); #endif /* SOLARIS_2 */ #endif #if defined(SO_USELOOPBACK) && !defined(__CYGWIN32__) opt = 1; if (SETSOCKOPT(fd, SOL_SOCKET, SO_USELOOPBACK, &opt, opt) < 0) report_error("setsockopt(SO_USELOOPBACK) %s:%s", cptr); #endif #ifdef SO_RCVBUF opt = 8192; if (SETSOCKOPT(fd, SOL_SOCKET, SO_RCVBUF, &opt, opt) < 0) report_error("setsockopt(SO_RCVBUF) %s:%s", cptr); #endif #ifdef SO_SNDBUF # ifdef _SEQUENT_ /* seems that Sequent freezes up if the receving buffer is a different size * to the sending buffer (maybe a tcp window problem too). */ # endif opt = 8192; if (SETSOCKOPT(fd, SOL_SOCKET, SO_SNDBUF, &opt, opt) < 0) report_error("setsockopt(SO_SNDBUF) %s:%s", cptr); # ifdef SO_SNDLOWAT /* * Setting the low water mark should improve performence by avoiding * early returns from select()/poll(). It shouldn't delay sending * data, provided that io_loop() combines read_message() and * flush_fdary/connections() calls properly. -kalt * This call isn't always implemented, even when defined.. so be quiet * about errors. -kalt */ opt = 8192; SETSOCKOPT(fd, SOL_SOCKET, SO_SNDLOWAT, &opt, opt); # endif #endif #if defined(IP_OPTIONS) && defined(IPPROTO_IP) && !defined(AIX) && \ !defined(INET6) /* * Mainly to turn off and alert us to source routing, here. * Method borrowed from Wietse Venema's TCP wrapper. */ { if (!IsListener(cptr) #ifdef UNIXPORT && !IsUnixSocket(cptr) #endif ) { u_char opbuf[256], *t = opbuf; char *s = readbuf; opt = sizeof(opbuf); if (GETSOCKOPT(fd, IPPROTO_IP, IP_OPTIONS, t, &opt) == -1) report_error("getsockopt(IP_OPTIONS) %s:%s", cptr); else if (opt > 0) { for (; opt > 0; opt--, s+= 3) (void)sprintf(s, " %02x", *t++); *s = '\0'; sendto_flag(SCH_NOTICE, "Connection %s with IP opts%s", get_client_name(cptr, TRUE), readbuf); Debug((DEBUG_NOTICE, "Connection %s with IP opts%s", get_client_name(cptr, TRUE), readbuf)); ret = -1; } } } #endif return ret; } int get_sockerr(aClient *cptr) { int errtmp = errno, err = 0; SOCK_LEN_TYPE len = sizeof(err); #ifdef SO_ERROR if (cptr->fd >= 0) if (!GETSOCKOPT(cptr->fd, SOL_SOCKET, SO_ERROR, &err, &len)) if (err) errtmp = err; #endif return errtmp; } /* ** set_non_blocking ** Set the client connection into non-blocking mode. If your ** system doesn't support this, you can make this a dummy ** function (and get all the old problems that plagued the ** blocking version of IRC--not a problem if you are a ** lightly loaded node...) */ void set_non_blocking(int fd, aClient *cptr) { int res, nonb = 0; /* ** NOTE: consult ALL your relevant manual pages *BEFORE* changing ** these ioctl's. There are quite a few variations on them, ** as can be seen by the PCS one. They are *NOT* all the same. ** Heed this well. - Avalon. */ #ifdef NBLOCK_POSIX nonb |= O_NONBLOCK; #endif #ifdef NBLOCK_BSD nonb |= O_NDELAY; #endif #ifdef NBLOCK_SYSV /* This portion of code might also apply to NeXT. -LynX */ res = 1; if (ioctl (fd, FIONBIO, &res) < 0) report_error("ioctl(fd,FIONBIO) failed for %s:%s", cptr); #else if ((res = fcntl(fd, F_GETFL, 0)) == -1) report_error("fcntl(fd, F_GETFL) failed for %s:%s",cptr); else if (fcntl(fd, F_SETFL, res | nonb) == -1) report_error("fcntl(fd, F_SETL, nonb) failed for %s:%s",cptr); #endif return; } #ifdef CLONE_CHECK /* * check_clones * adapted by jecete 4 IRC Ptnet */ static int check_clones(aClient *cptr) { struct abacklog { struct IN_ADDR ip; time_t PT; struct abacklog *next; }; static struct abacklog *backlog = NULL; register struct abacklog **blscn = &backlog, *blptr; register int count = 0; /* First, ditch old entries */ while (*blscn != NULL) { if ((*blscn)->PT+CLONE_PERIOD < timeofday) { blptr= *blscn; *blscn=blptr->next; MyFree(blptr); } else blscn = &(*blscn)->next; } /* Now add new item to the list */ blptr = (struct abacklog *) MyMalloc(sizeof(struct abacklog)); #ifdef INET6 bcopy(cptr->ip.s6_addr, blptr->ip.s6_addr, IN6ADDRSZ); #else blptr->ip.s_addr = cptr->ip.s_addr; #endif blptr->PT = timeofday; blptr->next = backlog; backlog = blptr; /* Count the number of entries from the same host */ blptr = backlog; while (blptr != NULL) { #ifdef INET6 if (bcmp(blptr->ip.s6_addr, cptr->ip.s6_addr, IN6ADDRSZ) == 0) #else if (blptr->ip.s_addr == cptr->ip.s_addr) #endif count++; blptr = blptr->next; } return (count); } #endif /* moved from inner blocks of add_connection to get rid of gotos */ void add_connection_refuse(int fd, aClient *acptr, int delay) { #if !defined(DELAY_CLOSE) delay = 0; #endif if (!delay) { (void)close(fd); } ircstp->is_ref++; acptr->fd = -2; free_client(acptr); } /* * Creates a client which has just connected to us on the given fd. * The sockhost field is initialized with the ip# of the host. * The client is added to the linked list of clients but isnt added to any * hash tables yet since it doesnt have a name. */ aClient *add_connection(aClient *cptr, int fd) { Link lin; aClient *acptr; aConfItem *aconf = NULL; acptr = make_client(NULL); aconf = cptr->confs->value.aconf; acptr->acpt = cptr; /* Removed preliminary access check. Full check is performed in * m_server and m_user instead. Also connection time out help to * get rid of unwanted connections. */ if (isatty(fd)) /* If descriptor is a tty, special checking... */ get_sockhost(acptr, cptr->sockhost); else { struct SOCKADDR_IN addr; SOCK_LEN_TYPE len = sizeof(struct SOCKADDR_IN); if (getpeername(fd, (SAP)&addr, &len) == -1) { #if defined(linux) if (errno != ENOTCONN) #endif report_error("Failed in connecting to %s :%s", cptr); add_connection_refuse(fd, acptr, 0); return NULL; } /* don't want to add "Failed in connecting to" here.. */ if (aconf && IsIllegal(aconf)) { add_connection_refuse(fd, acptr, 0); return NULL; } /* Copy ascii address to 'sockhost' just in case. Then we * have something valid to put into error messages... */ #ifdef INET6 inetntop(AF_INET6, (char *)&addr.sin6_addr, ipv6string, sizeof(ipv6string)); get_sockhost(acptr, (char *)ipv6string); #else get_sockhost(acptr, (char *)inetntoa((char *)&addr.sin_addr)); #endif bcopy ((char *)&addr.SIN_ADDR, (char *)&acptr->ip, sizeof(struct IN_ADDR)); acptr->port = ntohs(addr.SIN_PORT); #ifdef CLONE_CHECK if (check_clones(acptr) > CLONE_MAX) { sendto_flag(SCH_LOCAL, "Rejecting connection from %s.", acptr->sockhost); acptr->exitc = EXITC_CLONE; sendto_flog(acptr, EXITC_CLONE, "", acptr->sockhost); #ifdef DELAY_CLOSE nextdelayclose = delay_close(fd); #else (void)send(fd, "ERROR :Too rapid connections from your " "host\r\n", 46, 0); #endif /* If DELAY_CLOSE is not defined, delay will ** be changed to 0 inside. --B. */ add_connection_refuse(fd, acptr, 1); return NULL; } #endif lin.flags = ASYNC_CLIENT; lin.value.cptr = acptr; lin.next = NULL; #ifdef INET6 Debug((DEBUG_DNS, "lookup %s", inet_ntop(AF_INET6, (char *)&addr.sin6_addr, ipv6string, sizeof(ipv6string)))); #else Debug((DEBUG_DNS, "lookup %s", inetntoa((char *)&addr.sin_addr))); #endif acptr->hostp = gethost_byaddr((char *)&acptr->ip, &lin); if (!acptr->hostp) SetDNS(acptr); nextdnscheck = 1; } acptr->fd = fd; set_non_blocking(acptr->fd, acptr); if (set_sock_opts(acptr->fd, acptr) == -1) { add_connection_refuse(fd, acptr, 0); return NULL; } if (aconf) aconf->clients++; if (fd > highest_fd) highest_fd = fd; local[fd] = acptr; add_fd(fd, &fdall); add_client_to_list(acptr); start_auth(acptr); #if defined(USE_IAUTH) if (!isatty(fd) && !DoingDNS(acptr)) { int i = 0; while (acptr->hostp->h_aliases[i]) sendto_iauth("%d A %s", acptr->fd, acptr->hostp->h_aliases[i++]); if (acptr->hostp->h_name) sendto_iauth("%d N %s",acptr->fd,acptr->hostp->h_name); else if (acptr->hostp->h_aliases[0]) sendto_iauth("%d n", acptr->fd); } #endif return acptr; } #ifdef UNIXPORT static aClient *add_unixconnection(aClient *cptr, int fd) { aClient *acptr; aConfItem *aconf = NULL; acptr = make_client(NULL); /* Copy ascii address to 'sockhost' just in case. Then we * have something valid to put into error messages... */ get_sockhost(acptr, me.sockhost); aconf = cptr->confs->value.aconf; if (aconf) { if (IsIllegal(aconf)) { ircstp->is_ref++; acptr->fd = -2; free_client(acptr); (void)close(fd); return NULL; } else aconf->clients++; } acptr->fd = fd; if (fd > highest_fd) highest_fd = fd; local[fd] = acptr; add_fd(fd, &fdall); acptr->acpt = cptr; SetUnixSock(acptr); bcopy((char *)&me.ip, (char *)&acptr->ip, sizeof(struct IN_ADDR)); add_client_to_list(acptr); set_non_blocking(acptr->fd, acptr); (void)set_sock_opts(acptr->fd, acptr); # if defined(USE_IAUTH) /* ** iauth protocol and iauth itself should be extended to alllow ** dealing with this type of connection. */ sendto_iauth("%d O", acptr->fd); SetDoneXAuth(acptr); # endif return acptr; } #endif /* ** read_listener ** ** Accept incoming connections, extracted from read_message() 98/12 -kalt ** Up to LISTENER_MAXACCEPT connections will be accepted in one run. */ static void read_listener(aClient *cptr) { int fdnew, max = LISTENER_MAXACCEPT; aClient *acptr; while (max--) { /* ** There may be many reasons for error return, but in otherwise ** correctly working environment the probable cause is running ** out of file descriptors (EMFILE, ENFILE or others?). The ** man pages for accept don't seem to list these as possible, ** although it's obvious that it may happen here. ** Thus no specific errors are tested at this point, just ** assume that connections cannot be accepted until some old ** is closed first. */ if ((fdnew = accept(cptr->fd, NULL, NULL)) < 0) { if (errno != EWOULDBLOCK) report_error("Cannot accept connection %s:%s", cptr); break; } ircstp->is_ac++; if (fdnew >= MAXCLIENTS) { ircstp->is_ref++; sendto_flag(SCH_ERROR, "All connections in use. (%s)", get_client_name(cptr, TRUE)); find_bounce(NULL, 0, fdnew); (void)send(fdnew, "ERROR :All connections in use\r\n", 32, 0); (void)close(fdnew); continue; } /* Can cptr->confs->value.aconf be NULL? --B. */ if ((iconf.caccept == 0 || (iconf.caccept == 2 && iconf.split == 1)) && cptr->confs->value.aconf != NULL && IsConfDelayed(cptr->confs->value.aconf)) { /* Should we bother sendto_flag(SCH_ERROR...? --B. */ #ifdef CACCEPT_DELAYED_CLOSE nextdelayclose = delay_close(fdnew); ircstp->is_ref++; #else (void)send(fdnew, "ERROR :All client connections are " "temporarily refused.\r\n", 56, 0); (void)close(fdnew); #endif continue; } #ifdef UNIXPORT if (IsUnixSocket(cptr)) acptr = add_unixconnection(cptr, fdnew); else #endif acptr = add_connection(cptr, fdnew); if (acptr == NULL) { continue; } nextping = timeofday; /* isn't this abusive? -kalt */ istat.is_unknown++; /* Notice on connect. */ sendto_one(acptr, replies[RPL_HELLO], ME, HELLO_MSG); } } /* ** client_packet ** ** Process data from receive buffer to client. ** Extracted from read_packet() 960804/291p3/Vesa */ static int client_packet(aClient *cptr) { Reg int dolen = 0; while (DBufLength(&cptr->recvQ) && !NoNewLine(cptr) && ((cptr->status < STAT_UNKNOWN) || (cptr->since - timeofday < MAXPENALTY))) { /* ** If it has become registered as a Service or Server ** then skip the per-message parsing below. */ if (IsService(cptr) || IsServer(cptr)) { dolen = dbuf_get(&cptr->recvQ, readbuf, sizeof(readbuf)); if (dolen <= 0) break; dolen = dopacket(cptr, readbuf, dolen); if (dolen == 2 && cptr->since == cptr->lasttime) cptr->since += 5; if (dolen) return dolen; break; } dolen = dbuf_getmsg(&cptr->recvQ, readbuf, sizeof(readbuf)); /* ** Devious looking...whats it do ? well..if a client ** sends a *long* message without any CR or LF, then ** dbuf_getmsg fails and we pull it out using this ** loop which just gets the next 512 bytes and then ** deletes the rest of the buffer contents. ** -avalon */ while (dolen <= 0) { if (dolen < 0) return exit_client(cptr, cptr, &me, "dbuf_getmsg fail"); if (DBufLength(&cptr->recvQ) < 510) { /* hmm? */ cptr->flags |= FLAGS_NONL; break; } dolen = dbuf_get(&cptr->recvQ, readbuf, 511); if (dolen > 0 && DBufLength(&cptr->recvQ)) DBufClear(&cptr->recvQ); } /* Is it okay not to test for other return values? -krys */ if (dolen > 0 && (dopacket(cptr, readbuf, dolen) == FLUSH_BUFFER)) return FLUSH_BUFFER; } return 1; } /* ** read_packet ** ** Read a 'packet' of data from a connection and process it. Read in 8k ** chunks to give a better performance rating (for server connections). ** Do some tricky stuff for client connections to make sure they don't do ** any flooding >:-) -avalon */ static int read_packet(aClient *cptr, int msg_ready) { Reg int length = 0, done; if (msg_ready && !(IsPerson(cptr) && DBufLength(&cptr->recvQ) > 6090)) { errno = 0; #ifdef INET6 length = recvfrom(cptr->fd, readbuf, sizeof(readbuf), 0, 0, 0); #else length = recv(cptr->fd, readbuf, sizeof(readbuf), 0); #endif #if defined(DEBUGMODE) && defined(DEBUG_READ) if (length > 0) Debug((DEBUG_READ, "recv = %d bytes from %d[%s]:[%*.*s]\n", length, cptr->fd, cptr->name, length, length, readbuf)); #endif Debug((DEBUG_DEBUG, "Received %d(%d-%s) bytes from %d %s", length, errno, strerror(errno), cptr->fd, get_client_name(cptr, TRUE))); cptr->lasttime = timeofday; if (cptr->lasttime > cptr->since) cptr->since = cptr->lasttime; cptr->flags &= ~(FLAGS_PINGSENT|FLAGS_NONL); /* * If not ready, fake it so it isnt closed */ if (length == -1 && ((errno == EWOULDBLOCK) || (errno == EAGAIN))) return 1; if (length <= 0) return length; } else if (msg_ready) return exit_client(cptr, cptr, &me, "EOF From Client"); /* ** For server connections, we process as many as we can without ** worrying about the time of day or anything :) */ if (IsServer(cptr) || IsConnecting(cptr) || IsHandshake(cptr) || IsService(cptr)) { if (length > 0) { done = dopacket(cptr, readbuf, length); if (done && done != 2) return done; } } else { /* ** Before we even think of parsing what we just read, stick ** it on the end of the receive queue and do it when its ** turn comes around. */ /* why no poolsize increase here like in send? --B. */ if (length && dbuf_put(&cptr->recvQ, readbuf, length) < 0) return exit_client(cptr, cptr, &me, "dbuf_put fail"); if (IsPerson(cptr) && DBufLength(&cptr->recvQ) > CLIENT_FLOOD && !is_allowed(cptr, ACL_CANFLOOD)) { cptr->exitc = EXITC_FLOOD; return exit_client(cptr, cptr, &me, "Excess Flood"); } return client_packet(cptr); } return 1; } /* * Check all connections for new connections and input data that is to be * processed. Also check for connections with data queued and whether we can * write it out. * * Don't ever use ZERO for delay, unless you mean to poll and then * you have to have sleep/wait somewhere else in the code.--msa * Actually, ZERO is NOT ZERO anymore.. see below -kalt */ int read_message(time_t delay, FdAry *fdp, int ro) { #if !defined(USE_POLL) # define SET_READ_EVENT( thisfd ) FD_SET( thisfd, &read_set) # define SET_WRITE_EVENT( thisfd ) FD_SET( thisfd, &write_set) # define CLR_READ_EVENT( thisfd ) FD_CLR( thisfd, &read_set) # define CLR_WRITE_EVENT( thisfd ) FD_CLR( thisfd, &write_set) # define TST_READ_EVENT( thisfd ) FD_ISSET( thisfd, &read_set) # define TST_WRITE_EVENT( thisfd ) FD_ISSET( thisfd, &write_set) fd_set read_set, write_set; int highfd = -1; #else /* most of the following use pfd */ # define POLLSETREADFLAGS (POLLIN|POLLRDNORM) # define POLLREADFLAGS (POLLSETREADFLAGS|POLLHUP|POLLERR) # define POLLSETWRITEFLAGS (POLLOUT|POLLWRNORM) # define POLLWRITEFLAGS (POLLOUT|POLLWRNORM|POLLHUP|POLLERR) # define SET_READ_EVENT( thisfd ){ CHECK_PFD( thisfd );\ pfd->events |= POLLSETREADFLAGS;} # define SET_WRITE_EVENT( thisfd ){ CHECK_PFD( thisfd );\ pfd->events |= POLLSETWRITEFLAGS;} # define CLR_READ_EVENT( thisfd ) pfd->revents &= ~POLLSETREADFLAGS # define CLR_WRITE_EVENT( thisfd ) pfd->revents &= ~POLLSETWRITEFLAGS # define TST_READ_EVENT( thisfd ) pfd->revents & POLLREADFLAGS # define TST_WRITE_EVENT( thisfd ) pfd->revents & POLLWRITEFLAGS # define CHECK_PFD( thisfd ) \ if ( pfd->fd != thisfd ) { \ pfd = &poll_fdarray[nbr_pfds++];\ pfd->fd = thisfd; \ pfd->events = 0; \ pfd->revents = 0; \ } struct pollfd poll_fdarray[MAXCONNECTIONS]; struct pollfd * pfd = poll_fdarray; struct pollfd * res_pfd = NULL; struct pollfd * udp_pfd = NULL; struct pollfd * ad_pfd = NULL; aClient * authclnts[MAXCONNECTIONS]; /* mapping of auth fds to client ptrs */ int nbr_pfds = 0; #endif aClient *cptr; int nfds, ret = 0; struct timeval wait; time_t delay2 = delay; int res, length, fd, i; int auth; int write_err = 0; for (res = 0;;) { #if !defined(USE_POLL) FD_ZERO(&read_set); FD_ZERO(&write_set); #else /* set up such that CHECK_FD works */ nbr_pfds = 0; pfd = poll_fdarray; pfd->fd = -1; res_pfd = NULL; udp_pfd = NULL; ad_pfd = NULL; #endif /* USE_POLL */ auth = 0; #if defined(USE_POLL) if ( auth == 0 ) bzero((char *) authclnts, sizeof( authclnts )); #endif for (i = fdp->highest; i >= 0; i--) { fd = fdp->fd[i]; if (!(cptr = local[fd])) continue; Debug((DEBUG_L11, "fd %d cptr %#x %d %#x %s", fd, cptr, cptr->status, cptr->flags, get_client_name(cptr,TRUE))); /* authentication fd's */ if (DoingAuth(cptr)) { auth++; SET_READ_EVENT(cptr->authfd); Debug((DEBUG_NOTICE,"auth on %x %d", cptr, fd)); if (cptr->flags & FLAGS_WRAUTH) SET_WRITE_EVENT(cptr->authfd); #if defined(USE_POLL) authclnts[cptr->authfd] = cptr; #else if (cptr->authfd > highfd) highfd = cptr->authfd; #endif } /* ** if any of these is true, data won't be parsed ** so no need to check for anything! */ #if defined(USE_IAUTH) if (DoingDNS(cptr) || DoingAuth(cptr) || WaitingXAuth(cptr) || (DoingXAuth(cptr) && !(iauth_options & XOPT_EARLYPARSE))) #else if (DoingDNS(cptr) || DoingAuth(cptr)) #endif continue; #if !defined(USE_POLL) if (fd > highfd) highfd = fd; #endif if (IsListener(cptr)) { if ( #ifdef LISTENER_DELAY /* Checking for new connections is only ** done up to once per LD seconds. */ timeofday >= cptr->lasttime + LISTENER_DELAY && #endif ro == 0) { SET_READ_EVENT( fd ); } else if (delay2 > 1) delay2 = 1; continue; } /* ** This is very approximate, it should take ** cptr->since into account. -kalt */ if (DBufLength(&cptr->recvQ) && delay2 > 2) delay2 = 1; if (IsRegisteredUser(cptr)) { if (cptr->since - timeofday < MAXPENALTY+1) SET_READ_EVENT( fd ); } else if (DBufLength(&cptr->recvQ) < 4088) SET_READ_EVENT( fd ); /* ** If we have anything in the sendQ, check if there is ** room to write data. */ if (DBufLength(&cptr->sendQ) || #ifdef ZIP_LINKS ((cptr->flags & FLAGS_ZIP) && (cptr->zip->outcount > 0)) || #endif IsConnecting(cptr)) { if (IsServer(cptr) || IsConnecting(cptr) || ro == 0) { SET_WRITE_EVENT(fd); } } } if (udpfd >= 0) { SET_READ_EVENT(udpfd); #if !defined(USE_POLL) if (udpfd > highfd) highfd = udpfd; #else udp_pfd = pfd; #endif } if (resfd >= 0) { SET_READ_EVENT(resfd); #if !defined(USE_POLL) if (resfd > highfd) highfd = resfd; #else res_pfd = pfd; #endif } #if defined(USE_IAUTH) if (adfd >= 0) { SET_READ_EVENT(adfd); # if ! USE_POLL if (adfd > highfd) highfd = adfd; # else ad_pfd = pfd; # endif } #endif Debug((DEBUG_L11, "udpfd %d resfd %d adfd %d", udpfd, resfd, adfd)); #if !defined(USE_POLL) Debug((DEBUG_L11, "highfd %d", highfd)); #endif wait.tv_sec = MIN(delay2, delay); wait.tv_usec = (delay == 0) ? 200000 : 0; #if !defined(USE_POLL) nfds = select(highfd + 1, (SELECT_FDSET_TYPE *)&read_set, (SELECT_FDSET_TYPE *)&write_set, 0, &wait); #else nfds = poll( poll_fdarray, nbr_pfds, wait.tv_sec * 1000 + wait.tv_usec/1000 ); #endif ret = nfds; if (nfds == -1 && errno == EINTR) return -1; else if (nfds >= 0) break; #if !defined(USE_POLL) report_error("select %s:%s", &me); #else report_error("poll %s:%s", &me); #endif res++; if (res > 5) restart("too many select()/poll() errors"); sleep(10); timeofday = time(NULL); } /* for(res=0;;) */ timeofday = time(NULL); if (nfds > 0 && #if !defined(USE_POLL) resfd >= 0 && #else (pfd = res_pfd) && #endif TST_READ_EVENT(resfd)) { CLR_READ_EVENT(resfd); nfds--; do_dns_async(); } if (nfds > 0 && #if !defined(USE_POLL) udpfd >= 0 && #else (pfd = udp_pfd) && #endif TST_READ_EVENT(udpfd)) { CLR_READ_EVENT(udpfd); nfds--; polludp(); } #if defined(USE_IAUTH) if (nfds > 0 && # if ! USE_POLL adfd >= 0 && # else (pfd = ad_pfd) && # endif TST_READ_EVENT(adfd)) { CLR_READ_EVENT(adfd); nfds--; read_iauth(); } #endif #if !defined(USE_POLL) for (i = fdp->highest; i >= 0; i--) #else for (pfd = poll_fdarray, i = 0; i < nbr_pfds; i++, pfd++ ) #endif { #if !defined(USE_POLL) fd = fdp->fd[i]; if (!(cptr = local[fd])) continue; #else fd = pfd->fd; if ((cptr = authclnts[fd])) { #endif /* * check for the auth fd's */ if (auth > 0 && nfds > 0 #if !defined(USE_POLL) && cptr->authfd >= 0 #endif ) { auth--; if (TST_WRITE_EVENT(cptr->authfd)) { nfds--; send_authports(cptr); } else if (TST_READ_EVENT(cptr->authfd)) { nfds--; read_authports(cptr); } continue; } #if defined(USE_POLL) } fd = pfd->fd; if (!(cptr = local[fd])) continue; #else fd = cptr->fd; #endif /* * accept connections */ if (TST_READ_EVENT(fd) && IsListener(cptr) && !IsListenerInactive(cptr)) { CLR_READ_EVENT(fd); cptr->lasttime = timeofday; read_listener(cptr); continue; } if (IsMe(cptr)) continue; if (TST_WRITE_EVENT(fd)) { write_err = 0; /* ** ...room for writing, empty some queue then... */ if (IsConnecting(cptr)) write_err = completed_connection(cptr); if (!write_err) (void)send_queued(cptr); if (IsDead(cptr) || write_err) { deadsocket: if (TST_READ_EVENT(fd)) CLR_READ_EVENT(fd); if (cptr->exitc == EXITC_SENDQ) { (void)exit_client(cptr,cptr,&me, "Max SendQ exceeded"); } else { /* Keep (primary) error or it will not * be possible to discriminate socket * error from mbuf error. --B. */ if (cptr->exitc == EXITC_REG) cptr->exitc = EXITC_ERROR; (void)exit_client(cptr, cptr, &me, strerror(get_sockerr(cptr))); } continue; } } length = 1; /* for fall through case */ if (!NoNewLine(cptr) || TST_READ_EVENT(fd)) { if (!DoingAuth(cptr)) length = read_packet(cptr, TST_READ_EVENT(fd)); } readcalls++; if (length == FLUSH_BUFFER) continue; else if (length > 0) flush_connections(cptr->fd); if (IsDead(cptr)) goto deadsocket; if (length > 0) continue; /* Ghost! Unknown users are tagged in parse() since 2.9. * Let's not drop the uplink but just the ghost's message. */ if (length == -3) continue; /* ** NB: This following section has been modified to *expect* ** cptr to be valid (ie if (length == FLUSH_BUFFER) is ** above and stays there). - avalon 24/9/94 */ /* ** ...hmm, with non-blocking sockets we might get ** here from quite valid reasons, although.. why ** would select report "data available" when there ** wasn't... so, this must be an error anyway... --msa ** actually, EOF occurs when read() returns 0 and ** in due course, select() returns that fd as ready ** for reading even though it ends up being an EOF. -avalon */ Debug((DEBUG_ERROR, "READ ERROR: fd = %d %d %d", cptr->fd, errno, length)); if (IsServer(cptr) || IsHandshake(cptr)) { int timeconnected = timeofday - cptr->firsttime; if (length == 0) sendto_flag(SCH_NOTICE, "Server %s closed the connection (%d, %2d:%02d:%02d)", get_client_name(cptr, FALSE), timeconnected / 86400, (timeconnected % 86400) / 3600, (timeconnected % 3600)/60, timeconnected % 60); else /* this must be for -1 */ { report_error("Lost connection to %s:%s",cptr); sendto_flag(SCH_NOTICE, "%s had been connected for %d, %2d:%02d:%02d", get_client_name(cptr, FALSE), timeconnected / 86400, (timeconnected % 86400) / 3600, (timeconnected % 3600)/60, timeconnected % 60); } } (void)exit_client(cptr, cptr, &me, length >= 0 ? "EOF From client" : strerror(get_sockerr(cptr))); } /* for(i) */ return ret; } /* * connect_server */ int connect_server(aConfItem *aconf, aClient *by, struct hostent *hp) { Reg struct SOCKADDR *svp; Reg aClient *cptr, *c2ptr; Reg char *s; int i, len; #ifdef INET6 Debug((DEBUG_NOTICE,"Connect to %s[%s] @%s", aconf->name, aconf->host, inet_ntop(AF_INET6, (char *)&aconf->ipnum, ipv6string, sizeof(ipv6string)))); #else Debug((DEBUG_NOTICE,"Connect to %s[%s] @%s", aconf->name, aconf->host, inetntoa((char *)&aconf->ipnum))); #endif if ((c2ptr = find_server(aconf->name, NULL))) { sendto_flag(SCH_NOTICE, "Server %s already present from %s", aconf->name, get_client_name(c2ptr, TRUE)); if (by && IsPerson(by) && !MyClient(by)) sendto_one(by, ":%s NOTICE %s :Server %s already present from %s", ME, by->name, aconf->name, get_client_name(c2ptr, TRUE)); return -1; } /* * If we don't know the IP# for this host and it is a hostname and * not a ip# string, then try and find the appropriate host record. */ if (!aconf->ipnum.S_ADDR && *aconf->host != '/') { Link lin; lin.flags = ASYNC_CONNECT; lin.value.aconf = aconf; nextdnscheck = 1; s = (char *)index(aconf->host, '@'); s++; /* should NEVER be NULL */ #ifdef INET6 if (!inetpton(AF_INET6, s, aconf->ipnum.s6_addr)) #else if ((aconf->ipnum.s_addr = inetaddr(s)) == -1) #endif { #ifdef INET6 bzero(aconf->ipnum.s6_addr, IN6ADDRSZ); #else aconf->ipnum.s_addr = 0; #endif hp = gethost_byname(s, &lin); Debug((DEBUG_NOTICE, "co_sv: hp %x ac %x na %s ho %s", hp, aconf, aconf->name, s)); if (!hp) return 0; bcopy(hp->h_addr, (char *)&aconf->ipnum, sizeof(struct IN_ADDR)); } } cptr = make_client(NULL); if ((make_server(cptr))==NULL) { free_client(cptr); return -1; } cptr->hostp = hp; /* * Copy these in so we have something for error detection. */ strncpyzt(cptr->serv->namebuf, aconf->name, sizeof(cptr->serv->namebuf)); strncpyzt(cptr->sockhost, aconf->host, HOSTLEN+1); #ifdef UNIXPORT if (*aconf->host == '/') /* (/ starts a 2), Unix domain -- dl*/ svp = connect_unix(aconf, cptr, &len); else #endif svp = connect_inet(aconf, cptr, &len); if (!svp) { free_server: if (cptr->fd >= 0) (void)close(cptr->fd); cptr->fd = -2; /* make_server() sets ->bcptr, clear it now or free_server() ** complains. --B. */ cptr->serv->bcptr = NULL; free_server(cptr->serv); free_client(cptr); return -1; } set_non_blocking(cptr->fd, cptr); (void)set_sock_opts(cptr->fd, cptr); (void)signal(SIGALRM, dummy); (void)alarm(4); if (connect(cptr->fd, (SAP)svp, len) < 0 && errno != EINPROGRESS) { i = errno; /* other system calls may eat errno */ (void)alarm(0); report_error("Connect to host %s failed: %s",cptr); if (by && IsPerson(by) && !MyClient(by)) sendto_one(by, ":%s NOTICE %s :Connect to host %s failed.", ME, by->name, cptr->name); errno = i; if (errno == EINTR) errno = ETIMEDOUT; goto free_server; } (void)alarm(0); /* Attach config entries to client here rather than in * completed_connection. This to avoid null pointer references * when name returned by gethostbyaddr matches no C lines * (could happen in 2.6.1a when host and servername differ). * No need to check access and do gethostbyaddr calls. * There must at least be one as we got here C line... meLazy */ (void)attach_confs_host(cptr, aconf->host, CFLAG|NFLAG); if (!find_conf_host(cptr->confs, aconf->host, NFLAG) || !find_conf_host(cptr->confs, aconf->host, CFLAG)) { sendto_flag(SCH_NOTICE, "Host %s is not enabled for connecting:no C/N-line", aconf->host); if (by && IsPerson(by) && !MyClient(by)) sendto_one(by, ":%s NOTICE %s :Connect to host %s failed.", ME, by->name, cptr->name); det_confs_butmask(cptr, 0); goto free_server; } /* ** The socket has been connected or connect is in progress. */ if (by && IsPerson(by)) { (void)strcpy(cptr->serv->by, by->name); if (by->user) { strcpy(cptr->serv->byuid, by->user->uid); } cptr->serv->user = by->user; by->user->refcnt++; } else (void)strcpy(cptr->serv->by, "AutoConn."); cptr->serv->up = &me; cptr->serv->maskedby = cptr; cptr->serv->nline = aconf; if (cptr->fd > highest_fd) highest_fd = cptr->fd; add_fd(cptr->fd, &fdall); local[cptr->fd] = cptr; cptr->acpt = &me; SetConnecting(cptr); get_sockhost(cptr, aconf->host); add_client_to_list(cptr); nextping = timeofday; istat.is_unknown++; return 0; } static struct SOCKADDR *connect_inet(aConfItem *aconf, aClient *cptr, int *lenp) { static struct SOCKADDR_IN server; struct SOCKADDR_IN outip; Reg struct hostent *hp; aClient *acptr; int i; /* * Might as well get sockhost from here, the connection is attempted * with it so if it fails its useless. */ cptr->fd = socket(AFINET, SOCK_STREAM, 0); if (cptr->fd >= MAXCLIENTS) { sendto_flag(SCH_NOTICE, "No more connections allowed (%s)", cptr->name); return NULL; } bzero((char *)&server, sizeof(server)); server.SIN_FAMILY = AFINET; get_sockhost(cptr, aconf->host); if (!BadPtr(aconf->source_ip)) { memset(&outip, 0, sizeof(outip)); outip.SIN_PORT = 0; outip.SIN_FAMILY = AFINET; #ifdef INET6 if (!inetpton(AF_INET6, aconf->source_ip, outip.sin6_addr.s6_addr)) #else if ((outip.sin_addr.s_addr = inetaddr(aconf->source_ip)) == -1) #endif { sendto_flag(SCH_ERROR, "Invalid source IP (%s) in C:line", aconf->source_ip); memcpy(&outip, &mysk, sizeof(mysk)); } } else { memcpy(&outip, &mysk, sizeof(mysk)); } if (cptr->fd == -1) { report_error("opening stream socket to server %s:%s", cptr); return NULL; } /* ** Bind to a local IP# (with unknown port - let unix decide) so ** we have some chance of knowing the IP# that gets used for a host ** with more than one IP#. ** With VIFs, M:line defines outgoing IP# and initialises mysk. */ if (bind(cptr->fd, (SAP)&outip, sizeof(outip)) == -1) { report_error("error binding to local port for %s:%s", cptr); return NULL; } /* * By this point we should know the IP# of the host listed in the * conf line, whether as a result of the hostname lookup or the ip# * being present instead. If we don't know it, then the connect fails. */ #ifdef INET6 if (isdigit(*aconf->host) && (AND16(aconf->ipnum.s6_addr) == 255)) if (!inetpton(AF_INET6, aconf->host,aconf->ipnum.s6_addr)) bcopy(minus_one, aconf->ipnum.s6_addr, IN6ADDRSZ); if (AND16(aconf->ipnum.s6_addr) == 255) #else if (isdigit(*aconf->host) && (aconf->ipnum.s_addr == -1)) aconf->ipnum.s_addr = inetaddr(aconf->host); if (aconf->ipnum.s_addr == -1) #endif { hp = cptr->hostp; if (!hp) { Debug((DEBUG_FATAL, "%s: unknown host", aconf->host)); return NULL; } bcopy(hp->h_addr, (char *)&aconf->ipnum, sizeof(struct IN_ADDR)); } bcopy((char *)&aconf->ipnum, (char *)&server.SIN_ADDR, sizeof(struct IN_ADDR)); bcopy((char *)&aconf->ipnum, (char *)&cptr->ip, sizeof(struct IN_ADDR)); cptr->port = (aconf->port > 0) ? aconf->port : portnum; server.SIN_PORT = htons(cptr->port); /* * Look for a duplicate IP#,port pair among already open connections * (This caters for unestablished connections). */ for (i = highest_fd; i >= 0; i--) if ((acptr = local[i]) && !bcmp((char *)&cptr->ip, (char *)&acptr->ip, sizeof(cptr->ip)) && server.SIN_PORT == acptr->port) return NULL; *lenp = sizeof(server); return (struct SOCKADDR *)&server; } #ifdef UNIXPORT /* connect_unix * * Build a socket structure for cptr so that it can connet to the unix * socket defined by the conf structure aconf. */ static struct SOCKADDR *connect_unix(aConfItem *aconf, aClient *cptr, int *lenp) { static struct sockaddr_un sock; if ((cptr->fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { report_error("Unix domain connect to host %s failed: %s", cptr); return NULL; } else if (cptr->fd >= MAXCLIENTS) { sendto_flag(SCH_NOTICE, "No more connections allowed (%s)", cptr->name); return NULL; } get_sockhost(cptr, aconf->host); strncpyzt(sock.sun_path, aconf->host + 2, sizeof(sock.sun_path)); sock.sun_family = AF_UNIX; *lenp = strlen(sock.sun_path) + 2; SetUnixSock(cptr); return (struct sockaddr *)&sock; } #endif /* * The following section of code performs summoning of users to irc. */ #if defined(ENABLE_SUMMON) || defined(USERS_SHOWS_UTMP) int utmp_open(void) { #ifdef O_NOCTTY return (open(UTMP, O_RDONLY|O_NOCTTY)); #else return (open(UTMP, O_RDONLY)); #endif } int utmp_read(int fd, char *name, char *line, char *host, int hlen) { struct utmp ut; while (read(fd, (char *)&ut, sizeof (struct utmp)) == sizeof (struct utmp)) { strncpyzt(name, ut.ut_name, 9); strncpyzt(line, ut.ut_line, 10); #ifdef USER_PROCESS # if defined(HPUX) || defined(AIX) strncpyzt(host,(ut.ut_host[0]) ? (ut.ut_host) : ME, 16); # else strncpyzt(host, ME, 9); # endif if (ut.ut_type == USER_PROCESS) return 0; #else strncpyzt(host, (ut.ut_host[0]) ? (ut.ut_host) : ME, hlen); if (ut.ut_name[0]) return 0; #endif } return -1; } int utmp_close(int fd) { return(close(fd)); } #ifdef ENABLE_SUMMON void summon(aClient *who, char *namebuf, char *linebuf, char *chname) { static char wrerr[] = "NOTICE %s :Write error. Couldn't summon."; int fd; char line[512]; struct tm *tp; tp = localtime(&timeofday); if (strlen(linebuf) > (size_t) 9) { sendto_one(who,"NOTICE %s :Serious fault in SUMMON.", who->name); sendto_one(who, "NOTICE %s :linebuf too long. Inform Administrator", who->name); return; } /* * Following line added to prevent cracking to e.g. /dev/kmem if * UTMP is for some silly reason writable to everyone... */ if ((linebuf[0] != 't' || linebuf[1] != 't' || linebuf[2] != 'y') && (linebuf[0] != 'c' || linebuf[1] != 'o' || linebuf[2] != 'n') && (linebuf[0] != 'p' || linebuf[1] != 't' || linebuf[2] != 's') #ifdef HPUX && (linebuf[0] != 'p' || linebuf[1] != 't' || linebuf[2] != 'y' || linebuf[3] != '/') #endif ) { sendto_one(who, "NOTICE %s :Looks like mere mortal souls are trying to", who->name); sendto_one(who,"NOTICE %s :enter the twilight zone... ", who->name); Debug((0, "%s (%s@%s, nick %s, %s)", "FATAL: major security hack. Notify Administrator !", who->username, who->user->host, who->name, who->info)); return; } sprintf(line,"/dev/%s", linebuf); (void)alarm(5); #ifdef O_NOCTTY if ((fd = open(line, O_WRONLY | O_NDELAY | O_NOCTTY)) == -1) #else if ((fd = open(line, O_WRONLY | O_NDELAY)) == -1) #endif { (void)alarm(0); sendto_one(who, "NOTICE %s :%s seems to have disabled summoning...", who->name, namebuf); return; } #if !defined(O_NOCTTY) && defined(TIOCNOTTY) (void)ioctl(fd, TIOCNOTTY, NULL); #endif (void)alarm(0); (void)sprintf(line,"\n\r\007Message from IRC_Daemon@%s at %d:%02d\n\r", ME, tp->tm_hour, tp->tm_min); if (write(fd, line, strlen(line)) != strlen(line)) { (void)alarm(0); (void)close(fd); sendto_one(who, wrerr, who->name); return; } (void)alarm(0); (void)strcpy(line, "ircd: You are being summoned to Internet Relay \ Chat on\n\r"); (void)alarm(5); if (write(fd, line, strlen(line)) != strlen(line)) { (void)alarm(0); (void)close(fd); sendto_one(who, wrerr, who->name); return; } (void)alarm(0); sprintf(line, "ircd: Channel %s, by %s@%s (%s) %s\n\r", chname, who->user->username, who->user->host, who->name, who->info); (void)alarm(5); if (write(fd, line, strlen(line)) != strlen(line)) { (void)alarm(0); (void)close(fd); sendto_one(who, wrerr, who->name); return; } (void)alarm(0); (void)strcpy(line,"ircd: Respond with irc\n\r"); (void)alarm(5); if (write(fd, line, strlen(line)) != strlen(line)) { (void)alarm(0); (void)close(fd); sendto_one(who, wrerr, who->name); return; } (void)close(fd); (void)alarm(0); sendto_one(who, replies[RPL_SUMMONING], ME, BadTo(who->name), namebuf); return; } # endif #endif /* ENABLE_SUMMON */ /* ** find the real hostname for the host running the server (or one which ** matches the server's name) and its primary IP#. Hostname is stored ** in the client structure passed as a pointer. */ void get_my_name(aClient *cptr, char *name, int len) { static char tmp[HOSTLEN+1]; struct hostent *hp; char *cname = cptr->name; aConfItem *aconf; #ifdef HAVE_GETIPNODEBYNAME int error_num1, error_num2; struct hostent *hp1, *hp2; #endif /* ** Setup local socket structure to use for binding to. */ bzero((char *)&mysk, sizeof(mysk)); mysk.SIN_FAMILY = AFINET; mysk.SIN_PORT = 0; if ((aconf = find_me())->passwd && isdigit(*aconf->passwd)) #ifdef INET6 if(!inetpton(AF_INET6, aconf->passwd, mysk.sin6_addr.s6_addr)) bcopy(minus_one, mysk.sin6_addr.s6_addr, IN6ADDRSZ); #else mysk.sin_addr.s_addr = inetaddr(aconf->passwd); #endif if (gethostname(name, len) == -1) return; name[len] = '\0'; add_local_domain(name, len - strlen(name)); /* ** If hostname gives another name than cname, then check if there is ** a CNAME record for cname pointing to hostname. If so accept ** cname as our name. meLazy */ if (BadPtr(cname)) return; #ifdef HAVE_GETIPNODEBYNAME hp1 = getipnodebyname(cname, AF_INET6, AI_DEFAULT, &error_num1); hp2 = getipnodebyname(name, AF_INET6, AI_DEFAULT, &error_num2); if (! error_num1) hp=hp1; else hp=hp2; if ((! error_num1) || (! error_num2)) #else if ((hp = gethostbyname(cname)) || (hp = gethostbyname(name))) #endif { char *hname; int i = 0; for (hname = hp->h_name; hname; hname = hp->h_aliases[i++]) { strncpyzt(tmp, hname, sizeof(tmp)); add_local_domain(tmp, sizeof(tmp) - strlen(tmp)); /* ** Copy the matching name over and store the ** 'primary' IP# as 'myip' which is used ** later for making the right one is used ** for connecting to other hosts. */ if (!mycmp(ME, tmp)) break; } if (mycmp(ME, tmp)) strncpyzt(name, hp->h_name, len); else strncpyzt(name, tmp, len); #if 0 /* If someone puts IP in M:, fine, use it as outgoing ip, but using resolved M: name for outgoing ip is... troublesome. It can resolve to IP of some other host or 127.0.0.1 (in which case we'd be getting strange errors from connect()); if left empty, OS will decide itself what IP to use; if someone wants to control this, use M: or C: adequate fields. --B. */ if (BadPtr(aconf->passwd)) bcopy(hp->h_addr, (char *)&mysk.SIN_ADDR, sizeof(struct IN_ADDR)); #endif Debug((DEBUG_DEBUG,"local name is %s", get_client_name(&me,TRUE))); } #ifdef HAVE_GETIPNODEBYNAME freehostent(hp1); freehostent(hp2); #endif return; } /* ** setup a UDP socket and listen for incoming packets */ int setup_ping(aConfItem *aconf) { struct SOCKADDR_IN from; int on = 1; if (udpfd != -1) return udpfd; bzero((char *)&from, sizeof(from)); if (aconf->passwd && isdigit(*aconf->passwd)) #ifdef INET6 { if (!inetpton(AF_INET6, aconf->passwd,from.sin6_addr.s6_addr)) bcopy(minus_one, from.sin6_addr.s6_addr, IN6ADDRSZ); } #else from.sin_addr.s_addr = inetaddr(aconf->passwd); #endif else #ifdef INET6 from.SIN_ADDR = in6addr_any; #else from.sin_addr.s_addr = htonl(INADDR_ANY); /* hmmpf */ #endif from.SIN_PORT = htons((u_short) aconf->port); from.SIN_FAMILY = AFINET; if ((udpfd = socket(AFINET, SOCK_DGRAM, 0)) == -1) { Debug((DEBUG_ERROR, "socket udp : %s", strerror(errno))); return -1; } if (SETSOCKOPT(udpfd, SOL_SOCKET, SO_REUSEADDR, &on, on) == -1) { #ifdef USE_SYSLOG syslog(LOG_ERR, "setsockopt udp fd %d : %m", udpfd); #endif Debug((DEBUG_ERROR, "setsockopt so_reuseaddr : %s", strerror(errno))); (void)close(udpfd); return udpfd = -1; } on = 0; (void) SETSOCKOPT(udpfd, SOL_SOCKET, SO_BROADCAST, &on, on); if (bind(udpfd, (SAP)&from, sizeof(from))==-1) { #ifdef USE_SYSLOG syslog(LOG_ERR, "bind udp.%d fd %d : %m", ntohs(from.SIN_PORT), udpfd); #endif Debug((DEBUG_ERROR, "bind : %s", strerror(errno))); (void)close(udpfd); return udpfd = -1; } if (fcntl(udpfd, F_SETFL, FNDELAY)==-1) { Debug((DEBUG_ERROR, "fcntl fndelay : %s", strerror(errno))); (void)close(udpfd); return udpfd = -1; } Debug((DEBUG_INFO, "udpfd = %d, port %d", udpfd,ntohs(from.SIN_PORT))); return udpfd; } void send_ping(aConfItem *aconf) { Ping pi; struct SOCKADDR_IN sin; aCPing *cp = aconf->ping; #ifdef INET6 if (!aconf->ipnum.s6_addr || AND16(aconf->ipnum.s6_addr) == 255 || !cp->port) #else if (!aconf->ipnum.s_addr || aconf->ipnum.s_addr == -1 || !cp->port) #endif return; if (aconf->class->conFreq == 0) /* avoid flooding */ return; pi.pi_cp = aconf; pi.pi_id = htonl(PING_CPING); pi.pi_seq = cp->lseq++; cp->seq++; /* * Only recognise stats from the last 20 minutes as significant... * Try and fake sliding along a "window" here. */ if (cp->seq > 1 && cp->seq * aconf->class->conFreq > 1200) { if (cp->recvd) { cp->ping -= (cp->ping / cp->recvd); if (cp->recvd == cp->seq) cp->recvd--; } else cp->ping = 0; cp->seq--; } bzero((char *)&sin, sizeof(sin)); #ifdef INET6 bcopy(aconf->ipnum.s6_addr, sin.sin6_addr.s6_addr, IN6ADDRSZ); #else sin.sin_addr.s_addr = aconf->ipnum.s_addr; #endif sin.SIN_PORT = htons(cp->port); sin.SIN_FAMILY = AFINET; (void)gettimeofday(&pi.pi_tv, NULL); #ifdef INET6 Debug((DEBUG_SEND,"Send ping to %s,%d fd %d, %d bytes", inet_ntop(AF_INET6, (char *)&aconf->ipnum, ipv6string, sizeof(ipv6string)), cp->port, udpfd, sizeof(pi))); #else Debug((DEBUG_SEND,"Send ping to %s,%d fd %d, %d bytes", inetntoa((char *)&aconf->ipnum), cp->port, udpfd, sizeof(pi))); #endif (void)sendto(udpfd, (char *)&pi, sizeof(pi), 0,(SAP)&sin,sizeof(sin)); } static int check_ping(char *buf, int len) { Ping pi; aConfItem *aconf; struct timeval tv; double d; aCPing *cp = NULL; u_long rtt; (void)gettimeofday(&tv, NULL); if (len < sizeof(pi) + 8) return -1; bcopy(buf, (char *)&pi, sizeof(pi)); /* ensure nice byte align. */ for (aconf = conf; aconf; aconf = aconf->next) if (pi.pi_cp == aconf && (cp = aconf->ping)) break; if (!aconf || match(aconf->name, buf + sizeof(pi))) return -1; cp->recvd++; cp->lrecvd++; rtt = ((tv.tv_sec - pi.pi_tv.tv_sec) * 1000 + (tv.tv_usec - pi.pi_tv.tv_usec) / 1000); cp->ping += rtt; cp->rtt += rtt; if (cp->rtt > 1000000) { cp->ping = (cp->rtt /= cp->lrecvd); cp->recvd = cp->lrecvd = 1; cp->seq = cp->lseq = 1; } d = (double)cp->recvd / (double)cp->seq; d = pow(d, (double)20.0); d = (double)cp->ping / (double)cp->recvd / d; if (d > 10000.0) d = 10000.0; aconf->pref = (int) (d * 100.0); return 0; } /* * max # of pings set to 15/sec. */ static void polludp(void) { static time_t last = 0; static int cnt = 0, mlen = 0, lasterr = 0; Reg char *s; struct SOCKADDR_IN from; Ping pi; int n; SOCK_LEN_TYPE fromlen = sizeof(from); /* * find max length of data area of packet. */ if (!mlen) { mlen = sizeof(readbuf) - strlen(ME) - strlen(version); mlen -= 6; if (mlen < 0) mlen = 0; } Debug((DEBUG_DEBUG,"udp poll")); memset(&from, 0, fromlen); n = recvfrom(udpfd, readbuf, mlen, 0, (SAP)&from, &fromlen); if (n == -1) { ircstp->is_udperr++; if ((errno == EWOULDBLOCK) || (errno == EAGAIN)) return; else { #if 0 /* seems to create more confusion than it's worth */ char buf[100]; sprintf(buf, "udp port recvfrom() from %s to %%s: %%s", #ifdef INET6 from.sin6_addr.s6_addr #else from.sin_addr.s_addr #endif == 0 ? "unknown" : #ifdef INET6 inetntop(AF_INET6, (char *)&from.sin6_addr, ipv6string, sizeof(ipv6string)) #else inetntoa((char *)&from.sin_addr) #endif ); report_error(buf, &me); #endif /* confusion */ return; } } if (timeofday == last) { if (++cnt > 14) { if (timeofday > lasterr + 30) { sendto_flag(SCH_NOTICE, "udp packet dropped: %d bytes from %s.%d", #ifdef INET6 n, inetntop(AF_INET6, (char *)&from.sin6_addr, ipv6string, sizeof(ipv6string)), #else n,inetntoa((char *)&from.sin_addr), #endif ntohs(from.SIN_PORT)); lasterr = timeofday; } ircstp->is_udpdrop++; return; } } else cnt = 0, last = timeofday; #ifdef INET6 Debug((DEBUG_NOTICE, "udp (%d) %d bytes from %s,%d", cnt, n, inet_ntop(AF_INET6, (char *)&from.sin6_addr, ipv6string, sizeof(ipv6string)), ntohs(from.SIN_PORT))); #else Debug((DEBUG_NOTICE, "udp (%d) %d bytes from %s,%d", cnt, n, inetntoa((char *)&from.sin_addr), ntohs(from.SIN_PORT))); #endif readbuf[n] = '\0'; ircstp->is_udpok++; if (n < 8) return; bcopy(s = readbuf, (char *)&pi, MIN(n, sizeof(pi))); pi.pi_id = ntohl(pi.pi_id); Debug((DEBUG_INFO, "\tpi_id %#x pi_seq %d pi_cp %#x", pi.pi_id, pi.pi_seq, pi.pi_cp)); if ((pi.pi_id == (PING_CPING|PING_REPLY) || pi.pi_id == (PING_CPING|(PING_REPLY << 24))) && n >= sizeof(pi)) { check_ping(s, n); return; } else if (pi.pi_id & PING_REPLY) return; /* * attach my name and version for the reply */ pi.pi_id |= PING_REPLY; pi.pi_id = htonl(pi.pi_id); bcopy((char *)&pi, s, MIN(n, sizeof(pi))); s += n; (void)strcpy(s, ME); s += strlen(s)+1; (void)strcpy(s, version); s += strlen(s); (void)sendto(udpfd, readbuf, s-readbuf, 0, (SAP)&from ,sizeof(from)); return; } /* * do_dns_async * * Called when the fd returned from init_resolver() has been selected for * reading. */ static void do_dns_async(void) { static Link ln; aClient *cptr; aConfItem *aconf; struct hostent *hp; int bytes, pkts; pkts = 0; do { ln.flags = -1; hp = get_res((char *)&ln); Debug((DEBUG_DNS,"%#x = get_res(%d,%#x)", hp, ln.flags, ln.value.cptr)); switch (ln.flags) { case ASYNC_NONE : /* * no reply was processed that was outstanding or * had a client still waiting. */ break; case ASYNC_CLIENT : if ((cptr = ln.value.cptr)) { del_queries((char *)cptr); ClearDNS(cptr); cptr->hostp = hp; #if defined(USE_IAUTH) if (hp) { int i = 0; while (hp->h_aliases[i]) sendto_iauth("%d A %s", cptr->fd, hp->h_aliases[i++]); if (hp->h_name) sendto_iauth("%d N %s", cptr->fd, hp->h_name); else if (hp->h_aliases[0]) sendto_iauth("%d n", cptr->fd); } else sendto_iauth("%d d", cptr->fd); if (iauth_options & XOPT_EXTWAIT) cptr->lasttime = timeofday; #endif } break; case ASYNC_CONNECT : aconf = ln.value.aconf; if (hp && aconf) { bcopy(hp->h_addr, (char *)&aconf->ipnum, sizeof(struct IN_ADDR)); (void)connect_server(aconf, NULL, hp); } else sendto_flag(SCH_ERROR, "Connect to %s failed: host lookup", (aconf) ? aconf->host : "unknown"); break; case ASYNC_CONF : aconf = ln.value.aconf; if (hp && aconf) bcopy(hp->h_addr, (char *)&aconf->ipnum, sizeof(struct IN_ADDR)); break; default : break; } pkts++; if (ioctl(resfd, FIONREAD, &bytes) == -1) bytes = 0; } while ((bytes > 0) && (pkts < 10)); } #ifdef DELAY_CLOSE /* * Delaying close(2) on too rapid connections reduces cpu * and bandwidth usage. Not mentioning disk space, if you * log such crap. * * Based on Ari `DLR' Heikkinen irce0.9.1 * by Piotr `Beeth' Kucharski * * Note: calling with fd == -2 closes all delayed fds. */ time_t delay_close(int fd) { struct fdlog { struct fdlog *next; int fd; time_t time; }; static struct fdlog *first = NULL, *last = NULL; struct fdlog *next = first, *tmp; int tmpdel = 0; if (fd == -2) { /* special case used in m_close() -- close all! */ tmpdel = istat.is_delayclosewait; } else /* Make sure we don't delay close() on too many fds. If we have * kept more than half (possibly) available fds for clients * waiting to be closed, release quarter oldest of them. * >>1, >>2 are faster equivalents of /2, /4 --B. */ if (istat.is_delayclosewait > (MAXCLIENTS-istat.is_localc) >> 1) { tmpdel = istat.is_delayclosewait >> 2; } while ((tmp = next)) { if (tmp->time < timeofday || tmpdel-- > 0) { next = tmp->next; (void)send(fd, "ERROR :Too rapid connections " "from your host\r\n", 46, 0); close(tmp->fd); MyFree(tmp); istat.is_delayclosewait--; if (!next) { last = NULL; } first = next; } else { /* This linked list has entries chronologically * sorted, so if tmp is not old enough, all next * would also be not old enough to close. */ break; } } if (fd >= 0) { /* set socket in nonblocking state (just in case) */ set_non_blocking(fd, NULL); /* disallow further receives */ shutdown(fd, SHUT_RD); /* create a new entry with fd and time of close */ tmp = (struct fdlog *)MyMalloc(sizeof(*tmp)); tmp->next = NULL; tmp->fd = fd; tmp->time = timeofday + DELAY_CLOSE; istat.is_delayclosewait++; istat.is_delayclose++; /* then add it to the list */ if (last) { last->next = tmp; last = tmp; } else { first = last = tmp; } } return first ? first->time : 0; } #endif irc2.11.2p3/ircd/s_auth_ext.h0000644000175000017500000000315107744057363013610 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/s_auth_ext.h * Copyright (C) 1997 Alain Nissen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/s_auth.c. */ /* External definitions for global functions. */ #ifndef S_AUTH_C # if defined(USE_IAUTH) extern u_char iauth_options; extern u_int iauth_spawn; # endif # # define EXTERN extern #else /* S_AUTH_C */ # define EXTERN #endif /* S_AUTH_C */ #if defined(USE_IAUTH) EXTERN int vsendto_iauth (char *pattern, va_list va); EXTERN int sendto_iauth (char *pattern, ...); EXTERN void read_iauth(void); EXTERN void report_iauth_conf (aClient *, char *); EXTERN void report_iauth_stats (aClient *, char *); #endif EXTERN void start_auth (Reg aClient *cptr); EXTERN void send_authports (aClient *cptr); EXTERN void read_authports (Reg aClient *cptr); #undef EXTERN irc2.11.2p3/ircd/res_comp_ext.h0000644000175000017500000000347607744057363014146 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/res_comp_ext.h * Copyright (C) 1997 Alain Nissen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/res_comp.c. */ /* External definitions for global functions. */ #ifndef RES_COMP_C #define EXTERN extern #else /* RES_COMP_C */ #define EXTERN #endif /* RES_COMP_C */ EXTERN int ircd_dn_expand (const u_char *msg, const u_char *eomorig, const u_char *comp_dn, char *exp_dn, int length); EXTERN int ircd_dn_comp (const char *exp_dn, u_char *comp_dn, int length, u_char **dnptrs, u_char **lastdnptr); EXTERN int __ircd_dn_skipname (const u_char *comp_dn, const u_char *eom); EXTERN u_int16_t ircd_getshort (register const u_char *msgp); EXTERN u_int32_t ircd_getlong (register const u_char *msgp); EXTERN void ircd__putshort (register u_int16_t s, register u_char *msgp); EXTERN void ircd__putlong (register u_int32_t l, register u_char *msgp); #ifdef NEXT EXTERN u_int16_t res_getshort (register const u_char *msgp); #endif /* NEXT */ #undef EXTERN irc2.11.2p3/ircd/list_ext.h0000644000175000017500000000466110103461240013257 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/list_ext.h * Copyright (C) 1997 Alain Nissen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/list.c. */ /* External definitions for global variables. */ #ifndef LIST_C extern anUser *usrtop; extern aServer *svrtop; extern int numclients; extern const char *DefInfo; #endif /* LIST_C */ /* External definitions for global functions. */ #ifndef LIST_C #define EXTERN extern #else /* LIST_C */ #define EXTERN #endif /* LIST_C */ EXTERN void initlists(void); EXTERN void outofmemory(void); #ifdef DEBUGMODE EXTERN void checklists(void); EXTERN void send_listinfo (aClient *cptr, char *name); #endif /* DEBUGMOE */ EXTERN aClient *make_client (aClient *from); EXTERN void free_client (aClient *cptr); EXTERN anUser *make_user (aClient *cptr, int iplen); EXTERN aServer *make_server (aClient *cptr); EXTERN void free_user (anUser *user); EXTERN void free_server (aServer *serv); EXTERN void remove_client_from_list (Reg aClient *cptr); EXTERN void reorder_client_in_list (aClient *cptr); EXTERN void add_client_to_list (aClient *cptr); EXTERN Link *find_user_link (Reg Link *lp, Reg aClient *ptr); EXTERN Link *find_channel_link (Reg Link *lp, Reg aChannel *ptr); EXTERN Link *make_link(void); EXTERN invLink *make_invlink(void); EXTERN void free_link (Reg Link *lp); EXTERN void free_invlink (Reg invLink *lp); EXTERN aClass *make_class(void); EXTERN void free_class (Reg aClass *tmp); EXTERN aConfItem *make_conf(void); EXTERN void delist_conf (aConfItem *aconf); EXTERN void free_conf (aConfItem *aconf); EXTERN void add_fd (int fd, FdAry *ary); EXTERN int del_fd (int fd, FdAry *ary); #undef EXTERN irc2.11.2p3/ircd/s_bsd_ext.h0000644000175000017500000000640610166301003013374 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/s_bsd_ext.h * Copyright (C) 1997 Alain Nissen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/s_bsd.c. */ /* External definitions for global variables. */ #ifndef S_BSD_C extern aClient *local[]; extern FdAry fdas, fdaa, fdall; extern int highest_fd, readcalls, udpfd, resfd, adfd; extern time_t timeofday; #endif /* S_BSD_C */ /* External definitions for global functions. */ #ifndef S_BSD_C #define EXTERN extern #else /* S_BSD_C */ #define EXTERN #endif /* S_BSD_C */ EXTERN void add_local_domain (char *hname, size_t size); EXTERN void report_error (char *text, aClient *cptr); EXTERN int inetport (aClient *cptr, char *ip, char *ipmask, int port, int dolisten); EXTERN int add_listener (aConfItem *aconf); EXTERN void close_listeners(void); EXTERN void open_listener(aClient *cptr); EXTERN void reopen_listeners(void); EXTERN void activate_delayed_listeners(void); EXTERN void start_iauth (int); EXTERN void init_sys(void); EXTERN void daemonize(void); EXTERN void write_pidfile(void); EXTERN int check_client (Reg aClient *cptr); EXTERN int check_server_init (aClient *cptr); EXTERN int check_server (aClient *cptr, Reg struct hostent *hp, Reg aConfItem *c_conf, Reg aConfItem *n_conf); EXTERN void close_connection (aClient *cptr); EXTERN void close_client_fd(aClient *cptr); EXTERN int get_sockerr (aClient *cptr); EXTERN void set_non_blocking (int fd, aClient *cptr); EXTERN aClient *add_connection (aClient *cptr, int fd); EXTERN int read_message (time_t delay, FdAry *fdp, int ro); EXTERN int connect_server (aConfItem *aconf, aClient *by, struct hostent *hp); EXTERN void get_my_name (aClient *cptr, char *name, int len); EXTERN int setup_ping (aConfItem *aconf); EXTERN void send_ping (aConfItem *aconf); #if defined(ENABLE_SUMMON) || defined(ENABLE_USERS) EXTERN int utmp_open(void); EXTERN int utmp_read (int fd, char *name, char *line, char *host, int hlen); EXTERN int utmp_close(int fd); #ifdef ENABLE_SUMMON EXTERN void summon (aClient *who, char *namebuf, char *linebuf, char *chname); #endif /* ENABLE_SUMMON */ #endif /* ENABLE_SUMMON || ENABLE_USERS */ #ifdef UNIXPORT EXTERN int unixport (aClient *cptr, char *path, int port); #endif #ifdef DELAY_CLOSE EXTERN time_t delay_close (int); #endif #undef EXTERN #ifdef DELAY_CLOSE #ifndef SHUT_RD # error SHUT_RD not defined! Report buggy OS to ircd-bugs@irc.org /* Check shutdown(3) manpage for proper definition. */ # define SHUT_RD 0 #endif #endif irc2.11.2p3/ircd/ircd_ext.h0000644000175000017500000000401010074304452013221 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/ircd_ext.h * Copyright (C) 1997 Alain Nissen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/ircd.c. */ /* External definitions for global variables. */ #ifndef IRCD_C extern aClient me; extern aClient *client; extern istat_t istat; extern iconf_t iconf; extern char **myargv; extern int rehashed; extern int portnum; extern int serverbooting; extern int firstrejoindone; extern char *configfile; extern int debuglevel; extern int bootopt; extern char *debugmode; extern char *sbrk0; extern char *tunefile; #ifdef DELAY_CLOSE extern time_t nextdelayclose; #endif extern time_t nextconnect; extern time_t nextgarbage; extern time_t nextping; extern time_t nextdnscheck; extern time_t nextexpire; #ifdef TKLINE extern time_t nexttkexpire; #endif extern aClient *ListenerLL; #endif /* IRCD_C */ /* External definitions for global functions. */ #ifndef IRCD_C #define EXTERN extern #else /* IRCD_C */ #define EXTERN #endif /* IRCD_C */ EXTERN RETSIGTYPE s_die (int s); EXTERN void restart (char *mesg); EXTERN RETSIGTYPE s_restart (int s); EXTERN void server_reboot(void); EXTERN void ircd_writetune (char *filename); EXTERN void ircd_readtune (char *filename); #undef EXTERN irc2.11.2p3/ircd/s_defines.h0000644000175000017500000000252210062454503013365 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/s_defines.h * Copyright (C) 1997 Alain Nissen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file includes all files defining constants, macros and types definitions used by the IRC server. */ #include "config.h" #include "patchlevel.h" #include "common_def.h" #include "dbuf_def.h" #include "class_def.h" #include "struct_def.h" #include "numeric_def.h" #include "support_def.h" #include "channel_def.h" #include "hash_def.h" #include "res_def.h" #include "whowas_def.h" #include "service_def.h" #include "sys_def.h" #include "resolv_def.h" #include "nameser_def.h" irc2.11.2p3/ircd/hash_ext.h0000644000175000017500000000544011023575375013244 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/hash_ext.h * Copyright (C) 1997 Alain Nissen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/hash.c. */ /* External definitions for global variables. */ #ifndef HASH_C extern int _HASHSIZE; extern int _UIDSIZE; extern int _CHANNELHASHSIZE; extern int _SIDSIZE; #ifdef USE_HOSTHASH extern int _HOSTNAMEHASHSIZE; #endif #ifdef USE_IPHASH extern int _IPHASHSIZE; #endif #endif /* HASH_C */ /* External definitions for global functions. */ #ifndef HASH_C #define EXTERN extern #else /* HASH_C */ #define EXTERN #endif /* HASH_C */ EXTERN void inithashtables(void); EXTERN int add_to_client_hash_table (char *name, aClient *cptr); EXTERN int add_to_uid_hash_table (char *uid, aClient *cptr); EXTERN int add_to_channel_hash_table (char *name, aChannel *chptr); EXTERN int add_to_sid_hash_table (char *sid, aClient *cptr); EXTERN int del_from_client_hash_table (char *name, aClient *cptr); EXTERN int del_from_uid_hash_table (char *uid, aClient *cptr); EXTERN int del_from_channel_hash_table (char *name, aChannel *chptr); EXTERN int del_from_sid_hash_table (aServer *sptr); EXTERN aClient *hash_find_client (char *name, aClient *cptr); EXTERN aClient *hash_find_uid (char *uid, aClient *cptr); EXTERN aClient *hash_find_server (char *server, aClient *cptr); EXTERN aChannel *hash_find_channel (char *name, aChannel *chptr); EXTERN aChannel *hash_find_channels (char *name, aChannel *chptr); EXTERN aClient *hash_find_sid (char *sid, aClient *cptr); #ifdef USE_HOSTHASH EXTERN int add_to_hostname_hash_table (char *hostname, anUser *user); EXTERN int del_from_hostname_hash_table (char *hostname, anUser *user); EXTERN anUser *hash_find_hostname (char *hostname, anUser *user); #endif #ifdef USE_IPHASH EXTERN int add_to_ip_hash_table (char *ip, anUser *user); EXTERN int del_from_ip_hash_table (char *ip, anUser *user); EXTERN anUser *hash_find_ip (char *ip, anUser *user); #endif EXTERN int m_hash (aClient *cptr, aClient *sptr, int parc, char *parv[]); #undef EXTERN irc2.11.2p3/ircd/whowas_def.h0000644000175000017500000000216607364335412013570 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/whowas_def.h * Copyright (C) 1990 Markku Savela * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* ** WHOWAS structure moved here from whowas.c */ typedef struct aname { anUser *ww_user; aClient *ww_online; time_t ww_logout; char ww_nick[NICKLEN+1]; char ww_info[REALLEN+1]; } aName; typedef struct alock { time_t logout; char nick[NICKLEN + 1]; } aLock; irc2.11.2p3/ircd/res_ext.h0000644000175000017500000000324407744057363013121 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/res_ext.h * Copyright (C) 1997 Alain Nissen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/res.c. */ /* External definitions for global functions. */ #ifndef RES_C #define EXTERN extern #else /* RES_C */ #define EXTERN #endif /* RES_C */ extern int init_resolver (int op); EXTERN time_t timeout_query_list (time_t now); EXTERN void del_queries (char *cp); EXTERN struct hostent *gethost_byname (char *name, Link *lp); EXTERN struct hostent *gethost_byname_type (char *name, Link *lp, int type); EXTERN struct hostent *gethost_byaddr (char *addr, Link *lp); EXTERN struct hostent *get_res (char *lp); EXTERN time_t expire_cache (time_t now); EXTERN void flush_cache(void); EXTERN int m_dns (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN u_long cres_mem (aClient *sptr, char *nick); #undef EXTERN irc2.11.2p3/ircd/s_service_ext.h0000644000175000017500000000370211022664302014266 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/s_service_ext.h * Copyright (C) 1997 Alain Nissen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/s_service.c. */ /* External definitions for global variables. */ #ifndef S_SERVICE_C extern aService *svctop; #endif /* External definitions for global functions. */ #ifndef S_SERVICE_C #define EXTERN extern #else /* S_SERVICE_C */ #define EXTERN #endif /* S_SERVICE_C */ EXTERN aService *make_service (aClient *cptr); EXTERN void free_service (aClient *cptr); #ifdef USE_SERVICES EXTERN void check_services_butone (long action, aServer *servp, aClient *cptr, char *fmt, ...); EXTERN void check_services_num (aClient *sptr, char *umode); EXTERN aConfItem *find_conf_service (aClient *cptr, int type, aConfItem *aconf); EXTERN int m_servset (aClient *cptr, aClient *sptr, int parc, char *parv[]); #endif /* USE_SERVICES */ EXTERN int m_service (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_servlist (aClient *cptr, aClient *sptr, int parc, char *parv[]); EXTERN int m_squery (aClient *cptr, aClient *sptr, int parc, char *parv[]); #undef EXTERN irc2.11.2p3/ircd/class_ext.h0000644000175000017500000000346311022346576013427 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/class_ext.h * Copyright (C) 1997 Alain Nissen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/class.c. */ /* External definitions for global variables. */ #ifndef CLASS_C extern aClass *classes; #endif /* CLASS_C */ /* External definitions for global functions. */ #ifndef CLASS_C #define EXTERN extern #else /* CLASS_C */ #define EXTERN #endif /* CLASS_C */ EXTERN int get_conf_class (aConfItem *aconf); EXTERN int get_client_class (aClient *acptr); EXTERN int get_client_ping (aClient *acptr); EXTERN int get_con_freq (aClass *clptr); EXTERN void add_class (int class, int ping, int confreq, int maxli, int sendq, int bsendq, int hlocal, int uhlocal, int hglobal, int uhglobal #ifdef ENABLE_CIDR_LIMITS , char * #endif ); EXTERN aClass *find_class (int cclass); EXTERN void check_class(void); EXTERN void initclass(void); EXTERN void report_classes (aClient *sptr, char *to); EXTERN int get_sendq (aClient *cptr, int); #undef EXTERN irc2.11.2p3/ircd/class.c0000644000175000017500000001636011027474443012542 0ustar kkkk/* * IRC - Internet Relay Chat, ircd/class.c * Copyright (C) 1990 Darren Reed * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: class.c,v 1.28 2008/06/22 16:09:07 chopin Exp $"; #endif #include "os.h" #include "s_defines.h" #define CLASS_C #include "s_externs.h" #undef CLASS_C #ifdef ENABLE_CIDR_LIMITS #include "patricia_ext.h" #endif #define BAD_CONF_CLASS -1 #define BAD_PING -2 #define BAD_CLIENT_CLASS -3 aClass *classes; int get_conf_class(aConfItem *aconf) { if ((aconf) && Class(aconf)) return (ConfClass(aconf)); Debug((DEBUG_DEBUG,"No Class For %s", (aconf) ? aconf->name : "*No Conf*")); return (BAD_CONF_CLASS); } static int get_conf_ping(aConfItem *aconf) { if ((aconf) && Class(aconf)) return (ConfPingFreq(aconf)); Debug((DEBUG_DEBUG,"No Ping For %s", (aconf) ? aconf->name : "*No Conf*")); return (BAD_PING); } int get_client_class(aClient *acptr) { Reg Link *tmp; Reg aClass *cl; int retc = BAD_CLIENT_CLASS; if (acptr && !IsMe(acptr) && (acptr->confs)) for (tmp = acptr->confs; tmp; tmp = tmp->next) { if (!tmp->value.aconf || !(cl = tmp->value.aconf->class)) continue; retc = Class(cl); break; } Debug((DEBUG_DEBUG,"Returning Class %d For %s",retc,acptr->name)); return (retc); } int get_client_ping(aClient *acptr) { int ping = 0, ping2; aConfItem *aconf; Link *link; link = acptr->confs; if (link) while (link) { aconf = link->value.aconf; if (aconf->status & (CONF_CLIENT|CONF_CONNECT_SERVER| CONF_NOCONNECT_SERVER| CONF_ZCONNECT_SERVER)) { ping2 = get_conf_ping(aconf); if ((ping2 != BAD_PING) && ((ping > ping2) || !ping)) ping = ping2; } link = link->next; } else { ping = PINGFREQUENCY; Debug((DEBUG_DEBUG,"No Attached Confs")); } if (ping <= 0) ping = PINGFREQUENCY; Debug((DEBUG_DEBUG,"Client %s Ping %d", acptr->name, ping)); return (ping); } int get_con_freq(aClass *clptr) { if (clptr) return (MAX(60, ConFreq(clptr))); else return (CONNECTFREQUENCY); } /* * When adding a class, check to see if it is already present first. * if so, then update the information for that class, rather than create * a new entry for it and later delete the old entry. * if no present entry is found, then create a new one and add it in * immeadiately after the first one (class 0). */ void add_class(int class, int ping, int confreq, int maxli, int sendq, int bsendq, int hlocal, int uhlocal, int hglobal, int uhglobal #ifdef ENABLE_CIDR_LIMITS , char *cidrlen_s #endif ) { aClass *t, *p; #ifdef ENABLE_CIDR_LIMITS char *tmp; int cidrlen = 0, cidramount = 0; if(cidrlen_s) { if((tmp = index(cidrlen_s, '/'))) { *tmp++ = '\0'; cidramount = atoi(cidrlen_s); cidrlen = atoi(tmp); } } #endif t = find_class(class); if ((t == classes) && (class != 0)) { p = (aClass *)make_class(); NextClass(p) = NextClass(t); NextClass(t) = p; MaxSendq(p) = QUEUELEN; #ifdef ENABLE_CIDR_LIMITS CidrLen(p) = 0; p->ip_limits = NULL; #endif istat.is_class++; } else p = t; Debug((DEBUG_DEBUG, "Add Class %d: p %x t %x - cf: %d pf: %d ml: %d sq: %d.%d ml: %d.%d mg: %d.%d", class, p, t, confreq, ping, maxli, sendq, bsendq, hlocal, uhlocal, hglobal, uhglobal)); Class(p) = class; ConFreq(p) = confreq; PingFreq(p) = ping; MaxLinks(p) = maxli; if (sendq) MaxSendq(p) = sendq; MaxBSendq(p) = bsendq ? bsendq : 0; MaxHLocal(p) = hlocal; MaxUHLocal(p) = uhlocal; MaxHGlobal(p) = hglobal; MaxUHGlobal(p) = uhglobal; #ifdef ENABLE_CIDR_LIMITS if (cidrlen > 0 && CidrLen(p) == 0 && p->ip_limits == NULL) { CidrLen(p) = cidrlen; # ifdef INET6 p->ip_limits = (struct _patricia_tree_t *) patricia_new(128); # else p->ip_limits = (struct _patricia_tree_t *) patricia_new(32); # endif } if (CidrLen(p) != cidrlen) { /* Hmpf, sendto_somewhere maybe to warn? --B. */ Debug((DEBUG_NOTICE, "Cannot change cidrlen on the fly (class %d)", Class(p))); } if (CidrLen(p) > 0) MaxCidrAmount(p) = cidramount; #endif if (p != t) Links(p) = 0; } aClass *find_class(int cclass) { aClass *cltmp; for (cltmp = FirstClass(); cltmp; cltmp = NextClass(cltmp)) if (Class(cltmp) == cclass) return cltmp; return classes; } void check_class(void) { Reg aClass *cltmp, *cltmp2; Debug((DEBUG_DEBUG, "Class check:")); for (cltmp2 = cltmp = FirstClass(); cltmp; cltmp = NextClass(cltmp2)) { Debug((DEBUG_DEBUG, "Class %d : CF: %d PF: %d ML: %d LI: %d SQ: %ld", Class(cltmp), ConFreq(cltmp), PingFreq(cltmp), MaxLinks(cltmp), Links(cltmp), MaxSendq(cltmp))); if (MaxLinks(cltmp) < 0) { NextClass(cltmp2) = NextClass(cltmp); if (Links(cltmp) <= 0) { free_class(cltmp); istat.is_class--; } } else cltmp2 = cltmp; } } void initclass(void) { classes = (aClass *)make_class(); istat.is_class++; Class(FirstClass()) = 0; ConFreq(FirstClass()) = CONNECTFREQUENCY; PingFreq(FirstClass()) = PINGFREQUENCY; MaxLinks(FirstClass()) = MAXIMUM_LINKS; MaxSendq(FirstClass()) = QUEUELEN; MaxBSendq(FirstClass()) = 0; Links(FirstClass()) = 0; NextClass(FirstClass()) = NULL; MaxHLocal(FirstClass()) = 1; MaxUHLocal(FirstClass()) = 1; MaxHGlobal(FirstClass()) = 1; MaxUHGlobal(FirstClass()) = 1; #ifdef ENABLE_CIDR_LIMITS CidrLen(FirstClass()) = 0; FirstClass()->ip_limits = NULL; #endif } void report_classes(aClient *sptr, char *to) { Reg aClass *cltmp; char tmp[64] = ""; for (cltmp = FirstClass(); cltmp; cltmp = NextClass(cltmp)) { #ifdef ENABLE_CIDR_LIMITS if (MaxCidrAmount(cltmp) > 0 && CidrLen(cltmp) > 0) /* leading space is important */ snprintf(tmp, sizeof(tmp), " %d/%d", MaxCidrAmount(cltmp), CidrLen(cltmp)); else tmp[0] = '\0'; #endif sendto_one(sptr, replies[RPL_STATSYLINE], ME, BadTo(to), 'Y', Class(cltmp), PingFreq(cltmp), ConFreq(cltmp), MaxLinks(cltmp), MaxSendq(cltmp), MaxBSendq(cltmp), MaxHLocal(cltmp), MaxUHLocal(cltmp), MaxHGlobal(cltmp), MaxUHGlobal(cltmp), Links(cltmp), tmp); } } int get_sendq(aClient *cptr, int bursting) { Reg int sendq = QUEUELEN; Reg Link *tmp; Reg aClass *cl; if (cptr->serv && cptr->serv->nline) sendq = bursting && MaxBSendq(cptr->serv->nline->class) ? MaxBSendq(cptr->serv->nline->class) : MaxSendq(cptr->serv->nline->class); else if (cptr && !IsMe(cptr) && (cptr->confs)) for (tmp = cptr->confs; tmp; tmp = tmp->next) { if (!tmp->value.aconf || !(cl = tmp->value.aconf->class)) continue; sendq = bursting && MaxBSendq(cl) ? MaxBSendq(cl) : MaxSendq(cl); break; } return sendq; } irc2.11.2p3/ircd/config_read.c0000644000175000017500000001512510241163100013651 0ustar kkkk/* "@(#)$Id: config_read.c,v 1.33 2005/05/13 17:39:12 chopin Exp $"; */ /* used in config_error() */ #define CF_NONE 0 #define CF_WARN 1 #define CF_ERR 2 /* max file length */ #define FILEMAX 255 /* max nesting depth. ircd.conf itself is depth = 0 */ #define MAXDEPTH 13 #if defined(__sun) || defined(__sun__) || defined(sun) /* Sun has a buggy implementation of FILE functions ** (they do not work when fds 0-255 are already used). ** ircd-ratbox 1.5-3 had a nice reimplementation, so I took it. --B. */ #define FILE FBFILE #define fclose fbclose #define fdopen fdbopen #define fgets fbgets #define fopen fbopen #if !defined(HAVE_STRLCPY) #define strlcpy(x, y, N) strncpyzt((x), (y), (N)) #endif #include "fileio.c" #endif typedef struct File aFile; struct File { char *filename; int includeline; aFile *parent; aFile *next; }; typedef struct Config aConfig; struct Config { char *line; int linenum; aFile *file; aConfig *next; }; #ifdef CONFIG_DIRECTIVE_INCLUDE static aConfig *config_read(FILE *, int, aFile *); static void config_free(aConfig *); aFile *new_config_file(char *, aFile *, int); void config_error(int, aFile *, int, char *, ...); #else void config_error(int, char *, int, char *, ...); #endif #ifdef CONFIG_DIRECTIVE_INCLUDE /* ** Syntax of include is simple (but very strict): ** #include "filename" ** # must be first char on the line, word include, one space, then ", ** filename and another " must be the last char on the line. ** If filename does not start with slash, it's loaded from IRCDCONF_DIR. */ /* read from supplied fd, putting line by line onto aConfig struct. ** calls itself recursively for each #include directive */ aConfig *config_read(FILE *fd, int depth, aFile *curfile) { int linenum = 0; aConfig *ConfigTop = NULL; aConfig *ConfigCur = NULL; char line[BUFSIZE+1]; FILE *fdn; if (curfile == NULL) { curfile = new_config_file(configfile, NULL, 0); } while (NULL != (fgets(line, sizeof(line), fd))) { char *p; aConfig *new; int linelen; linenum++; if ((p = strchr(line, '\n')) != NULL) *p = '\0'; if ((p = strchr(line, '\r')) != NULL) *p = '\0'; if (*line == '\0') continue; linelen = strlen(line); if (*line == '#' && strncasecmp(line + 1, "include ", 8) == 0) { char *start = line + 9; char *end = line + linelen - 1; char file[FILEMAX + 1]; char *filep = file; char *savefilep; aConfig *ret; aFile *tcf; /* eat all white chars around filename */ while (isspace(*end)) { end--; } while (isspace(*start)) { start++; } /* remove quotes, when they're both there */ if (*start == '"' && *end == '"') { start++; end--; } if (start >= end) { config_error(CF_ERR, curfile, linenum, "config: empty include"); goto eatline; } *filep = '\0'; if (depth >= MAXDEPTH) { config_error(CF_ERR, curfile, linenum, "config: too nested (max %d)", depth); goto eatline; } if (*start != '/') { filep += snprintf(file, FILEMAX, "%s", IRCDCONF_DIR); } if ((end - start) + (filep - file) >= FILEMAX) { config_error(CF_ERR, curfile, linenum, "too long filename (max %d with " "path)", FILEMAX); goto eatline; } savefilep = filep; memcpy(filep, start, (end - start) + 1); filep += (end - start) + 1; *filep = '\0'; for (tcf = curfile; tcf; tcf = tcf->parent) { if (0 == strcmp(tcf->filename, file)) { config_error(CF_ERR, curfile, linenum, "would loop include"); goto eatline; } } if ((fdn = fopen(file, "r")) == NULL) { config_error(CF_ERR, curfile, linenum, "cannot open \"%s\"", savefilep); goto eatline; } ret = config_read(fdn, depth + 1, new_config_file(file, curfile, linenum)); fclose(fdn); if (ConfigCur) { ConfigCur->next = ret; } else { ConfigTop = ret; ConfigCur = ret; } while ((ConfigCur && ConfigCur->next)) { ConfigCur = ConfigCur->next; } /* good #include is replaced by its content */ continue; } eatline: new = (aConfig *)MyMalloc(sizeof(aConfig)); new->line = (char *) MyMalloc((linelen+1) * sizeof(char)); memcpy(new->line, line, linelen); new->line[linelen] = '\0'; new->linenum = linenum; new->file = curfile; new->next = NULL; if (ConfigCur) { ConfigCur->next = new; } else { ConfigTop = new; } ConfigCur = new; } return ConfigTop; } /* should be called with topmost config struct */ void config_free(aConfig *cnf) { aConfig *p; aFile *pf, *pt; if (cnf == NULL) { return; } pf = cnf->file; while(pf) { pt = pf; pf = pf->next; MyFree(pt->filename); MyFree(pt); } while (cnf) { p = cnf; cnf = cnf->next; MyFree(p->line); MyFree(p); } return; } aFile *new_config_file(char *filename, aFile *parent, int fnr) { aFile *tmp = (aFile *) MyMalloc(sizeof(aFile)); tmp->filename = mystrdup(filename); tmp->includeline = fnr; tmp->parent = parent; tmp->next = NULL; /* First get to the root of the file tree */ while (parent && parent->parent) { parent = parent->parent; } /* Then go to the end to add a new one */ while (parent && parent->next) { parent = parent->next; } if (parent) { parent->next = tmp; } return tmp; } #endif /* CONFIG_DIRECTIVE_INCLUDE */ #ifdef CONFIG_DIRECTIVE_INCLUDE void config_error(int level, aFile *curF, int line, char *pattern, ...) #else void config_error(int level, char *filename, int line, char *pattern, ...) #endif { static int etclen = 0; va_list va; char vbuf[8192]; char *filep; #ifdef CONFIG_DIRECTIVE_INCLUDE char *filename = curF->filename; #endif if (!etclen) { etclen = strlen(IRCDCONF_DIR); } va_start(va, pattern); vsprintf(vbuf, pattern, va); va_end(va); /* no need to show full path, if the same dir */ filep = filename; if (0 == strncmp(filename, IRCDCONF_DIR, etclen)) filep += etclen; #ifdef CHKCONF_COMPILE if (level == CF_NONE) { fprintf(stdout, "%s\n", vbuf); } else { fprintf(stderr, "%s:%d %s%s\n", filep, line, ((level == CF_ERR) ? "ERROR: " : "WARNING: "), vbuf); # ifdef CONFIG_DIRECTIVE_INCLUDE while ((curF && curF->parent)) { filep = curF->parent->filename; if (0 == strncmp(filep, IRCDCONF_DIR, etclen)) filep += etclen; fprintf(stderr, "\tincluded in %s:%d\n", filep, curF->includeline); curF = curF->parent; } # endif } #else if (level != CF_ERR) return; /* for ircd &ERRORS reporting show only config file name, ** without full path. --B. */ if (filep[0] == '/') filep = strrchr(filename, '/') + 1; sendto_flag(SCH_ERROR, "config %s:%d %s", filep, line, vbuf); #endif return; } irc2.11.2p3/ircd/whowas.c0000644000175000017500000002571710147406320012742 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/whowas.c * Copyright (C) 1990 Markku Savela * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * --- avalon --- 6th April 1992 * rewritten to scrap linked lists and use a table of structures which * is referenced like a circular loop. Should be faster and more efficient. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: whowas.c,v 1.12 2004/11/19 15:10:08 chopin Exp $"; #endif #include "os.h" #include "s_defines.h" #define WHOWAS_C #include "s_externs.h" #undef WHOWAS_C static aName *was; int ww_index = 0, ww_size = MAXCONNECTIONS*2; static aLock *locked; int lk_index = 0, lk_size = MAXCONNECTIONS*2; static void grow_whowas(void) { int osize = ww_size; Debug((DEBUG_ERROR, "grow_whowas ww:%d, lk:%d, #%d, %#x/%#x", ww_size, lk_size, numclients, was, locked)); ww_size = (int)((float)numclients * 1.1); was = (aName *)MyRealloc((char *)was, sizeof(*was) * ww_size); bzero((char *)(was + osize), sizeof(*was) * (ww_size - osize)); Debug((DEBUG_ERROR, "grow_whowas %#x", was)); ircd_writetune(tunefile); } static void grow_locked(void) { int osize = lk_size; lk_size = ww_size; locked = (aLock *)MyRealloc((char *)locked, sizeof(*locked) * lk_size); bzero((char *)(locked + osize), sizeof(*locked) * (lk_size - osize)); } /* ** add_history ** Add the currently defined name of the client to history. ** usually called before changing to a new name (nick). ** Client must be a fully registered user (specifically, ** the user structure must have been allocated). ** if nodelay is NULL, then the nickname will be subject to NickDelay */ void add_history(aClient *cptr, aClient *nodelay) { Reg aName *np; Reg Link *uwas; cptr->user->refcnt++; np = &was[ww_index]; if ((np->ww_online && (np->ww_online != &me)) && !(np->ww_user && np->ww_user->uwas)) #ifdef DEBUGMODE dumpcore("whowas[%d] %#x %#x %#x", ww_index, np->ww_online, np->ww_user, np->ww_user->uwas); #else sendto_flag(SCH_ERROR, "whowas[%d] %#x %#x %#x", ww_index, np->ww_online, np->ww_user, np->ww_user->uwas); #endif /* ** The entry to be overwritten in was[] is still online. ** its uwas has to be updated */ if (np->ww_online && (np->ww_online != &me)) { Reg Link **old_uwas; old_uwas = &(np->ww_user->uwas); /* (*old_uwas) should NEVER happen to be NULL. -krys */ while ((*old_uwas)->value.i != ww_index) old_uwas = &((*old_uwas)->next); uwas = *old_uwas; *old_uwas = uwas->next; free_link(uwas); free_user(np->ww_user); istat.is_wwuwas--; } else if (np->ww_user) { /* ** Testing refcnt here is quite ugly, and unexact. ** Nonetheless, the result is almost correct, and another ** ugly thing in free_server() shoud make it exact. ** The problem is that 1 anUser structure might be ** referenced several times from whowas[] but is only counted ** once. One knows when to add, not when to substract - krys */ if (np->ww_user->refcnt == 1) { istat.is_wwusers--; if (np->ww_user->away) { istat.is_wwaways--; istat.is_wwawaysmem -=strlen(np->ww_user->away) + 1; } } free_user(np->ww_user); } if (np->ww_logout != 0) { int elapsed = timeofday - np->ww_logout; /* some stats */ ircstp->is_wwcnt++; ircstp->is_wwt += elapsed; if (elapsed < ircstp->is_wwmt) ircstp->is_wwmt = elapsed; if (elapsed > ircstp->is_wwMt) ircstp->is_wwMt = elapsed; if (np->ww_online == NULL) { if (locked[lk_index].logout) { elapsed = timeofday - locked[lk_index].logout; /* some stats first */ ircstp->is_lkcnt++; ircstp->is_lkt += elapsed; if (elapsed < ircstp->is_lkmt) ircstp->is_lkmt = elapsed; if (elapsed > ircstp->is_lkMt) ircstp->is_lkMt = elapsed; } /* ** This nickname has to be locked, thus copy it to the ** lock[] array. */ strcpy(locked[lk_index].nick, np->ww_nick); locked[lk_index++].logout = np->ww_logout; if ((lk_index == lk_size) && (lk_size != ww_size)) { grow_locked(); } if (lk_index >= lk_size) lk_index = 0; } } if (nodelay == cptr) /* &me is NOT a valid value, see off_history() */ { /* ** The client is online, np->ww_online is going to point to ** it. The client user struct has to point to this entry ** as well for faster off_history() ** this uwas, and the ww_online form a pair. */ uwas = make_link(); istat.is_wwuwas++; /* ** because of reallocs, one can not store a pointer inside ** the array. store the index instead. */ uwas->value.i = ww_index; uwas->flags = timeofday; uwas->next = cptr->user->uwas; cptr->user->uwas = uwas; } np->ww_logout = timeofday; np->ww_user = cptr->user; np->ww_online = (nodelay != NULL) ? nodelay : NULL; strncpyzt(np->ww_nick, cptr->name, NICKLEN+1); strncpyzt(np->ww_info, cptr->info, REALLEN+1); ww_index++; if ((ww_index == ww_size) && (numclients > ww_size)) grow_whowas(); if (ww_index >= ww_size) ww_index = 0; return; } /* ** get_history ** Return the current client that was using the given ** nickname within the timelimit. Returns NULL, if no ** one found... */ aClient *get_history(char *nick, time_t timelimit) { Reg aName *wp, *wp2; wp = wp2 = &was[ww_index]; timelimit = timeofday - timelimit; do { if (wp == was) { wp = was + ww_size; } wp--; if (wp->ww_logout < timelimit) { /* no point in checking more, only old or unused * entry's left. */ return NULL; } if (wp->ww_online == &me) { /* This one is offline */ continue; } if (wp->ww_online && !mycmp(nick, wp->ww_nick)) { return wp->ww_online; } } while (wp != wp2); return (NULL); } /* ** find_history ** Returns 1 if a user was using the given nickname within ** the timelimit and it's locked. Returns 0, if none found... */ int find_history(char *nick, time_t timelimit) { Reg aName *wp, *wp2; Reg aLock *lp, *lp2; wp = wp2 = &was[ww_index]; #ifdef RANDOM_NDELAY timelimit = timeofday - timelimit - (lk_index % 60); #else timelimit = timeofday - timelimit; #endif do { if (wp == was) { wp = was + ww_size; } wp--; if (wp->ww_logout < timelimit) { return 0; } /* wp->ww_online == NULL means it's locked */ if ((!wp->ww_online) && (!mycmp(nick, wp->ww_nick))) { return 1; } } while (wp != wp2); lp = lp2 = &locked[lk_index]; do { if (lp == locked) { lp = locked + lk_size; } lp--; if (lp->logout < timelimit) { return 0; } if (!mycmp(nick, lp->nick)) { return 1; } } while (lp != lp2); return (0); } /* ** off_history ** This must be called when the client structure is about to ** be released. History mechanism keeps pointers to client ** structures and it must know when they cease to exist. This ** also implicitly calls AddHistory. */ void off_history(aClient *cptr) { Reg Link *uwas; /* ** If the client has uwas entry/ies, there are also entries in ** the whowas array which point back to it. ** They have to be removed, by pairs */ while ((uwas = cptr->user->uwas)) { if (was[uwas->value.i].ww_online != cptr) #ifdef DEBUGMODE dumpcore("was[%d]: %#x != %#x", uwas->value.i, was[uwas->value.i].ww_online, cptr); #else sendto_flag(SCH_ERROR, "was[%d]: %#x != %#x", uwas->value.i, was[uwas->value.i].ww_online, cptr); #endif /* ** using &me to make ww_online non NULL (nicknames to be ** locked). &me can safely be used, it is constant. */ was[uwas->value.i].ww_online = &me; cptr->user->uwas = uwas->next; free_link(uwas); istat.is_wwuwas--; } istat.is_wwusers++; if (cptr->user->away) { istat.is_wwaways++; istat.is_wwawaysmem += strlen(cptr->user->away) + 1; } return; } void initwhowas(void) { Reg int i; was = (aName *)MyMalloc(sizeof(*was) * ww_size); for (i = 0; i < ww_size; i++) bzero((char *)&was[i], sizeof(aName)); locked = (aLock *)MyMalloc(sizeof(*locked) * lk_size); for (i = 0; i < lk_size; i++) bzero((char *)&locked[i], sizeof(aLock)); ircstp->is_wwmt = ircstp->is_lkmt = DELAYCHASETIMELIMIT * DELAYCHASETIMELIMIT; return; } /* ** m_whowas ** parv[0] = sender prefix ** parv[1] = nickname queried */ int m_whowas(aClient *cptr, aClient *sptr, int parc, char *parv[]) { Reg aName *wp, *wp2 = NULL; Reg int j = 0; Reg anUser *up = NULL; int max = -1; char *p, *nick, *s; if (parc < 2) { sendto_one(sptr, replies[ERR_NONICKNAMEGIVEN], ME, BadTo(parv[0])); return 1; } if (parc > 2) max = atoi(parv[2]); if (parc > 3) if (hunt_server(cptr,sptr,":%s WHOWAS %s %s :%s", 3,parc,parv)) return 3; parv[1] = canonize(parv[1]); if (!MyConnect(sptr)) max = MIN(max, 20); for (s = parv[1]; (nick = strtoken(&p, s, ",")); s = NULL) { wp = wp2 = &was[(ww_index ? ww_index : ww_size) - 1]; j = 0; do { if (mycmp(nick, wp->ww_nick) == 0) { up = wp->ww_user; sendto_one(sptr, replies[RPL_WHOWASUSER], ME, BadTo(parv[0]), wp->ww_nick, up->username, up->host, wp->ww_info); sendto_one(sptr, replies[RPL_WHOISSERVER], ME, BadTo(parv[0]), wp->ww_nick, up->server, myctime(wp->ww_logout)); j++; } if (max > 0 && j >= max) break; if (wp == was) wp = &was[ww_size - 1]; else wp--; } while (wp != wp2); if (up == NULL) { if (strlen(nick) > (size_t) NICKLEN) nick[NICKLEN] = '\0'; sendto_one(sptr, replies[ERR_WASNOSUCHNICK], ME, BadTo(parv[0]), nick); } else up = NULL; if (p) p[-1] = ','; } sendto_one(sptr, replies[RPL_ENDOFWHOWAS], ME, BadTo(parv[0]), parv[1]); return 2; } /* ** for debugging...counts related structures stored in whowas array. */ void count_whowas_memory(int *wwu, int *wwa, u_long *wwam, int *wwuw) { Reg anUser *tmp; Reg Link *tmpl; Reg int i, j; int u = 0, a = 0, w = 0; u_long am = 0; for (i = 0; i < ww_size; i++) if ((tmp = was[i].ww_user)) { for (j = 0; j < i; j++) if (was[j].ww_user == tmp) break; if (j < i) continue; if (was[i].ww_online == NULL || was[i].ww_online == &me) { u++; if (tmp->away) { a++; am += (strlen(tmp->away)+1); } } else { tmpl = tmp->uwas; while (tmpl) { w++; tmpl = tmpl->next; } } } *wwu = u; *wwa = a; *wwam = am; *wwuw = w; return; } irc2.11.2p3/ircd/patricia.c0000644000175000017500000005472511157044733013237 0ustar kkkk/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: patricia.c,v 1.4 2009/03/15 00:20:43 chopin Exp $ * * Imported from ratbox with minor function name changes. * Id: patricia.c,v 7.14 2003/06/12 13:46:26 androsyn Exp * * Yanked out of Net::Patricia by Aaron Sethman * * Dave Plonka * * This product includes software developed by the University of Michigan, * Merit Network, Inc., and their contributors. * * This file had been called "radix.c" in the MRT sources. * * Dave Plonka renamed it to "patricia.c" since it's not an implementation of a general * radix trie. He also pulled in various requirements from "prefix.c" and * "demo.c" so that it could be used as a standalone API. * * This product includes software developed by the University of Michigan, Merit * Network, Inc., and their contributors. * */ #include "os.h" #include "s_defines.h" #define PATRICIA_C #include "s_externs.h" #undef PATRICIA_C /* Enable both of these to debug patricia.c * #define PATRICIA_NOTYET 1 * #define PATRICIA_DEBUG 1 */ #ifndef inetpton #define inetpton inet_pton #endif static int patricia_comp_with_mask(void *addr, void *dest, u_int mask) { if(memcmp(addr, dest, mask / 8) == 0) { int n = mask / 8; int m = ((-1) << (8 - (mask % 8))); if(mask % 8 == 0 || (((u_char *) addr)[n] & m) == (((u_char *) dest)[n] & m)) { return (1); } } return (0); } /* patricia_prefix_tochar * convert prefix information to bytes */ static u_char * patricia_prefix_tochar(prefix_t * prefix) { if(prefix == NULL) return (NULL); return ((u_char *) & prefix->add.sin); } #ifdef PATRICIA_NOTYET static char * patricia_prefix_toa2x(prefix_t * prefix, char *buf, int buf_len, int with_len) { static char tmp[6]; if(prefix == NULL) { strcpy(buf, "(NULL)"); return (buf); } inet_ntop(prefix->family, &prefix->add.sin, buf, buf_len); if(with_len) { sprintf(tmp, "/%d", prefix->bitlen); strcat(buf, tmp); } return (buf); } /* patricia_prefix_toa2 * convert prefix information to ascii string */ static char * patricia_prefix_toa2(prefix_t * prefix, char *buff, int buf_len) { return (patricia_prefix_toa2x(prefix, buff, buf_len, 0)); } static char * prefix_toa(prefix_t * prefix) { #ifdef INET6 static char buf[INET6_ADDRSTRLEN + 6]; #else static char buf[16 + 6]; #endif return (patricia_prefix_toa2(prefix, buf, sizeof(buf))); } #endif static prefix_t * patricia_new_prefix2(int family, void *dest, int bitlen, prefix_t * prefix) { int dynamic_allocated = 0; #ifdef INET6 int default_bitlen = 128; #else int default_bitlen = 32; #endif #ifdef INET6 if(family == AF_INET6) { default_bitlen = 128; if(prefix == NULL) { prefix = (prefix_t *) MyMalloc(sizeof(prefix_t)); dynamic_allocated++; } memcpy(&prefix->add.sin6, dest, 16); } else #endif /* IPV6 */ if(family == AF_INET) { if(prefix == NULL) { prefix = (prefix_t *) MyMalloc(sizeof(prefix_t)); dynamic_allocated++; } memcpy(&prefix->add.sin, dest, 4); } else { return (NULL); } prefix->bitlen = (bitlen >= 0) ? bitlen : default_bitlen; prefix->family = family; prefix->ref_count = 0; if(dynamic_allocated) { prefix->ref_count++; } return (prefix); } static prefix_t * New_Prefix(int family, void *dest, int bitlen) { return (patricia_new_prefix2(family, dest, bitlen, NULL)); } /* ascii2prefix */ static prefix_t * ascii2prefix(int family, const char *string) { u_long bitlen, maxbitlen = 0; char *cp; struct in_addr sinaddr; #ifdef INET6 struct in6_addr sinaddr6; #endif /* IPV6 */ int result; char save[MAXLINE]; if(string == NULL) return (NULL); /* easy way to handle both families */ if(family == 0) { family = AF_INET; #ifdef INET6 if(strchr(string, ':')) family = AF_INET6; #endif /* IPV6 */ } if(family == AF_INET) { maxbitlen = 32; } #ifdef INET6 else if(family == AF_INET6) { maxbitlen = 128; } #endif /* IPV6 */ if((cp = strchr(string, '/')) != NULL) { bitlen = atol(cp + 1); /* *cp = '\0'; */ /* copy the string to save. Avoid destroying the string */ assert(cp - string < MAXLINE); memcpy(save, string, cp - string); save[cp - string] = '\0'; string = save; if(bitlen < 0 || bitlen > maxbitlen) bitlen = maxbitlen; } else { bitlen = maxbitlen; } if(family == AF_INET) { if((result = inetpton(AF_INET, string, &sinaddr)) <= 0) return (NULL); return (New_Prefix(AF_INET, &sinaddr, bitlen)); } #ifdef INET6 else if(family == AF_INET6) { if((result = inetpton(AF_INET6, string, &sinaddr6)) <= 0) return (NULL); return (New_Prefix(AF_INET6, &sinaddr6, bitlen)); } #endif /* IPV6 */ else return (NULL); } static prefix_t * patricia_ref_prefix(prefix_t * prefix) { if(prefix == NULL) return (NULL); if(prefix->ref_count == 0) { /* make a copy in case of a static prefix */ return (patricia_new_prefix2(prefix->family, &prefix->add, prefix->bitlen, NULL)); } prefix->ref_count++; return (prefix); } static void patricia_deref_prefix(prefix_t * prefix) { if(prefix == NULL) return; /* for secure programming, raise an assert. no static prefix can call this */ assert(prefix->ref_count > 0); prefix->ref_count--; assert(prefix->ref_count >= 0); if(prefix->ref_count <= 0) { MyFree(prefix); return; } } /* } */ /* #define PATRICIA_DEBUG 1 */ static int num_active_patricia = 0; /* these routines support continuous mask only */ patricia_tree_t * patricia_new(int maxbits) { patricia_tree_t *patricia = (patricia_tree_t *) MyMalloc(sizeof(patricia_tree_t)); patricia->maxbits = maxbits; patricia->head = NULL; patricia->num_active_node = 0; assert(maxbits <= PATRICIA_MAXBITS); /* XXX */ num_active_patricia++; return (patricia); } /* * if func is supplied, it will be called as func(node->data) * before deleting the node */ void patricia_clear(patricia_tree_t * patricia, void_fn_t func) { assert(patricia); if(patricia->head) { patricia_node_t *Xstack[PATRICIA_MAXBITS + 1]; patricia_node_t **Xsp = Xstack; patricia_node_t *Xrn = patricia->head; while (Xrn) { patricia_node_t *l = Xrn->l; patricia_node_t *r = Xrn->r; if(Xrn->prefix) { patricia_deref_prefix(Xrn->prefix); if(Xrn->data && func) func(Xrn->data); } else { assert(Xrn->data == NULL); } MyFree(Xrn); patricia->num_active_node--; if(l) { if(r) { *Xsp++ = r; } Xrn = l; } else if(r) { Xrn = r; } else if(Xsp != Xstack) { Xrn = *(--Xsp); } else { Xrn = (patricia_node_t *) 0; } } } assert(patricia->num_active_node == 0); MyFree(patricia); } void patricia_destroy(patricia_tree_t * patricia, void_fn_t func) { patricia_clear(patricia, func); num_active_patricia--; } /* * if func is supplied, it will be called as func(node->prefix, node->data) */ void patricia_process(patricia_tree_t * patricia, void_fn_t func) { patricia_node_t *node; assert(func); PATRICIA_WALK(patricia->head, node) { func(node->prefix, node->data); } PATRICIA_WALK_END; } patricia_node_t * patricia_search_exact(patricia_tree_t * patricia, prefix_t * prefix) { patricia_node_t *node; u_char *addr; u_int bitlen; assert(patricia); assert(prefix); assert(prefix->bitlen <= patricia->maxbits); if(patricia->head == NULL) return (NULL); node = patricia->head; addr = prefix_touchar(prefix); bitlen = prefix->bitlen; while (node->bit < bitlen) { if(BIT_TEST(addr[node->bit >> 3], 0x80 >> (node->bit & 0x07))) { #ifdef PATRICIA_DEBUG if(node->prefix) fprintf(stderr, "patricia_search_exact: take right %s/%d\n", prefix_toa(node->prefix), node->prefix->bitlen); else fprintf(stderr, "patricia_search_exact: take right at %d\n", node->bit); #endif /* PATRICIA_DEBUG */ node = node->r; } else { #ifdef PATRICIA_DEBUG if(node->prefix) fprintf(stderr, "patricia_search_exact: take left %s/%d\n", prefix_toa(node->prefix), node->prefix->bitlen); else fprintf(stderr, "patricia_search_exact: take left at %d\n", node->bit); #endif /* PATRICIA_DEBUG */ node = node->l; } if(node == NULL) return (NULL); } #ifdef PATRICIA_DEBUG if(node->prefix) fprintf(stderr, "patricia_search_exact: stop at %s/%d %d\n", prefix_toa(node->prefix), node->prefix->bitlen, node->bit); else fprintf(stderr, "patricia_search_exact: stop at %d\n", node->bit); #endif /* PATRICIA_DEBUG */ if(node->bit > bitlen || node->prefix == NULL) return (NULL); assert(node->bit == bitlen); assert(node->bit == node->prefix->bitlen); if(patricia_comp_with_mask(patricia_prefix_tochar(node->prefix), patricia_prefix_tochar(prefix), bitlen)) { #ifdef PATRICIA_DEBUG fprintf(stderr, "patricia_search_exact: found %s/%d\n", prefix_toa(node->prefix), node->prefix->bitlen); #endif /* PATRICIA_DEBUG */ return (node); } return (NULL); } /* if inclusive != 0, "best" may be the given prefix itself */ patricia_node_t * patricia_search_best2(patricia_tree_t * patricia, prefix_t * prefix, int inclusive) { patricia_node_t *node; patricia_node_t *stack[PATRICIA_MAXBITS + 1]; u_char *addr; u_int bitlen; int cnt = 0; assert(patricia); assert(prefix); assert(prefix->bitlen <= patricia->maxbits); if(patricia->head == NULL) return (NULL); node = patricia->head; addr = prefix_touchar(prefix); bitlen = prefix->bitlen; while (node->bit < bitlen) { if(node->prefix) { #ifdef PATRICIA_DEBUG fprintf(stderr, "patricia_search_best: push %s/%d\n", prefix_toa(node->prefix), node->prefix->bitlen); #endif /* PATRICIA_DEBUG */ stack[cnt++] = node; } if(BIT_TEST(addr[node->bit >> 3], 0x80 >> (node->bit & 0x07))) { #ifdef PATRICIA_DEBUG if(node->prefix) fprintf(stderr, "patricia_search_best: take right %s/%d\n", prefix_toa(node->prefix), node->prefix->bitlen); else fprintf(stderr, "patricia_search_best: take right at %d\n", node->bit); #endif /* PATRICIA_DEBUG */ node = node->r; } else { #ifdef PATRICIA_DEBUG if(node->prefix) fprintf(stderr, "patricia_search_best: take left %s/%d\n", prefix_toa(node->prefix), node->prefix->bitlen); else fprintf(stderr, "patricia_search_best: take left at %d\n", node->bit); #endif /* PATRICIA_DEBUG */ node = node->l; } if(node == NULL) break; } if(inclusive && node && node->prefix) stack[cnt++] = node; #ifdef PATRICIA_DEBUG if(node == NULL) fprintf(stderr, "patricia_search_best: stop at null\n"); else if(node->prefix) fprintf(stderr, "patricia_search_best: stop at %s/%d\n", prefix_toa(node->prefix), node->prefix->bitlen); else fprintf(stderr, "patricia_search_best: stop at %d\n", node->bit); #endif /* PATRICIA_DEBUG */ if(cnt <= 0) return (NULL); while (--cnt >= 0) { node = stack[cnt]; #ifdef PATRICIA_DEBUG fprintf(stderr, "patricia_search_best: pop %s/%d\n", prefix_toa(node->prefix), node->prefix->bitlen); #endif /* PATRICIA_DEBUG */ if(patricia_comp_with_mask(patricia_prefix_tochar(node->prefix), patricia_prefix_tochar(prefix), node->prefix->bitlen)) { #ifdef PATRICIA_DEBUG fprintf(stderr, "patricia_search_best: found %s/%d\n", prefix_toa(node->prefix), node->prefix->bitlen); #endif /* PATRICIA_DEBUG */ return (node); } } return (NULL); } patricia_node_t * patricia_search_best(patricia_tree_t * patricia, prefix_t * prefix) { return (patricia_search_best2(patricia, prefix, 1)); } patricia_node_t * patricia_lookup(patricia_tree_t * patricia, prefix_t * prefix) { patricia_node_t *node, *new_node, *parent, *glue; u_char *addr, *test_addr; u_int bitlen, check_bit, differ_bit; unsigned int i, j, r; assert(patricia); assert(prefix); assert(prefix->bitlen <= patricia->maxbits); if(patricia->head == NULL) { node = (patricia_node_t *) MyMalloc(sizeof(patricia_node_t)); node->bit = prefix->bitlen; node->prefix = patricia_ref_prefix(prefix); node->parent = NULL; node->l = node->r = NULL; node->data = NULL; patricia->head = node; #ifdef PATRICIA_DEBUG fprintf(stderr, "patricia_lookup: new_node #0 %s/%d (head)\n", prefix_toa(prefix), prefix->bitlen); #endif /* PATRICIA_DEBUG */ patricia->num_active_node++; return (node); } addr = prefix_touchar(prefix); bitlen = prefix->bitlen; node = patricia->head; while (node->bit < bitlen || node->prefix == NULL) { if(node->bit < patricia->maxbits && BIT_TEST(addr[node->bit >> 3], 0x80 >> (node->bit & 0x07))) { if(node->r == NULL) break; #ifdef PATRICIA_DEBUG if(node->prefix) fprintf(stderr, "patricia_lookup: take right %s/%d\n", prefix_toa(node->prefix), node->prefix->bitlen); else fprintf(stderr, "patricia_lookup: take right at %d\n", node->bit); #endif /* PATRICIA_DEBUG */ node = node->r; } else { if(node->l == NULL) break; #ifdef PATRICIA_DEBUG if(node->prefix) fprintf(stderr, "patricia_lookup: take left %s/%d\n", prefix_toa(node->prefix), node->prefix->bitlen); else fprintf(stderr, "patricia_lookup: take left at %d\n", node->bit); #endif /* PATRICIA_DEBUG */ node = node->l; } assert(node); } assert(node->prefix); #ifdef PATRICIA_DEBUG fprintf(stderr, "patricia_lookup: stop at %s/%d\n", prefix_toa(node->prefix), node->prefix->bitlen); #endif /* PATRICIA_DEBUG */ test_addr = prefix_touchar(node->prefix); /* find the first bit different */ check_bit = (node->bit < bitlen) ? node->bit : bitlen; differ_bit = 0; for (i = 0; i * 8 < check_bit; i++) { if((r = (addr[i] ^ test_addr[i])) == 0) { differ_bit = (i + 1) * 8; continue; } /* I know the better way, but for now */ for (j = 0; j < 8; j++) { if(BIT_TEST(r, (0x80 >> j))) break; } /* must be found */ assert(j < 8); differ_bit = i * 8 + j; break; } if(differ_bit > check_bit) differ_bit = check_bit; #ifdef PATRICIA_DEBUG fprintf(stderr, "patricia_lookup: differ_bit %d\n", differ_bit); #endif /* PATRICIA_DEBUG */ parent = node->parent; while (parent && parent->bit >= differ_bit) { node = parent; parent = node->parent; #ifdef PATRICIA_DEBUG if(node->prefix) fprintf(stderr, "patricia_lookup: up to %s/%d\n", prefix_toa(node->prefix), node->prefix->bitlen); else fprintf(stderr, "patricia_lookup: up to %d\n", node->bit); #endif /* PATRICIA_DEBUG */ } if(differ_bit == bitlen && node->bit == bitlen) { if(node->prefix) { #ifdef PATRICIA_DEBUG fprintf(stderr, "patricia_lookup: found %s/%d\n", prefix_toa(node->prefix), node->prefix->bitlen); #endif /* PATRICIA_DEBUG */ return (node); } node->prefix = patricia_ref_prefix(prefix); #ifdef PATRICIA_DEBUG fprintf(stderr, "patricia_lookup: new node #1 %s/%d (glue mod)\n", prefix_toa(prefix), prefix->bitlen); #endif /* PATRICIA_DEBUG */ assert(node->data == NULL); return (node); } new_node = (patricia_node_t *) MyMalloc(sizeof(patricia_node_t)); new_node->bit = prefix->bitlen; new_node->prefix = patricia_ref_prefix(prefix); new_node->parent = NULL; new_node->l = new_node->r = NULL; new_node->data = NULL; patricia->num_active_node++; if(node->bit == differ_bit) { new_node->parent = node; if(node->bit < patricia->maxbits && BIT_TEST(addr[node->bit >> 3], 0x80 >> (node->bit & 0x07))) { assert(node->r == NULL); node->r = new_node; } else { assert(node->l == NULL); node->l = new_node; } #ifdef PATRICIA_DEBUG fprintf(stderr, "patricia_lookup: new_node #2 %s/%d (child)\n", prefix_toa(prefix), prefix->bitlen); #endif /* PATRICIA_DEBUG */ return (new_node); } if(bitlen == differ_bit) { if(bitlen < patricia->maxbits && BIT_TEST(test_addr[bitlen >> 3], 0x80 >> (bitlen & 0x07))) { new_node->r = node; } else { new_node->l = node; } new_node->parent = node->parent; if(node->parent == NULL) { assert(patricia->head == node); patricia->head = new_node; } else if(node->parent->r == node) { node->parent->r = new_node; } else { node->parent->l = new_node; } node->parent = new_node; #ifdef PATRICIA_DEBUG fprintf(stderr, "patricia_lookup: new_node #3 %s/%d (parent)\n", prefix_toa(prefix), prefix->bitlen); #endif /* PATRICIA_DEBUG */ } else { glue = (patricia_node_t *) MyMalloc(sizeof(patricia_node_t)); glue->bit = differ_bit; glue->prefix = NULL; glue->parent = node->parent; glue->data = NULL; patricia->num_active_node++; if(differ_bit < patricia->maxbits && BIT_TEST(addr[differ_bit >> 3], 0x80 >> (differ_bit & 0x07))) { glue->r = new_node; glue->l = node; } else { glue->r = node; glue->l = new_node; } new_node->parent = glue; if(node->parent == NULL) { assert(patricia->head == node); patricia->head = glue; } else if(node->parent->r == node) { node->parent->r = glue; } else { node->parent->l = glue; } node->parent = glue; #ifdef PATRICIA_DEBUG fprintf(stderr, "patricia_lookup: new_node #4 %s/%d (glue+node)\n", prefix_toa(prefix), prefix->bitlen); #endif /* PATRICIA_DEBUG */ } return (new_node); } void patricia_remove(patricia_tree_t * patricia, patricia_node_t * node) { patricia_node_t *parent, *child; assert(patricia); assert(node); if(node->r && node->l) { #ifdef PATRICIA_DEBUG fprintf(stderr, "patricia_remove: #0 %s/%d (r & l)\n", prefix_toa(node->prefix), node->prefix->bitlen); #endif /* PATRICIA_DEBUG */ /* this might be a placeholder node -- have to check and make sure * there is a prefix aossciated with it ! */ if(node->prefix != NULL) patricia_deref_prefix(node->prefix); node->prefix = NULL; /* Also I needed to clear data pointer -- masaki */ node->data = NULL; return; } if(node->r == NULL && node->l == NULL) { #ifdef PATRICIA_DEBUG fprintf(stderr, "patricia_remove: #1 %s/%d (!r & !l)\n", prefix_toa(node->prefix), node->prefix->bitlen); #endif /* PATRICIA_DEBUG */ parent = node->parent; patricia_deref_prefix(node->prefix); patricia->num_active_node--; if(parent == NULL) { assert(patricia->head == node); patricia->head = NULL; MyFree(node); return; } if(parent->r == node) { parent->r = NULL; child = parent->l; } else { assert(parent->l == node); parent->l = NULL; child = parent->r; } MyFree(node); if(parent->prefix) return; /* we need to remove parent too */ if(parent->parent == NULL) { assert(patricia->head == parent); patricia->head = child; } else if(parent->parent->r == parent) { parent->parent->r = child; } else { assert(parent->parent->l == parent); parent->parent->l = child; } child->parent = parent->parent; MyFree(parent); patricia->num_active_node--; return; } #ifdef PATRICIA_DEBUG fprintf(stderr, "patricia_remove: #2 %s/%d (r ^ l)\n", prefix_toa(node->prefix), node->prefix->bitlen); #endif /* PATRICIA_DEBUG */ if(node->r) { child = node->r; } else { assert(node->l); child = node->l; } parent = node->parent; child->parent = parent; patricia_deref_prefix(node->prefix); patricia->num_active_node--; if(parent == NULL) { assert(patricia->head == node); patricia->head = child; MyFree(node); return; } if(parent->r == node) { parent->r = child; } else { assert(parent->l == node); parent->l = child; } MyFree(node); } patricia_node_t * patricia_make_and_lookup_ip(patricia_tree_t * tree, struct IN_ADDR *ip, int bitlen) { prefix_t *prefix; patricia_node_t *node; prefix = New_Prefix(AFINET, ip, bitlen); if(prefix == NULL) return NULL; node = patricia_lookup(tree, prefix); patricia_deref_prefix(prefix); return (node); } patricia_node_t * patricia_make_and_lookup(patricia_tree_t * tree, const char *string) { prefix_t *prefix; patricia_node_t *node; if((prefix = ascii2prefix(AF_INET, string)) != NULL) { node = patricia_lookup(tree, prefix); } else #ifdef INET6 if((prefix = ascii2prefix(AF_INET6, string)) != NULL) { node = patricia_lookup(tree, prefix); } else #endif return NULL; #ifdef PATRICIA_DEBUG printf("patricia_make_and_lookup: %s/%d\n", prefix_toa(prefix), prefix->bitlen); #endif patricia_deref_prefix(prefix); return (node); } #ifdef PATRICIA_NOTYET static patricia_node_t * patricia_try_search_exact(patricia_tree_t * tree, char *string) { prefix_t *prefix; patricia_node_t *node; if((prefix = ascii2prefix(AF_INET, string)) != NULL) { node = patricia_search_exact(tree, prefix); patricia_deref_prefix(prefix); return (node); } #ifdef INET6 else if((prefix = ascii2prefix(AF_INET6, string)) != NULL) { node = patricia_search_exact(tree, prefix); patricia_deref_prefix(prefix); return (node); } #endif else return NULL; } void patricia_lookup_then_remove(patricia_tree_t * tree, char *string) { patricia_node_t *node; if((node = patricia_try_search_exact(tree, string))) patricia_remove(tree, node); } #endif patricia_node_t * patricia_match_ip(patricia_tree_t * tree, struct IN_ADDR *ip) { prefix_t *prefix; patricia_node_t *node; #ifdef INET6 int len = 128; #else int len = 32; #endif if((prefix = New_Prefix(AFINET, ip, len)) != NULL) { node = patricia_search_best(tree, prefix); patricia_deref_prefix(prefix); return (node); } return NULL; } patricia_node_t * patricia_match_string(patricia_tree_t * tree, const char *string) { patricia_node_t *node; prefix_t *prefix; if((prefix = ascii2prefix(AF_INET, string)) != NULL) { node = patricia_search_best(tree, prefix); patricia_deref_prefix(prefix); } else #ifdef INET6 if((prefix = ascii2prefix(AF_INET6, string)) != NULL) { node = patricia_search_best(tree, prefix); patricia_deref_prefix(prefix); } else #endif return NULL; return node; } patricia_node_t * patricia_match_exact_string(patricia_tree_t * tree, const char *string) { prefix_t *prefix; patricia_node_t *node; if((prefix = ascii2prefix(AF_INET, string)) != NULL) { node = patricia_search_exact(tree, prefix); patricia_deref_prefix(prefix); } else #ifdef INET6 if((prefix = ascii2prefix(AF_INET6, string)) != NULL) { node = patricia_search_exact(tree, prefix); patricia_deref_prefix(prefix); } else #endif return NULL; return node; } irc2.11.2p3/ircd/s_misc_ext.h0000644000175000017500000000417010025115130013551 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/s_misc_ext.h * Copyright (C) 1997 Alain Nissen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file contains external definitions for global variables and functions defined in ircd/s_misc.c. */ /* External definitions for global variables. */ #ifndef S_MISC_C extern struct stats ircst, *ircstp; extern aMotd *motd; extern time_t motd_mtime; #endif /* S_MISC_C */ /* External definitions for global functions. */ #ifndef S_MISC_C #define EXTERN extern #else /* S_MISC_C */ #define EXTERN #endif /* S_MISC_C */ EXTERN char *date (time_t clock); EXTERN int check_registered_user (aClient *sptr); EXTERN int check_registered (aClient *sptr); EXTERN int check_registered_service (aClient *sptr); EXTERN char *get_client_name (aClient *sptr, int showip); EXTERN char *get_client_host (aClient *cptr); EXTERN void get_sockhost (Reg aClient *cptr, Reg char *host); EXTERN char *my_name_for_link (char *name, Reg int count); EXTERN int mark_blind_servers (aClient *cptr, aClient *server); EXTERN int exit_client (aClient *cptr, aClient *sptr, aClient *from, const char *comment); EXTERN void checklist(void); EXTERN void initstats(void); EXTERN void initruntimeconf(void); EXTERN void tstats (aClient *cptr, char *name); EXTERN void read_motd (char *filename); EXTERN void check_split(void); EXTERN int myrand(void); EXTERN void mysrand(unsigned int seed); #undef EXTERN irc2.11.2p3/ircd/buildm40000755000175000017500000000675207472025522012562 0ustar kkkk#! /bin/sh # IRC - Internet Relay Chat, ircd/buildm4 # Copyright (C) 1993, 1994 Darren Reed # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 1, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # $Id: buildm4,v 1.12 2002/05/19 22:46:42 jv Exp $ # # # If only this was a perl script...*sigh* # INCLUDE=`../support/config.guess` # Installation with absolute path now (Kratz) M4=$1 /bin/rm -f $M4 egrep "^#def[^P]*PATCHLEVEL" ../common/patchlevel.h | \ sed -e 's/[^\"]*\"\([^\"]*\)\"/define(VERSION,\1)/' >>$M4 DEBUG=`egrep "^#define[ ]*DEBUGMODE" config.h` if [ -n "$DEBUG" ] ; then echo "define(DEBUGMODE,1)" >>$M4 else echo "undefine(DEBUGMODE)" >>$M4 fi HOST="`hostname | sed -e 's/\([a-zA-Z0-9\-]*\).*/\1/'`" echo "define(HOSTNAME,$HOST)" >> $M4 echo "define(USER,$USER)" >>$M4 PORT=`egrep '^#define[ ]*PORT[ ]*[0-9]*' ../$INCLUDE/config.h | \ sed -e 's/[^0-9]*\([0-9]*\).*/\1/'` echo "define(PORT,$PORT)" >> $M4 PING=`egrep '^#define[ ]*PINGFREQUENCY[ ]*[0-9]*' ../$INCLUDE/config.h\ | sed -e 's/[^0-9]*\([0-9]*\).*/\1/'` echo "define(PFREQ,$PING)" >> $M4 CONT=`egrep '^#define[ ]*CONNECTFREQUENCY[ ]*[0-9]*' ../$INCLUDE/config.h\ | sed -e 's/[^0-9]*\([0-9]*\).*/\1/'` echo "define(CFREQ,$CONT)" >> $M4 MAXL=`egrep '^#define[ ]*MAXIMUM_LINKS[ ]*[0-9]* | head -1' \ ../$INCLUDE/config.h | sed -e 's/[^0-9]*\([0-9]*\).*/\1/'` echo "define(MAXLINKS,$MAXL)" >> $M4 DOM=`egrep '^domain' /etc/resolv.conf | \ sed -e 's/^domain[ ]*\([^ ]*\).*/\1/'` echo "define(DOMAIN,$DOM)" >> $M4 cat >>$M4 <<_EOF_ define(CL,\`ifelse(len(\$1),0,0,\$1)') define(MAXSENDQ,0) define(HOST,\$1) define(HOSTM,\$1) define(ID,*@\$1) define(PASS,\$1) define(PING,\`ifelse(len(\$1),0,PFREQ,\$1)') define(APORT,\`ifelse(len(\$1),0,PORT,\$1)') define(FREQ,\`ifelse(len(\$1),0,CFREQ,\$1)') define(SENDQ,\`ifelse(len(\$1),0,MAXSENDQ,\$1)') define(MAX,\`ifelse(len(\$1),0,MAXLINKS,\$1)') define(UID,\`ifelse(len(\$1),0,unknown,\$1)') define(CPORT,\$1) define(SERV,\$1) define(ADMIN,A:\$1:\$2:\$3:\$4:\$5) define(ALLOW,N:\`HOST(\$1)':\`PASS(\$2)':\`SERV(\$3)':\`HOSTM(\$4)':\`CL(\$5)') define(BAN,K:\$1:\$2:\$3:\$4:) define(BANIDENT,k:\$1:\$2:\`UID(\$3)':\$4:) define(CLASS,Y:\$1:\`PING(\$2)':\$3:\`MAX(\$4)':\`SENDQ(\$5)':\$6:\$7) define(CLIENT,I:\`HOST(\$1)':\`PASS(\$2)':\`ifelse(len(HOST(\$3)),0,\$1,\$3)':\ \`APORT(\$4)':\`CL(\$5)') define(RESTRICTED,i:\`HOST(\$1)':\`PASS(\$2)':\ \`ifelse(len(HOST(\$3)),0,\$1,\$3)':\`APORT(\$4)':\`CL(\$5)') define(BOUNCE,B:\$1::\$2:\$3:) define(CONNECT,C:\`HOST(\$1)':\`PASS(\$2)':\`SERV(\$3)':\ \`CPORT(\$4)':\`CL(\$5)') define(EXCLUDEVERSION,V:\$1:\$2:\`ifelse(len(\$3),0,*,\$3)'::) define(ME,M:\$1:\$2:\$3:\$4:\$5 P:\$2:*:*:\$4) define(HUB,H:\`ifelse(len(\$2),0,*,\$2)':*:\$1) define(LEAF,L:\`ifelse(len(\$2),0,*,\$2)':*:\$1:1) define(SERVER,\` CONNECT(\$1,\$2,\$3,\$5,\$6) ALLOW(\$1,\$2,\$3,\$4,\$6) ') define(SERVICE,S:\`HOST(\$1)':\`PASS(\$2)':\$3:\`ifelse(len(\$4),0,0,\$4)':\ \`CL(\$5)') define(EXTRAPORT,P:\`ifelse(len(\$2),0,*,\$2)':*:*:\$1) _EOF_ irc2.11.2p3/ircd/s_misc.c0000644000175000017500000007422511277336253012721 0ustar kkkk/************************************************************************ * IRC - Internet Relay Chat, ircd/s_misc.c (formerly ircd/date.c) * Copyright (C) 1990 Jarkko Oikarinen and * University of Oulu, Computing Center * * See file AUTHORS in IRC package for additional names of * the programmers. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef lint static const volatile char rcsid[] = "@(#)$Id: s_misc.c,v 1.119 2009/11/13 20:08:11 chopin Exp $"; #endif #include "os.h" #include "s_defines.h" #define S_MISC_C #include "s_externs.h" #undef S_MISC_C static void exit_one_client (aClient *, aClient *, aClient *, const char *); static void exit_server(aClient *, aClient *, aClient *, const char *, const char *); static char *months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; static char *weekdays[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; /* * stats stuff */ struct stats ircst, *ircstp = &ircst; char *date(time_t clock) { static char buf[80], plus; Reg struct tm *lt, *gm; struct tm gmbuf; int minswest; if (!clock) time(&clock); gm = gmtime(&clock); bcopy((char *)gm, (char *)&gmbuf, sizeof(gmbuf)); gm = &gmbuf; lt = localtime(&clock); minswest = (gm->tm_hour - lt->tm_hour) * 60 + (gm->tm_min - lt->tm_min); if (lt->tm_yday != gm->tm_yday) { if ((lt->tm_yday > gm->tm_yday && lt->tm_year == gm->tm_year) || (lt->tm_yday < gm->tm_yday && lt->tm_year != gm->tm_year)) { minswest -= 24 * 60; } else { minswest += 24 * 60; } } plus = (minswest > 0) ? '-' : '+'; if (minswest < 0) minswest = -minswest; (void)sprintf(buf, "%s %s %d %d -- %02d:%02d %c%02d:%02d", weekdays[lt->tm_wday], months[lt->tm_mon],lt->tm_mday, lt->tm_year + 1900, lt->tm_hour, lt->tm_min, plus, minswest/60, minswest%60); return buf; } /* ** check_registered_user is used to cancel message, if the ** originator is a server or not registered yet. In other ** words, passing this test, *MUST* guarantee that the ** sptr->user exists (not checked after this--let there ** be coredumps to catch bugs... this is intentional --msa ;) ** ** There is this nagging feeling... should this NOT_REGISTERED ** error really be sent to remote users? This happening means ** that remote servers have this user registered, althout this ** one has it not... Not really users fault... Perhaps this ** error message should be restricted to local clients and some ** other thing generated for remotes... */ int check_registered_user(aClient *sptr) { if (!IsRegisteredUser(sptr)) { sendto_one(sptr, replies[ERR_NOTREGISTERED], ME, "*"); return -1; } return 0; } /* ** check_registered user cancels message, if 'x' is not ** registered (e.g. we don't know yet whether a server ** or user) */ int check_registered(aClient *sptr) { if (!IsRegistered(sptr)) { sendto_one(sptr, replies[ERR_NOTREGISTERED], ME, "*"); return -1; } return 0; } /* ** check_registered_service cancels message, if 'x' is not ** a registered service. */ int check_registered_service(aClient *sptr) { if (!IsService(sptr)) { sendto_one(sptr, replies[ERR_NOTREGISTERED], ME, "*"); return -1; } return 0; } /* ** get_client_name ** Return the name of the client for various tracking and ** admin purposes. The main purpose of this function is to ** return the "socket host" name of the client, if that ** differs from the advertised name (other than case). ** But, this can be used to any client structure. ** ** Returns: ** "name[user@ip#.port]" if 'showip' is true; ** "name[username@sockethost]", if name and sockhost are different and ** showip is false; else ** "name". ** ** NOTE 1: ** Watch out the allocation of "nbuf", if either sptr->name ** or sptr->sockhost gets changed into pointers instead of ** directly allocated within the structure... ** ** NOTE 2: ** Function return either a pointer to the structure (sptr) or ** to internal buffer (nbuf). *NEVER* use the returned pointer ** to modify what it points!!! */ char *get_client_name(aClient *sptr, int showip) { static char nbuf[HOSTLEN * 2 + USERLEN + 5]; if (MyConnect(sptr)) { #ifdef UNIXPORT if (IsUnixSocket(sptr)) { if (showip) sprintf(nbuf, "%s[%s]", sptr->name, sptr->sockhost); else sprintf(nbuf, "%s[%s]", sptr->name, me.sockhost); } else #endif { if (showip) (void)sprintf(nbuf, "%s[%.*s@%s]", sptr->name, USERLEN, (!(sptr->flags & FLAGS_GOTID)) ? "" : sptr->auth, sptr->user ? sptr->user->sip : #ifdef INET6 inetntop(AF_INET6, (char *)&sptr->ip, ipv6string, sizeof(ipv6string)) #else inetntoa((char *)&sptr->ip) #endif ); else { if (mycmp(sptr->name, sptr->sockhost)) /* Show username for clients and * ident for others. */ sprintf(nbuf, "%s[%.*s@%s]", sptr->name, USERLEN, IsPerson(sptr) ? sptr->user->username : sptr->auth, IsPerson(sptr) ? sptr->user->host : sptr->sockhost); else return sptr->name; } } return nbuf; } return sptr->name; } char *get_client_host(aClient *cptr) { static char nbuf[HOSTLEN * 2 + USERLEN + 5]; if (!MyConnect(cptr)) return cptr->name; if (!cptr->user) return get_client_name(cptr, TRUE); #ifdef UNIXPORT if (IsUnixSocket(cptr)) sprintf(nbuf, "%s[%s]", cptr->name, ME); else #endif (void)sprintf(nbuf, "%s[%-.*s@%-.*s]", cptr->name, USERLEN, (!(cptr->flags & FLAGS_GOTID)) ? "" : cptr->auth, HOSTLEN, cptr->user->sip); return nbuf; } /* * Form sockhost such that if the host is of form user@host, only the host * portion is copied. */ void get_sockhost(aClient *cptr, char *host) { Reg char *s; if (!cptr || !host) { /* however unlikely this is, don't risk */ return; } if ((s = (char *)index(host, '@'))) { s++; } else { s = host; } strncpyzt(cptr->sockhost, s, sizeof(cptr->sockhost)); Debug((DEBUG_DNS,"get_sockhost %s",s)); } /* * Return wildcard name of my server name according to given config entry * --Jto */ char *my_name_for_link(char *name, int count) { static char namebuf[HOSTLEN]; Reg char *start = name; if (count <= 0 || count > 5) return start; while (count-- && name) { name++; name = (char *)index(name, '.'); } if (!name) return start; namebuf[0] = '*'; (void)strncpy(&namebuf[1], name, HOSTLEN - 1); namebuf[HOSTLEN - 1] = '\0'; return namebuf; } /* * Goes thru the list of locally connected servers (except cptr), * check if my neighbours can see the server "server" (or if it is hidden * by a hostmask) * Returns the number of marked servers */ int mark_blind_servers (aClient *cptr, aClient *server) { Reg int i, j = 0; Reg aClient *acptr; Reg aConfItem *aconf; for (i = fdas.highest; i >= 0; i--) { if (!(acptr = local[fdas.fd[i]]) || !IsServer(acptr)) continue; if (acptr == cptr->from || IsMe(acptr)) { acptr->flags &= ~FLAGS_HIDDEN; continue; } if (((aconf = acptr->serv->nline) && !match(my_name_for_link(ME, aconf->port), server->name))) { acptr->flags |= FLAGS_HIDDEN; j++; } else { acptr->flags &= ~FLAGS_HIDDEN; } } return j; } /* ** exit_server(): Removes all dependent servers and clients, and ** sends the right messages to the right client/servers. ** ** We will send all SQUITs to &servers, and QUITs to local users. ** We only send 1 SQUIT to a 2.11 servers. ** We send all SQUITs to a 2.10 servers that can see it, or QUITs otherwise. ** ** Argument: ** cptr: The real server to SQUIT. ** acptr: One of the depended servers to SQUIT. ** from: Originator of SQUIT. ** comment: The original comment for the SQUIT. (Only for cptr itself.) ** comment2: The comment for (S)QUIT reasons for the rest. */ static void exit_server(aClient *cptr, aClient *acptr, aClient *from, const char *comment, const char *comment2) { aClient *acptr2; int flags; /* Remove all the servers recursively. */ while (acptr->serv->down) { exit_server(cptr, acptr->serv->down, from, comment, comment2); } /* Here we should send "Received SQUIT" for last server, ** but exit_client() is doing (well, almost) this --Beeth */ /* This server doesn't have any depedent servers anymore, only ** users/services left. */ flags = FLAGS_SPLIT; /* ** We'll mark all servers that can't see that server as hidden. ** If we found any, we'll also mark all users on that server hidden. ** If a user is marked hidden, and we try to send it to a currently ** marked server, the server can't see that user's server. ** Note that a 2.11 can see it, so we don't have to send the QUITs ** to it. */ if (mark_blind_servers(cptr, acptr)) { flags |= FLAGS_HIDDEN; } /* Quit all users and services. */ while (GotDependantClient(acptr)) { acptr2 = acptr->prev; acptr2->flags |= flags; exit_one_client(cptr->from, acptr2, from, comment2); } /* Make sure we only send the last SQUIT to a 2.11 server. */ if (acptr == cptr) { acptr->flags |= FLAGS_SQUIT; } if (!IsMasked(acptr)) { sendto_flag(SCH_SERVER, "Received SQUIT %s from %s (%s)", acptr->name, from->name, acptr == cptr ? comment : comment2); } exit_one_client(cptr->from, acptr, from, acptr == cptr ? comment : comment2); return; } /* ** exit_client ** This is old "m_bye". Name changed, because this is not a ** protocol function, but a general server utility function. ** ** This function exits a client of *any* type (user, server, etc) ** from this server. Also, this generates all necessary prototol ** messages that this exit may cause. ** ** 1) If the client is a local client, then this implicitly ** exits all other clients depending on this connection (e.g. ** remote clients having 'from'-field that points to this. ** ** 2) If the client is a remote client, then only this is exited. ** ** For convenience, this function returns a suitable value for ** m_funtion return value: ** ** FLUSH_BUFFER if (cptr == sptr) ** 0 if (cptr != sptr) ** ** Parameters: ** ** aClient *cptr ** The local client originating the exit or NULL, if this ** exit is generated by this server for internal reasons. ** This will not get any of the generated messages. ** aClient *sptr ** Client exiting ** aClient *from ** Client firing off this Exit, never NULL! ** char *comment ** Reason for the exit */ int exit_client(aClient *cptr, aClient *sptr, aClient *from, const char *comment) { char comment1[HOSTLEN + HOSTLEN + 2]; if (MyConnect(sptr)) { if (sptr->flags & FLAGS_KILLED) { sendto_flag(SCH_NOTICE, "Killed: %s.", get_client_name(sptr, TRUE)); sptr->exitc = EXITC_KILL; } sptr->flags |= FLAGS_CLOSING; #if (defined(FNAME_USERLOG) || defined(FNAME_CONNLOG) \ || defined(USE_SERVICES)) \ || (defined(USE_SYSLOG) && (defined(SYSLOG_USERS) || defined(SYSLOG_CONN))) if (IsPerson(sptr)) { # if defined(FNAME_USERLOG) || defined(USE_SERVICES) || \ (defined(USE_SYSLOG) && defined(SYSLOG_USERS)) sendto_flog(sptr, EXITC_REG, sptr->user->username, sptr->user->host); # endif # if defined(CLIENTS_CHANNEL) && (CLIENTS_CHANNEL_LEVEL & CCL_QUIT) sendto_flag(SCH_CLIENT, "%s %s %s %s QUIT %c" # if (CLIENTS_CHANNEL_LEVEL & CCL_QUITINFO) " :%s" # endif , sptr->user->uid, sptr->name, sptr->user->username, sptr->user->host, sptr->exitc # if (CLIENTS_CHANNEL_LEVEL & CCL_QUITINFO) , comment # endif ); # endif } else if (!IsService(sptr)) { # if defined(FNAME_CONNLOG) || defined(USE_SERVICES) || \ (defined(USE_SYSLOG) && defined(SYSLOG_CONN)) if (sptr->exitc == '\0' || sptr->exitc == EXITC_REG) { sptr->exitc = EXITC_UNDEF; } sendto_flog(sptr, sptr->exitc, sptr->user && sptr->user->username ? sptr->user->username : "", #ifdef UNIXPORT (IsUnixSocket(sptr)) ? me.sockhost : #endif ((sptr->hostp) ? sptr->hostp->h_name : sptr->sockhost)); # endif } #endif if (MyConnect(sptr)) { if (IsPerson(sptr)) { istat.is_myclnt--; } else if (IsServer(sptr)) { istat.is_myserv--; } else if (IsService(sptr)) { istat.is_myservice--; } else { istat.is_unknown--; } if (istat.is_myclnt % CLCHNO == 0 && istat.is_myclnt != istat.is_l_myclnt) { sendto_flag(SCH_NOTICE, "Local %screase from %d to %d clients " "in %d seconds", istat.is_myclnt>istat.is_l_myclnt?"in":"de", istat.is_l_myclnt, istat.is_myclnt, timeofday - istat.is_l_myclnt_t); istat.is_l_myclnt_t = timeofday; istat.is_l_myclnt = istat.is_myclnt; } /* Send SQUIT message to 2.11 servers to tell them * the squit reason for rebroadcast on the other side * - jv */ if (IsServer(sptr)) { sendto_one(sptr, ":%s SQUIT %s :%s", me.serv->sid, sptr->serv->sid, comment); } if (cptr != NULL && sptr != cptr) { sendto_one(sptr, "ERROR :Closing Link: " "%s %s (%s)", get_client_name(sptr,FALSE), cptr->name, comment); } else { sendto_one(sptr, "ERROR :Closing Link: %s (%s)", get_client_name(sptr,FALSE), comment); } if (sptr->auth != sptr->username) { istat.is_authmem -= strlen(sptr->auth) + 1; istat.is_auth -= 1; MyFree(sptr->auth); sptr->auth = sptr->username; } } /* ** Currently only server connections can have ** depending remote clients here, but it does no ** harm to check for all local clients. In ** future some other clients than servers might ** have remotes too... ** now, I think it harms big client servers... - krys ** ** Close the Client connection first and mark it ** so that no messages are attempted to send to it. ** (The following *must* make MyConnect(sptr) == FALSE!). ** It also makes sptr->from == NULL, thus it's unnecessary ** to test whether "sptr != acptr" in the following loops. */ close_connection(sptr); } /* if (MyConnect(sptr) */ if (IsServer(sptr)) { /* Remove all dependent servers and clients. */ if (!IsMasked(sptr)) { sprintf(comment1, "%s %s", sptr->serv->up->name, sptr->name); } else { /* It was a masked server, the squit reason should ** give the right quit reason for clients. */ strncpyzt(comment1, comment, sizeof(comment1)); } /* cptr != sptr means non-local server */ if (cptr != sptr && nextconnect == 0 && find_conf_name(sptr->name, (CONF_CONNECT_SERVER|CONF_ZCONNECT_SERVER))) { /* try AC */ nextconnect = timeofday + HANGONRETRYDELAY; } exit_server(sptr, sptr, from, comment, comment1); check_split(); if ((cptr == sptr)) { /* It serves no purpose. --B. sendto_flag(SCH_SERVER, "Sending SQUIT %s (%s)", cptr->name, comment); */ return FLUSH_BUFFER; } return 0; } /* ** Try to guess from comment if the client is exiting ** normally (KILL or issued QUIT), or if it is splitting ** It requires comment for splitting users to be ** "server.some.where splitting.some.where" */ comment1[0] = '\0'; if ((sptr->flags & FLAGS_KILLED) == 0) { if (comment[0] == '"') { /* definitely user quit, see m_quit */ sptr->flags |= FLAGS_QUIT; } else { const char *c = comment; int i = 0; while (*c && *c != ' ') if (*c++ == '.') i++; if (*c++ && i) { i = 0; while (*c && *c != ' ') if (*c++ == '.') i++; if (!i || *c) sptr->flags |= FLAGS_QUIT; } else { sptr->flags |= FLAGS_QUIT; } } if (sptr == cptr && !(sptr->flags & FLAGS_QUIT)) { /* ** This will avoid nick delay to be abused by ** letting local users put a comment looking ** like a server split. */ strncpyzt(comment1, comment, HOSTLEN + HOSTLEN); strcat(comment1, " "); sptr->flags |= FLAGS_QUIT; } } exit_one_client(cptr, sptr, from, (*comment1) ? comment1 : comment); /* XXX: we probably should not call it every client exit */ /* checking every server quit should suffice --B. */ /* check_split(); */ return cptr == sptr ? FLUSH_BUFFER : 0; } /* ** Exit one client, local or remote. Assuming all dependants have ** been already removed, and socket closed for local client. */ static void exit_one_client(aClient *cptr, aClient *sptr, aClient *from, const char *comment) { Reg aClient *acptr; Reg int i; Reg Link *lp; invLink *ilp; /* ** For a server or user quitting, propagage the information to ** other servers (except to the one where is came from (cptr)) */ if (IsMe(sptr)) { sendto_flag(SCH_ERROR, "ERROR: tried to exit me! : %s", comment); return; /* ...must *never* exit self!! */ } else if (IsServer(sptr)) { /* ** Old sendto_serv_but_one() call removed because we now ** need to send different names to different servers ** (domain name matching) */ if (!IsMasked(sptr)) { istat.is_serv--; } if (!IsBursting(sptr)) { istat.is_eobservers--; } for (i = fdas.highest; i >= 0; i--) { if (!(acptr = local[fdas.fd[i]]) || !IsServer(acptr) || acptr == cptr || IsMe(acptr)) { continue; } if (!(sptr->flags & FLAGS_SQUIT)) { /* Make sure we only send the last SQUIT ** to a 2.11. */ continue; } if ((acptr->flags & FLAGS_HIDDEN) && !IsMasked(sptr)) { /* We need a special SQUIT reason, so ** the remote server can send the ** right quit message. */ sendto_one(acptr, ":%s SQUIT %s :%s %s", sptr->serv->up->serv->sid, sptr->serv->sid, sptr->serv->up->name, sptr->name); } else { sendto_one(acptr, ":%s SQUIT %s :%s", sptr->serv->up->serv->sid, sptr->serv->sid, comment); } } #ifdef USE_SERVICES check_services_butone(SERVICE_WANT_SQUIT, sptr->serv, sptr, ":%s SQUIT %s :%s", from->name, sptr->name, comment); #endif del_from_sid_hash_table(sptr->serv); remove_server_from_tree(sptr); /* remove server from svrtop */ unregister_server(sptr); } else if (!IsPerson(sptr) && !IsService(sptr)) { /* ...this test is *dubious*, would need ** some thougth.. but for now it plugs a ** nasty hole in the server... --msa */ ; /* Nothing */ } else if (sptr->name[0] && !IsService(sptr)) /* clean with QUIT... */ { /* ** If this exit is generated from "m_kill", then there ** is no sense in sending the QUIT--KILL's have been ** sent instead. */ if ((sptr->flags & FLAGS_KILLED) == 0) { if ((sptr->flags & FLAGS_SPLIT) == 0) { sendto_serv_butone(cptr, ":%s QUIT :%s", sptr->user->uid, comment); #ifdef USE_SERVICES check_services_butone(SERVICE_WANT_QUIT| SERVICE_WANT_RQUIT, (sptr->user) ? sptr->user->servp : NULL, cptr, ":%s QUIT :%s", sptr->name, comment); #endif } else { if (sptr->flags & FLAGS_HIDDEN) /* joys of hostmasking */ for (i = fdas.highest; i >= 0; i--) { if (!(acptr =local[fdas.fd[i]]) || acptr == cptr || IsMe(acptr)) continue; if (acptr->flags & FLAGS_HIDDEN) sendto_one(acptr, ":%s QUIT :%s", sptr->user->uid, comment); } #ifdef USE_SERVICES check_services_butone(SERVICE_WANT_QUIT, (sptr->user) ? sptr->user->servp : NULL, cptr, ":%s QUIT :%s", sptr->name, comment); #endif } } #ifdef USE_SERVICES else { /* Send QUIT to services which desire such as well. ** Services with both _QUIT and _KILL will get both ** for now --jv */ check_services_butone(SERVICE_WANT_QUIT, (sptr->user) ? sptr->user->servp : NULL, cptr, ":%s QUIT :%s", sptr->name, comment); } #endif /* ** If a person is on a channel, send a QUIT notice ** to every client (person) on the same channel (so ** that the client can show the "**signoff" message). ** (Note: The notice is to the local clients *only*) */ if (sptr->user) { if (IsInvisible(sptr)) { istat.is_user[1]--; sptr->user->servp->usercnt[1]--; } else { istat.is_user[0]--; sptr->user->servp->usercnt[0]--; } if (IsAnOper(sptr)) { sptr->user->servp->usercnt[2]--; istat.is_oper--; } sendto_common_channels(sptr, ":%s QUIT :%s", sptr->name, comment); if (!(acptr = cptr ? cptr : sptr->from)) acptr = sptr; while ((lp = sptr->user->channel)) { /* ** Mark channels from where remote chop left, ** this will eventually lock the channel. ** close_connection() has already been called, ** it makes MyConnect == False - krys */ if (sptr != cptr) { if (*lp->value.chptr->chname == '!') { if (!(sptr->flags &FLAGS_QUIT)) lp->value.chptr->history = timeofday + LDELAYCHASETIMELIMIT; } else if ( #ifndef BETTER_CDELAY !(sptr->flags & FLAGS_QUIT) && #endif is_chan_op(sptr, lp->value.chptr)) { lp->value.chptr->history = timeofday + DELAYCHASETIMELIMIT; } } if (IsAnonymous(lp->value.chptr) && !IsQuiet(lp->value.chptr)) { sendto_channel_butserv(lp->value.chptr, sptr, ":%s PART %s :None", sptr->name, lp->value.chptr->chname); } remove_user_from_channel(sptr,lp->value.chptr); } /* Clean up invitefield */ while ((ilp = sptr->user->invited)) { del_invite(sptr, ilp->chptr); /* again, this is all that is needed */ } /* remove from uid hash table */ if (sptr->user) { del_from_uid_hash_table(sptr->user->uid, sptr); } /* Add user to history */ #ifndef BETTER_NDELAY add_history(sptr, (sptr->flags & FLAGS_QUIT) ? &me : NULL); #else add_history(sptr, (sptr == cptr) ? &me : NULL); #endif off_history(sptr); #ifdef USE_HOSTHASH del_from_hostname_hash_table(sptr->user->host, sptr->user); #endif #ifdef USE_IPHASH del_from_ip_hash_table(sptr->user->sip, sptr->user); #endif } } else if (sptr->name[0] && IsService(sptr)) { /* ** If this exit is generated from "m_kill", then there ** is no sense in sending the QUIT--KILL's have been ** sent instead. */ if ((sptr->flags & FLAGS_KILLED) == 0) { /* ** A service quitting is annoying, It has to be sent ** to connected servers depending on ** sptr->service->dist */ for (i = fdas.highest; i >= 0; i--) { if (!(acptr = local[fdas.fd[i]]) || !IsServer(acptr) || acptr == cptr || IsMe(acptr)) { continue; } if (match(sptr->service->dist, acptr->name) && match(sptr->service->dist, acptr->serv->sid)) { continue; } sendto_one(acptr, ":%s QUIT :%s", sptr->name, comment); } } #ifdef USE_SERVICES check_services_butone(SERVICE_WANT_SERVICE, NULL, NULL, ":%s QUIT :%s", sptr->name, comment); #endif /* MyConnect(sptr) is always FALSE here */ if (cptr == sptr) { sendto_flag(SCH_NOTICE, "Service %s disconnected", get_client_name(sptr, TRUE)); } sendto_flag(SCH_SERVICE, "Received QUIT %s from %s (%s)", sptr->name, from->name, comment); istat.is_service--; } /* Remove sptr from the client list */ if (del_from_client_hash_table(sptr->name, sptr) != 1) { Debug((DEBUG_ERROR, "%#x !in tab %s[%s] %#x %#x %#x %d %d %#x", sptr, sptr->name, sptr->from ? sptr->from->sockhost : "??host", sptr->from, sptr->next, sptr->prev, sptr->fd, sptr->status, sptr->user)); } remove_client_from_list(sptr); return; } void checklist(void) { Reg aClient *acptr; Reg int i,j; if (!(bootopt & BOOT_AUTODIE)) return; for (j = i = 0; i <= highest_fd; i++) if (!(acptr = local[i])) continue; else if (IsClient(acptr)) j++; if (!j) { #ifdef USE_SYSLOG syslog(LOG_WARNING,"ircd exiting: autodie"); #endif exit(0); } return; } void initstats(void) { bzero((char *)&istat, sizeof(istat)); istat.is_serv = 1; istat.is_localc = 1; /* me */ istat.is_m_users_t = timeofday; istat.is_m_myclnt_t = timeofday; istat.is_l_myclnt_t = timeofday; bzero((char *)&ircst, sizeof(ircst)); } void initruntimeconf(void) { memset((char *)&iconf, 0, sizeof(iconf)); iconf.aconnect = 1; /* default to ON */ iconf.split = 1; /* ircd starts in split-mode */ iconf.caccept = 2; /* accept clients when no split */ /* Defaults set in config.h */ iconf.split_minservers = DEFAULT_SPLIT_SERVERS; iconf.split_minusers = DEFAULT_SPLIT_USERS; if ((bootopt & BOOT_STANDALONE)) { /* standalone mode */ iconf.split = 3; } } void tstats(aClient *cptr, char *name) { Reg aClient *acptr; Reg int i; Reg struct stats *sp; struct stats tmp; sp = &tmp; bcopy((char *)ircstp, (char *)sp, sizeof(*sp)); for (i = 0; i < MAXCONNECTIONS; i++) { if (!(acptr = local[i])) continue; if (IsServer(acptr)) { sp->is_sbs += acptr->sendB; sp->is_sbr += acptr->receiveB; sp->is_sti += timeofday - acptr->firsttime; sp->is_sv++; } else if (IsClient(acptr)) { sp->is_cbs += acptr->sendB; sp->is_cbr += acptr->receiveB; sp->is_cti += timeofday - acptr->firsttime; sp->is_cl++; } else if (IsUnknown(acptr)) sp->is_ni++; } sendto_one(cptr, ":%s %d %s :accepts %lu refused %lu", ME, RPL_STATSDEBUG, name, sp->is_ac, sp->is_ref); sendto_one(cptr, ":%s %d %s :unknown: commands %lu prefixes %lu", ME, RPL_STATSDEBUG, name, sp->is_unco, sp->is_unpf); sendto_one(cptr, ":%s %d %s :nick collisions %lu saves %lu, unknown closes %lu", ME, RPL_STATSDEBUG, name, sp->is_kill, sp->is_save, sp->is_ni); sendto_one(cptr, ":%s %d %s :wrong direction %lu empty %lu", ME, RPL_STATSDEBUG, name, sp->is_wrdi, sp->is_empt); sendto_one(cptr, ":%s %d %s :users without servers %lu ghosts N/A", ME, RPL_STATSDEBUG, name, sp->is_nosrv); sendto_one(cptr, ":%s %d %s :numerics seen %lu mode fakes %lu", ME, RPL_STATSDEBUG, name, sp->is_num, sp->is_fake); sendto_one(cptr, ":%s %d %s :auth: successes %lu fails %lu", ME, RPL_STATSDEBUG, name, sp->is_asuc, sp->is_abad); sendto_one(cptr,":%s %d %s :local connections %lu udp packets %lu", ME, RPL_STATSDEBUG, name, sp->is_loc, sp->is_udpok); sendto_one(cptr,":%s %d %s :udp errors %lu udp dropped %lu", ME, RPL_STATSDEBUG, name, sp->is_udperr, sp->is_udpdrop); sendto_one(cptr, ":%s %d %s :link checks %lu passed %lu 15s/%lu 30s dropped %luSq/%luYg/%luFl", ME, RPL_STATSDEBUG, name, sp->is_ckl, sp->is_cklq, sp->is_cklok, sp->is_cklQ, sp->is_ckly, sp->is_cklno); if (sp->is_wwcnt) sendto_one(cptr, ":%s %d %s :whowas turnover %lu/%lu/%lu [%lu]", ME, RPL_STATSDEBUG, name, sp->is_wwmt, (u_int) (sp->is_wwt / sp->is_wwcnt), sp->is_wwMt, KILLCHASETIMELIMIT); if (sp->is_lkcnt) sendto_one(cptr, ":%s %d %s :ndelay turnover %lu/%lu/%lu [%lu]", ME, RPL_STATSDEBUG, name, sp->is_lkmt, (u_int) (sp->is_lkt / sp->is_lkcnt), sp->is_lkMt, DELAYCHASETIMELIMIT); sendto_one(cptr, ":%s %d %s :abuse protections %u strict %u", ME, RPL_STATSDEBUG, name, (bootopt & BOOT_PROT) ? 1 : 0, (bootopt & BOOT_STRICTPROT) ? 1 : 0); #ifdef DELAY_CLOSE sendto_one(cptr, ":%s %d %s :delay close %lu total %lu", ME, RPL_STATSDEBUG, name, istat.is_delayclosewait, istat.is_delayclose); #endif sendto_one(cptr, ":%s %d %s :local channels reops %d remote %d", ME, RPL_STATSDEBUG, name, sp->is_reop, sp->is_rreop); sendto_one(cptr, ":%s %d %s :Client - Server", ME, RPL_STATSDEBUG, name); sendto_one(cptr, ":%s %d %s :connected %lu %lu", ME, RPL_STATSDEBUG, name, sp->is_cl, sp->is_sv); sendto_one(cptr, ":%s %d %s :bytes sent %llu %llu", ME, RPL_STATSDEBUG, name, sp->is_cbs, sp->is_sbs); sendto_one(cptr, ":%s %d %s :bytes recv %llu %llu", ME, RPL_STATSDEBUG, name, sp->is_cbr, sp->is_sbr); sendto_one(cptr, ":%s %d %s :time connected %lu %lu", ME, RPL_STATSDEBUG, name, sp->is_cti, sp->is_sti); #if defined(USE_IAUTH) report_iauth_stats(cptr, name); #endif } aMotd *motd = NULL; time_t motd_mtime; void read_motd(char *filename) { int fd, len; register aMotd *temp, *last; struct stat Sb; char line[80]; register char *tmp; if ((fd = open(filename, O_RDONLY)) == -1) return; if (fstat(fd, &Sb) == -1) { close(fd); return; } if (Sb.st_mtime <= motd_mtime) { close(fd); return; } motd_mtime = Sb.st_mtime; for(;motd != NULL;motd=last) { last = motd->next; MyFree(motd->line); MyFree(motd); } (void)dgets(-1, NULL, 0); /* make sure buffer is at empty pos */ last = NULL; while ((len=dgets(fd, line, sizeof(line)-1)) > 0) { if ((tmp = strchr(line, '\n')) != NULL) *tmp = (char) 0; else if ((tmp = strchr(line, '\r')) != NULL) *tmp = (char) 0; else line[len] = '\0'; temp = (aMotd *)MyMalloc(sizeof(aMotd)); temp->line = mystrdup(line); temp->next = NULL; if (!motd) motd = temp; else last->next = temp; last = temp; } (void)dgets(-1, NULL, 0); /* make sure buffer is at empty pos */ close(fd); } void check_split(void) { if ((bootopt & BOOT_STANDALONE)) return; if (istat.is_eobservers < iconf.split_minservers || istat.is_user[0] + istat.is_user[1] < iconf.split_minusers) { /* Split detected */ if (!IsSplit()) { sendto_flag(SCH_NOTICE, "Network split detected, split mode activated"); iconf.split = timeofday; } } else { /* End of split */ if (IsSplit()) { sendto_flag(SCH_NOTICE, "Network rejoined, split mode deactivated"); iconf.split = 0; if (!firstrejoindone) { firstrejoindone = 1; activate_delayed_listeners(); #ifdef CACCEPT_DEFAULT iconf.caccept = CACCEPT_DEFAULT; #endif } } } } /* Some day play with better random functions (configure) etc. --B. */ int myrand(void) { return rand(); } void mysrand(unsigned int seed) { srand(seed); } irc2.11.2p3/ircd/res_comp.c0000644000175000017500000005112310127336166013237 0ustar kkkk/* * ++Copyright++ 1985, 1993 * - * Copyright (c) 1985, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Portions Copyright (c) 1993 by Digital Equipment Corporation. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies, and that * the name of Digital Equipment Corporation not be used in advertising or * publicity pertaining to distribution of the document or software without * specific, written prior permission. * * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * - * --Copyright-- */ #if defined(LIBC_SCCS) && !defined(lint) static const volatile char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93"; static const volatile char rcsid[] = "$Id: res_comp.c,v 1.10 2004/10/01 20:22:14 chopin Exp $"; #endif /* LIBC_SCCS and not lint */ #include "os.h" #include "s_defines.h" #define RES_COMP_C #include "s_externs.h" #undef RES_COMP_C static int ns_name_ntop (const u_char *, char *, size_t); static int ns_name_pton (const char *, u_char *, size_t); static int ns_name_unpack (const u_char *, const u_char *, const u_char *, u_char *, size_t); static int ns_name_pack (const u_char *, u_char *, int, const u_char **, const u_char **); static int ns_name_uncompress (const u_char *, const u_char *, const u_char *, char *, size_t); static int ns_name_compress (const char *, u_char *, size_t, const u_char **, const u_char **); static int ns_name_skip (const u_char **, const u_char *); /* * Expand compressed domain name 'comp_dn' to full domain name. * 'msg' is a pointer to the begining of the message, * 'eomorig' points to the first location after the message, * 'exp_dn' is a pointer to a buffer of size 'length' for the result. * Return size of compressed name or -1 if there was an error. */ int ircd_dn_expand(const u_char *msg, const u_char *eom, const u_char *src, char *dst, int dstsiz) { int n = ns_name_uncompress(msg, eom, src, dst, (size_t)dstsiz); if (n > 0 && dst[0] == '.') dst[0] = '\0'; return (n); } /* * Pack domain name 'exp_dn' in presentation form into 'comp_dn'. * Return the size of the compressed name or -1. * 'length' is the size of the array pointed to by 'comp_dn'. */ int ircd_dn_comp(const char *src, u_char *dst, int dstsiz, u_char **dnptrs, u_char **lastdnptr) { return (ns_name_compress(src, dst, (size_t)dstsiz, (const u_char **)dnptrs, (const u_char **)lastdnptr)); } /* * Skip over a compressed domain name. Return the size or -1. */ int __ircd_dn_skipname(const u_char *ptr, const u_char *eom) { const u_char *saveptr = ptr; if (ns_name_skip(&ptr, eom) == -1) return (-1); return (ptr - saveptr); } /* * Verify that a domain name uses an acceptable character set. */ /* * Note the conspicuous absence of ctype macros in these definitions. On * non-ASCII hosts, we can't depend on string literals or ctype macros to * tell us anything about network-format data. The rest of the BIND system * is not careful about this, but for some reason, we're doing it right here. */ #define PERIOD 0x2e #define hyphenchar(c) ((c) == 0x2d) #define bslashchar(c) ((c) == 0x5c) #define periodchar(c) ((c) == PERIOD) #define asterchar(c) ((c) == 0x2a) #define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) \ || ((c) >= 0x61 && (c) <= 0x7a)) #define digitchar(c) ((c) >= 0x30 && (c) <= 0x39) #define borderchar(c) (alphachar(c) || digitchar(c)) #define middlechar(c) (borderchar(c) || hyphenchar(c)) #define domainchar(c) ((c) > 0x20 && (c) < 0x7f) #if 0 /* it seems that we don't need these -krys */ int res_hnok(const char *dn) { int ppch = '\0', pch = PERIOD, ch = *dn++; while (ch != '\0') { int nch = *dn++; if (periodchar(ch)) { NULL; } else if (periodchar(pch)) { if (!borderchar(ch)) return (0); } else if (periodchar(nch) || nch == '\0') { if (!borderchar(ch)) return (0); } else { if (!middlechar(ch)) return (0); } ppch = pch, pch = ch, ch = nch; } return (1); } /* * hostname-like (A, MX, WKS) owners can have "*" as their first label * but must otherwise be as a host name. */ int res_ownok(const char *dn) { if (asterchar(dn[0])) { if (periodchar(dn[1])) return (res_hnok(dn+2)); if (dn[1] == '\0') return (1); } return (res_hnok(dn)); } /* * SOA RNAMEs and RP RNAMEs can have any printable character in their first * label, but the rest of the name has to look like a host name. */ int res_mailok(const char *dn) { int ch, escaped = 0; /* "." is a valid missing representation */ if (*dn == '\0') return(1); /* otherwise