From 8534a21cefcb5af23bf2b945755d53c5566ea6ac Mon Sep 17 00:00:00 2001 From: Bryan Stansell Date: Sun, 20 Apr 2014 21:47:40 -0700 Subject: [PATCH] Imported from conserver-8.2.0.tar.gz --- CHANGES | 16 +- INSTALL | 17 +- autologin/autologin.c | 34 +- autologin/main.c | 14 +- autologin/main.h | 2 +- compat.h | 96 +-- config.h.in | 21 +- configure | 243 ++++-- configure.in | 127 +++- conserver.cf/conserver.cf.man | 2 +- conserver.cf/conserver.passwd.man | 2 +- conserver.html | 4 +- conserver/access.c | 161 ++-- conserver/access.h | 14 +- conserver/client.c | 101 +-- conserver/client.h | 15 +- conserver/consent.c | 314 ++++---- conserver/consent.h | 30 +- conserver/conserver.man | 2 +- conserver/convert.c | 21 +- conserver/cutil.c | 612 +++------------ conserver/cutil.h | 167 ++-- conserver/fallback.c | 80 +- conserver/group.c | 669 +++++----------- conserver/group.h | 41 +- conserver/main.c | 327 ++++---- conserver/main.h | 15 +- conserver/master.c | 147 ++-- conserver/master.h | 6 +- conserver/readcfg.c | 1179 +---------------------------- conserver/readcfg.h | 20 +- conserver/version.h | 6 +- console/console.c | 250 +++--- console/console.man | 2 +- console/getpassword.c | 21 +- console/getpassword.h | 6 +- console/readconf.c | 164 +--- console/readconf.h | 8 +- contrib/redhat-rpm/conserver.spec | 2 +- contrib/solaris-package/pkginfo | 2 +- 40 files changed, 1618 insertions(+), 3342 deletions(-) diff --git a/CHANGES b/CHANGES index 49199bf..fe957c8 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,20 @@ CHANGES ======= +version 8.2.0 (Apr 20, 2014): + - added --with-trust-uds-cred which uses getsockopt() to fetch and + trust the client uid, bypassing password lookups - patch by Anton + Lundin + - missing closedir() causing memory leak - patch by Anton Lundin + + - sending a break signal over IPMI was broken - based on patch by + Alexander Y. Fomichev + - IPv6 support (marked as experimental at this point because it's + untested (except by the author), there's a lack of documentation, and + I'm hoping for non-getifaddrs() system support) - patch by Milos + Vyletel + - no more K&R compiler support + version 8.1.20 (Apr 4, 2014): - IPMI serial over LAN support via FreeIPMI - based on patch by Anton D. Kachalov @@ -938,5 +952,5 @@ before version 6.05: and enhancements of various types were applied. # -# $Id: CHANGES,v 1.239 2014/04/04 16:27:38 bryan Exp $ +# $Id: CHANGES,v 1.247 2014/04/21 04:47:37 bryan Exp $ # diff --git a/INSTALL b/INSTALL index 0d46cf9..bd293c2 100644 --- a/INSTALL +++ b/INSTALL @@ -156,8 +156,9 @@ Detailed Instructions --with-port=PORT Specify port number [conserver] --with-base=PORT Base port for secondary channel [0] --with-master=MASTER Specify master server hostname [console] - --with-cffile=CFFILE Specify config filename - [SYSCONFDIR/conserver.cf] + --with-ccffile=CFFILE Specify client config filename + [SYSCONFDIR/console.cf] + --with-cffile=CFFILE Specify config filename [SYSCONFDIR/conserver.cf] --with-pwdfile=PWDFILE Specify password filename [SYSCONFDIR/conserver.passwd] --with-logfile=LOGFILE Specify log filename [/var/log/conserver] @@ -166,12 +167,22 @@ Detailed Instructions --with-timeout=TIMEOUT Specify connect() timeout in seconds [10] --with-trustrevdns Trust reverse DNS information --with-extmsgs Produce extended messages + --with-rpath Use -R as well as -L for libraries + --with-cycladests (deprecated - noop) Build for a Cyclades TS --with-uds[=DIR] Use Unix domain sockets for client/server communication [/tmp/conserver] + --with-trust-uds-cred Trust UDS credentials obtained via socket --with-libwrap[=PATH] Compile in libwrap (tcp_wrappers) support --with-openssl[=PATH] Compile in OpenSSL support + --with-req-server-cert Require server SSL certificate by client + --with-gssapi[=PATH] Compile in GSS-API support + --with-striprealm retry username without @REALM with gss-api + authentication + --with-freeipmi[=PATH] Compile in FreeIPMI support --with-dmalloc[=PATH] Compile in dmalloc support --with-pam Enable PAM support + --with-ipv6 (experimental) Use IPv6 for client/server + communication Not surprisingly, some match the old conserver/cons.h items...here they are for reference: @@ -278,5 +289,5 @@ Other Information And Gotchas # -# $Id: INSTALL,v 1.39 2005/05/21 13:47:16 bryan Exp $ +# $Id: INSTALL,v 1.41 2014/04/20 06:45:07 bryan Exp $ # diff --git a/autologin/autologin.c b/autologin/autologin.c index 35ac390..70ec43e 100644 --- a/autologin/autologin.c +++ b/autologin/autologin.c @@ -34,13 +34,13 @@ * to change the /etc/security/audit_event line. */ -#define AUE_autologin 32900 +# define AUE_autologin 32900 -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include #endif #include @@ -69,7 +69,7 @@ */ #ifndef lint -char *rcsid = "$Id: autologin.c,v 1.27 2013/09/20 21:15:13 bryan Exp $"; +char *rcsid = "$Id: autologin.c,v 1.28 2014/04/20 06:45:07 bryan Exp $"; #endif /* not lint */ extern char *progname; gid_t awGrps[NGROUPS_MAX]; @@ -86,7 +86,7 @@ void make_utmp(); void usage(); int -Process() +Process(void) { int iErrs = 0; int i, iNewGrp; @@ -411,8 +411,7 @@ Process() #ifndef HAVE_PUTENV int -putenv(pcAssign) - char *pcAssign; +putenv(char *pcAssign) { register char *pcEq; @@ -427,8 +426,7 @@ putenv(pcAssign) #endif int -addgroup(pcGrp) - char *pcGrp; +addgroup(char *pcGrp) { struct group *grp; @@ -451,9 +449,7 @@ addgroup(pcGrp) /* install a utmp entry to show the use we know is here is here (ksb) */ void -make_utmp(pclogin, pctty) - char *pclogin; - char *pctty; +make_utmp(char *pclogin, char *pctty) { register int iFound, iPos; register int fdUtmp; @@ -513,7 +509,7 @@ make_utmp(pclogin, pctty) (void)strncpy(utmp.ut_line, pcDev, sizeof(utmp.ut_line)); } #else -#ifdef HAVE_SETTTYENT +# ifdef HAVE_SETTTYENT { register struct ttyent *ty; @@ -534,7 +530,7 @@ make_utmp(pclogin, pctty) (void)strncpy(utmp.ut_line, pcDev, sizeof(utmp.ut_line)); (void)strncpy(utmp.ut_name, pclogin, sizeof(utmp.ut_name)); (void)strncpy(utmp.ut_host, "(autologin)", sizeof(utmp.ut_host)); -#else +# else /* look through /etc/utmp by hand (sigh) */ iFound = iPos = 0; @@ -546,7 +542,7 @@ make_utmp(pclogin, pctty) iPos++; } (void)strncpy(utmp.ut_name, pclogin, sizeof(utmp.ut_name)); -#endif +# endif #endif utmp.ut_time = time((time_t *)0); @@ -562,7 +558,7 @@ make_utmp(pclogin, pctty) void -usage() +usage(void) { char *u_pch; int u_loop; diff --git a/autologin/main.c b/autologin/main.c index 15ab12b..302bdbe 100644 --- a/autologin/main.c +++ b/autologin/main.c @@ -20,9 +20,7 @@ static int * does +arg if you give a last argument of "+", else give (char *)0 */ static int -getopt(nargc, nargv, ostr) - int nargc; - char **nargv, *ostr; +getopt(int nargc, char **nargv, char *ostr) { register char *oli; /* option letter list index */ static char EMSG[] = ""; /* just a null place */ @@ -84,7 +82,7 @@ getopt(nargc, nargv, ostr) char *progname = - "$Id: main.c,v 1.2 2013/09/20 21:15:13 bryan Exp $", *au_terse[] = { + "$Id: main.c,v 1.3 2014/04/20 06:45:07 bryan Exp $", *au_terse[] = { " [-u] [-c cmd] [-e env=value] [-g group] [-l login] [-t tty]", " -h", " -V", @@ -104,18 +102,16 @@ int fMakeUtmp = 1, iErrs = 0; #ifndef u_terse -#define u_terse (au_terse[0]) +# define u_terse (au_terse[0]) #endif -static char *rcsid = "$Id: main.c,v 1.2 2013/09/20 21:15:13 bryan Exp $"; +static char *rcsid = "$Id: main.c,v 1.3 2014/04/20 06:45:07 bryan Exp $"; /* * parser */ int -main(argc, argv) - int argc; - char **argv; +main(int argc, char **argv) { static char sbOpt[] = "c:e:g:hl:t:uV", *u_pch = (char *)0; diff --git a/autologin/main.h b/autologin/main.h index fe92e2b..ddc3745 100644 --- a/autologin/main.h +++ b/autologin/main.h @@ -4,7 +4,7 @@ extern char *progname, *au_terse[4], *u_help[9]; #ifndef u_terse -#define u_terse (au_terse[0]) +# define u_terse (au_terse[0]) #endif extern int main(); extern int fMakeUtmp, iErrs; diff --git a/compat.h b/compat.h index 686f5e3..4ddd62f 100644 --- a/compat.h +++ b/compat.h @@ -49,15 +49,15 @@ /* For legacy compile-time setting of the port... */ #if ! defined(DEFPORT) -# if defined(SERVICENAME) -# define DEFPORT SERVICENAME +# if defined(SERVICENAME) +# define DEFPORT SERVICENAME +# else +# if defined(PORTNUMBER) +# define DEFPORT PORTNUMBER # else -# if defined(PORTNUMBER) -# define DEFPORT PORTNUMBER -# else -# define DEFPORT "conserver" -# endif +# define DEFPORT "conserver" # endif +# endif #endif #if STDC_HEADERS @@ -129,7 +129,7 @@ typedef long fd_set; #endif #if HAVE_TYPES_H -#include +# include #endif #if HAVE_SYS_WAIT_H @@ -138,30 +138,30 @@ typedef long fd_set; #define LO(s) ((unsigned)((s) & 0377)) #define HI(s) ((unsigned)(((s) >> 8) & 0377)) #if !defined(WIFEXITED) -#define WIFEXITED(s) (LO(s)==0) +# define WIFEXITED(s) (LO(s)==0) #endif #if !defined(WEXITSTATUS) -#define WEXITSTATUS(s) HI(s) +# define WEXITSTATUS(s) HI(s) #endif #if !defined(WIFSIGNALED) -#define WIFSIGNALED(s) ((LO(s)>0)&&(HI(s)==0)) +# define WIFSIGNALED(s) ((LO(s)>0)&&(HI(s)==0)) #endif #if !defined(WTERMSIG) -#define WTERMSIG(s) (LO(s)&0177) +# define WTERMSIG(s) (LO(s)&0177) #endif #if !defined(WIFSTOPPED) -#define WIFSTOPPED(s) ((LO(s)==0177)&&(HI(s)!=0)) +# define WIFSTOPPED(s) ((LO(s)==0177)&&(HI(s)!=0)) #endif #if !defined(WSTOPSIG) -#define WSTOPSIG(s) HI(s) +# define WSTOPSIG(s) HI(s) #endif #if HAVE_SYSEXITS_H -#include +# include #else -#define EX_OK 0 -#define EX_UNAVAILABLE 69 -#define EX_TEMPFAIL 75 +# define EX_OK 0 +# define EX_UNAVAILABLE 69 +# define EX_TEMPFAIL 75 #endif #include @@ -235,19 +235,19 @@ extern char *h_errlist[]; #endif #ifdef HAVE_USERSEC_H -#include +# include #endif #ifdef HAVE_PTY_H -#include +# include #endif #ifdef HAVE_LIBUTIL_H -#include +# include #endif #ifdef HAVE_UTIL_H -#include +# include #endif @@ -280,58 +280,66 @@ typedef int socklen_t; * as legacy definitions. */ #ifndef IUCLC -#define IUCLC 0 +# define IUCLC 0 #endif #ifndef OLCUC -#define OLCUC 0 +# define OLCUC 0 #endif #ifndef XCASE -#define XCASE 0 +# define XCASE 0 #endif /* Some systems don't have OFILL or *DLY. */ #ifndef OFILL -#define OFILL 0 +# define OFILL 0 #endif #ifndef NLDLY -#define NLDLY 0 +# define NLDLY 0 #endif #ifndef CRDLY -#define CRDLY 0 +# define CRDLY 0 #endif #ifndef TABDLY -#define TABDLY 0 +# define TABDLY 0 #endif #ifndef BSDLY -#define BSDLY 0 +# define BSDLY 0 #endif #ifndef ONOCR -#define ONOCR 0 +# define ONOCR 0 #endif #ifndef ONLRET -#define ONLRET 0 +# define ONLRET 0 #endif #ifndef SEEK_SET -#define SEEK_SET L_SET -#endif - -#ifndef PARAMS -# if PROTOTYPES -# define PARAMS(protos) protos -# else /* no PROTOTYPES */ -# define PARAMS(protos) () -# endif /* no PROTOTYPES */ +# define SEEK_SET L_SET #endif /* setup a conditional debugging line */ #ifndef CONDDEBUG -#define CONDDEBUG(line) if (fDebug) {debugFileName=__FILE__; debugLineNo=__LINE__; Debug line;} +# define CONDDEBUG(line) if (fDebug) {debugFileName=__FILE__; debugLineNo=__LINE__; Debug line;} #endif #if HAVE_DMALLOC -#include +# include #endif #if HAVE_FREEIPMI -#include +# include +#endif + +#ifndef INADDR_STYPE +# if USE_IPV6 +# define INADDR_STYPE struct sockaddr_storage +# else +# define INADDR_STYPE struct in_addr +# endif +#endif + +#ifndef SOCKADDR_STYPE +# if USE_IPV6 +# define SOCKADDR_STYPE struct sockaddr_storage +# else +# define SOCKADDR_STYPE struct sockaddr_in +# endif #endif diff --git a/config.h.in b/config.h.in index c135e98..afc4bad 100644 --- a/config.h.in +++ b/config.h.in @@ -330,9 +330,6 @@ /* pidfile to write to */ #undef PIDFILE -/* Define to 1 if the C compiler supports function prototypes. */ -#undef PROTOTYPES - /* Defined if client requires server SSL certificate */ #undef REQ_SERVER_CERT @@ -351,12 +348,27 @@ /* Defined if we trust reverse DNS */ #undef TRUST_REVERSE_DNS +/* Defined if we trust credentials from UDS client */ +#undef TRUST_UDS_CRED + /* Directory for Unix domain sockets */ #undef UDSDIR +/* Defined to UDS credential socket option */ +#undef UDS_CRED_SO + +/* Defined to UDS credential structure name */ +#undef UDS_CRED_STYPE + +/* Defined to UDS credential structure uid field */ +#undef UDS_CRED_UID + /* Defined if we produce extended messages */ #undef USE_EXTENDED_MESSAGES +/* Defined if building with IPv6 support */ +#undef USE_IPV6 + /* use tcp_wrappers libwrap */ #undef USE_LIBWRAP @@ -395,9 +407,6 @@ /* 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 diff --git a/configure b/configure index 543d495..9609206 100755 --- a/configure +++ b/configure @@ -682,9 +682,10 @@ with_maxmemb with_timeout with_trustrevdns with_extmsgs -with_uds with_rpath with_cycladests +with_uds +with_trust_uds_cred with_libwrap with_openssl with_req_server_cert @@ -693,6 +694,7 @@ with_striprealm with_freeipmi with_dmalloc with_pam +with_ipv6 ' ac_precious_vars='build_alias host_alias @@ -1329,10 +1331,11 @@ Optional Packages: --with-timeout=TIMEOUT Specify connect() timeout in seconds [10] --with-trustrevdns Trust reverse DNS information --with-extmsgs Produce extended messages + --with-rpath Use -R as well as -L for libraries + --with-cycladests (deprecated - noop) Build for a Cyclades TS --with-uds[=DIR] Use Unix domain sockets for client/server communication [/tmp/conserver] - --with-rpath Use -R as well as -L for libraries - --with-cycladests Build for a Cyclades TS + --with-trust-uds-cred Trust UDS credentials obtained via socket --with-libwrap[=PATH] Compile in libwrap (tcp_wrappers) support --with-openssl[=PATH] Compile in OpenSSL support --with-req-server-cert Require server SSL certificate by client @@ -1342,6 +1345,8 @@ Optional Packages: --with-freeipmi[=PATH] Compile in FreeIPMI support --with-dmalloc[=PATH] Compile in dmalloc support --with-pam Enable PAM support + --with-ipv6 (experimental) Use IPv6 for client/server + communication Some influential environment variables: CC C compiler command @@ -2604,52 +2609,6 @@ $as_echo "no" >&6; } fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use Unix domain sockets" >&5 -$as_echo_n "checking whether to use Unix domain sockets... " >&6; } -cons_with_uds="NO" - -# Check whether --with-uds was given. -if test "${with_uds+set}" = set; then : - withval=$with_uds; case "$withval" in - yes) - cat >>confdefs.h <<_ACEOF -#define UDSDIR "/tmp/conserver" -_ACEOF - - $as_echo "#define USE_UNIX_DOMAIN_SOCKETS 1" >>confdefs.h - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: /tmp/conserver" >&5 -$as_echo "/tmp/conserver" >&6; } - cons_with_uds="YES" - ;; - no) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - ;; - *) - cat >>confdefs.h <<_ACEOF -#define UDSDIR "$withval" -_ACEOF - - $as_echo "#define USE_UNIX_DOMAIN_SOCKETS 1" >>confdefs.h - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: '$withval'" >&5 -$as_echo "'$withval'" >&6; } - cons_with_uds="YES" - if expr "$withval" : '/' >/dev/null 2>&1; then - : - else - echo "*** WARNING *** you may have better success using a fully-qualified path" - echo "*** WARNING *** instead of '$withval'" - fi - ;; - esac -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - use_dash_r=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use -R paths as well as -L" >&5 $as_echo_n "checking whether to use -R paths as well as -L... " >&6; } @@ -4192,22 +4151,6 @@ $as_echo "#define const /**/" >>confdefs.h fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for function prototypes" >&5 -$as_echo_n "checking for function prototypes... " >&6; } -if test "$ac_cv_prog_cc_c89" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -$as_echo "#define PROTOTYPES 1" >>confdefs.h - - -$as_echo "#define __PROTOTYPES 1" >>confdefs.h - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 @@ -4995,6 +4938,149 @@ fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use Unix domain sockets" >&5 +$as_echo_n "checking whether to use Unix domain sockets... " >&6; } +cons_with_uds="NO" + +# Check whether --with-uds was given. +if test "${with_uds+set}" = set; then : + withval=$with_uds; case "$withval" in + yes) + cat >>confdefs.h <<_ACEOF +#define UDSDIR "/tmp/conserver" +_ACEOF + + $as_echo "#define USE_UNIX_DOMAIN_SOCKETS 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: /tmp/conserver" >&5 +$as_echo "/tmp/conserver" >&6; } + cons_with_uds="YES" + ;; + no) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + ;; + *) + cat >>confdefs.h <<_ACEOF +#define UDSDIR "$withval" +_ACEOF + + $as_echo "#define USE_UNIX_DOMAIN_SOCKETS 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: '$withval'" >&5 +$as_echo "'$withval'" >&6; } + cons_with_uds="YES" + if expr "$withval" : '/' >/dev/null 2>&1; then + : + else + echo "*** WARNING *** you may have better success using a fully-qualified path" + echo "*** WARNING *** instead of '$withval'" + fi + ;; + esac + + if test $cons_with_uds = YES; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to trust UDS credentials" >&5 +$as_echo_n "checking whether to trust UDS credentials... " >&6; } + +# Check whether --with-trust-uds-cred was given. +if test "${with_trust_uds_cred+set}" = set; then : + withval=$with_trust_uds_cred; case "$withval" in + yes) + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include +int +main () +{ + +struct ucred u; +u.uid = 0; +#if !defined(SO_PEERCRED) +#error "no SO_PEERCRED defined" +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define UDS_CRED_STYPE ucred" >>confdefs.h + + +$as_echo "#define UDS_CRED_UID uid" >>confdefs.h + + +$as_echo "#define UDS_CRED_SO SO_PEERCRED" >>confdefs.h + + $as_echo "#define TRUST_UDS_CRED 1" >>confdefs.h + +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include +int +main () +{ + +struct peercred_struct u; +u.euid = 0; +#if !defined(SO_PEERID) +#error "no SO_PEERID defined" +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define UDS_CRED_STYPE peercred_struct" >>confdefs.h + + +$as_echo "#define UDS_CRED_UID euid" >>confdefs.h + + +$as_echo "#define UDS_CRED_SO SO_PEERID" >>confdefs.h + + $as_echo "#define TRUST_UDS_CRED 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + ;; + esac +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + fi + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + cons_with_libwrap="NO" # Check whether --with-libwrap was given. @@ -5574,6 +5660,32 @@ $as_echo "no" >&6; } fi +cons_with_ipv6="NO" +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support IPv6" >&5 +$as_echo_n "checking whether to support IPv6... " >&6; } + +# Check whether --with-ipv6 was given. +if test "${with_ipv6+set}" = set; then : + withval=$with_ipv6; case "$withval" in + yes) + $as_echo "#define USE_IPV6 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + cons_with_ipv6="YES" + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + ;; + esac +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + for ac_header in pty.h libutil.h util.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` @@ -7065,6 +7177,7 @@ echo " strip @REALM (--with-striprealm): $cons_strip_realm" fi echo " dmalloc (--with-dmalloc) : $cons_with_dmalloc" echo " PAM support (--with-pam) : $cons_with_pam" +echo " IPv6 support (--with-ipv6) : $cons_with_ipv6" echo "" echo "==============================================================" diff --git a/configure.in b/configure.in index a35309a..a060811 100644 --- a/configure.in +++ b/configure.in @@ -22,9 +22,11 @@ AH_TEMPLATE([HAVE_SA_LEN],[Defined if sa_len member exists in struct sockaddr]) AH_TEMPLATE([TRUST_REVERSE_DNS],[Defined if we trust reverse DNS]) AH_TEMPLATE([USE_EXTENDED_MESSAGES],[Defined if we produce extended messages]) AH_TEMPLATE([USE_UNIX_DOMAIN_SOCKETS],[Defined if we use Unix domain sockets]) +AH_TEMPLATE([USE_IPV6], [Defined if building with IPv6 support]) AH_TEMPLATE([UDSDIR], [Directory for Unix domain sockets]) AH_TEMPLATE([FOR_CYCLADES_TS], [Defined if building for a Cyclades TS]) AH_TEMPLATE([REQ_SERVER_CERT], [Defined if client requires server SSL certificate]) +AH_TEMPLATE([TRUST_UDS_CRED], [Defined if we trust credentials from UDS client]) dnl ### Normal initialization. ###################################### AC_INIT @@ -258,35 +260,6 @@ AC_ARG_WITH(extmsgs, ;; esac],[AC_MSG_RESULT(no)]) -AC_MSG_CHECKING(whether to use Unix domain sockets) -cons_with_uds="NO" -AC_ARG_WITH(uds, - AS_HELP_STRING([--with-uds@<:@=DIR@:>@ ], - [Use Unix domain sockets for client/server communication @<:@/tmp/conserver@:>@]), - [case "$withval" in - yes) - AC_DEFINE_UNQUOTED(UDSDIR, "/tmp/conserver") - AC_DEFINE(USE_UNIX_DOMAIN_SOCKETS) - AC_MSG_RESULT([/tmp/conserver]) - cons_with_uds="YES" - ;; - no) - AC_MSG_RESULT(no) - ;; - *) - AC_DEFINE_UNQUOTED(UDSDIR, "$withval") - AC_DEFINE(USE_UNIX_DOMAIN_SOCKETS) - AC_MSG_RESULT('$withval') - cons_with_uds="YES" - if expr "$withval" : '/' >/dev/null 2>&1; then - : - else - echo "*** WARNING *** you may have better success using a fully-qualified path" - echo "*** WARNING *** instead of '$withval'" - fi - ;; - esac],[AC_MSG_RESULT(no)]) - use_dash_r=no AC_MSG_CHECKING(whether to use -R paths as well as -L) AC_ARG_WITH(rpath, @@ -304,7 +277,7 @@ AC_ARG_WITH(rpath, AC_MSG_CHECKING(whether we are building for a Cyclades TS) AC_ARG_WITH(cycladests, - AS_HELP_STRING([--with-cycladests],[Build for a Cyclades TS]), + AS_HELP_STRING([--with-cycladests],[(deprecated - noop) Build for a Cyclades TS]), [case "$withval" in yes) AC_DEFINE(FOR_CYCLADES_TS) @@ -325,7 +298,6 @@ AC_PROG_MAKE_SET dnl ### Compiler characteristics. ################################## AC_AIX AC_C_CONST -AC_C_PROTOTYPES dnl AC_CHECK_SIZEOF(long) dnl if test "$ac_cv_sizeof_long" -gt 4; then @@ -402,6 +374,81 @@ AC_SEARCH_LIBS(crypt,crypt) AC_SUBST(CONSLIBS) AC_SUBST(CONSCPPFLAGS) AC_SUBST(CONSLDFLAGS) + +AC_MSG_CHECKING(whether to use Unix domain sockets) +cons_with_uds="NO" +AC_ARG_WITH(uds, + AS_HELP_STRING([--with-uds@<:@=DIR@:>@ ], + [Use Unix domain sockets for client/server communication @<:@/tmp/conserver@:>@]), + [case "$withval" in + yes) + AC_DEFINE_UNQUOTED(UDSDIR, "/tmp/conserver") + AC_DEFINE(USE_UNIX_DOMAIN_SOCKETS) + AC_MSG_RESULT([/tmp/conserver]) + cons_with_uds="YES" + ;; + no) + AC_MSG_RESULT(no) + ;; + *) + AC_DEFINE_UNQUOTED(UDSDIR, "$withval") + AC_DEFINE(USE_UNIX_DOMAIN_SOCKETS) + AC_MSG_RESULT('$withval') + cons_with_uds="YES" + if expr "$withval" : '/' >/dev/null 2>&1; then + : + else + echo "*** WARNING *** you may have better success using a fully-qualified path" + echo "*** WARNING *** instead of '$withval'" + fi + ;; + esac + + if test $cons_with_uds = YES; then + AC_MSG_CHECKING(whether to trust UDS credentials) + AC_ARG_WITH(trust-uds-cred, + AS_HELP_STRING([--with-trust-uds-cred],[Trust UDS credentials obtained via socket]), + [case "$withval" in + yes) + AC_TRY_COMPILE([#include + #include ], + [ +struct ucred u; +u.uid = 0; +#if !defined(SO_PEERCRED) +#error "no SO_PEERCRED defined" +#endif + ], + [AC_MSG_RESULT(yes) + AC_DEFINE(UDS_CRED_STYPE, ucred, [Defined to UDS credential structure name]) + AC_DEFINE(UDS_CRED_UID, uid, [Defined to UDS credential structure uid field]) + AC_DEFINE(UDS_CRED_SO, SO_PEERCRED, [Defined to UDS credential socket option]) + AC_DEFINE(TRUST_UDS_CRED)], + [ + AC_TRY_COMPILE([#include + #include ], + [ +struct peercred_struct u; +u.euid = 0; +#if !defined(SO_PEERID) +#error "no SO_PEERID defined" +#endif + ], + [AC_MSG_RESULT(yes) + AC_DEFINE(UDS_CRED_STYPE, peercred_struct, [Defined to UDS credential structure name]) + AC_DEFINE(UDS_CRED_UID, euid, [Defined to UDS credential structure uid field]) + AC_DEFINE(UDS_CRED_SO, SO_PEERID, [Defined to UDS credential socket option]) + AC_DEFINE(TRUST_UDS_CRED)], + [AC_MSG_RESULT(no)]) + ]) + ;; + *) + AC_MSG_RESULT(no) + ;; + esac],[AC_MSG_RESULT(no)]) + fi + ],[AC_MSG_RESULT(no)]) + cons_with_libwrap="NO" AC_ARG_WITH(libwrap, AS_HELP_STRING([--with-libwrap@<:@=PATH@:>@], @@ -749,6 +796,23 @@ AC_ARG_WITH(pam, AC_MSG_RESULT(no) fi],[AC_MSG_RESULT(no)]) +cons_with_ipv6="NO" +AC_MSG_CHECKING(whether to support IPv6) +AC_ARG_WITH(ipv6, + AS_HELP_STRING([--with-ipv6], + [(experimental) Use IPv6 for client/server communication]), + [case "$withval" in + yes) + AC_DEFINE(USE_IPV6) + AC_MSG_RESULT(yes) + cons_with_ipv6="YES" + ;; + *) + AC_MSG_RESULT(no) + ;; + esac],[AC_MSG_RESULT(no)]) + + dnl Checks for pty allocation... dnl According to the xemacs distribution: dnl getpt() is the preferred pty allocation method on glibc systems. @@ -796,6 +860,7 @@ echo " strip @REALM (--with-striprealm): $cons_strip_realm" fi echo " dmalloc (--with-dmalloc) : $cons_with_dmalloc" echo " PAM support (--with-pam) : $cons_with_pam" +echo " IPv6 support (--with-ipv6) : $cons_with_ipv6" echo "" echo "==============================================================" ] diff --git a/conserver.cf/conserver.cf.man b/conserver.cf/conserver.cf.man index e4c5c44..58cdc1a 100644 --- a/conserver.cf/conserver.cf.man +++ b/conserver.cf/conserver.cf.man @@ -1,5 +1,5 @@ .\" $Id: conserver.cf.man,v 1.85 2014/04/04 16:17:45 bryan Exp $ -.TH CONSERVER.CF 5 "2014/04/04" "conserver-8.1.20" "conserver" +.TH CONSERVER.CF 5 "2014/04/04" "conserver-8.2.0" "conserver" .SH NAME conserver.cf \- console configuration file for .BR conserver (8) diff --git a/conserver.cf/conserver.passwd.man b/conserver.cf/conserver.passwd.man index 03d408d..68ea879 100644 --- a/conserver.cf/conserver.passwd.man +++ b/conserver.cf/conserver.passwd.man @@ -1,5 +1,5 @@ .\" $Id: conserver.passwd.man,v 1.10 2004/01/08 16:12:33 bryan Exp $ -.TH CONSERVER.PASSWD 5 "2004/01/08" "conserver-8.1.20" "conserver" +.TH CONSERVER.PASSWD 5 "2004/01/08" "conserver-8.2.0" "conserver" .SH NAME conserver.passwd \- user access information for .BR conserver (8) diff --git a/conserver.html b/conserver.html index 4c62e91..ba29743 100644 --- a/conserver.html +++ b/conserver.html @@ -177,8 +177,8 @@ body {

Downloading

-

The current version, released on Apr 4, 2014, is - 8.1.20.tar.gz. See the The current version, released on Apr 20, 2014, is + 8.2.0.tar.gz. See the CHANGES file for information on the latest updates.

diff --git a/conserver/access.c b/conserver/access.c index d7d3fd9..2165957 100644 --- a/conserver/access.c +++ b/conserver/access.c @@ -1,5 +1,5 @@ /* - * $Id: access.c,v 5.73 2004/05/23 16:44:25 bryan Exp $ + * $Id: access.c,v 5.74 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -44,7 +44,14 @@ #include #include +#if USE_IPV6 +# include +# include +# include +# include +#endif +#if !USE_IPV6 /* Compare an Internet address (IPv4 expected), with an address pattern * passed as a character string representing an address in the Internet * standard `.' notation, optionally followed by a slash and an integer @@ -58,20 +65,14 @@ * Returns 0 if the addresses match, else returns 1. */ int -#if PROTOTYPES AddrCmp(struct in_addr *addr, char *pattern) -#else -AddrCmp(addr, pattern) - struct in_addr *addr; - char *pattern; -#endif { in_addr_t hostaddr, pattern_addr, netmask; char *p, *slash_posn; static STRING *buf = (STRING *)0; -#if HAVE_INET_ATON +# if HAVE_INET_ATON struct in_addr inetaddr; -#endif +# endif if (buf == (STRING *)0) buf = AllocString(); @@ -84,15 +85,15 @@ AddrCmp(addr, pattern) } else p = pattern; -#if HAVE_INET_ATON +# if HAVE_INET_ATON if (inet_aton(p, &inetaddr) == 0) return 1; pattern_addr = inetaddr.s_addr; -#else +# else pattern_addr = inet_addr(p); if (pattern_addr == (in_addr_t) (-1)) return 1; /* malformed address */ -#endif +# endif if (slash_posn) { /* convert explicit netmask */ @@ -121,33 +122,70 @@ AddrCmp(addr, pattern) pattern_addr & netmask, pattern_addr, netmask)); return (hostaddr & netmask) != (pattern_addr & netmask); } +#endif /* USE_IPV6 */ /* return the access type for a given host entry (ksb) */ char -#if PROTOTYPES -AccType(struct in_addr *addr, char **peername) -#else -AccType(addr, peername) - struct in_addr *addr; - char **peername; -#endif +AccType(INADDR_STYPE *addr, char **peername) { ACCESS *pACtmp; socklen_t so; + char ret; +#if USE_IPV6 + int error; + char host[NI_MAXHOST]; + char ipaddr[NI_MAXHOST]; +#else struct hostent *he = (struct hostent *)0; int a; - char ret; -#if TRUST_REVERSE_DNS +# if TRUST_REVERSE_DNS char **revNames = (char **)0; -#endif +# endif CONDDEBUG((1, "AccType(): ip=%s", inet_ntoa(*addr))); +#endif /* USE_IPV6 */ ret = config->defaultaccess; so = sizeof(*addr); -#if TRUST_REVERSE_DNS +#if USE_IPV6 + error = + getnameinfo((struct sockaddr *)addr, so, ipaddr, sizeof(ipaddr), + NULL, 0, NI_NUMERICHOST); + if (error) { + Error("AccType(): getnameinfo failed: %s", gai_strerror(error)); + goto common_ret; + } + CONDDEBUG((1, "AccType(): ip=%s", ipaddr)); + + error = + getnameinfo((struct sockaddr *)addr, so, host, sizeof(host), NULL, + 0, 0); + if (!error) + CONDDEBUG((1, "AccType(): host=%s", host)); + + for (pACtmp = pACList; pACtmp != (ACCESS *)0; pACtmp = pACtmp->pACnext) { + CONDDEBUG((1, "AccType(): who=%s, trust=%c", pACtmp->pcwho, + pACtmp->ctrust)); + + if (strstr(ipaddr, pACtmp->pcwho) != NULL) { + CONDDEBUG((1, "AccType(): match for ip=%s", ipaddr)); + ret = pACtmp->ctrust; + goto common_ret; + } + + if (!error && strstr(host, pACtmp->pcwho) != NULL) { + CONDDEBUG((1, "AccType(): match for host=%s", host)); + ret = pACtmp->ctrust; + goto common_ret; + } + } + common_ret: + if (config->loghostnames == FLAGTRUE && !error) + *peername = StrDup(host); +#else +# if TRUST_REVERSE_DNS /* if we trust reverse dns, we get the names associated with * the address we're checking and then check each of those * against the access list entries (below). @@ -177,7 +215,7 @@ AccType(addr, peername) } } } -#endif +# endif for (pACtmp = pACList; pACtmp != (ACCESS *)0; pACtmp = pACtmp->pACnext) { CONDDEBUG((1, "AccType(): who=%s, trust=%c", pACtmp->pcwho, @@ -203,20 +241,20 @@ AccType(addr, peername) inet_ntoa(*(struct in_addr *) (he->h_addr_list[a])))); if ( -#if HAVE_MEMCMP +# if HAVE_MEMCMP memcmp(&(addr->s_addr), he->h_addr_list[a], he->h_length) -#else +# else bcmp(&(addr->s_addr), he->h_addr_list[a], he->h_length) -#endif +# endif == 0) { ret = pACtmp->ctrust; goto common_ret; } } } -#if TRUST_REVERSE_DNS +# if TRUST_REVERSE_DNS /* we chop bits off client names so that we can put domain * names in access lists or even top-level domains. * allowed conserver.com, net; @@ -245,43 +283,49 @@ AccType(addr, peername) } } } -#endif +# endif } common_ret: if (config->loghostnames == FLAGTRUE && peername != (char **)0) { -#if TRUST_REVERSE_DNS +# if TRUST_REVERSE_DNS if (revNames != (char **)0 && revNames[0] != (char *)0) *peername = StrDup(revNames[0]); -#else +# else if ((he = gethostbyaddr((char *)addr, so, AF_INET)) != (struct hostent *)0) { *peername = StrDup(he->h_name); } -#endif +# endif } -#if TRUST_REVERSE_DNS +# if TRUST_REVERSE_DNS common_ret2: if (revNames != (char **)0) { for (a = 0; revNames[a] != (char *)0; a++) free(revNames[a]); free(revNames); } -#endif +# endif +#endif /* USE_IPV6 */ return ret; } void -#if PROTOTYPES -SetDefAccess(struct in_addr *pAddr, char *pHost) +SetDefAccess( +#if USE_IPV6 + void #else -SetDefAccess(pAddr, pHost) - struct in_addr *pAddr; - char *pHost; + struct in_addr *pAddr, char *pHost #endif + ) { ACCESS *a; +#if USE_IPV6 + int error; + char addr[NI_MAXHOST]; + struct ifaddrs *myAddrs, *ifa; +#endif /* USE_IPV6 */ while (pACList != (ACCESS *)0) { a = pACList->pACnext; @@ -289,7 +333,39 @@ SetDefAccess(pAddr, pHost) pACList = a; } -#if USE_UNIX_DOMAIN_SOCKETS +#if USE_IPV6 + /* get list of all addresses on system */ + error = getifaddrs(&myAddrs); + if (error) { + Error("SetDefAccess(): getifaddrs: %s", strerror(errno)); + return; + } + + for (ifa = myAddrs; ifa != NULL; ifa = ifa->ifa_next) { + /* skip interfaces without address or in down state */ + if (ifa->ifa_addr == NULL || !(ifa->ifa_flags & IFF_UP)) + continue; + + error = + getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_storage), + addr, sizeof(addr), NULL, 0, NI_NUMERICHOST); + if (error) + continue; + + if ((a = (ACCESS *)calloc(1, sizeof(ACCESS))) == (ACCESS *)0) + OutOfMem(); + if ((a->pcwho = StrDup(addr)) == (char *)0) + OutOfMem(); + + a->ctrust = 'a'; + a->pACnext = pACList; + pACList = a; + + CONDDEBUG((1, "SetDefAccess(): trust=%c, who=%s", pACList->ctrust, + pACList->pcwho)); + } + freeifaddrs(myAddrs); +#elif USE_UNIX_DOMAIN_SOCKETS if ((pACList = (ACCESS *)calloc(1, sizeof(ACCESS))) == (ACCESS *)0) OutOfMem(); if ((pACList->pcwho = StrDup("127.0.0.1")) == (char *)0) @@ -318,12 +394,7 @@ SetDefAccess(pAddr, pHost) } void -#if PROTOTYPES DestroyAccessList(ACCESS *pACList) -#else -DestroyAccessList(pACList) - ACCESS *pACList; -#endif { if (pACList == (ACCESS *)0) return; diff --git a/conserver/access.h b/conserver/access.h index dbf4a4b..9bb46ec 100644 --- a/conserver/access.h +++ b/conserver/access.h @@ -1,5 +1,5 @@ /* - * $Id: access.h,v 5.26 2003/08/10 18:11:20 bryan Exp $ + * $Id: access.h,v 5.27 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -44,6 +44,12 @@ typedef struct access { struct access *pACnext; /* next access list */ } ACCESS; -extern char AccType PARAMS((struct in_addr *, char **)); -extern void SetDefAccess PARAMS((struct in_addr *, char *)); -extern void DestroyAccessList PARAMS((ACCESS *)); +extern char AccType(INADDR_STYPE *, char **); +extern void SetDefAccess( +#if USE_IPV6 + void +#else + struct in_addr *, char * +#endif + ); +extern void DestroyAccessList(ACCESS *); diff --git a/conserver/client.c b/conserver/client.c index 214b81c..83c68f2 100644 --- a/conserver/client.c +++ b/conserver/client.c @@ -1,5 +1,5 @@ /* - * $Id: client.c,v 5.96 2014/04/02 04:45:31 bryan Exp $ + * $Id: client.c,v 5.97 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -43,9 +43,14 @@ #include #include +#if USE_IPV6 +# include +# include +#endif /* USE_IPV6 */ + #if defined(USE_LIBWRAP) -#include -#include +# include +# include int allow_severity = LOG_INFO; int deny_severity = LOG_WARNING; #endif @@ -54,12 +59,7 @@ int deny_severity = LOG_WARNING; /* find the next guy who wants to write on the console (ksb) */ void -#if PROTOTYPES FindWrite(CONSENT *pCE) -#else -FindWrite(pCE) - CONSENT *pCE; -#endif { CONSCLIENT *pCLfound = (CONSCLIENT *)0; CONSCLIENT *pCL; @@ -91,13 +91,7 @@ FindWrite(pCE) } void -#if PROTOTYPES BumpClient(CONSENT *pCE, char *message) -#else -BumpClient(pCE, message) - CONSENT *pCE; - char *message; -#endif { if ((CONSCLIENT *)0 == pCE->pCLwr) return; @@ -118,14 +112,7 @@ BumpClient(pCE, message) #define REPLAYBUFFER 4096 void -#if PROTOTYPES Replay(CONSENT *pCE, CONSFILE *fdOut, unsigned short back) -#else -Replay(pCE, fdOut, back) - CONSENT *pCE; - CONSFILE *fdOut; - unsigned short back; -#endif { CONSFILE *fdLog = (CONSFILE *)0; STRING *line = (STRING *)0; @@ -424,12 +411,7 @@ static HELP aHLTable[] = { /* list the commands we know for the user (ksb) */ void -#if PROTOTYPES HelpUser(CONSCLIENT *pCL) -#else -HelpUser(pCL, pCE) - CONSCLIENT *pCL; -#endif { int i, j, iCmp; static char @@ -505,34 +487,19 @@ HelpUser(pCL, pCE) } int -#if PROTOTYPES ClientAccessOk(CONSCLIENT *pCL) -#else -ClientAccessOk(pCL) - CONSCLIENT *pCL; -#endif { char *peername = (char *)0; int retval = 1; -#if USE_UNIX_DOMAIN_SOCKETS - struct in_addr addr; - -# if HAVE_INET_ATON - inet_aton("127.0.0.1", &addr); -# else - addr.s_addr = inet_addr("127.0.0.1"); -# endif - pCL->caccess = AccType(&addr, &peername); - if (pCL->caccess == 'r') { - FileWrite(pCL->fd, FLAGFALSE, "access from your host refused\r\n", - -1); - retval = 0; - } -#else +#if USE_IPV6 || !USE_UNIX_DOMAIN_SOCKETS socklen_t so; int cfd; - struct sockaddr_in in_port; +# if USE_IPV6 + int error; + char addr[NI_MAXHOST]; +# endif + SOCKADDR_STYPE in_port; int getpeer = -1; cfd = FileFDNum(pCL->fd); @@ -559,20 +526,56 @@ ClientAccessOk(pCL) retval = 0; goto setpeer; } - pCL->caccess = AccType(&in_port.sin_addr, &peername); + pCL->caccess = AccType( +# if USE_IPV6 + &in_port, +# else + &in_port.sin_addr, +# endif + &peername); if (pCL->caccess == 'r') { FileWrite(pCL->fd, FLAGFALSE, "access from your host refused\r\n", -1); retval = 0; } setpeer: +#else + struct in_addr addr; + +# if HAVE_INET_ATON + inet_aton("127.0.0.1", &addr); +# else + addr.s_addr = inet_addr("127.0.0.1"); +# endif + pCL->caccess = AccType(&addr, &peername); + if (pCL->caccess == 'r') { + FileWrite(pCL->fd, FLAGFALSE, "access from your host refused\r\n", + -1); + retval = 0; + } #endif if (pCL->peername != (STRING *)0) { BuildString((char *)0, pCL->peername); if (peername != (char *)0) BuildString(peername, pCL->peername); -#if USE_UNIX_DOMAIN_SOCKETS +#if USE_IPV6 + else if (getpeer != -1) { + error = + getnameinfo((struct sockaddr *)&in_port, so, addr, + sizeof(addr), NULL, 0, NI_NUMERICHOST); + if (error) { + FileWrite(pCL->fd, FLAGFALSE, "getnameinfo failed\r\n", + -1); + Error("ClientAccessOk(): gatenameinfo: %s", + gai_strerror(error)); + retval = 0; + } + + BuildString(addr, pCL->peername); + } else + BuildString("", pCL->peername); +#elif USE_UNIX_DOMAIN_SOCKETS else BuildString("127.0.0.1", pCL->peername); #else diff --git a/conserver/client.h b/conserver/client.h index 62c53bb..551a3e5 100644 --- a/conserver/client.h +++ b/conserver/client.h @@ -1,5 +1,5 @@ /* - * $Id: client.h,v 5.44 2013/09/23 22:58:21 bryan Exp $ + * $Id: client.h,v 5.45 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -87,15 +87,14 @@ typedef struct client { /* Connection Information: */ IOSTATE ioState; /* state of the socket */ time_t stateTimer; /* timer for various ioState states */ STRING *accmd; /* the command the user issued */ - struct sockaddr_in - cnct_port; /* where from */ + INADDR_STYPE cnct_port; /* where from */ FLAG confirmed; /* confirm state */ CLIENTSTATE cState; /* state needing confirmation */ char cOption; /* option initiating the confirmation */ } CONSCLIENT; -extern void Replay PARAMS((CONSENT *, CONSFILE *, unsigned short)); -extern void HelpUser PARAMS((CONSCLIENT *)); -extern void FindWrite PARAMS((CONSENT *)); -extern int ClientAccessOk PARAMS((CONSCLIENT *)); -extern void BumpClient PARAMS((CONSENT *, char *)); +extern void Replay(CONSENT *, CONSFILE *, unsigned short); +extern void HelpUser(CONSCLIENT *); +extern void FindWrite(CONSENT *); +extern int ClientAccessOk(CONSCLIENT *); +extern void BumpClient(CONSENT *, char *); diff --git a/conserver/consent.c b/conserver/consent.c index ed5f8f2..4a986ea 100644 --- a/conserver/consent.c +++ b/conserver/consent.c @@ -1,5 +1,5 @@ /* - * $Id: consent.c,v 5.154 2014/04/02 04:45:31 bryan Exp $ + * $Id: consent.c,v 5.155 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -88,37 +88,37 @@ BAUD baud[] = { {"3500000", 32}, {"4000000", 33}, #else /* FOR_CYCLADES_TS */ -#if defined(B115200) +# if defined(B115200) {"115200", B115200}, -#endif -#if defined(B57600) +# endif +# if defined(B57600) {"57600", B57600}, -#endif -#if defined(B38400) +# endif +# if defined(B38400) {"38400", B38400}, -#endif -#if defined(B19200) +# endif +# if defined(B19200) {"19200", B19200}, -#endif -#if defined(B9600) +# endif +# if defined(B9600) {"9600", B9600}, -#endif -#if defined(B4800) +# endif +# if defined(B4800) {"4800", B4800}, -#endif -#if defined(B2400) +# endif +# if defined(B2400) {"2400", B2400}, -#endif -#if defined(B1800) +# endif +# if defined(B1800) {"1800", B1800}, -#endif +# endif {"1200", B1200}, -#if defined(B600) +# if defined(B600) {"600", B600}, -#endif -#if defined(B300) +# endif +# if defined(B300) {"300", B300}, -#endif +# endif #endif /* FOR_CYCLADES_TS */ }; @@ -126,12 +126,7 @@ BAUD baud[] = { /* find a baud rate for the string "9600x" -> B9600 (ksb) */ BAUD * -#if PROTOTYPES FindBaud(char *pcMode) -#else -FindBaud(pcMode) - char *pcMode; -#endif { int i; @@ -143,9 +138,9 @@ FindBaud(pcMode) } -# if !defined(PAREXT) -# define PAREXT 0 -# endif +#if !defined(PAREXT) +# define PAREXT 0 +#endif struct parity parity[] = { {"even", PARENB | CS7, 0}, {"mark", PARENB | CS7 | PARODD | PAREXT, 0}, @@ -157,12 +152,7 @@ struct parity parity[] = { /* find a parity "even" or "E" or "ev" -> EVEN */ PARITY * -#if PROTOTYPES FindParity(char *pcMode) -#else -FindParity(pcMode) - char *pcMode; -#endif { int i; @@ -177,12 +167,7 @@ FindParity(pcMode) /* setup a tty device (ksb) */ static int -#if PROTOTYPES TtyDev(CONSENT *pCE) -#else -TtyDev(pCE) - CONSENT *pCE; -#endif { struct termios termp; struct stat stPerm; @@ -290,25 +275,20 @@ TtyDev(pCE) } #endif } -# if HAVE_STROPTS_H +#if HAVE_STROPTS_H /* * eat all the streams modules upto and including ttcompat */ while (ioctl(cofile, I_FIND, "ttcompat") == 1) { ioctl(cofile, I_POP, 0); } -# endif +#endif pCE->fup = 1; return 0; } void -#if PROTOTYPES StopInit(CONSENT *pCE) -#else -StopInit(pCE) - CONSENT *pCE; -#endif { if (pCE->initcmd == (char *)0) return; @@ -341,12 +321,7 @@ StopInit(pCE) #if HAVE_FREEIPMI ipmiconsole_ctx_t -#if PROTOTYPES IpmiSOLCreate(CONSENT *pCE) -#else -IpmiSOLCreate(pCE) - CONSENT *pCE; -#endif { ipmiconsole_ctx_t ctx; struct ipmiconsole_ipmi_config ipmi; @@ -389,12 +364,7 @@ IpmiSOLCreate(pCE) /* invoke the initcmd command */ void -#if PROTOTYPES StartInit(CONSENT *pCE) -#else -StartInit(pCE) - CONSENT *pCE; -#endif { int i; pid_t iNewGrp; @@ -495,15 +465,15 @@ StartInit(pCE) close(1); close(0); -# if HAVE_SETSID +#if HAVE_SETSID iNewGrp = setsid(); if (-1 == iNewGrp) { Error("[%s] setsid(): %s", pCE->server, strerror(errno)); iNewGrp = getpid(); } -# else +#else iNewGrp = getpid(); -# endif +#endif if (dup(pout[0]) != 0 || dup(pin[1]) != 1) { Error("[%s] StartInit(): fd sync error", pCE->server); @@ -534,17 +504,11 @@ StartInit(pCE) /* We exit() here, so only call this in a child process before an exec() */ void -#if PROTOTYPES SetupTty(CONSENT *pCE, int fd) -#else -SetupTty(pCE, fd) - CONSENT *pCE; - int fd; -#endif { struct termios n_tio; -# if HAVE_STROPTS_H && !defined(_AIX) +#if HAVE_STROPTS_H && !defined(_AIX) /* SYSVr4 semantics for opening stream ptys (gregf) * under PTX (others?) we have to push the compatibility * streams modules `ptem', `ld', and `ttcompat' @@ -552,7 +516,7 @@ SetupTty(pCE, fd) ioctl(1, I_PUSH, "ptem"); ioctl(1, I_PUSH, "ldterm"); ioctl(1, I_PUSH, "ttcompat"); -# endif +#endif if (0 != tcgetattr(1, &n_tio)) { exit(EX_OSERR); @@ -587,12 +551,7 @@ SetupTty(pCE, fd) /* setup a virtual device (ksb) */ static int -#if PROTOTYPES VirtDev(CONSENT *pCE) -#else -VirtDev(pCE) - CONSENT *pCE; -#endif { int i; pid_t iNewGrp; @@ -645,15 +604,15 @@ VirtDev(pCE) close(1); close(0); -# if HAVE_SETSID +#if HAVE_SETSID iNewGrp = setsid(); if (-1 == iNewGrp) { Error("[%s] setsid(): %s", pCE->server, strerror(errno)); iNewGrp = getpid(); } -# else +#else iNewGrp = getpid(); -# endif +#endif if (dup(pCE->execSlaveFD) != 0 || dup(pCE->execSlaveFD) != 1) { Error("[%s] fd sync error", pCE->server); @@ -707,12 +666,7 @@ VirtDev(pCE) } char * -#if PROTOTYPES ConsState(CONSENT *pCE) -#else -ConsState(pCE) - CONSENT *pCE; -#endif { if (!pCE->fup) return "down"; @@ -747,14 +701,7 @@ ConsState(pCE) * with the "runtime" members of the structure here. */ void -#if PROTOTYPES ConsDown(CONSENT *pCE, FLAG downHard, FLAG force) -#else -ConsDown(pCE, downHard, force) - CONSENT *pCE; - FLAG downHard; - FLAG force; -#endif { if (force != FLAGTRUE && !(FileBufEmpty(pCE->fdlog) && FileBufEmpty(pCE->cofile) && @@ -811,15 +758,10 @@ ConsDown(pCE, downHard, force) * We also maintian the select set for the caller. */ void -#if PROTOTYPES ConsInit(CONSENT *pCE) -#else -ConsInit(pCE) - CONSENT *pCE; -#endif { time_t tyme; - extern int FallBack PARAMS((char **, int *)); + extern int FallBack(char **, int *); int cofile = -1; int ret; #if HAVE_GETTIMEOFDAY @@ -914,19 +856,86 @@ ConsInit(pCE) break; case HOST: { +#if USE_IPV6 + int error; + char host[NI_MAXHOST]; + char serv[NI_MAXSERV]; + struct addrinfo *ai, *rp, hints; +#else struct sockaddr_in port; struct hostent *hp; +#endif /* USE_IPV6 */ #if HAVE_SETSOCKOPT int one = 1; #endif usleep(100000); /* Not all terminal servers can keep up */ -#if HAVE_MEMSET - memset((void *)&port, 0, sizeof(port)); +#if USE_IPV6 +# if HAVE_MEMSET + memset(&hints, 0, sizeof(hints)); +# else + bzero(&hints, sizeof(hints)); +# endif + + hints.ai_flags = AI_ADDRCONFIG; + hints.ai_socktype = SOCK_STREAM; + snprintf(serv, sizeof(serv), "%hu", pCE->netport); + + error = getaddrinfo(pCE->host, serv, &hints, &ai); + if (error) { + Error("[%s] getaddrinfo(%s): %s: forcing down", + pCE->server, pCE->host, gai_strerror(error)); + ConsDown(pCE, FLAGTRUE, FLAGTRUE); + return; + } + + rp = ai; + while (rp) { + error = + getnameinfo(rp->ai_addr, rp->ai_addrlen, host, + sizeof(host), serv, sizeof(serv), + NI_NUMERICHOST | NI_NUMERICSERV); + if (error) + continue; + CONDDEBUG((1, + "[%s]: trying hostname=%s, ip=%s, port=%s", + pCE->server, pCE->host, host, serv)); + + cofile = + socket(rp->ai_family, rp->ai_socktype, + rp->ai_protocol); + if (cofile != -1) { +# if HAVE_SETSOCKOPT + if (setsockopt + (cofile, SOL_SOCKET, SO_KEEPALIVE, + (char *)&one, sizeof(one)) < 0) + goto fail; +# endif + if (!SetFlags(cofile, O_NONBLOCK, 0)) + goto fail; + if ((ret = + connect(cofile, rp->ai_addr, + rp->ai_addrlen)) == 0) + goto success; + fail: + close(cofile); + } + rp = rp->ai_next; + } + + Error("[%s]: Unable to connect to %s:%s", pCE->server, + host, serv); + ConsDown(pCE, FLAGTRUE, FLAGTRUE); + return; + success: + freeaddrinfo(ai); #else +# if HAVE_MEMSET + memset((void *)&port, 0, sizeof(port)); +# else bzero((char *)&port, sizeof(port)); -#endif +# endif if ((hp = gethostbyname(pCE->host)) == NULL) { Error("[%s] gethostbyname(%s): %s: forcing down", @@ -934,13 +943,13 @@ ConsInit(pCE) ConsDown(pCE, FLAGTRUE, FLAGTRUE); return; } -#if HAVE_MEMCPY +# if HAVE_MEMCPY memcpy(&port.sin_addr.s_addr, hp->h_addr_list[0], hp->h_length); -#else +# else bcopy(hp->h_addr_list[0], &port.sin_addr.s_addr, hp->h_length); -#endif +# endif port.sin_family = hp->h_addrtype; port.sin_port = htons(pCE->netport); @@ -951,7 +960,7 @@ ConsInit(pCE) ConsDown(pCE, FLAGTRUE, FLAGTRUE); return; } -#if HAVE_SETSOCKOPT +# if HAVE_SETSOCKOPT if (setsockopt (cofile, SOL_SOCKET, SO_KEEPALIVE, (char *)&one, sizeof(one)) < 0) { @@ -962,7 +971,7 @@ ConsInit(pCE) close(cofile); return; } -#endif +# endif if (!SetFlags(cofile, O_NONBLOCK, 0)) { ConsDown(pCE, FLAGTRUE, FLAGTRUE); @@ -982,6 +991,7 @@ ConsInit(pCE) return; } } +#endif /* USE_IPV6 */ } if ((pCE->cofile = FileOpenFD(cofile, simpleSocket)) == (CONSFILE *)0) { @@ -1238,48 +1248,93 @@ ConsInit(pCE) } int -#if PROTOTYPES AddrsMatch(char *addr1, char *addr2) -#else -AddrsMatch(addr1, addr2) - char *addr1; - char *addr2; -#endif { +#if USE_IPV6 + int error, ret = 0; + struct addrinfo *ai1, *ai2, hints; +#else /* so, since we might use inet_addr, we're going to use * (in_addr_t)(-1) as a sign of an invalid ip address. * sad, but true. */ in_addr_t inAddr1 = (in_addr_t) (-1); in_addr_t inAddr2 = (in_addr_t) (-1); -#if HAVE_INET_ATON +# if HAVE_INET_ATON struct in_addr inetAddr1; struct in_addr inetAddr2; -#endif +# endif +#endif /* USE_IPV6 */ /* first try simple character string match */ if (strcasecmp(addr1, addr2) == 0) return 1; +#if USE_IPV6 +# if HAVE_MEMSET + memset(&hints, 0, sizeof(hints)); +# else + bzero(&hints, sizeof(hints)); +# endif + hints.ai_flags = AI_ADDRCONFIG; + hints.ai_socktype = SOCK_STREAM; + + error = getaddrinfo(addr1, NULL, &hints, &ai1); + if (error) { + Error("getaddrinfo(%s): %s", addr1, gai_strerror(error)); + goto done; + } + error = getaddrinfo(addr2, NULL, &hints, &ai2); + if (error) { + Error("getaddrinfo(%s): %s", addr2, gai_strerror(error)); + goto done; + } + + for (; ai1 != NULL; ai1 = ai1->ai_next) { + for (; ai2 != NULL; ai2 = ai2->ai_next) { + if (ai1->ai_addr->sa_family != ai2->ai_addr->sa_family) + continue; + + if ( +# if HAVE_MEMCMP + memcmp(&ai1->ai_addr, &ai2->ai_addr, + sizeof(struct sockaddr_storage)) +# else + bcmp(&ai1->ai_addr, &ai2->ai_addr, + sizeof(struct sockaddr_storage)) +# endif + == 0) { + ret = 1; + goto done; + } + } + } + + done: + freeaddrinfo(ai1); + freeaddrinfo(ai2); + Msg("compare %s and %s returns %d", addr1, addr2, ret); + return ret; +#else /* now try ip address match (could have leading zeros or something) */ -#if HAVE_INET_ATON +# if HAVE_INET_ATON if (inet_aton(addr1, &inetAddr1) != 0) inAddr1 = inetAddr1.s_addr; if (inet_aton(addr2, &inetAddr2) != 0) inAddr2 = inetAddr2.s_addr; -#else +# else inAddr1 = inet_addr(addr1); inAddr2 = inet_addr(addr2); -#endif +# endif /* if both are ip addresses, we just match */ if (inAddr1 != (in_addr_t) (-1) && inAddr2 != (in_addr_t) (-1)) return ! -#if HAVE_MEMCMP +# if HAVE_MEMCMP memcmp(&inAddr1, &inAddr2, sizeof(inAddr1)) -#else +# else bcmp(&inAddr1, &inAddr2, sizeof(inAddr1)) -#endif +# endif ; /* both are hostnames...this sucks 'cause we have to copy one @@ -1307,11 +1362,11 @@ AddrsMatch(addr1, addr2) if (addrs == (in_addr_t *) 0) OutOfMem(); for (i = 0; i < c; i++) { -#if HAVE_MEMCPY +# if HAVE_MEMCPY memcpy(&(addrs[i]), he->h_addr_list[i], he->h_length); -#else +# else bcopy(he->h_addr_list[i], &(addrs[i]), he->h_length); -#endif +# endif } /* now process the second hostname */ @@ -1331,12 +1386,12 @@ AddrsMatch(addr1, addr2) for (j = 0; he->h_addr_list[j] != (char *)0; j++) { for (i = 0; i < c; i++) { if ( -#if HAVE_MEMCMP +# if HAVE_MEMCMP memcmp(&(addrs[i]), he->h_addr_list[j], he->h_length) -#else +# else bcmp(&(addrs[i]), he->h_addr_list[j], he->h_length) -#endif +# endif == 0) { free(addrs); return 1; @@ -1370,28 +1425,24 @@ AddrsMatch(addr1, addr2) } for (i = 0; he->h_addr_list[i] != (char *)0; i++) { if ( -#if HAVE_MEMCMP +# if HAVE_MEMCMP memcmp(iaddr, he->h_addr_list[i], he->h_length) -#else +# else bcmp(iaddr, he->h_addr_list[i], he->h_length) -#endif +# endif == 0) return 1; } } return 0; +#endif /* USE_IPV6 */ } /* thread ther list of uniq console server machines, aliases for (ksb) * machines will screw us up */ REMOTE * -#if PROTOTYPES FindUniq(REMOTE *pRCAll) -#else -FindUniq(pRCAll) - REMOTE *pRCAll; -#endif { REMOTE *pRC; @@ -1414,12 +1465,7 @@ FindUniq(pRCAll) } void -#if PROTOTYPES DestroyRemoteConsole(REMOTE *pRCList) -#else -DestroyRemoteConsole(pRCList) - REMOTE *pRCList; -#endif { NAMES *name = (NAMES *)0; diff --git a/conserver/consent.h b/conserver/consent.h index 1600e03..8cb39e5 100644 --- a/conserver/consent.h +++ b/conserver/consent.h @@ -1,5 +1,5 @@ /* - * $Id: consent.h,v 5.74 2014/04/04 16:17:10 bryan Exp $ + * $Id: consent.h,v 5.75 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -64,10 +64,10 @@ typedef enum consType { } CONSTYPE; #if HAVE_FREEIPMI -#define IPMIL_UNKNOWN (0) -#define IPMIL_USER (IPMICONSOLE_PRIVILEGE_USER+1) -#define IPMIL_OPERATOR (IPMICONSOLE_PRIVILEGE_OPERATOR+1) -#define IPMIL_ADMIN (IPMICONSOLE_PRIVILEGE_ADMIN+1) +# define IPMIL_UNKNOWN (0) +# define IPMIL_USER (IPMICONSOLE_PRIVILEGE_USER+1) +# define IPMIL_OPERATOR (IPMICONSOLE_PRIVILEGE_OPERATOR+1) +# define IPMIL_ADMIN (IPMICONSOLE_PRIVILEGE_ADMIN+1) #endif typedef struct names { @@ -209,13 +209,13 @@ typedef struct remote { /* console at another host */ NAMES *aliases; /* aliases for remote server name */ } REMOTE; -extern PARITY *FindParity PARAMS((char *)); -extern BAUD *FindBaud PARAMS((char *)); -extern void ConsInit PARAMS((CONSENT *)); -extern void ConsDown PARAMS((CONSENT *, FLAG, FLAG)); -extern REMOTE *FindUniq PARAMS((REMOTE *)); -extern void DestroyRemoteConsole PARAMS((REMOTE *)); -extern void StartInit PARAMS((CONSENT *)); -extern void StopInit PARAMS((CONSENT *)); -extern char *ConsState PARAMS((CONSENT *)); -extern void SetupTty PARAMS((CONSENT *, int)); +extern PARITY *FindParity(char *); +extern BAUD *FindBaud(char *); +extern void ConsInit(CONSENT *); +extern void ConsDown(CONSENT *, FLAG, FLAG); +extern REMOTE *FindUniq(REMOTE *); +extern void DestroyRemoteConsole(REMOTE *); +extern void StartInit(CONSENT *); +extern void StopInit(CONSENT *); +extern char *ConsState(CONSENT *); +extern void SetupTty(CONSENT *, int); diff --git a/conserver/conserver.man b/conserver/conserver.man index df68c58..d78a47f 100644 --- a/conserver/conserver.man +++ b/conserver/conserver.man @@ -1,6 +1,6 @@ .\" @(#)conserver.8 01/06/91 OSU CIS; Thomas A. Fine .\" $Id: conserver.man,v 1.54 2006/12/31 02:02:48 bryan Exp $ -.TH CONSERVER 8 "2006/12/31" "conserver-8.1.20" "conserver" +.TH CONSERVER 8 "2006/12/31" "conserver-8.2.0" "conserver" .SH NAME conserver \- console server daemon .SH SYNOPSIS diff --git a/conserver/convert.c b/conserver/convert.c index 1a047b4..10dd6ef 100644 --- a/conserver/convert.c +++ b/conserver/convert.c @@ -1,5 +1,5 @@ /* - * $Id: convert.c,v 1.13 2014/04/02 04:45:32 bryan Exp $ + * $Id: convert.c,v 1.14 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -58,14 +58,7 @@ DestroyDataStructures() } char * -#if PROTOTYPES ReadLine2(FILE *fp, STRING *save, int *iLine) -#else -ReadLine2(fp, save, iLine) - FILE *fp; - STRING *save; - int *iLine; -#endif { static char buf[1024]; char *wholeline = (char *)0; @@ -154,13 +147,7 @@ ReadLine2(fp, save, iLine) * to manage the consoles */ void -#if PROTOTYPES ReadCfg(char *pcFile, FILE *fp) -#else -ReadCfg(pcFile, fp) - char *pcFile; - FILE *fp; -#endif { int iLine; unsigned char *acIn; @@ -480,13 +467,7 @@ ReadCfg(pcFile, fp) } int -#if PROTOTYPES main(int argc, char **argv) -#else -main(argc, argv) - int argc; - char **argv; -#endif { char *pcFile; FILE *fp; diff --git a/conserver/cutil.c b/conserver/cutil.c index e8655cd..21dee1b 100644 --- a/conserver/cutil.c +++ b/conserver/cutil.c @@ -1,5 +1,5 @@ /* - * $Id: cutil.c,v 1.140 2014/04/04 16:17:10 bryan Exp $ + * $Id: cutil.c,v 1.142 2014/04/20 07:17:56 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -12,11 +12,14 @@ #include #include +#if USE_IPV6 +# include +#endif #if HAVE_SYS_SOCKIO_H # include #endif #if HAVE_OPENSSL -#include +# include #endif @@ -27,7 +30,9 @@ pid_t thepid = 0; int fDebug = 0; STRING *allStrings = (STRING *)0; int stringCount = 0; /* count of allStrings list */ +#if !USE_IPV6 struct in_addr *myAddrs = (struct in_addr *)0; +#endif char myHostname[MAXHOSTNAME]; /* staff.cc.purdue.edu */ fd_set rinit; fd_set winit; @@ -39,11 +44,7 @@ int isMaster = 1; /* in the routines below (the init code) we can bomb if malloc fails (ksb) */ void -#if PROTOTYPES -OutOfMem() -#else -OutOfMem() -#endif +OutOfMem(void) { static char acNoMem[] = ": out of memory\n"; @@ -54,12 +55,7 @@ OutOfMem() /* do a general cleanup and exit */ void -#if PROTOTYPES Bye(int status) -#else -Bye(status) - int status; -#endif { DestroyDataStructures(); #if HAVE_OPENSSL @@ -74,12 +70,7 @@ Bye(status) * It's overwritten each time, so use it and forget it. */ const char * -#if PROTOTYPES StrTime(time_t *ltime) -#else -StrTime(ltime) - time_t *ltime; -#endif { static char curtime[40]; /* just in case ctime() varies */ time_t tyme; @@ -95,13 +86,7 @@ StrTime(ltime) #define STRING_ALLOC_SIZE 64 char * -#if PROTOTYPES BuildStringChar(const char ch, STRING *msg) -#else -BuildStringChar(ch, msg) - const char ch; - STRING *msg; -#endif { if (msg->used + 1 >= msg->allocated) { if (0 == msg->allocated) { @@ -132,13 +117,7 @@ BuildStringChar(ch, msg) } char * -#if PROTOTYPES BuildString(const char *str, STRING *msg) -#else -BuildString(str, msg) - const char *str; - STRING *msg; -#endif { int len; @@ -190,14 +169,7 @@ BuildString(str, msg) } char * -#if PROTOTYPES BuildStringN(const char *str, int n, STRING *msg) -#else -BuildStringN(str, n, msg) - const char *str; - int n; - STRING *msg; -#endif { int len; @@ -245,14 +217,7 @@ BuildStringN(str, n, msg) } void * -#if PROTOTYPES MemMove(void *dest, void *src, size_t n) -#else -MemMove(void *dest, void *src, size_t n) - void *dest; - void *src; - size_t n; -#endif { #if HAVE_MEMMOVE return memmove(dest, src, n); @@ -274,13 +239,7 @@ MemMove(void *dest, void *src, size_t n) } char * -#if PROTOTYPES ShiftString(STRING *msg, int n) -#else -ShiftString(msg, n) - STRING *msg; - int n; -#endif { if (msg == (STRING *)0 || n <= 0 || n > msg->used - 1) return (char *)0; @@ -292,24 +251,14 @@ ShiftString(msg, n) } void -#if PROTOTYPES InitString(STRING *msg) -#else -InitString(msg) - STRING *msg; -#endif { msg->string = (char *)0; msg->used = msg->allocated = 0; } void -#if PROTOTYPES DestroyString(STRING *msg) -#else -DestroyString(msg) - STRING *msg; -#endif { if (msg->prev == (STRING *)0 && msg->next == (STRING *)0 && allStrings != msg) { @@ -334,11 +283,7 @@ DestroyString(msg) } STRING * -#if PROTOTYPES AllocString(void) -#else -AllocString() -#endif { STRING *s; if ((s = (STRING *)calloc(1, sizeof(STRING))) @@ -357,11 +302,7 @@ AllocString() } void -#if PROTOTYPES DestroyStrings(void) -#else -DestroyStrings() -#endif { while (allStrings != (STRING *)0) { DestroyString(allStrings); @@ -371,12 +312,7 @@ DestroyStrings() static STRING *mymsg = (STRING *)0; char * -#if PROTOTYPES BuildTmpString(const char *str) -#else -BuildTmpString(str) - const char *str; -#endif { if (mymsg == (STRING *)0) mymsg = AllocString(); @@ -384,12 +320,7 @@ BuildTmpString(str) } char * -#if PROTOTYPES BuildTmpStringChar(const char c) -#else -BuildTmpStringChar(c) - const char c; -#endif { if (mymsg == (STRING *)0) mymsg = AllocString(); @@ -397,14 +328,7 @@ BuildTmpStringChar(c) } char * -#if PROTOTYPES ReadLine(FILE *fp, STRING *save, int *iLine) -#else -ReadLine(fp, save, iLine) - FILE *fp; - STRING *save; - int *iLine; -#endif { static char buf[1024]; char *wholeline = (char *)0; @@ -496,13 +420,7 @@ ReadLine(fp, save, iLine) * another */ char * -#if PROTOTYPES FmtCtl(int ci, STRING *pcIn) -#else -FmtCtl(ci, pcIn) - int ci; - STRING *pcIn; -#endif { unsigned char c; @@ -529,14 +447,7 @@ FmtCtl(ci, pcIn) } void -#if PROTOTYPES FmtCtlStr(char *pcIn, int len, STRING *pcOut) -#else -FmtCtlStr(pcIn, len, pcOut) - char *pcIn; - int len; - STRING *pcOut; -#endif { unsigned char c; @@ -565,24 +476,13 @@ FmtCtlStr(pcIn, len, pcOut) } void -#if PROTOTYPES Debug(int level, char *fmt, ...) -#else -Debug(level, fmt, va_alist) - int level; - char *fmt; - va_dcl -#endif { va_list ap; if (fDebug < level) return; -#if PROTOTYPES va_start(ap, fmt); -#else - va_start(ap); -#endif if (isMultiProc) fprintf(stderr, "[%s] %s (%lu): DEBUG: [%s:%d] ", StrTime((time_t *)0), progname, (unsigned long)thepid, @@ -596,20 +496,10 @@ Debug(level, fmt, va_alist) } void -#if PROTOTYPES Error(char *fmt, ...) -#else -Error(fmt, va_alist) - char *fmt; - va_dcl -#endif { va_list ap; -#if PROTOTYPES va_start(ap, fmt); -#else - va_start(ap); -#endif if (isMultiProc) fprintf(stderr, "[%s] %s (%lu): ERROR: ", StrTime((time_t *)0), progname, (unsigned long)thepid); @@ -622,20 +512,10 @@ Error(fmt, va_alist) } void -#if PROTOTYPES Msg(char *fmt, ...) -#else -Msg(fmt, va_alist) - char *fmt; - va_dcl -#endif { va_list ap; -#if PROTOTYPES va_start(ap, fmt); -#else - va_start(ap); -#endif if (isMultiProc) fprintf(stdout, "[%s] %s (%lu): ", StrTime((time_t *)0), progname, (unsigned long)thepid); @@ -647,24 +527,14 @@ Msg(fmt, va_alist) } void -#if PROTOTYPES Verbose(char *fmt, ...) -#else -Verbose(fmt, va_alist) - char *fmt; - va_dcl -#endif { va_list ap; if (!fVerbose) return; -#if PROTOTYPES va_start(ap, fmt); -#else - va_start(ap); -#endif if (isMultiProc) fprintf(stdout, "[%s] %s (%lu): INFO: ", StrTime((time_t *)0), progname, (unsigned long)thepid); @@ -676,13 +546,7 @@ Verbose(fmt, va_alist) } void -#if PROTOTYPES SimpleSignal(int sig, RETSIGTYPE(*disp) (int)) -#else -SimpleSignal(sig, disp) - int sig; -RETSIGTYPE(*disp) (int); -#endif { #if HAVE_SIGACTION struct sigaction sa; @@ -697,11 +561,7 @@ RETSIGTYPE(*disp) (int); } int -#if PROTOTYPES -GetMaxFiles() -#else -GetMaxFiles() -#endif +GetMaxFiles(void) { int mf; #if HAVE_SYSCONF @@ -740,13 +600,7 @@ GetMaxFiles() * object. Returns a CONSFILE pointer to that object. */ CONSFILE * -#if PROTOTYPES FileOpenFD(int fd, enum consFileType type) -#else -FileOpenFD(fd, type) - int fd; - enum consFileType type; -#endif { CONSFILE *cfp; @@ -790,13 +644,7 @@ FileOpenFD(fd, type) * object. Returns a CONSFILE pointer to that object. */ CONSFILE * -#if PROTOTYPES FileOpenPipe(int fd, int fdout) -#else -FileOpenPipe(fd, fdout) - int fd; - int fdout; -#endif { CONSFILE *cfp; @@ -840,12 +688,7 @@ FileOpenPipe(fd, fdout) /* This is to "unencapsulate" the file descriptor */ int -#if PROTOTYPES FileUnopen(CONSFILE *cfp) -#else -FileUnopen(cfp) - CONSFILE *cfp; -#endif { int retval = 0; @@ -888,14 +731,7 @@ FileUnopen(cfp) * or a (CONSFILE *)0 on error */ CONSFILE * -#if PROTOTYPES FileOpen(const char *path, int flag, int mode) -#else -FileOpen(path, flag, mode) - const char *path; - int flag; - int mode; -#endif { CONSFILE *cfp; int fd; @@ -945,12 +781,7 @@ FileOpen(path, flag, mode) * this function - even if there was an error. */ int -#if PROTOTYPES FileClose(CONSFILE **pcfp) -#else -FileClose(pcfp) - CONSFILE **pcfp; -#endif { CONSFILE *cfp; int retval = 0; @@ -1044,14 +875,7 @@ FileClose(pcfp) /* returns: -1 on error or eof, >= 0 for valid reads */ int -#if PROTOTYPES FileRead(CONSFILE *cfp, void *buf, int len) -#else -FileRead(cfp, buf, len) - CONSFILE *cfp; - void *buf; - int len; -#endif { int retval = -1; @@ -1122,10 +946,10 @@ FileRead(cfp, buf, len) cfp->ftype = simpleSocket; break; } -#if DEBUG_CONSFILE_IO +# if DEBUG_CONSFILE_IO if (cfp->debugrfd != -1) write(cfp->debugrfd, buf, retval); -#endif +# endif break; #endif default: @@ -1165,15 +989,7 @@ FileRead(cfp, buf, len) /* returns: -1 on error or eof, >= 0 for valid reads */ int -#if PROTOTYPES FileWrite(CONSFILE *cfp, FLAG bufferonly, char *buf, int len) -#else -FileWrite(cfp, bufferonly, buf, len) - CONSFILE *cfp; - FLAG bufferonly; - char *buf; - int len; -#endif { int len_orig = len; int len_out = 0; @@ -1324,10 +1140,10 @@ FileWrite(cfp, bufferonly, buf, len) } if (retval <= 0) break; -#if DEBUG_CONSFILE_IO +# if DEBUG_CONSFILE_IO if (cfp->debugwfd != -1) write(cfp->debugwfd, buf, retval); -#endif +# endif buf += retval; len -= retval; len_out += retval; @@ -1380,14 +1196,7 @@ FileWrite(cfp, bufferonly, buf, len) } int -#if PROTOTYPES FileCanRead(CONSFILE *cfp, fd_set *prfd, fd_set *pwfd) -#else -FileCanRead(cfp, prfd, pwfd) - CONSFILE *cfp; - fd_set *prfd; - fd_set *pwfd; -#endif { #if HAVE_OPENSSL int fdout; @@ -1414,14 +1223,7 @@ FileCanRead(cfp, prfd, pwfd) } int -#if PROTOTYPES FileCanWrite(CONSFILE *cfp, fd_set *prfd, fd_set *pwfd) -#else -FileCanWrite(cfp, prfd, pwfd) - CONSFILE *cfp; - fd_set *prfd; - fd_set *pwfd; -#endif { int fdout; @@ -1443,12 +1245,7 @@ FileCanWrite(cfp, prfd, pwfd) } int -#if PROTOTYPES FileBufEmpty(CONSFILE *cfp) -#else -FileBufEmpty(cfp) - CONSFILE *cfp; -#endif { if (cfp == (CONSFILE *)0) return 1; @@ -1456,16 +1253,7 @@ FileBufEmpty(cfp) } void -#if PROTOTYPES VWrite(CONSFILE *cfp, FLAG bufferonly, STRING *str, char *fmt, va_list ap) -#else -VWrite(cfp, bufferonly, str, fmt, ap) - CONSFILE *cfp; - FLAG bufferonly; - STRING *str; - char *fmt; - va_list ap; -#endif { int s, l, e; char c; @@ -1683,21 +1471,10 @@ VWrite(cfp, bufferonly, str, fmt, ap) } char * -#if PROTOTYPES BuildStringPrint(STRING *str, char *fmt, ...) -#else -BuildStringPrint(str, fmt, va_alist) - STRING *str; - char *fmt; - va_dcl -#endif { va_list ap; -#if PROTOTYPES va_start(ap, fmt); -#else - va_start(ap); -#endif VWrite((CONSFILE *)0, FLAGFALSE, str, fmt, ap); va_end(ap); if (str == (STRING *)0) @@ -1707,20 +1484,10 @@ BuildStringPrint(str, fmt, va_alist) } char * -#if PROTOTYPES BuildTmpStringPrint(char *fmt, ...) -#else -BuildTmpStringPrint(fmt, va_alist) - char *fmt; - va_dcl -#endif { va_list ap; -#if PROTOTYPES va_start(ap, fmt); -#else - va_start(ap); -#endif if (mymsg == (STRING *)0) mymsg = AllocString(); VWrite((CONSFILE *)0, FLAGFALSE, mymsg, fmt, ap); @@ -1729,49 +1496,23 @@ BuildTmpStringPrint(fmt, va_alist) } void -#if PROTOTYPES FileVWrite(CONSFILE *cfp, FLAG bufferonly, char *fmt, va_list ap) -#else -FileVWrite(cfp, bufferonly, fmt, ap) - CONSFILE *cfp; - FLAG bufferonly; - char *fmt; - va_list ap; -#endif { VWrite(cfp, bufferonly, (STRING *)0, fmt, ap); } void -#if PROTOTYPES FilePrint(CONSFILE *cfp, FLAG bufferonly, char *fmt, ...) -#else -FilePrint(cfp, bufferonly, fmt, va_alist) - CONSFILE *cfp; - FLAG bufferonly; - char *fmt; - va_dcl -#endif { va_list ap; -#if PROTOTYPES va_start(ap, fmt); -#else - va_start(ap); -#endif FileVWrite(cfp, bufferonly, fmt, ap); va_end(ap); } /* Unless otherwise stated, returns the same values as fstat(2) */ int -#if PROTOTYPES FileStat(CONSFILE *cfp, struct stat *buf) -#else -FileStat(cfp, buf) - CONSFILE *cfp; - struct stat *buf; -#endif { int retval = 0; @@ -1806,14 +1547,7 @@ FileStat(cfp, buf) /* Unless otherwise stated, returns the same values as lseek(2) */ int -#if PROTOTYPES FileSeek(CONSFILE *cfp, off_t offset, int whence) -#else -FileSeek(cfp, offset, whence) - CONSFILE *cfp; - off_t offset; - int whence; -#endif { int retval = 0; @@ -1848,12 +1582,7 @@ FileSeek(cfp, offset, whence) /* Returns the file descriptor number of the underlying file */ int -#if PROTOTYPES FileFDNum(CONSFILE *cfp) -#else -FileFDNum(cfp) - CONSFILE *cfp; -#endif { int retval = 0; @@ -1885,12 +1614,7 @@ FileFDNum(cfp) /* Returns the file descriptor number of the underlying file */ int -#if PROTOTYPES FileFDOutNum(CONSFILE *cfp) -#else -FileFDOutNum(cfp) - CONSFILE *cfp; -#endif { if (cfp == (CONSFILE *)0 || cfp->ftype != simplePipe) return -1; @@ -1900,12 +1624,7 @@ FileFDOutNum(cfp) /* Returns the file type */ enum consFileType -#if PROTOTYPES FileGetType(CONSFILE *cfp) -#else -FileGetType(cfp) - CONSFILE *cfp; -#endif { switch (cfp->ftype) { case simpleFile: @@ -1925,37 +1644,20 @@ FileGetType(cfp) /* Sets the file type */ void -#if PROTOTYPES FileSetType(CONSFILE *cfp, enum consFileType type) -#else -FileSetType(cfp, type) - CONSFILE *cfp; - enum consFileType type; -#endif { cfp->ftype = type; } /* Sets the file quoting method */ void -#if PROTOTYPES FileSetQuoteIAC(CONSFILE *cfp, FLAG flag) -#else -FileSetQuoteIAC(cfp, flag) - CONSFILE *cfp; - FLAG flag; -#endif { cfp->quoteiac = flag; } FLAG -#if PROTOTYPES FileSawQuoteSusp(CONSFILE *cfp) -#else -FileSawQuoteSusp(cfp) - CONSFILE *cfp; -#endif { FLAG r = cfp->sawiacsusp; cfp->sawiacsusp = FLAGFALSE; @@ -1963,12 +1665,7 @@ FileSawQuoteSusp(cfp) } FLAG -#if PROTOTYPES FileSawQuoteExec(CONSFILE *cfp) -#else -FileSawQuoteExec(cfp) - CONSFILE *cfp; -#endif { FLAG r = cfp->sawiacexec; cfp->sawiacexec = FLAGFALSE; @@ -1976,12 +1673,7 @@ FileSawQuoteExec(cfp) } FLAG -#if PROTOTYPES FileSawQuoteAbrt(CONSFILE *cfp) -#else -FileSawQuoteAbrt(cfp) - CONSFILE *cfp; -#endif { FLAG r = cfp->sawiacabrt; cfp->sawiacabrt = FLAGFALSE; @@ -1989,12 +1681,7 @@ FileSawQuoteAbrt(cfp) } FLAG -#if PROTOTYPES FileSawQuoteGoto(CONSFILE *cfp) -#else -FileSawQuoteGoto(cfp) - CONSFILE *cfp; -#endif { FLAG r = cfp->sawiacgoto; cfp->sawiacgoto = FLAGFALSE; @@ -2004,39 +1691,21 @@ FileSawQuoteGoto(cfp) #if HAVE_OPENSSL /* Get the SSL instance */ SSL * -#if PROTOTYPES FileGetSSL(CONSFILE *cfp) -#else -FileGetSSL(cfp) - CONSFILE *cfp; -#endif { return cfp->ssl; } /* Sets the SSL instance */ void -#if PROTOTYPES FileSetSSL(CONSFILE *cfp, SSL *ssl) -#else -FileSetSSL(cfp, ssl) - CONSFILE *cfp; - SSL *ssl; -#endif { cfp->ssl = ssl; } /* return -1 on error, 0 for "wait" state, 1 for success */ int -#if PROTOTYPES FileCanSSLAccept(CONSFILE *cfp, fd_set *prfd, fd_set *pwfd) -#else -FileCanSSLAccept(cfp) - CONSFILE *cfp; - fd_set *prfd; - fd_set *pwfd; -#endif { if (cfp == (CONSFILE *)0) return 0; @@ -2049,12 +1718,7 @@ FileCanSSLAccept(cfp) /* return -1 on error, 0 for "wait" state, 1 for success */ int -#if PROTOTYPES FileSSLAccept(CONSFILE *cfp) -#else -FileSSLAccept(cfp) - CONSFILE *cfp; -#endif { int retval; if (cfp->waitForWrite == FLAGTRUE) { @@ -2096,15 +1760,7 @@ FileSSLAccept(cfp) /* Unless otherwise stated, returns the same values as send(2) */ int -#if PROTOTYPES FileSend(CONSFILE *cfp, const void *msg, size_t len, int flags) -#else -FileSend(cfp, msg, len, flags) - CONSFILE *cfp; - const void *msg; - size_t len; - int flags; -#endif { int retval = 0; int fdout; @@ -2151,12 +1807,7 @@ FileSend(cfp, msg, len, flags) * a pointer to the start of the non-space part */ char * -#if PROTOTYPES PruneSpace(char *string) -#else -PruneSpace(string) - char *string; -#endif { char *p; char *head = (char *)0; @@ -2187,24 +1838,20 @@ PruneSpace(string) return string; } +#if !USE_IPV6 /* fills the myAddrs array with host interface addresses */ void -#if PROTOTYPES ProbeInterfaces(in_addr_t bindAddr) -#else -ProbeInterfaces(bindAddr) - in_addr_t bindAddr; -#endif { -#ifdef SIOCGIFCONF +# ifdef SIOCGIFCONF struct ifconf ifc; struct ifreq *ifr; -#ifdef SIOCGIFFLAGS +# ifdef SIOCGIFFLAGS struct ifreq ifrcopy; -#endif -#ifdef SIOCGIFNUM +# endif +# ifdef SIOCGIFNUM int nifr; -#endif +# endif int sock; int r = 0, m = 0; int bufsize = 2048; @@ -2215,11 +1862,11 @@ ProbeInterfaces(bindAddr) myAddrs = (struct in_addr *)calloc(2, sizeof(struct in_addr)); if (myAddrs == (struct in_addr *)0) OutOfMem(); -#if HAVE_MEMCPY +# if HAVE_MEMCPY memcpy(&(myAddrs[0].s_addr), &bindAddr, sizeof(in_addr_t)); -#else +# else bcopy(&bindAddr, &(myAddrs[0].s_addr), sizeof(in_addr_t)); -#endif +# endif Verbose("interface address %s (-M option)", inet_ntoa(myAddrs[0])); return; } @@ -2228,10 +1875,10 @@ ProbeInterfaces(bindAddr) Error("ProbeInterfaces(): socket(): %s", strerror(errno)); Bye(EX_OSERR); } -#ifdef SIOCGIFNUM +# ifdef SIOCGIFNUM if (ioctl(sock, SIOCGIFNUM, &nifr) == 0) bufsize = nifr * sizeof(struct ifreq) + 512; -#endif +# endif while (bufsize) { ifc.ifc_len = bufsize; @@ -2291,11 +1938,11 @@ ProbeInterfaces(bindAddr) /* don't use less than a ifreq sized chunk */ if ((ifc.ifc_len - r) < sizeof(*ifr)) break; -#ifdef HAVE_SA_LEN +# ifdef HAVE_SA_LEN if (sa->sa_len > sizeof(ifr->ifr_ifru)) r += sizeof(ifr->ifr_name) + sa->sa_len; else -#endif +# endif r += sizeof(*ifr); if (sa->sa_family == AF_INET) { @@ -2305,32 +1952,32 @@ ProbeInterfaces(bindAddr) * signal the end of our list */ if ( -#if HAVE_MEMCMP +# if HAVE_MEMCMP memcmp(&(myAddrs[m]), &(sin->sin_addr), sizeof(struct in_addr)) -#else +# else bcmp(&(myAddrs[m]), &(sin->sin_addr), sizeof(struct in_addr)) -#endif +# endif == 0) continue; -#ifdef SIOCGIFFLAGS +# ifdef SIOCGIFFLAGS /* make sure the interface is up */ ifrcopy = *ifr; if ((ioctl(sock, SIOCGIFFLAGS, &ifrcopy) == 0) && ((ifrcopy.ifr_flags & IFF_UP) == 0)) continue; -#endif +# endif CONDDEBUG((1, "ProbeInterfaces(): name=%s addr=%s", ifr->ifr_name, inet_ntoa(sin->sin_addr))); -#if HAVE_MEMCPY +# if HAVE_MEMCPY memcpy(&myAddrs[m], &(sin->sin_addr), sizeof(struct in_addr)); -#else +# else bcopy(&(sin->sin_addr), &myAddrs[m], sizeof(struct in_addr)); -#endif +# endif Verbose("interface address %s (%s)", inet_ntoa(myAddrs[m]), ifr->ifr_name); @@ -2343,7 +1990,7 @@ ProbeInterfaces(bindAddr) } close(sock); free(ifc.ifc_req); -#else /* use the hostname like the old code did (but use all addresses!) */ +# else /* use the hostname like the old code did (but use all addresses!) */ int count; struct hostent *he; @@ -2352,11 +1999,11 @@ ProbeInterfaces(bindAddr) myAddrs = (struct in_addr *)calloc(2, sizeof(struct in_addr)); if (myAddrs == (struct in_addr *)0) OutOfMem(); -#if HAVE_MEMCPY +# if HAVE_MEMCPY memcpy(&(myAddrs[0].s_addr), &bindAddr, sizeof(in_addr_t)); -#else +# else bcopy(&bindAddr, &(myAddrs[0].s_addr), sizeof(in_addr_t)); -#endif +# endif Verbose("interface address %s (-M option)", inet_ntoa(myAddrs[0])); return; } @@ -2384,51 +2031,113 @@ ProbeInterfaces(bindAddr) if (myAddrs == (struct in_addr *)0) OutOfMem(); for (count--; count >= 0; count--) { -#if HAVE_MEMCPY +# if HAVE_MEMCPY memcpy(&(myAddrs[count].s_addr), he->h_addr_list[count], he->h_length); -#else +# else bcopy(he->h_addr_list[count], &(myAddrs[count].s_addr), he->h_length); -#endif +# endif Verbose("interface address %s (hostname address)", inet_ntoa(myAddrs[count])); } -#endif +# endif } +#endif /* USE_IPV6 */ int -#if PROTOTYPES IsMe(char *id) -#else -IsMe(id) - char *id; -#endif { +#if USE_IPV6 + int ret = 0; + int error; + struct addrinfo hints; + struct addrinfo *res, *rp; + struct ifaddrs *myAddrs, *ifa; + void *a, *b; + size_t len; + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + + /* get IP based on hostname */ + error = getaddrinfo(id, NULL, &hints, &res); + if (error) { + perror(gai_strerror(error)); + return 0; + } + + /* get list of all addresses on system */ + error = getifaddrs(&myAddrs); + if (error) { + perror("getifaddrs failed"); + return 0; + } + + /* try to find a match */ + for (ifa = myAddrs; ifa != NULL; ifa = ifa->ifa_next) { + /* skip interfaces without address or in down state */ + if (ifa->ifa_addr == NULL || !(ifa->ifa_flags & IFF_UP)) + continue; + + for (rp = res; rp != NULL; rp = rp->ai_next) { + if (ifa->ifa_addr->sa_family == rp->ai_addr->sa_family) { + /* I really don't like to hardcode it but we have to */ + if (ifa->ifa_addr->sa_family == AF_INET) { /* IPv4 */ + a = &(((struct sockaddr_in *)ifa->ifa_addr)->sin_addr); + b = &(((struct sockaddr_in *)rp->ai_addr)->sin_addr); + len = sizeof(struct in_addr); + } else { /* IPv6 */ + a = &(((struct sockaddr_in6 *)ifa->ifa_addr)-> + sin6_addr); + b = &(((struct sockaddr_in6 *)rp->ai_addr)->sin6_addr); + len = sizeof(struct in6_addr); + } + + if ( +# if HAVE_MEMCMP + memcmp(a, b, len) +# else + bcmp(a, b, len) +# endif + == 0) { + ret = 1; + goto done; + } + } + } + } + + done: + freeaddrinfo(res); + freeifaddrs(myAddrs); + CONDDEBUG((1, "IsMe: ret %d id %s", ret, id)); + return ret; +#else int j, i; struct hostent *he; in_addr_t addr; -#if HAVE_INET_ATON +# if HAVE_INET_ATON struct in_addr inetaddr; -#endif +# endif /* check for ip address match */ -#if HAVE_INET_ATON +# if HAVE_INET_ATON if (inet_aton(id, &inetaddr) != 0) { addr = inetaddr.s_addr; -#else +# else addr = inet_addr(id); if (addr != (in_addr_t) (-1)) { -#endif +# endif for (i = 0; myAddrs != (struct in_addr *)0 && myAddrs[i].s_addr != (in_addr_t) 0; i++) { if ( -#if HAVE_MEMCMP +# if HAVE_MEMCMP memcmp(&(myAddrs[i].s_addr), &addr, sizeof(addr)) -#else +# else bcmp(&(myAddrs[i].s_addr), &addr, sizeof(addr)) -#endif +# endif == 0) return 1; } @@ -2452,30 +2161,25 @@ IsMe(id) myAddrs != (struct in_addr *)0 && myAddrs[i].s_addr != (in_addr_t) 0; i++) { if ( -#if HAVE_MEMCMP +# if HAVE_MEMCMP memcmp(&(myAddrs[i].s_addr), he->h_addr_list[j], he->h_length) -#else +# else bcmp(&(myAddrs[i].s_addr), he->h_addr_list[j], he->h_length) -#endif +# endif == 0) return 1; } } return 0; +#endif /* USE_IPV6 */ } #if HAVE_OPENSSL /* Unless otherwise stated, returns the same values as send(2) */ int -#if PROTOTYPES SSLVerifyCallback(int ok, X509_STORE_CTX *store) -#else -SSLVerifyCallback(ok, store) - int ok; - X509_STORE_CTX *store; -#endif { char data[256]; if (ok) { @@ -2510,12 +2214,7 @@ SSLVerifyCallback(ok, store) #endif int -#if PROTOTYPES SetFlags(int fd, int s, int c) -#else -SetFlags(fd, s, c) - int fd, s, c; -#endif { int flags; @@ -2535,12 +2234,7 @@ SetFlags(fd, s, c) } char * -#if PROTOTYPES StrDup(const char *msg) -#else -StrDup(msg) - const char *msg; -#endif { int len; char *buf; @@ -2560,14 +2254,7 @@ StrDup(msg) } char * -#if PROTOTYPES StringChar(STRING *msg, int offset, char c) -#else -StringChar(msg, offset, c) - STRING *msg; - int offset; - char c; -#endif { int o; @@ -2590,14 +2277,7 @@ StringChar(msg, offset, c) * this *WILL* modify the buffer (OB_IAC sequences get extracted/shrunk) */ int -#if PROTOTYPES ParseIACBuf(CONSFILE *cfp, void *msg, int *len) -#else -ParseIACBuf(cfp, msg, len) - CONSFILE *cfp; - void *msg; - int *len; -#endif { int l = 0; unsigned char *b = msg; @@ -2704,15 +2384,7 @@ int line = 1; /* current line number */ char *file = (char *)0; TOKEN -#if PROTOTYPES GetWord(FILE *fp, int *line, short spaceok, STRING *word) -#else -GetWord(fp, line, spaceok, word) - FILE *fp; - int *line; - short spaceok; - STRING *word; -#endif { int c; short backslash = 0; @@ -2754,11 +2426,7 @@ GetWord(fp, line, spaceok, word) if (c == '\n') { if (fname->used > 0) { while (fname->used > 1 && isspace((int) - (fname-> - string - [fname-> - used - - 2]))) + (fname->string[fname->used - 2]))) fname->used--; if (fname->used > 0) fname->string[fname->used - 1] = '\000'; @@ -2863,14 +2531,7 @@ GetWord(fp, line, spaceok, word) } void -#if PROTOTYPES ParseFile(char *filename, FILE *fp, int level) -#else -ParseFile(filename, fp, level) - char *filename; - FILE *fp; - int level; -#endif { /* things that should be used between recursions */ static STATES state = START; @@ -3048,8 +2709,8 @@ ParseFile(filename, fp, level) case VALUE: switch (token) { case WORD: - (*sections[secIndex].items[keyIndex]. - reg) (word->string); + (*sections[secIndex]. + items[keyIndex].reg) (word->string); state = SEMI; break; case SEMICOLON: @@ -3146,16 +2807,7 @@ ParseFile(filename, fp, level) } void -#if PROTOTYPES ProcessSubst(SUBST *s, char **repl, char **str, char *name, char *id) -#else -ProcessSubst(s, repl, str, name, id) - SUBST *s; - char **repl; - char **str; - char *name; - char *id; -#endif { /* * (CONSENT *pCE) and (char **repl) are used when a replacement is to @@ -3391,11 +3043,7 @@ ProcessSubst(s, repl, str, name, id) } char * -#if PROTOTYPES MyVersion(void) -#else -MyVersion() -#endif { static STRING *version = (STRING *)0; if (version != (STRING *)0) @@ -3407,12 +3055,7 @@ MyVersion() } unsigned int -#if PROTOTYPES AtoU(char *str) -#else -AtoU(c) - char *str; -#endif { unsigned int v; int i; @@ -3425,14 +3068,7 @@ AtoU(c) } void -#if PROTOTYPES StrCpy(char *dst, const char *src, unsigned int size) -#else -StrCpy(dst, src, size) - char *dst; - const char *src; - unsigned int size; -#endif { #ifdef HAVE_STRLCPY strlcpy(dst, src, size); diff --git a/conserver/cutil.h b/conserver/cutil.h index 51a429b..e21010f 100644 --- a/conserver/cutil.h +++ b/conserver/cutil.h @@ -1,22 +1,18 @@ /* - * $Id: cutil.h,v 1.69 2009/09/26 09:23:04 bryan Exp $ + * $Id: cutil.h,v 1.70 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * * Maintainer/Enhancer: Bryan Stansell (bryan@conserver.com) */ -#if PROTOTYPES #include -#else -#include -#endif #if HAVE_OPENSSL -#include -#include +# include +# include #endif #if HAVE_GSSAPI -#include +# include #endif /* communication constants @@ -98,15 +94,15 @@ typedef struct consFile { typedef struct item { char *id; - void (*reg) PARAMS((char *)); + void (*reg) (char *); } ITEM; typedef struct section { char *id; - void (*begin) PARAMS((char *)); - void (*end) PARAMS((void)); - void (*abort) PARAMS((void)); - void (*destroy) PARAMS((void)); + void (*begin) (char *); + void (*end) (void); + void (*abort) (void); + void (*destroy) (void); ITEM *items; } SECTION; @@ -119,14 +115,14 @@ typedef enum substToken { typedef struct subst { /* function to retrieve a token type based on a character */ - SUBSTTOKEN (*token) PARAMS((char)); + SUBSTTOKEN (*token) (char); /* data for callback function */ void *data; /* function to retrieve a value (as a char* or int or both) for * a substitution */ - int (*value) PARAMS((char, char **, int *)); + int (*value) (char, char **, int *); } SUBST; extern int isMultiProc, fDebug, fVerbose, fErrorPrinted; @@ -134,7 +130,9 @@ extern char *progname; extern pid_t thepid; #define MAXHOSTNAME 1024 extern char myHostname[]; +#if !USE_IPV6 extern struct in_addr *myAddrs; +#endif extern fd_set rinit; extern fd_set winit; extern int maxfd; @@ -145,73 +143,74 @@ extern char *file; /* used by ParseFile */ extern SECTION sections[]; /* used by ParseFile */ extern int isMaster; -extern const char *StrTime PARAMS((time_t *)); -extern void Debug PARAMS((int, char *, ...)); -extern void Error PARAMS((char *, ...)); -extern void Msg PARAMS((char *, ...)); -extern void Verbose PARAMS((char *, ...)); -extern void SimpleSignal PARAMS((int, RETSIGTYPE(*)(int))); -extern int GetMaxFiles PARAMS(()); -extern char *FmtCtl PARAMS((int, STRING *)); -extern void FmtCtlStr PARAMS((char *, int, STRING *)); -extern CONSFILE *FileOpenFD PARAMS((int, enum consFileType)); -extern CONSFILE *FileOpenPipe PARAMS((int, int)); -extern CONSFILE *FileOpen PARAMS((const char *, int, int)); -extern int FileClose PARAMS((CONSFILE **)); -extern int FileRead PARAMS((CONSFILE *, void *, int)); -extern int FileWrite PARAMS((CONSFILE *, FLAG, char *, int)); -extern void FileVWrite PARAMS((CONSFILE *, FLAG, char *, va_list)); -extern void FilePrint PARAMS((CONSFILE *, FLAG, char *, ...)); -extern int FileStat PARAMS((CONSFILE *, struct stat *)); -extern int FileSeek PARAMS((CONSFILE *, off_t, int)); -extern int FileSend PARAMS((CONSFILE *, const void *, size_t, int)); -extern int FileFDNum PARAMS((CONSFILE *)); -extern int FileFDOutNum PARAMS((CONSFILE *)); -extern int FileUnopen PARAMS((CONSFILE *)); -extern void OutOfMem PARAMS(()); -extern char *BuildTmpString PARAMS((const char *)); -extern char *BuildTmpStringChar PARAMS((const char)); -extern char *BuildTmpStringPrint PARAMS((char *, ...)); -extern char *BuildString PARAMS((const char *, STRING *)); -extern char *BuildStringChar PARAMS((const char, STRING *)); -extern char *BuildStringPrint PARAMS((STRING *, char *, ...)); -extern char *BuildStringN PARAMS((const char *, int, STRING *)); -extern char *ShiftString PARAMS((STRING *, int)); -extern void InitString PARAMS((STRING *)); -extern void DestroyString PARAMS((STRING *)); -extern void DestroyStrings PARAMS((void)); -extern STRING *AllocString PARAMS((void)); -extern char *ReadLine PARAMS((FILE *, STRING *, int *)); -extern enum consFileType FileGetType PARAMS((CONSFILE *)); -extern void FileSetType PARAMS((CONSFILE *, enum consFileType)); -extern void FileSetQuoteIAC PARAMS((CONSFILE *, FLAG)); -extern FLAG FileSawQuoteSusp PARAMS((CONSFILE *)); -extern FLAG FileSawQuoteExec PARAMS((CONSFILE *)); -extern FLAG FileSawQuoteAbrt PARAMS((CONSFILE *)); -extern FLAG FileSawQuoteGoto PARAMS((CONSFILE *)); -extern void Bye PARAMS((int)); -extern void DestroyDataStructures PARAMS((void)); -extern int IsMe PARAMS((char *)); -extern char *PruneSpace PARAMS((char *)); -extern int FileCanRead PARAMS((CONSFILE *, fd_set *, fd_set *)); -extern int FileCanWrite PARAMS((CONSFILE *, fd_set *, fd_set *)); -extern int FileBufEmpty PARAMS((CONSFILE *)); -extern int SetFlags PARAMS((int, int, int)); -extern char *StrDup PARAMS((const char *)); -extern int ParseIACBuf PARAMS((CONSFILE *, void *, int *)); -extern void *MemMove PARAMS((void *, void *, size_t)); -extern char *StringChar PARAMS((STRING *, int, char)); -extern void ParseFile PARAMS((char *, FILE *, int)); -extern void ProbeInterfaces PARAMS((in_addr_t)); -extern void ProcessSubst -PARAMS((SUBST *, char **, char **, char *, char *)); -extern char *MyVersion PARAMS((void)); -extern unsigned int AtoU PARAMS((char *)); -extern void StrCpy PARAMS((char *, const char *, unsigned int)); -#if HAVE_OPENSSL -extern SSL *FileGetSSL PARAMS((CONSFILE *)); -extern void FileSetSSL PARAMS((CONSFILE *, SSL *)); -extern int SSLVerifyCallback PARAMS((int, X509_STORE_CTX *)); -extern int FileSSLAccept PARAMS((CONSFILE *)); -extern int FileCanSSLAccept PARAMS((CONSFILE *, fd_set *, fd_set *)); +extern const char *StrTime(time_t *); +extern void Debug(int, char *, ...); +extern void Error(char *, ...); +extern void Msg(char *, ...); +extern void Verbose(char *, ...); +extern void SimpleSignal(int, RETSIGTYPE(*)(int)); +extern int GetMaxFiles(); +extern char *FmtCtl(int, STRING *); +extern void FmtCtlStr(char *, int, STRING *); +extern CONSFILE *FileOpenFD(int, enum consFileType); +extern CONSFILE *FileOpenPipe(int, int); +extern CONSFILE *FileOpen(const char *, int, int); +extern int FileClose(CONSFILE **); +extern int FileRead(CONSFILE *, void *, int); +extern int FileWrite(CONSFILE *, FLAG, char *, int); +extern void FileVWrite(CONSFILE *, FLAG, char *, va_list); +extern void FilePrint(CONSFILE *, FLAG, char *, ...); +extern int FileStat(CONSFILE *, struct stat *); +extern int FileSeek(CONSFILE *, off_t, int); +extern int FileSend(CONSFILE *, const void *, size_t, int); +extern int FileFDNum(CONSFILE *); +extern int FileFDOutNum(CONSFILE *); +extern int FileUnopen(CONSFILE *); +extern void OutOfMem(); +extern char *BuildTmpString(const char *); +extern char *BuildTmpStringChar(const char); +extern char *BuildTmpStringPrint(char *, ...); +extern char *BuildString(const char *, STRING *); +extern char *BuildStringChar(const char, STRING *); +extern char *BuildStringPrint(STRING *, char *, ...); +extern char *BuildStringN(const char *, int, STRING *); +extern char *ShiftString(STRING *, int); +extern void InitString(STRING *); +extern void DestroyString(STRING *); +extern void DestroyStrings(void); +extern STRING *AllocString(void); +extern char *ReadLine(FILE *, STRING *, int *); +extern enum consFileType FileGetType(CONSFILE *); +extern void FileSetType(CONSFILE *, enum consFileType); +extern void FileSetQuoteIAC(CONSFILE *, FLAG); +extern FLAG FileSawQuoteSusp(CONSFILE *); +extern FLAG FileSawQuoteExec(CONSFILE *); +extern FLAG FileSawQuoteAbrt(CONSFILE *); +extern FLAG FileSawQuoteGoto(CONSFILE *); +extern void Bye(int); +extern void DestroyDataStructures(void); +extern int IsMe(char *); +extern char *PruneSpace(char *); +extern int FileCanRead(CONSFILE *, fd_set *, fd_set *); +extern int FileCanWrite(CONSFILE *, fd_set *, fd_set *); +extern int FileBufEmpty(CONSFILE *); +extern int SetFlags(int, int, int); +extern char *StrDup(const char *); +extern int ParseIACBuf(CONSFILE *, void *, int *); +extern void *MemMove(void *, void *, size_t); +extern char *StringChar(STRING *, int, char); +extern void ParseFile(char *, FILE *, int); +#if !USE_IPV6 +extern void ProbeInterfaces(in_addr_t); +#endif +extern void ProcessSubst(SUBST *, char **, char **, char *, char *); +extern char *MyVersion(void); +extern unsigned int AtoU(char *); +extern void StrCpy(char *, const char *, unsigned int); +#if HAVE_OPENSSL +extern SSL *FileGetSSL(CONSFILE *); +extern void FileSetSSL(CONSFILE *, SSL *); +extern int SSLVerifyCallback(int, X509_STORE_CTX *); +extern int FileSSLAccept(CONSFILE *); +extern int FileCanSSLAccept(CONSFILE *, fd_set *, fd_set *); #endif diff --git a/conserver/fallback.c b/conserver/fallback.c index 017f4e8..406e39f 100644 --- a/conserver/fallback.c +++ b/conserver/fallback.c @@ -1,5 +1,5 @@ /* - * $Id: fallback.c,v 5.61 2004/04/16 16:58:09 bryan Exp $ + * $Id: fallback.c,v 5.62 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -27,44 +27,38 @@ * packages, i think things are ok...hopefully it's true! */ static int -#if PROTOTYPES GetPseudoTTY(STRING *slave, int *slaveFD) -#else -GetPseudoTTY(slave, slaveFD) - STRING *slave; - int *slaveFD; -#endif { #if HAVE_OPENPTY int fd = -1; int sfd = -1; int opty = 0; char *pcName; -#if HAVE_SIGACTION +# if HAVE_SIGACTION sigset_t oldmask, newmask; -#else - extern RETSIGTYPE FlagReapVirt PARAMS((int)); -#endif +# else + extern RETSIGTYPE FlagReapVirt(int); +# endif -#if HAVE_SIGACTION +# if HAVE_SIGACTION sigemptyset(&newmask); sigaddset(&newmask, SIGCHLD); if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0) Error("GetPseudoTTY(): sigprocmask(SIG_BLOCK): %s", strerror(errno)); -#else +# else SimpleSignal(SIGCHLD, SIG_DFL); -#endif +# endif opty = openpty(&fd, &sfd, NULL, NULL, NULL); -#if HAVE_SIGACTION +# if HAVE_SIGACTION if (sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0) Error("GetPseudoTTY(): sigprocmask(SIG_SETMASK): %s", strerror(errno)); -#else +# else SimpleSignal(SIGCHLD, FlagReapVirt); -#endif +# endif if (opty != 0) { if (fd >= 0) @@ -84,15 +78,15 @@ GetPseudoTTY(slave, slaveFD) *slaveFD = sfd; return fd; #else -#if (HAVE_PTSNAME && HAVE_GRANTPT && HAVE_UNLOCKPT) || defined(_AIX) +# if (HAVE_PTSNAME && HAVE_GRANTPT && HAVE_UNLOCKPT) || defined(_AIX) int fd = -1; int sfd = -1; char *pcName; -#if HAVE_SIGACTION +# if HAVE_SIGACTION sigset_t oldmask, newmask; -#else - extern RETSIGTYPE FlagReapVirt PARAMS((int)); -#endif +# else + extern RETSIGTYPE FlagReapVirt(int); +# endif int c; /* clone list and idea stolen from xemacs distribution */ static char *clones[] = { @@ -111,48 +105,48 @@ GetPseudoTTY(slave, slaveFD) if (fd < 0) return -1; -#if HAVE_SIGACTION +# if HAVE_SIGACTION sigemptyset(&newmask); sigaddset(&newmask, SIGCHLD); if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0) Error("GetPseudoTTY(): sigprocmask(SIG_BLOCK): %s", strerror(errno)); -#else +# else SimpleSignal(SIGCHLD, SIG_DFL); -#endif +# endif -#if HAVE_GRANTPT +# if HAVE_GRANTPT grantpt(fd); /* change permission of slave */ -#endif +# endif -#if HAVE_SIGACTION +# if HAVE_SIGACTION if (sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0) Error("GetPseudoTTY(): sigprocmask(SIG_SETMASK): %s", strerror(errno)); -#else +# else SimpleSignal(SIGCHLD, FlagReapVirt); -#endif +# endif -#if HAVE_UNLOCKPT +# if HAVE_UNLOCKPT unlockpt(fd); /* unlock slave */ -#endif +# endif -#if defined(_AIX) +# if defined(_AIX) if ((pcName = ttyname(fd)) == (char *)0) { close(fd); return -1; } -#else -# if HAVE_PTSNAME +# else +# if HAVE_PTSNAME if ((pcName = ptsname(fd)) == (char *)0) { close(fd); return -1; } -# else +# else close(fd); return -1; -# endif -#endif +# endif +# endif /* go ahead and open the slave */ if ((sfd = open(pcName, O_RDWR, 0)) < 0) { @@ -166,7 +160,7 @@ GetPseudoTTY(slave, slaveFD) *slaveFD = sfd; return fd; -#else +# else /* * Below is the string for finding /dev/ptyXX. For each architecture we * leave some pty's world writable because we don't have source for @@ -234,7 +228,7 @@ GetPseudoTTY(slave, slaveFD) *slaveFD = sfd; return fd; -#endif /* (HAVE_PTSNAME && HAVE_GRANTPT && HAVE_UNLOCKPT) || defined(_AIX) */ +# endif /* (HAVE_PTSNAME && HAVE_GRANTPT && HAVE_UNLOCKPT) || defined(_AIX) */ #endif /* HAVE_OPENPTY */ } @@ -242,13 +236,7 @@ GetPseudoTTY(slave, slaveFD) * get a pty using the GetPseudoTTY code above */ int -#if PROTOTYPES FallBack(char **slave, int *sfd) -#else -FallBack(slave, sfd) - char **slave; - int *sfd; -#endif { int fd; static STRING *pcTSlave = (STRING *)0; diff --git a/conserver/group.c b/conserver/group.c index 87ac302..99f0fcd 100644 --- a/conserver/group.c +++ b/conserver/group.c @@ -1,5 +1,5 @@ /* - * $Id: group.c,v 5.346 2014/04/04 16:17:10 bryan Exp $ + * $Id: group.c,v 5.350 2014/04/20 07:20:56 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -56,11 +56,7 @@ #include #include -#if PROTOTYPES #include -#else -#include -#endif #include #include @@ -74,7 +70,7 @@ #include #if HAVE_PAM -#include +# include #endif @@ -90,13 +86,7 @@ static unsigned long dmallocMarkClientConnection = 0; #endif void -#if PROTOTYPES SendIWaitClientsMsg(CONSENT *pCE, char *message) -#else -SendIWaitClientsMsg(pCE, message) - CONSENT *pCE; - char *message; -#endif { CONSCLIENT *pCL; @@ -113,13 +103,7 @@ SendIWaitClientsMsg(pCE, message) } void -#if PROTOTYPES SendClientsMsg(CONSENT *pCE, char *message) -#else -SendClientsMsg(pCE, message) - CONSENT *pCE; - char *message; -#endif { CONSCLIENT *pCL; @@ -135,14 +119,7 @@ SendClientsMsg(pCE, message) } void -#if PROTOTYPES SendCertainClientsMsg(GRPENT *pGE, char *who, char *message) -#else -SendCertainClientsMsg(pGE, who, message) - GRPENT *pGE; - char *who; - char *message; -#endif { CONSCLIENT *pCL; char *console = (char *)0; @@ -170,13 +147,7 @@ SendCertainClientsMsg(pGE, who, message) } void -#if PROTOTYPES SendAllClientsMsg(GRPENT *pGE, char *message) -#else -SendAllClientsMsg(pGE, message) - GRPENT *pGE; - char *message; -#endif { CONSCLIENT *pCL; @@ -192,11 +163,7 @@ SendAllClientsMsg(pGE, message) } void -#if PROTOTYPES AbortAnyClientExec(CONSCLIENT *pCL) -#else -AbortAnyClientExec(pCL) -#endif { if (pCL->iState == S_CEXEC) { FileSetQuoteIAC(pCL->fd, FLAGFALSE); @@ -208,12 +175,7 @@ AbortAnyClientExec(pCL) } void -#if PROTOTYPES StopTask(CONSENT *pCE) -#else -StopTask(pCE) - CONSENT *pCE; -#endif { if (pCE->taskpid != 0) { kill(pCE->taskpid, SIGHUP); @@ -230,12 +192,7 @@ StopTask(pCE) } void -#if PROTOTYPES ClientWantsWrite(CONSCLIENT *pCL) -#else -ClientWantsWrite(pCL) - CONSCLIENT *pCL; -#endif { CONSENT *pCE; @@ -271,15 +228,7 @@ ClientWantsWrite(pCL) } void -#if PROTOTYPES DisconnectClient(GRPENT *pGE, CONSCLIENT *pCL, char *message, FLAG force) -#else -DisconnectClient(pGE, pCL, message, force) - GRPENT *pGE; - CONSCLIENT *pCL; - char *message; - FLAG force; -#endif { CONSENT *pCEServing; @@ -356,14 +305,7 @@ DisconnectClient(pGE, pCL, message, force) } int -#if PROTOTYPES DisconnectCertainClients(GRPENT *pGE, char *admin, char *who) -#else -DisconnectCertainClients(pGE, admin, who) - GRPENT *pGE; - char *admin; - char *who; -#endif { CONSCLIENT *pCL; char *console = (char *)0; @@ -406,13 +348,7 @@ DisconnectCertainClients(pGE, admin, who) } void -#if PROTOTYPES DisconnectAllClients(GRPENT *pGE, char *message) -#else -DisconnectAllClients(pGE, message) - GRPENT *pGE; - char *message; -#endif { CONSCLIENT *pCL; @@ -426,12 +362,7 @@ DisconnectAllClients(pGE, message) } void -#if PROTOTYPES DestroyClient(CONSCLIENT *pCL) -#else -DestroyClient(pCL) - CONSCLIENT *pCL; -#endif { if (pCL == (CONSCLIENT *)0) return; @@ -448,12 +379,7 @@ DestroyClient(pCL) } void -#if PROTOTYPES DestroyConsentUsers(CONSENTUSERS **cu) -#else -DestroyConsentUsers(cu) - CONSENTUSERS **cu; -#endif { CONSENTUSERS *n = (CONSENTUSERS *)0; @@ -468,13 +394,7 @@ DestroyConsentUsers(cu) } CONSENTUSERS * -#if PROTOTYPES ConsentFindUser(CONSENTUSERS *pCU, char *id) -#else -ConsentFindUser(pCU, id) - CONSENTUSERS *pCU; - char *id; -#endif { short close = 0; struct group *g = (struct group *)0; @@ -514,13 +434,7 @@ ConsentFindUser(pCU, id) } int -#if PROTOTYPES ConsentUserOk(CONSENTUSERS *pCU, char *id) -#else -ConsentUserOk(pCU, id) - CONSENTUSERS *pCU; - char *id; -#endif { CONSENTUSERS *c; @@ -533,13 +447,7 @@ ConsentUserOk(pCU, id) /* check user permissions. return 0 for r/w, 1 for r/o, -1 for none */ int -#if PROTOTYPES ClientAccess(CONSENT *pCE, char *user) -#else -ClientAccess(pCE, user) - CONSENT *pCE; - char *user; -#endif { CONDDEBUG((1, "ClientAccess(): Authenticating user %s", user)); @@ -578,13 +486,7 @@ ClientAccess(pCE, user) } void -#if PROTOTYPES DestroyConsent(GRPENT *pGE, CONSENT *pCE) -#else -DestroyConsent(pGE, pCE) - GRPENT *pGE; - CONSENT *pCE; -#endif { CONSCLIENT *pCL; CONSENT **ppCE; @@ -698,12 +600,7 @@ DestroyConsent(pGE, pCE) } void -#if PROTOTYPES DestroyGroup(GRPENT *pGE) -#else -DestroyGroup(pGE) - GRPENT *pGE; -#endif { CONSENT *pCEtmp, *pCE; CONSCLIENT *pCLtmp, *pCL; @@ -742,16 +639,8 @@ DestroyGroup(pGE) #if HAVE_PAM int -#if PROTOTYPES QuietConv(int num_msg, struct pam_message **msg, struct pam_response **resp, void *appdata_ptr) -#else -QuietConv(num_msg, msg, resp, appdata_ptr) - int num_msg; - struct pam_message **msg; - struct pam_response **resp; - void *appdata_ptr; -#endif { int i; struct pam_response *response = NULL; @@ -806,14 +695,7 @@ QuietConv(num_msg, msg, resp, appdata_ptr) * given a special epass try it first. */ int -#if PROTOTYPES CheckPass(char *pcUser, char *pcWord, FLAG empty_check) -#else -CheckPass(pcUser, pcWord, empty_check) - char *pcUser; - char *pcWord; - FLAG empty_check; -#endif { if (pcWord == (char *)0) { pcWord = ""; @@ -865,12 +747,12 @@ CheckPass(pcUser, pcWord, empty_check) struct passwd *pwd; int retval = AUTH_SUCCESS; char *pass; -#if HAVE_ISCOMSEC && HAVE_GETPRPWNAM +# if HAVE_ISCOMSEC && HAVE_GETPRPWNAM struct pr_passwd *prpwd; -#endif -#if HAVE_GETSPNAM +# endif +# if HAVE_GETSPNAM struct spwd *spwd; -#endif +# endif if ((pwd = getpwnam(pcUser)) == (struct passwd *)0) { CONDDEBUG((1, "CheckPass(): getpwnam(%s): %s", pcUser, @@ -880,7 +762,7 @@ CheckPass(pcUser, pcWord, empty_check) } pass = pwd->pw_passwd; -#if HAVE_ISCOMSEC && HAVE_GETPRPWNAM +# if HAVE_ISCOMSEC && HAVE_GETPRPWNAM if (iscomsec()) { CONDDEBUG((1, "CheckPass(): trusted password check")); if ((prpwd = getprpwnam(pcUser)) == (struct pr_passwd *)0) { @@ -891,9 +773,9 @@ CheckPass(pcUser, pcWord, empty_check) } pass = prpwd->ufld.fd_encrypt; } -#endif +# endif -#if HAVE_GETSPNAM +# if HAVE_GETSPNAM if ('x' == pass[0] && '\000' == pass[1]) { CONDDEBUG((1, "CheckPass(): shadow password check")); if ((spwd = getspnam(pcUser)) == (struct spwd *)0) { @@ -904,7 +786,7 @@ CheckPass(pcUser, pcWord, empty_check) } pass = spwd->sp_pwdp; } -#endif +# endif if (pass[0] == '\000' && pcWord[0] == '\000') { retval = AUTH_SUCCESS; /* let empty password match */ @@ -917,11 +799,11 @@ CheckPass(pcUser, pcWord, empty_check) else salt = pass; -#if HAVE_ISCOMSEC && HAVE_BIGCRYPT +# if HAVE_ISCOMSEC && HAVE_BIGCRYPT if (iscomsec()) encrypted = bigcrypt(pcWord, salt); else -#endif +# endif encrypted = crypt(pcWord, salt); if ((strcmp(pass, encrypted) != 0)) { CONDDEBUG((1, "CheckPass(): password check failed (%s)", @@ -932,13 +814,13 @@ CheckPass(pcUser, pcWord, empty_check) finished_pass: endpwent(); -#if HAVE_ISCOMSEC && HAVE_GETPRPWNAM +# if HAVE_ISCOMSEC && HAVE_GETPRPWNAM if (iscomsec()) endprpwent(); -#endif -#if HAVE_GETSPNAM +# endif +# if HAVE_GETSPNAM endspent(); -#endif +# endif return retval; #endif /* getpw*() */ } @@ -948,12 +830,7 @@ CheckPass(pcUser, pcWord, empty_check) * lucky for us: log file fd's can change async from the group driver! */ static RETSIGTYPE -#if PROTOTYPES FlagSawChldHUP(int sig) -#else -FlagSawChldHUP(sig) - int sig; -#endif { fSawChldHUP = 1; #if !HAVE_SIGACTION @@ -965,12 +842,7 @@ FlagSawChldHUP(sig) * lucky for us: log file fd's can change async from the group driver! */ static RETSIGTYPE -#if PROTOTYPES FlagSawChldUSR2(int sig) -#else -FlagSawChldUSR2(sig) - int sig; -#endif { fSawChldUSR2 = 1; #if !HAVE_SIGACTION @@ -979,12 +851,7 @@ FlagSawChldUSR2(sig) } void -#if PROTOTYPES ConsoleError(CONSENT *pCE) -#else -ConsoleError(pCE) - CONSENT *pCE; -#endif { if (pCE->autoreinit != FLAGTRUE) { ConsDown(pCE, FLAGTRUE, FLAGTRUE); @@ -1000,12 +867,7 @@ ConsoleError(pCE) } static void -#if PROTOTYPES ReOpen(GRPENT *pGE) -#else -ReOpen(pGE) - GRPENT *pGE; -#endif { CONSENT *pCE; @@ -1030,12 +892,7 @@ ReOpen(pGE) } static RETSIGTYPE -#if PROTOTYPES FlagReUp(int sig) -#else -FlagReUp(sig) - int sig; -#endif { fSawReUp = 1; #if !HAVE_SIGACTION @@ -1053,12 +910,7 @@ static struct delay { * the time when the next init should happen */ static time_t -#if PROTOTYPES InitDelay(CONSENT *pCE) -#else -InitDelay(pCE) - CONSENT *pCE; -#endif { char *l; struct delay *d; @@ -1080,12 +932,7 @@ InitDelay(pCE) } static void -#if PROTOTYPES UpdateDelay(CONSENT *pCE) -#else -UpdateDelay(pCE) - CONSENT *pCE; -#endif { char *l; struct delay *d; @@ -1113,13 +960,7 @@ UpdateDelay(pCE) } static void -#if PROTOTYPES ReUp(GRPENT *pGE, short automatic) -#else -ReUp(pGE, automatic) - GRPENT *pGE; - short automatic; -#endif { CONSENT *pCE; int autoReUp; @@ -1190,21 +1031,10 @@ ReUp(pGE, automatic) } void -#if PROTOTYPES TagLogfile(const CONSENT *pCE, char *fmt, ...) -#else -TagLogfile(pCE, fmt, va_alist) - const CONSENT *pCE; - char *fmt; - va_dcl -#endif { va_list ap; -#if PROTOTYPES va_start(ap, fmt); -#else - va_start(ap); -#endif if ((pCE == (CONSENT *)0) || (pCE->fdlog == (CONSFILE *)0)) return; @@ -1216,21 +1046,10 @@ TagLogfile(pCE, fmt, va_alist) } void -#if PROTOTYPES TagLogfileAct(const CONSENT *pCE, char *fmt, ...) -#else -TagLogfileAct(pCE, fmt, va_alist) - const CONSENT *pCE; - char *fmt; - va_dcl -#endif { va_list ap; -#if PROTOTYPES va_start(ap, fmt); -#else - va_start(ap); -#endif if ((pCE == (CONSENT *)0) || (pCE->fdlog == (CONSFILE *)0) || (pCE->activitylog != FLAGTRUE)) @@ -1243,12 +1062,7 @@ TagLogfileAct(pCE, fmt, va_alist) } static void -#if PROTOTYPES RollLogs(GRPENT *pGE) -#else -RollLogs(pGE) - GRPENT *pGE; -#endif { CONSENT *pCE; struct stat stLog; @@ -1353,12 +1167,7 @@ RollLogs(pGE) } static void -#if PROTOTYPES Mark(GRPENT *pGE) -#else -Mark(pGE) - GRPENT *pGE; -#endif { time_t tyme; CONSENT *pCE; @@ -1400,14 +1209,7 @@ Mark(pGE) } void -#if PROTOTYPES WriteLog(CONSENT *pCE, char *s, int len) -#else -WriteLog(pCE, s, len) - CONSENT *pCE; - char *s; - int len; -#endif { int i = 0; int j; @@ -1450,12 +1252,7 @@ WriteLog(pCE, s, len) } static RETSIGTYPE -#if PROTOTYPES FlagGoAway(int sig) -#else -FlagGoAway(sig) - int sig; -#endif { fSawGoAway = 1; #if !HAVE_SIGACTION @@ -1465,12 +1262,7 @@ FlagGoAway(sig) /* yep, basically the same...ah well, maybe someday */ static RETSIGTYPE -#if PROTOTYPES FlagGoAwayAlso(int sig) -#else -FlagGoAwayAlso(sig) - int sig; -#endif { fSawGoAway = 1; #if !HAVE_SIGACTION @@ -1478,16 +1270,8 @@ FlagGoAwayAlso(sig) #endif } -#if HAVE_SIGACTION -static -#endif - RETSIGTYPE -#if PROTOTYPES +static RETSIGTYPE FlagReapVirt(int sig) -#else -FlagReapVirt(sig) - int sig; -#endif { fSawReapVirt = 1; #if !HAVE_SIGACTION @@ -1498,13 +1282,7 @@ FlagReapVirt(sig) /* on a TERM we have to cleanup utmp entries (ask ptyd to do it) (ksb) */ void -#if PROTOTYPES DeUtmp(GRPENT *pGE, int sfd) -#else -DeUtmp(pGE, sfd) - GRPENT *pGE; - int sfd; -#endif { CONSENT *pCE; #if USE_UNIX_DOMAIN_SOCKETS @@ -1542,12 +1320,7 @@ DeUtmp(pGE, sfd) * reader on the pseudo will cause us to notice the death in Kiddie... */ static void -#if PROTOTYPES ReapVirt(GRPENT *pGE) -#else -ReapVirt(pGE) - GRPENT *pGE; -#endif { pid_t pid; int UWbuf; @@ -1649,19 +1422,42 @@ ReapVirt(pGE) } int -#if PROTOTYPES CheckPasswd(CONSCLIENT *pCL, char *pw_string, FLAG empty_check) -#else -CheckPasswd(pCL, pw_string, empty_check) - CONSCLIENT *pCL; - char *pw_string; - FLAG empty_check; -#endif { FILE *fp; int iLine = 0; char *this_pw, *user; +#if USE_UNIX_DOMAIN_SOCKETS +# if TRUST_UDS_CRED + struct UDS_CRED_STYPE client_cred; + socklen_t client_cred_len = sizeof(client_cred); + memset(&client_cred, 0, sizeof(client_cred)); + int err; + + if ((err = + getsockopt(pCL->fd->fd, SOL_SOCKET, UDS_CRED_SO, &client_cred, + &client_cred_len)) == -1) { + Error("CheckPasswd(): getsockopt(CREDENTIALS) failed: %s", + strerror(err)); + } else if (client_cred.pid != 0) { + /* Does pCL->username->string and client_cred.uid match ? */ + struct passwd *pwd = (struct passwd *)0; + + /* we allow root to impersonate anyone */ + if (client_cred.UDS_CRED_UID == 0) + return AUTH_SUCCESS; + + if ((pwd = getpwnam(pCL->username->string)) != NULL) { + if (pwd->pw_uid == client_cred.UDS_CRED_UID) { + Verbose("user %s authenticated", pCL->username->string); + return AUTH_SUCCESS; + } + } + } +# endif +#endif + if ((fp = fopen(config->passwdfile, "r")) == (FILE *)0) { if (CheckPass(pCL->username->string, pw_string, empty_check) == AUTH_SUCCESS) { @@ -1721,12 +1517,7 @@ CheckPasswd(pCL, pw_string, empty_check) } static char * -#if PROTOTYPES IdleTyme(long tyme) -#else -IdleTyme(tyme) - long tyme; -#endif { long hours, minutes; static STRING *timestr = (STRING *)0; @@ -1752,14 +1543,7 @@ IdleTyme(tyme) } void -#if PROTOTYPES PutConsole(CONSENT *pCEServing, unsigned char c, int quote) -#else -PutConsole(pCEServing, c, quote) - CONSENT *pCEServing; - unsigned char c; - int quote; -#endif { /* if we need to send an IAC char to a telnet-based port, quote * the thing (which means send two to the port). but, since we're @@ -1802,14 +1586,7 @@ PutConsole(pCEServing, c, quote) } void -#if PROTOTYPES ExpandString(char *str, CONSENT *pCE, short breaknum) -#else -ExpandString(str, pCE, breaknum) - char *str; - CONSENT *pCE; - short breaknum; -#endif { char s; short backslash = 0; @@ -1898,14 +1675,7 @@ ExpandString(str, pCE, breaknum) } void -#if PROTOTYPES SendBreak(CONSCLIENT *pCLServing, CONSENT *pCEServing, short bt) -#else -SendBreak(pCLServing, pCEServing, bt) - CONSCLIENT *pCLServing; - CONSENT *pCEServing; - short bt; -#endif { CONSCLIENT *pCL; @@ -1970,20 +1740,12 @@ SendBreak(pCLServing, pCEServing, bt) } static int -#if PROTOTYPES StartTask(CONSENT *pCE, char *cmd, uid_t uid, gid_t gid) -#else -StartTask(pCE, cmd, uid, gid) - CONSENT *pCE; - char *cmd; - uid_t uid; - gid_t gid; -#endif { int i; extern char **environ; char *pcShell, **ppcArgv; - extern int FallBack PARAMS((char **, int *)); + extern int FallBack(char **, int *); char *execSlave; /* pseudo-device slave side */ int execSlaveFD; /* fd of slave side */ int cofile; @@ -2075,14 +1837,7 @@ StartTask(pCE, cmd, uid, gid) } void -#if PROTOTYPES InvokeTask(CONSCLIENT *pCLServing, CONSENT *pCEServing, char id) -#else -InvokeTask(pCLServing, pCEServing, id) - CONSCLIENT *pCLServing; - CONSENT *pCEServing; - char id; -#endif { TASKS *t = (TASKS *)0; char *cmd; @@ -2169,12 +1924,7 @@ InvokeTask(pCLServing, pCEServing, id) #if HAVE_OPENSSL int -#if PROTOTYPES AttemptSSL(CONSCLIENT *pCL) -#else -AttemptSSL(pCL) - CONSCLIENT *pCL; -#endif { int fdnum; SSL *ssl; @@ -2204,12 +1954,7 @@ AttemptSSL(pCL) #if HAVE_GSSAPI int -#if PROTOTYPES AttemptGSSAPI(CONSCLIENT *pCL) -#else -AttemptGSSAPI(pCL) - CONSCLIENT *pCL; -#endif { int nr, ret = 0; char buf[1024]; @@ -2262,13 +2007,7 @@ AttemptGSSAPI(pCL) #endif CONSENT * -#if PROTOTYPES HuntForConsole(GRPENT *pGE, char *name) -#else -HuntForConsole(pGE, name) - GRPENT *pGE; - char *name; -#endif { /* try to find a given console * we assume all the right checks for ambiguity @@ -2309,16 +2048,8 @@ HuntForConsole(pGE, name) } void -#if PROTOTYPES CommandAttach(GRPENT *pGE, CONSCLIENT *pCLServing, CONSENT *pCEServing, long tyme) -#else -CommandAttach(pGE, pCLServing, pCEServing, tyme) - GRPENT *pGE; - CONSCLIENT *pCLServing; - CONSENT *pCEServing; - long tyme; -#endif { CONSCLIENT *pCL; @@ -2353,16 +2084,8 @@ CommandAttach(pGE, pCLServing, pCEServing, tyme) } void -#if PROTOTYPES CommandChangeFlow(GRPENT *pGE, CONSCLIENT *pCLServing, CONSENT *pCEServing, long tyme) -#else -CommandChangeFlow(pGE, pCLServing, pCEServing, tyme) - GRPENT *pGE; - CONSCLIENT *pCLServing; - CONSENT *pCEServing; - long tyme; -#endif { struct termios sbuf; int cofile; @@ -2398,16 +2121,8 @@ CommandChangeFlow(pGE, pCLServing, pCEServing, tyme) } void -#if PROTOTYPES CommandDown(GRPENT *pGE, CONSCLIENT *pCLServing, CONSENT *pCEServing, long tyme) -#else -CommandDown(pGE, pCLServing, pCEServing, tyme) - GRPENT *pGE; - CONSCLIENT *pCLServing; - CONSENT *pCEServing; - long tyme; -#endif { CONSCLIENT *pCL; @@ -2437,17 +2152,8 @@ CommandDown(pGE, pCLServing, pCEServing, tyme) } void -#if PROTOTYPES CommandExamine(GRPENT *pGE, CONSCLIENT *pCLServing, CONSENT *pCEServing, long tyme, char *args) -#else -CommandExamine(pGE, pCLServing, pCEServing, tyme, args) - GRPENT *pGE; - CONSCLIENT *pCLServing; - CONSENT *pCEServing; - long tyme; - char *args; -#endif { CONSENT *pCE; @@ -2505,16 +2211,8 @@ CommandExamine(pGE, pCLServing, pCEServing, tyme, args) } void -#if PROTOTYPES CommandForce(GRPENT *pGE, CONSCLIENT *pCLServing, CONSENT *pCEServing, long tyme) -#else -CommandForce(pGE, pCLServing, pCEServing, tyme) - GRPENT *pGE; - CONSCLIENT *pCLServing; - CONSENT *pCEServing; - long tyme; -#endif { CONSCLIENT *pCL; @@ -2568,17 +2266,8 @@ CommandForce(pGE, pCLServing, pCEServing, tyme) } void -#if PROTOTYPES CommandGroup(GRPENT *pGE, CONSCLIENT *pCLServing, CONSENT *pCEServing, long tyme, char *args) -#else -CommandGroup(pGE, pCLServing, pCEServing, tyme, args) - GRPENT *pGE; - CONSCLIENT *pCLServing; - CONSENT *pCEServing; - long tyme; - char *args; -#endif { CONSCLIENT *pCL; CONSENT *pCE; @@ -2602,17 +2291,8 @@ CommandGroup(pGE, pCLServing, pCEServing, tyme, args) } void -#if PROTOTYPES CommandHosts(GRPENT *pGE, CONSCLIENT *pCLServing, CONSENT *pCEServing, long tyme, char *args) -#else -CommandHosts(pGE, pCLServing, pCEServing, tyme, args) - GRPENT *pGE; - CONSCLIENT *pCLServing; - CONSENT *pCEServing; - long tyme; - char *args; -#endif { CONSENT *pCE; @@ -2636,17 +2316,8 @@ CommandHosts(pGE, pCLServing, pCEServing, tyme, args) } void -#if PROTOTYPES CommandInfo(GRPENT *pGE, CONSCLIENT *pCLServing, CONSENT *pCEServing, long tyme, char *args) -#else -CommandInfo(pGE, pCLServing, pCEServing, tyme, args) - GRPENT *pGE; - CONSCLIENT *pCLServing; - CONSENT *pCEServing; - long tyme; - char *args; -#endif { CONSENT *pCE; CONSCLIENT *pCL; @@ -2788,16 +2459,8 @@ CommandInfo(pGE, pCLServing, pCEServing, tyme, args) } void -#if PROTOTYPES CommandLogging(GRPENT *pGE, CONSCLIENT *pCLServing, CONSENT *pCEServing, long tyme) -#else -CommandLogging(pGE, pCLServing, pCEServing, tyme) - GRPENT *pGE; - CONSCLIENT *pCLServing; - CONSENT *pCEServing; - long tyme; -#endif { if (pCLServing->fwr) { pCEServing->nolog = !pCEServing->nolog; @@ -2817,16 +2480,8 @@ CommandLogging(pGE, pCLServing, pCEServing, tyme) } void -#if PROTOTYPES CommandOpen(GRPENT *pGE, CONSCLIENT *pCLServing, CONSENT *pCEServing, long tyme) -#else -CommandOpen(pGE, pCLServing, pCEServing, tyme) - GRPENT *pGE; - CONSCLIENT *pCLServing; - CONSENT *pCEServing; - long tyme; -#endif { CONSCLIENT *pCL; @@ -2863,16 +2518,8 @@ CommandOpen(pGE, pCLServing, pCEServing, tyme) } void -#if PROTOTYPES CommandWho(GRPENT *pGE, CONSCLIENT *pCLServing, CONSENT *pCEServing, long tyme) -#else -CommandWho(pGE, pCLServing, pCEServing, tyme) - GRPENT *pGE; - CONSCLIENT *pCLServing; - CONSENT *pCEServing; - long tyme; -#endif { CONSCLIENT *pCL; @@ -2887,12 +2534,7 @@ CommandWho(pGE, pCLServing, pCEServing, tyme) } char * -#if PROTOTYPES TelOpt(int o) -#else -TelOpt(o) - int o; -#endif { static char opt[128]; char *telopts[] = { @@ -2917,12 +2559,7 @@ TelOpt(o) } void -#if PROTOTYPES DoConsoleRead(CONSENT *pCEServing) -#else -DoConsoleRead(pCEServing) - CONSENT *pCEServing; -#endif { unsigned char acIn[BUFSIZ], acInOrig[BUFSIZ]; int nr, i; @@ -3130,12 +2767,7 @@ DoConsoleRead(pCEServing) } void -#if PROTOTYPES DoTaskRead(CONSENT *pCEServing) -#else -DoTaskRead(pCEServing) - CONSENT *pCEServing; -#endif { unsigned char acInOrig[BUFSIZ]; int nr, fd; @@ -3165,12 +2797,7 @@ DoTaskRead(pCEServing) } void -#if PROTOTYPES DoCommandRead(CONSENT *pCEServing) -#else -DoCommandRead(pCEServing) - CONSENT *pCEServing; -#endif { unsigned char acInOrig[BUFSIZ]; int nr, i, fd; @@ -3223,11 +2850,7 @@ unsigned char CM[] = { }; unsigned char * -#if PROTOTYPES -Challenge() -#else -Challenge() -#endif +Challenge(void) { int i; static unsigned char **n = (unsigned char **)0; @@ -3277,14 +2900,7 @@ typedef enum gatherType { } GATHERTYPE; int -#if PROTOTYPES GatherLine(char c, int limit, GATHERTYPE g, CONSCLIENT *pCL) -#else -GatherLine(c, pCL) - char c; - GATHERTYPE g; - CONSCLIENT *pCL; -#endif { if (c == '\r') return 1; @@ -3312,13 +2928,7 @@ GatherLine(c, pCL) } void -#if PROTOTYPES DoClientRead(GRPENT *pGE, CONSCLIENT *pCLServing) -#else -DoClientRead(pGE, pCLServing) - GRPENT *pGE; - CONSCLIENT *pCLServing; -#endif { CONSENT *pCEServing = pCLServing->pCEto; int nr, i, l; @@ -4451,12 +4061,7 @@ DoClientRead(pGE, pCLServing) } void -#if PROTOTYPES FlushConsole(CONSENT *pCEServing) -#else -FlushConsole(pCEServing) - CONSENT *pCEServing; -#endif { static STRING *buf = (STRING *)0; int offset = 0; @@ -4593,14 +4198,32 @@ FlushConsole(pCEServing) usleep(delay * 1000); } else if (next == BREAK) { CONDDEBUG((1, - "Kiddie(): heavy IAC - doing tcsendbreak() for [%s]", + "Kiddie(): heavy IAC - sending break for [%s]", pCEServing->server)); - if (tcsendbreak(FileFDNum(pCEServing->cofile), 0) - == -1) { - if (pCEServing->pCLwr != (CONSCLIENT *)0) - FileWrite(pCEServing->pCLwr->fd, FLAGFALSE, - "[tcsendbreak() failed]\r\n", -1); +#if HAVE_FREEIPMI + if (pCEServing->type == IPMI) { + if (ipmiconsole_ctx_generate_break + (pCEServing->ipmictx) == -1) { + if (pCEServing->pCLwr != (CONSCLIENT *)0) + FilePrint(pCEServing->pCLwr->fd, FLAGFALSE, + "[ipmiconsole_ctx_generate_break() failed: %s]\r\n", + ipmiconsole_ctx_errormsg + (pCEServing->ipmictx)); + + } + } else { +#endif + + if (tcsendbreak(FileFDNum(pCEServing->cofile), 0) + == -1) { + if (pCEServing->pCLwr != (CONSCLIENT *)0) + FileWrite(pCEServing->pCLwr->fd, FLAGFALSE, + "[tcsendbreak() failed]\r\n", + -1); + } +#if HAVE_FREEIPMI } +#endif } /* we do this 'cause we just potentially paused for * a half-second doing a break...or even the @@ -4729,13 +4352,7 @@ FlushConsole(pCEServing) * */ static void -#if PROTOTYPES Kiddie(GRPENT *pGE, int sfd) -#else -Kiddie(pGE, sfd) - GRPENT *pGE; - int sfd; -#endif { CONSCLIENT *pCL, /* console we must scan/notify */ *pCLServing; /* client we are serving */ @@ -5274,7 +4891,7 @@ Kiddie(pGE, sfd) #if HAVE_DMALLOC && DMALLOC_MARK_CLIENT_CONNECTION dmallocMarkClientConnection = dmalloc_mark(); #endif - so = sizeof(struct sockaddr_in); + so = sizeof(INADDR_STYPE); fd = accept(sfd, (struct sockaddr *)&pGE->pCLfree->cnct_port, &so); if (fd < 0) { Error("Kiddie(): accept(): %s", strerror(errno)); @@ -5386,36 +5003,133 @@ Kiddie(pGE, sfd) * fork off a process for each group with an open socket for connections */ void -#if PROTOTYPES Spawn(GRPENT *pGE, int msfd) -#else -Spawn(pGE, msfd) - GRPENT *pGE; - int msfd; -#endif { pid_t pid; int sfd; -#if USE_UNIX_DOMAIN_SOCKETS - struct sockaddr_un lstn_port; - static STRING *portPath = (STRING *)0; -#else +#if USE_IPV6 || !USE_UNIX_DOMAIN_SOCKETS +# if USE_IPV6 + int error; + struct addrinfo *rp, hints, *res; + char host[NI_MAXHOST]; + char serv[NI_MAXSERV]; + unsigned short bindBasePort; +# else socklen_t so; + struct sockaddr_in lstn_port; +# endif # if HAVE_SETSOCKOPT int true = 1; # endif unsigned short portInc = 0; - struct sockaddr_in lstn_port; -#endif - - /* get a socket for listening */ -#if HAVE_MEMSET - memset((void *)&lstn_port, 0, sizeof(lstn_port)); #else - bzero((char *)&lstn_port, sizeof(lstn_port)); + struct sockaddr_un lstn_port; + static STRING *portPath = (STRING *)0; #endif -#if USE_UNIX_DOMAIN_SOCKETS +#if !USE_IPV6 + /* get a socket for listening */ +# if HAVE_MEMSET + memset((void *)&lstn_port, 0, sizeof(lstn_port)); +# else + bzero((char *)&lstn_port, sizeof(lstn_port)); +# endif +#endif + +#if USE_IPV6 + for (rp = bindBaseAddr; rp != NULL; rp = rp->ai_next) { + if ((sfd = + socket(rp->ai_family, rp->ai_socktype, + rp->ai_protocol)) < 0) { + Error("Spawn(): socket(): %s", strerror(errno)); + continue; + } +# if HAVE_SETSOCKOPT + if (setsockopt + (sfd, SOL_SOCKET, SO_REUSEADDR, (char *)&true, + sizeof(true)) < 0) { + Error("Spawn(): setsockopt(%u,SO_REUSEADDR): %s", sfd, + strerror(errno)); + return; + } +# endif + if (!SetFlags(sfd, O_NONBLOCK, 0)) + return; + + error = + getnameinfo(rp->ai_addr, rp->ai_addrlen, host, sizeof(host), + serv, sizeof(serv), + NI_NUMERICHOST | NI_NUMERICSERV); + if (error) { + Error("Spawn(): getnameinfo failed: %s", gai_strerror(error)); + return; + } + bindBasePort = (unsigned short)strtol(serv, NULL, 10); + + while (bind(sfd, rp->ai_addr, rp->ai_addrlen) < 0) { + if (bindBasePort && ( +# if defined(EADDRINUSE) + (errno == EADDRINUSE) || +# endif + (errno == EACCES)) && ++portInc) { + /* + * instead of checking for ai_family and modifying + * the structure directly we will generate new addrinfo + * structure, copy over first entry and release it. + */ + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = + AI_PASSIVE | AI_NUMERICHOST | AI_NUMERICSERV; + snprintf(serv, sizeof(serv), "%hu", + bindBasePort + portInc); + error = getaddrinfo(host, serv, &hints, &res); + if (error) + goto OUT; + + memcpy(rp->ai_addr, res->ai_addr, rp->ai_addrlen); + freeaddrinfo(res); + continue; + } else + goto OUT; + } + break; /* if we're here bind was succesful so get out */ + + OUT: + portInc = 0; + close(sfd); + } + + /* if rp is null we did not bind */ + if (rp == NULL) { + Error("Spawn(): could not bind"); + Bye(EX_OSERR); + } + + if (-1 == getsockname(sfd, rp->ai_addr, &rp->ai_addrlen)) { + Error("Spawn(): getsockname(%u): %s", sfd, strerror(errno)); + Bye(EX_OSERR); + } + + /* + * if bindBasePort is 0 we did auto-assign our port. to find out + * what we bind to we need to call getsockname (above) and call + * getnameinfo again. otherwise we have the port info in + * bindBasePort + portInc + */ + if (!bindBasePort) { + error = + getnameinfo(rp->ai_addr, rp->ai_addrlen, NULL, 0, serv, + sizeof(serv), NI_NUMERICSERV); + if (error) { + Error("Spawn(): getnameinfo failed: %s", gai_strerror(error)); + Bye(EX_OSERR); + } + pGE->port = (unsigned short)strtol(serv, NULL, 10); + } else + pGE->port = bindBasePort + portInc; +#elif USE_UNIX_DOMAIN_SOCKETS lstn_port.sun_family = AF_UNIX; if (portPath == (STRING *)0) @@ -5444,6 +5158,11 @@ Spawn(pGE, msfd) strerror(errno)); Bye(EX_OSERR); } +# ifdef TRUST_UDS_CRED + /* Allow everyone to connect, but we later auth them via SO_PEERCRED */ + chmod(lstn_port.sun_path, 0666); +# endif + pGE->port = pGE->id; #else lstn_port.sin_family = AF_INET; diff --git a/conserver/group.h b/conserver/group.h index 989e3d2..78267ae 100644 --- a/conserver/group.h +++ b/conserver/group.h @@ -1,5 +1,5 @@ /* - * $Id: group.h,v 5.51 2013/09/23 23:17:42 bryan Exp $ + * $Id: group.h,v 5.52 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -64,25 +64,24 @@ typedef struct grpent { /* group info */ extern time_t timers[]; -extern void Spawn PARAMS((GRPENT *, int)); -extern int CheckPass PARAMS((char *, char *, FLAG)); -extern void TagLogfile PARAMS((const CONSENT *, char *, ...)); -extern void TagLogfileAct PARAMS((const CONSENT *, char *, ...)); -extern void DestroyGroup PARAMS((GRPENT *)); -extern void DestroyConsent PARAMS((GRPENT *, CONSENT *)); -extern void SendClientsMsg PARAMS((CONSENT *, char *)); -extern void ResetMark PARAMS((void)); -extern void DestroyConsentUsers PARAMS((CONSENTUSERS **)); -extern CONSENTUSERS *ConsentFindUser PARAMS((CONSENTUSERS *, char *)); -extern int ConsentUserOk PARAMS((CONSENTUSERS *, char *)); -extern void DisconnectClient -PARAMS((GRPENT *, CONSCLIENT *, char *, FLAG)); -extern int ClientAccess PARAMS((CONSENT *, char *)); -extern void DestroyClient PARAMS((CONSCLIENT *)); -extern int CheckPasswd PARAMS((CONSCLIENT *, char *, FLAG)); -extern void DeUtmp PARAMS((GRPENT *, int)); -extern void ClientWantsWrite PARAMS((CONSCLIENT *)); -extern void SendIWaitClientsMsg PARAMS((CONSENT *, char *)); +extern void Spawn(GRPENT *, int); +extern int CheckPass(char *, char *, FLAG); +extern void TagLogfile(const CONSENT *, char *, ...); +extern void TagLogfileAct(const CONSENT *, char *, ...); +extern void DestroyGroup(GRPENT *); +extern void DestroyConsent(GRPENT *, CONSENT *); +extern void SendClientsMsg(CONSENT *, char *); +extern void ResetMark(void); +extern void DestroyConsentUsers(CONSENTUSERS **); +extern CONSENTUSERS *ConsentFindUser(CONSENTUSERS *, char *); +extern int ConsentUserOk(CONSENTUSERS *, char *); +extern void DisconnectClient(GRPENT *, CONSCLIENT *, char *, FLAG); +extern int ClientAccess(CONSENT *, char *); +extern void DestroyClient(CONSCLIENT *); +extern int CheckPasswd(CONSCLIENT *, char *, FLAG); +extern void DeUtmp(GRPENT *, int); +extern void ClientWantsWrite(CONSCLIENT *); +extern void SendIWaitClientsMsg(CONSENT *, char *); #if HAVE_OPENSSL -extern int AttemptSSL PARAMS((CONSCLIENT *)); +extern int AttemptSSL(CONSCLIENT *); #endif diff --git a/conserver/main.c b/conserver/main.c index a4e5e3b..5c2ce5d 100644 --- a/conserver/main.c +++ b/conserver/main.c @@ -1,5 +1,5 @@ /* - * $Id: main.c,v 5.210 2014/04/04 16:17:10 bryan Exp $ + * $Id: main.c,v 5.212 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -54,9 +54,15 @@ int fAll = 0, fNoinit = 0, fVersion = 0, fStrip = 0, fReopen = char *pcConfig = CONFIGFILE; int cMaxMemb = MAXMEMB; +#if USE_IPV6 +struct addrinfo *bindAddr; +struct addrinfo *bindBaseAddr; +#else in_addr_t bindAddr = INADDR_ANY; unsigned short bindPort; unsigned short bindBasePort; +struct sockaddr_in in_port; +#endif static STRING *startedMsg = (STRING *)0; CONFIG *optConf = (CONFIG *)0; CONFIG *config = (CONFIG *)0; @@ -73,7 +79,6 @@ CONFIG defConfig = #endif }; -struct sockaddr_in in_port; CONSFILE *unifiedlog = (CONSFILE *)0; #if HAVE_DMALLOC && DMALLOC_MARK_MAIN @@ -89,11 +94,7 @@ DH *dh4096 = (DH *)0; DH * -#if PROTOTYPES GetDH512(void) -#else -GetDH512() -#endif { static unsigned char dh512_p[] = { 0xF5, 0x2A, 0xFF, 0x3C, 0xE1, 0xB1, 0x29, 0x40, 0x18, 0x11, 0x8D, @@ -121,11 +122,7 @@ GetDH512() } DH * -#if PROTOTYPES GetDH1024(void) -#else -GetDH1024() -#endif { static unsigned char dh1024_p[] = { 0xF4, 0x88, 0xFD, 0x58, 0x4E, 0x49, 0xDB, 0xCD, 0x20, 0xB4, 0x9D, @@ -159,11 +156,7 @@ GetDH1024() } DH * -#if PROTOTYPES GetDH2048(void) -#else -GetDH2048() -#endif { static unsigned char dh2048_p[] = { 0xF6, 0x42, 0x57, 0xB7, 0x08, 0x7F, 0x08, 0x17, 0x72, 0xA2, 0xBA, @@ -210,11 +203,7 @@ GetDH2048() } DH * -#if PROTOTYPES GetDH4096(void) -#else -GetDH4096() -#endif { static unsigned char dh4096_p[] = { 0xFA, 0x14, 0x72, 0x52, 0xC1, 0x4D, 0xE1, 0x5A, 0x49, 0xD4, 0xEF, @@ -287,14 +276,7 @@ GetDH4096() } DH * -#if PROTOTYPES TmpDHCallback(SSL *ssl, int is_export, int keylength) -#else -TmpDHCallback(ssl, is_export, keylength) - SSL *ssl; - int is_export; - int keylength; -#endif { CONDDEBUG((1, "TmpDHCallback(): asked for a DH key length %u", keylength)); @@ -319,11 +301,7 @@ TmpDHCallback(ssl, is_export, keylength) } void -#if PROTOTYPES SetupSSL(void) -#else -SetupSSL() -#endif { if (ctx == (SSL_CTX *)0) { char *ciphers; @@ -411,11 +389,7 @@ gss_name_t gss_myname = GSS_C_NO_NAME; gss_cred_id_t gss_mycreds = GSS_C_NO_CREDENTIAL; void -#if PROTOTYPES SetupGSSAPI(void) -#else -SetupGSSAPI() -#endif { OM_uint32 stmaj, stmin; char namestr[128]; @@ -443,11 +417,7 @@ SetupGSSAPI() #endif void -#if PROTOTYPES ReopenLogfile(void) -#else -ReopenLogfile() -#endif { static int tag = 1; /* redirect stdout and stderr to the logfile. @@ -489,11 +459,7 @@ ReopenLogfile() } void -#if PROTOTYPES ReopenUnifiedlog(void) -#else -ReopenUnifiedlog() -#endif { /* close any existing */ if (unifiedlog != (CONSFILE *)0) @@ -516,11 +482,7 @@ ReopenUnifiedlog() /* become a daemon (ksb) */ static void -#if PROTOTYPES -Daemonize() -#else -Daemonize() -#endif +Daemonize(void) { int res; #if !HAVE_SETSID @@ -581,12 +543,7 @@ Daemonize() /* output a long message to the user (ksb) */ static void -#if PROTOTYPES Usage(int wantfull) -#else -Usage(wantfull) - int wantfull; -#endif { static char u_terse[] = "[-7dDEFhinoRSuvV] [-a type] [-m max] [-M master] [-p port] [-b port] [-c cred] [-C config] [-P passwd] [-L logfile] [-O min] [-U logfile]"; @@ -645,11 +602,7 @@ Usage(wantfull) /* show the user our version info (ksb) */ static void -#if PROTOTYPES -Version() -#else -Version() -#endif +Version(void) { static STRING *acA1 = (STRING *)0; static STRING *acA2 = (STRING *)0; @@ -723,12 +676,12 @@ Version() BuildStringChar('0' + DMALLOC_VERSION_MINOR, acA1); BuildStringChar('.', acA1); BuildStringChar('0' + DMALLOC_VERSION_PATCH, acA1); -#if defined(DMALLOC_VERSION_BETA) +# if defined(DMALLOC_VERSION_BETA) if (DMALLOC_VERSION_BETA != 0) { BuildString("-b", acA1); BuildStringChar('0' + DMALLOC_VERSION_BETA, acA1); } -#endif +# endif Msg("dmalloc version: %s", acA1->string); #endif #if HAVE_FREEIPMI @@ -751,11 +704,7 @@ Version() } void -#if PROTOTYPES DestroyDataStructures(void) -#else -DestroyDataStructures() -#endif { GRPENT *pGE; REMOTE *pRC; @@ -798,8 +747,14 @@ DestroyDataStructures() DH_free(dh4096); #endif +#if USE_IPV6 + /* clean up addrinfo stucts */ + freeaddrinfo(bindAddr); + freeaddrinfo(bindBaseAddr); +#else if (myAddrs != (struct in_addr *)0) free(myAddrs); +#endif DestroyBreakList(); DestroyTaskList(); @@ -810,11 +765,7 @@ DestroyDataStructures() } void -#if PROTOTYPES SummarizeDataStructures(void) -#else -SummarizeDataStructures() -#endif { GRPENT *pGE; REMOTE *pRC; @@ -943,11 +894,7 @@ SummarizeDataStructures() } void -#if PROTOTYPES DumpDataStructures(void) -#else -DumpDataStructures() -#endif { GRPENT *pGE; CONSENT *pCE; @@ -1149,17 +1096,14 @@ DumpDataStructures() */ #if USE_UNIX_DOMAIN_SOCKETS int -#if PROTOTYPES VerifyEmptyDirectory(char *d) -#else -VerifyEmptyDirectory(d) - char *d; -#endif { struct stat dstat; DIR *dir; struct dirent *de; +# if 0 /* See below */ STRING *path = (STRING *)0; +# endif int retval = 0; while (1) { @@ -1200,7 +1144,7 @@ VerifyEmptyDirectory(d) * database, config files, etc. too many important files could be * shredded with a small typo. */ -#if 0 +# if 0 if (path == (STRING *)0) path = AllocString(); BuildStringPrint(path, "%s/%s", d, de->d_name); @@ -1222,11 +1166,16 @@ VerifyEmptyDirectory(d) break; } } -#endif +# endif } +# if 0 /* See above */ if (path != (STRING *)0) DestroyString(path); +# endif + + /* free dir data structure */ + closedir(dir); return retval; } @@ -1241,13 +1190,7 @@ VerifyEmptyDirectory(d) * exit happy */ int -#if PROTOTYPES main(int argc, char **argv) -#else -main(argc, argv) - int argc; - char **argv; -#endif { int i; FILE *fpConfig = (FILE *)0; @@ -1260,9 +1203,14 @@ main(argc, argv) int curuid = 0; GRPENT *pGE = (GRPENT *)0; #if !USE_UNIX_DOMAIN_SOCKETS -#if HAVE_INET_ATON +# if USE_IPV6 + int s; + struct addrinfo hints; +# else +# if HAVE_INET_ATON struct in_addr inetaddr; -#endif +# endif +# endif #endif isMultiProc = 1; /* make sure stuff has the pid */ @@ -1460,7 +1408,115 @@ main(argc, argv) if (fSyntaxOnly) Msg("performing configuration file syntax check"); -#if USE_UNIX_DOMAIN_SOCKETS + /* must do all this so IsMe() works right */ + if (gethostname(myHostname, MAXHOSTNAME) != 0) { + Error("gethostname(): %s", strerror(errno)); + Bye(EX_OSERR); + } +#if !USE_IPV6 + ProbeInterfaces(bindAddr); +#endif + + /* initialize the timers */ + for (i = 0; i < T_MAX; i++) + timers[i] = (time_t)0; + + /* read the config file */ + if ((FILE *)0 == (fpConfig = fopen(pcConfig, "r"))) { + Error("fopen(%s): %s", pcConfig, strerror(errno)); + Bye(EX_NOINPUT); + } + ReadCfg(pcConfig, fpConfig); + fclose(fpConfig); + +#if !USE_UNIX_DOMAIN_SOCKETS + /* set up the port to bind to */ + if (optConf->primaryport != (char *)0) + config->primaryport = StrDup(optConf->primaryport); + else if (pConfig->primaryport != (char *)0) + config->primaryport = StrDup(pConfig->primaryport); + else + config->primaryport = StrDup(defConfig.primaryport); + if (config->primaryport == (char *)0) + OutOfMem(); + +# if !USE_IPV6 + /* Look for non-numeric characters */ + for (i = 0; config->primaryport[i] != '\000'; i++) + if (!isdigit((int)config->primaryport[i])) + break; + + if (config->primaryport[i] == '\000') { + /* numeric only */ + bindPort = atoi(config->primaryport); + } else { + /* non-numeric only */ + struct servent *pSE; + if ((struct servent *)0 == + (pSE = getservbyname(config->primaryport, "tcp"))) { + Error("getservbyname(%s) failed", config->primaryport); + Bye(EX_OSERR); + } else { + bindPort = ntohs((unsigned short)pSE->s_port); + } + } +# endif + + /* set up the secondary port to bind to */ + if (optConf->secondaryport != (char *)0) + config->secondaryport = StrDup(optConf->secondaryport); + else if (pConfig->secondaryport != (char *)0) + config->secondaryport = StrDup(pConfig->secondaryport); + else + config->secondaryport = StrDup(defConfig.secondaryport); + if (config->secondaryport == (char *)0) + OutOfMem(); + +# if !USE_IPV6 + /* Look for non-numeric characters */ + for (i = 0; config->secondaryport[i] != '\000'; i++) + if (!isdigit((int)config->secondaryport[i])) + break; + + if (config->secondaryport[i] == '\000') { + /* numeric only */ + bindBasePort = atoi(config->secondaryport); + } else { + /* non-numeric only */ + struct servent *pSE; + if ((struct servent *)0 == + (pSE = getservbyname(config->secondaryport, "tcp"))) { + Error("getservbyname(%s) failed", config->secondaryport); + Bye(EX_OSERR); + } else { + bindBasePort = ntohs((unsigned short)pSE->s_port); + } + } +# endif +#endif + +#if USE_IPV6 + /* set up the address to bind to */ + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags |= AI_PASSIVE; + + /* create list or IPs suitable for primaryport */ + s = getaddrinfo(interface, config->primaryport, &hints, &bindAddr); + if (s) { + Error("getaddrinfo(%s): %s", interface, gai_strerror(s)); + Bye(EX_OSERR); + } + + /* create list or IPs suitable for secondaryport */ + s = getaddrinfo(interface, config->secondaryport, &hints, + &bindBaseAddr); + if (s) { + Error("getaddrinfo(%s): %s", interface, gai_strerror(s)); + Bye(EX_OSERR); + } +#elif USE_UNIX_DOMAIN_SOCKETS /* Don't do any redirects if we're purely local * (but it allows them to see where remote consoles are) */ @@ -1494,87 +1550,6 @@ main(argc, argv) } #endif - /* must do all this so IsMe() works right */ - if (gethostname(myHostname, MAXHOSTNAME) != 0) { - Error("gethostname(): %s", strerror(errno)); - Bye(EX_OSERR); - } - ProbeInterfaces(bindAddr); - - /* initialize the timers */ - for (i = 0; i < T_MAX; i++) - timers[i] = (time_t)0; - - /* read the config file */ - if ((FILE *)0 == (fpConfig = fopen(pcConfig, "r"))) { - Error("fopen(%s): %s", pcConfig, strerror(errno)); - Bye(EX_NOINPUT); - } - ReadCfg(pcConfig, fpConfig); - fclose(fpConfig); - -#if !USE_UNIX_DOMAIN_SOCKETS - /* set up the port to bind to */ - if (optConf->primaryport != (char *)0) - config->primaryport = StrDup(optConf->primaryport); - else if (pConfig->primaryport != (char *)0) - config->primaryport = StrDup(pConfig->primaryport); - else - config->primaryport = StrDup(defConfig.primaryport); - if (config->primaryport == (char *)0) - OutOfMem(); - - /* Look for non-numeric characters */ - for (i = 0; config->primaryport[i] != '\000'; i++) - if (!isdigit((int)config->primaryport[i])) - break; - - if (config->primaryport[i] == '\000') { - /* numeric only */ - bindPort = atoi(config->primaryport); - } else { - /* non-numeric only */ - struct servent *pSE; - if ((struct servent *)0 == - (pSE = getservbyname(config->primaryport, "tcp"))) { - Error("getservbyname(%s) failed", config->primaryport); - Bye(EX_OSERR); - } else { - bindPort = ntohs((unsigned short)pSE->s_port); - } - } - - /* set up the secondary port to bind to */ - if (optConf->secondaryport != (char *)0) - config->secondaryport = StrDup(optConf->secondaryport); - else if (pConfig->secondaryport != (char *)0) - config->secondaryport = StrDup(pConfig->secondaryport); - else - config->secondaryport = StrDup(defConfig.secondaryport); - if (config->secondaryport == (char *)0) - OutOfMem(); - - /* Look for non-numeric characters */ - for (i = 0; config->secondaryport[i] != '\000'; i++) - if (!isdigit((int)config->secondaryport[i])) - break; - - if (config->secondaryport[i] == '\000') { - /* numeric only */ - bindBasePort = atoi(config->secondaryport); - } else { - /* non-numeric only */ - struct servent *pSE; - if ((struct servent *)0 == - (pSE = getservbyname(config->secondaryport, "tcp"))) { - Error("getservbyname(%s) failed", config->secondaryport); - Bye(EX_OSERR); - } else { - bindBasePort = ntohs((unsigned short)pSE->s_port); - } - } -#endif - if (optConf->passwdfile != (char *)0) config->passwdfile = StrDup(optConf->passwdfile); else if (pConfig->passwdfile != (char *)0) @@ -1727,7 +1702,11 @@ main(argc, argv) /* if no one can use us we need to come up with a default */ if (pACList == (ACCESS *)0) +#if USE_IPV6 + SetDefAccess(); +#else SetDefAccess(myAddrs, myHostname); +#endif /* spawn all the children, so fix kids has an initial pid */ @@ -1749,13 +1728,15 @@ main(argc, argv) local += pGE->imembers; for (pRC = pRCList; (REMOTE *)0 != pRC; pRC = pRC->pRCnext) remote++; -# if USE_UNIX_DOMAIN_SOCKETS - setproctitle("master: port 0, %d local, %d remote", local, - remote); -#else - setproctitle("master: port %hu, %d local, %d remote", bindPort, + setproctitle("master: port %hu, %d local, %d remote", +# if USE_IPV6 + config->primaryport, +# elif USE_UNIX_DOMAIN_SOCKETS + 0, +# else + bindPort, +# endif local, remote); -#endif } #endif diff --git a/conserver/main.h b/conserver/main.h index ff93ecc..c6bc39d 100644 --- a/conserver/main.h +++ b/conserver/main.h @@ -1,5 +1,5 @@ /* - * $Id: main.h,v 5.54 2009/09/26 09:23:04 bryan Exp $ + * $Id: main.h,v 5.55 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -39,11 +39,16 @@ extern char rcsid[]; extern int fAll, fNoinit, fInteractive, fStrip, fDaemon, fReopen, fNoautoreup, fSyntaxOnly; +#if USE_IPV6 +extern struct addrinfo *bindAddr; +extern struct addrinfo *bindBaseAddr; +#else extern in_addr_t bindAddr; +extern struct sockaddr_in in_port; +#endif extern unsigned short bindPort, bindBasePort; extern char *pcConfig; extern int cMaxMemb; -extern struct sockaddr_in in_port; extern CONFIG *optConf; extern CONFIG *config; extern CONFIG defConfig; @@ -58,6 +63,6 @@ extern SSL_CTX *ctx; extern gss_name_t gss_myname; extern gss_cred_id_t gss_mycreds; #endif -extern void ReopenLogfile PARAMS((void)); -extern void ReopenUnifiedlog PARAMS((void)); -extern void DumpDataStructures PARAMS((void)); +extern void ReopenLogfile(void); +extern void ReopenUnifiedlog(void); +extern void DumpDataStructures(void); diff --git a/conserver/master.c b/conserver/master.c index 693e06a..f012034 100644 --- a/conserver/master.c +++ b/conserver/master.c @@ -1,5 +1,5 @@ /* - * $Id: master.c,v 5.139 2013/09/23 23:17:42 bryan Exp $ + * $Id: master.c,v 5.141 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -49,12 +49,7 @@ static unsigned long dmallocMarkClientConnection = 0; static RETSIGTYPE -#if PROTOTYPES FlagSawCHLD(int sig) -#else -FlagSawCHLD(sig) - int sig; -#endif { fSawCHLD = 1; #if !HAVE_SIGACTION @@ -66,12 +61,7 @@ FlagSawCHLD(sig) * Called when master process receives SIGCHLD */ static void -#if PROTOTYPES FixKids(int msfd) -#else -FixKids(msfd) - int msfd; -#endif { pid_t pid; int UWbuf; @@ -135,12 +125,7 @@ FixKids(msfd) * Called when master process receives SIGTERM */ static RETSIGTYPE -#if PROTOTYPES FlagQuitIt(int arg) -#else -FlagQuitIt(arg) - int arg; -#endif { fSawQuit = 1; #if !HAVE_SIGACTION @@ -152,12 +137,7 @@ FlagQuitIt(arg) * want to do something special on SIGINT at some point. */ static RETSIGTYPE -#if PROTOTYPES FlagSawINT(int arg) -#else -FlagSawINT(arg) - int arg; -#endif { fSawQuit = 1; #if !HAVE_SIGACTION @@ -166,12 +146,7 @@ FlagSawINT(arg) } static RETSIGTYPE -#if PROTOTYPES FlagSawHUP(int arg) -#else -FlagSawHUP(arg) - int arg; -#endif { fSawHUP = 1; #if !HAVE_SIGACTION @@ -180,12 +155,7 @@ FlagSawHUP(arg) } static RETSIGTYPE -#if PROTOTYPES FlagSawUSR2(int arg) -#else -FlagSawUSR2(arg) - int arg; -#endif { fSawUSR2 = 1; #if !HAVE_SIGACTION @@ -194,12 +164,7 @@ FlagSawUSR2(arg) } static RETSIGTYPE -#if PROTOTYPES FlagSawUSR1(int arg) -#else -FlagSawUSR1(arg) - int arg; -#endif { fSawUSR1 = 1; #if !HAVE_SIGACTION @@ -210,12 +175,7 @@ FlagSawUSR1(arg) /* Signal all the kids... */ void -#if PROTOTYPES SignalKids(int arg) -#else -SignalKids(arg) - int arg; -#endif { GRPENT *pGE; @@ -232,12 +192,7 @@ SignalKids(arg) } REMOTE * -#if PROTOTYPES FindRemoteConsole(char *args) -#else -FindRemoteConsole(args) - char *args; -#endif { REMOTE *pRC; NAMES *name; @@ -254,13 +209,7 @@ FindRemoteConsole(args) } void -#if PROTOTYPES CommandCall(CONSCLIENT *pCL, char *args) -#else -CommandCall(pCL, args) - CONSCLIENT *pCL; - char *args; -#endif { int found; REMOTE *pRC, *pRCFound; @@ -383,13 +332,7 @@ CommandCall(pCL, args) } void -#if PROTOTYPES DropMasterClient(CONSCLIENT *pCLServing, FLAG force) -#else -DropMasterClient(pCLServing, force) - CONSCLIENT *pCLServing; - FLAG force; -#endif { /* if we have data buffered and aren't forced to close, * we can't close quite yet @@ -425,12 +368,7 @@ DropMasterClient(pCLServing, force) } void -#if PROTOTYPES DoNormalRead(CONSCLIENT *pCLServing) -#else -DoNormalRead(pCLServing) - CONSCLIENT *pCLServing; -#endif { char *pcCmd; char *pcArgs; @@ -586,11 +524,9 @@ DoNormalRead(pCLServing) int iSep = 1; if ((GRPENT *)0 != pGroups) { -#if USE_UNIX_DOMAIN_SOCKETS - FilePrint(pCLServing->fd, FLAGTRUE, "@0"); - iSep = 0; -#else - struct sockaddr_in lcl; +#if USE_IPV6 || !USE_UNIX_DOMAIN_SOCKETS + SOCKADDR_STYPE lcl; + socklen_t so = sizeof(lcl); if (-1 == getsockname(FileFDNum(pCLServing->fd), @@ -602,10 +538,25 @@ DoNormalRead(pCLServing) FileFDNum(pCLServing->fd), strerror(errno)); iSep = -1; } else { +# if USE_IPV6 + int error; + char addr[NI_MAXHOST]; + error = + getnameinfo((struct sockaddr *)&lcl, so, addr, + sizeof(addr), NULL, 0, + NI_NUMERICHOST); + if (!error) + FilePrint(pCLServing->fd, FLAGTRUE, "@%s", + addr); +# else FilePrint(pCLServing->fd, FLAGTRUE, "@%s", inet_ntoa(lcl.sin_addr)); +# endif iSep = 0; } +#else + FilePrint(pCLServing->fd, FLAGTRUE, "@0"); + iSep = 0; #endif } if (iSep >= 0) { @@ -723,24 +674,24 @@ DoNormalRead(pCLServing) /* this routine is used by the master console server process (ksb) */ void -#if PROTOTYPES Master(void) -#else -Master() -#endif { int cfd; int msfd; socklen_t so; fd_set rmask, wmask; -#if USE_UNIX_DOMAIN_SOCKETS - struct sockaddr_un master_port; - static STRING *portPath = (STRING *)0; -#else +#if USE_IPV6 || !USE_UNIX_DOMAIN_SOCKETS +# if USE_IPV6 + struct addrinfo *rp; +# else struct sockaddr_in master_port; +# endif # if HAVE_SETSOCKOPT int true = 1; # endif +#else + struct sockaddr_un master_port; + static STRING *portPath = (STRING *)0; #endif FILE *fp; CONSCLIENT *pCLServing = (CONSCLIENT *)0; @@ -780,13 +731,44 @@ Master() /* set up port for master to listen on */ -#if HAVE_MEMSET +#if !USE_IPV6 +# if HAVE_MEMSET memset((void *)&master_port, 0, sizeof(master_port)); -#else +# else bzero((char *)&master_port, sizeof(master_port)); +# endif #endif -#if USE_UNIX_DOMAIN_SOCKETS +#if USE_IPV6 + for (rp = bindAddr; rp != NULL; rp = rp->ai_next) { + if ((msfd = + socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol)) < 0) + continue; + +# if HAVE_SETSOCKOPT + if (setsockopt + (msfd, SOL_SOCKET, SO_REUSEADDR, (char *)&true, + sizeof(true)) < 0) + goto fail; +# endif + if (!SetFlags(msfd, O_NONBLOCK, 0)) + goto fail; + + if (bind(msfd, rp->ai_addr, rp->ai_addrlen) == 0) + break; + + fail: + close(msfd); + } + + if (listen(msfd, SOMAXCONN) < 0) { + Error("Master(): listen(): %s", strerror(errno)); + return; + } + + /* save addrlen for accept */ + so = rp->ai_addrlen; +#elif USE_UNIX_DOMAIN_SOCKETS master_port.sun_family = AF_UNIX; if (portPath == (STRING *)0) @@ -819,6 +801,11 @@ Master() strerror(errno)); return; } +# ifdef TRUST_UDS_CRED + /* Allow everyone to connect, but we later auth them via SO_PEERCRED */ + chmod(master_port.sun_path, 0666); +# endif + #else master_port.sin_family = AF_INET; master_port.sin_addr.s_addr = bindAddr; @@ -985,7 +972,9 @@ Master() dmallocMarkClientConnection = dmalloc_mark(); #endif +#if !USE_IPV6 so = sizeof(struct sockaddr_in); +#endif for (cfd = 0; cfd == 0;) { cfd = accept(msfd, (struct sockaddr *)&pCLmfree->cnct_port, &so); diff --git a/conserver/master.h b/conserver/master.h index 18fc0be..041140f 100644 --- a/conserver/master.h +++ b/conserver/master.h @@ -1,5 +1,5 @@ /* - * $Id: master.h,v 5.17 2003/10/03 14:23:37 bryan Exp $ + * $Id: master.h,v 5.18 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -39,5 +39,5 @@ */ extern CONSCLIENT *pCLmall; extern CONSCLIENT *pCLmfree; -extern void Master PARAMS((void)); -extern void SignalKids PARAMS((int)); +extern void Master(void); +extern void SignalKids(int); diff --git a/conserver/readcfg.c b/conserver/readcfg.c index cd9416e..3d77e4a 100644 --- a/conserver/readcfg.c +++ b/conserver/readcfg.c @@ -1,5 +1,5 @@ /* - * $Id: readcfg.c,v 5.204 2014/04/04 16:17:10 bryan Exp $ + * $Id: readcfg.c,v 5.206 2014/04/20 07:17:56 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -66,13 +66,7 @@ REMOTE **ppRC = (REMOTE **)0; /* 'task' handling (plus) */ void -#if PROTOTYPES ProcessYesNo(char *id, FLAG *flag) -#else -ProcessYesNo(id, flag) - char *id; - FLAG *flag; -#endif { if (id == (char *)0 || id[0] == '\000') *flag = FLAGFALSE; @@ -87,12 +81,7 @@ ProcessYesNo(id, flag) } void -#if PROTOTYPES DestroyTask(TASKS *task) -#else -DestroyTask(task) - TASKS *task; -#endif { if (task->cmd != (STRING *)0) { DestroyString(task->cmd); @@ -108,11 +97,7 @@ DestroyTask(task) } void -#if PROTOTYPES DestroyTaskList(void) -#else -DestroyTaskList() -#endif { TASKS *n; while (taskList != (TASKS *)0) { @@ -127,11 +112,7 @@ DestroyTaskList() } void -#if PROTOTYPES DestroyBreakList(void) -#else -DestroyBreakList() -#endif { int i; @@ -144,11 +125,7 @@ DestroyBreakList() } void -#if PROTOTYPES DestroyUserList(void) -#else -DestroyUserList() -#endif { NAMES *n; while (userList != (NAMES *)0) { @@ -161,12 +138,7 @@ DestroyUserList() } NAMES * -#if PROTOTYPES FindUserList(char *id) -#else -FindUserList(id) - char *id; -#endif { NAMES *u; for (u = userList; u != (NAMES *)0; u = u->next) { @@ -177,12 +149,7 @@ FindUserList(id) } NAMES * -#if PROTOTYPES AddUserList(char *id) -#else -AddUserList(id) - char *id; -#endif { NAMES *u; @@ -206,14 +173,7 @@ int parserBreakNum = 0; FLAG parserBreakConfirm = FLAGFALSE; CONSENTUSERS * -#if PROTOTYPES ConsentAddUser(CONSENTUSERS **ppCU, char *id, short not) -#else -ConsentAddUser(ppCU, id, not) - CONSENTUSERS **ppCU; - char *id; - short not; -#endif { CONSENTUSERS *u = (CONSENTUSERS *)0; CONSENTUSERS *p = (CONSENTUSERS *)0; @@ -244,12 +204,7 @@ ConsentAddUser(ppCU, id, not) } void -#if PROTOTYPES BreakBegin(char *id) -#else -BreakBegin(id) - char *id; -#endif { CONDDEBUG((1, "BreakBegin(%s) [%s:%d]", id, file, line)); if ((id == (char *)0) || (*id == '\000') || id[0] < '1' || id[0] > '9' @@ -269,11 +224,7 @@ BreakBegin(id) } void -#if PROTOTYPES BreakEnd(void) -#else -BreakEnd() -#endif { CONDDEBUG((1, "BreakEnd() [%s:%d]", file, line)); @@ -288,22 +239,14 @@ BreakEnd() } void -#if PROTOTYPES BreakAbort(void) -#else -BreakAbort() -#endif { CONDDEBUG((1, "BreakAbort() [%s:%d]", file, line)); parserBreakNum = 0; } void -#if PROTOTYPES BreakDestroy(void) -#else -BreakDestroy() -#endif { CONDDEBUG((1, "BreakDestroy() [%s:%d]", file, line)); if (parserBreak != (STRING *)0) { @@ -316,9 +259,9 @@ BreakDestroy() for (i = 0; i < 9; i++) { Msg("Break[%d] = `%s', delay=%d", i, breakList[i].seq == - (STRING *)0 ? "(null)" : (breakList[i]. - seq->string ? breakList[i]. - seq->string : "(null)"), + (STRING *)0 ? "(null)" : (breakList[i].seq-> + string ? breakList[i].seq-> + string : "(null)"), breakList[i].delay); } } @@ -326,12 +269,7 @@ BreakDestroy() } void -#if PROTOTYPES BreakItemString(char *id) -#else -BreakItemString(id) - char *id; -#endif { CONDDEBUG((1, "BreakItemString(%s) [%s:%d]", id, file, line)); BuildString((char *)0, parserBreak); @@ -341,12 +279,7 @@ BreakItemString(id) } void -#if PROTOTYPES BreakItemDelay(char *id) -#else -BreakItemDelay(id) - char *id; -#endif { char *p; int delay; @@ -371,12 +304,7 @@ BreakItemDelay(id) } void -#if PROTOTYPES BreakItemConfirm(char *id) -#else -BreakItemConfirm(id) - char *id; -#endif { CONDDEBUG((1, "BreakItemConfirm(%s) [%s:%d]", id, file, line)); ProcessYesNo(id, &(parserBreakConfirm)); @@ -393,12 +321,7 @@ PARSERGROUP *parserGroups = (PARSERGROUP *)0; PARSERGROUP *parserGroupTemp = (PARSERGROUP *)0; void -#if PROTOTYPES DestroyParserGroup(PARSERGROUP *pg) -#else -DestroyParserGroup(pg) - PARSERGROUP *pg; -#endif { PARSERGROUP **ppg = &parserGroups; @@ -426,12 +349,7 @@ DestroyParserGroup(pg) } PARSERGROUP * -#if PROTOTYPES GroupFind(char *id) -#else -GroupFind(id) - char *id; -#endif { PARSERGROUP *pg; for (pg = parserGroups; pg != (PARSERGROUP *)0; pg = pg->next) { @@ -442,12 +360,7 @@ GroupFind(id) } void -#if PROTOTYPES GroupBegin(char *id) -#else -GroupBegin(id) - char *id; -#endif { CONDDEBUG((1, "GroupBegin(%s) [%s:%d]", id, file, line)); if (id == (char *)0 || id[0] == '\000') { @@ -465,11 +378,7 @@ GroupBegin(id) } void -#if PROTOTYPES GroupEnd(void) -#else -GroupEnd() -#endif { PARSERGROUP *pg = (PARSERGROUP *)0; @@ -493,11 +402,7 @@ GroupEnd() } void -#if PROTOTYPES GroupAbort(void) -#else -GroupAbort() -#endif { CONDDEBUG((1, "GroupAbort() [%s:%d]", file, line)); DestroyParserGroup(parserGroupTemp); @@ -505,11 +410,7 @@ GroupAbort() } void -#if PROTOTYPES GroupDestroy(void) -#else -GroupDestroy() -#endif { CONDDEBUG((1, "GroupDestroy() [%s:%d]", file, line)); #if DUMPDATA @@ -537,27 +438,13 @@ GroupDestroy() } CONSENTUSERS * -#if PROTOTYPES GroupAddUser(PARSERGROUP *pg, char *id, short not) -#else -GroupAddUser(pg, id, not) - PARSERGROUP *pg; - char *id; - short not; -#endif { return ConsentAddUser(&(pg->users), id, not); } void -#if PROTOTYPES CopyConsentUserList(CONSENTUSERS *s, CONSENTUSERS **d, short not) -#else -CopyConsentUserList(s, d, not) - CONSENTUSERS *s; - CONSENTUSERS **d; - short not; -#endif { /* we have to add things backwards, since it's an ordered list */ if (s == (CONSENTUSERS *)0 || d == (CONSENTUSERS **)0) @@ -570,12 +457,7 @@ CopyConsentUserList(s, d, not) void -#if PROTOTYPES GroupItemUsers(char *id) -#else -GroupItemUsers(id) - char *id; -#endif { char *token = (char *)0; PARSERGROUP *pg = (PARSERGROUP *)0; @@ -608,14 +490,7 @@ CONSENT **parserDefaultsTail = &parserDefaults; CONSENT *parserDefaultTemp = (CONSENT *)0; void -#if PROTOTYPES DestroyParserDefaultOrConsole(CONSENT *c, CONSENT **ph, CONSENT ***pt) -#else -DestroyParserDefaultOrConsole(c, ph, pt) - CONSENT *c; - CONSENT **ph; - CONSENT ***pt; -#endif { if (c == (CONSENT *)0) return; @@ -702,13 +577,7 @@ DestroyParserDefaultOrConsole(c, ph, pt) } CONSENT * -#if PROTOTYPES FindParserDefaultOrConsole(CONSENT *c, char *id) -#else -FindParserDefaultOrConsole(c, id) - CONSENT *c; - char *id; -#endif { for (; c != (CONSENT *)0; c = c->pCEnext) { if (strcasecmp(id, c->server) == 0) @@ -718,13 +587,7 @@ FindParserDefaultOrConsole(c, id) } void -#if PROTOTYPES ApplyDefault(CONSENT *d, CONSENT *c) -#else -ApplyDefault(d, c) - CONSENT *d; - CONSENT *c; -#endif { if (d->type != UNKNOWNTYPE) c->type = d->type; @@ -926,12 +789,7 @@ ApplyDefault(d, c) } void -#if PROTOTYPES DefaultBegin(char *id) -#else -DefaultBegin(id) - char *id; -#endif { CONDDEBUG((1, "DefaultBegin(%s) [%s: %d]", id, file, line)); if (id == (char *)0 || id[0] == '\000') { @@ -952,11 +810,7 @@ DefaultBegin(id) } void -#if PROTOTYPES DefaultEnd(void) -#else -DefaultEnd() -#endif { CONSENT *c = (CONSENT *)0; @@ -985,11 +839,7 @@ DefaultEnd() } void -#if PROTOTYPES DefaultAbort(void) -#else -DefaultAbort() -#endif { CONDDEBUG((1, "DefaultAbort() [%s:%d]", file, line)); DestroyParserDefaultOrConsole(parserDefaultTemp, (CONSENT **)0, @@ -998,11 +848,7 @@ DefaultAbort() } void -#if PROTOTYPES DefaultDestroy(void) -#else -DefaultDestroy() -#endif { CONDDEBUG((1, "DefaultDestroy() [%s:%d]", file, line)); @@ -1015,13 +861,7 @@ DefaultDestroy() } void -#if PROTOTYPES ProcessBaud(CONSENT *c, char *id) -#else -ProcessBaud(c, id) - CONSENT *c; - char *id; -#endif { if ((id == (char *)0) || (*id == '\000')) { c->baud = (BAUD *)0; @@ -1035,25 +875,14 @@ ProcessBaud(c, id) } void -#if PROTOTYPES DefaultItemBaud(char *id) -#else -DefaultItemBaud(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemBaud(%s) [%s:%d]", id, file, line)); ProcessBaud(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessBreak(CONSENT *c, char *id) -#else -ProcessBreak(c, id) - CONSENT *c; - char *id; -#endif { if ((id == (char *)0) || (*id == '\000')) { c->breakNum = 0; @@ -1068,25 +897,14 @@ ProcessBreak(c, id) } void -#if PROTOTYPES DefaultItemBreak(char *id) -#else -DefaultItemBreak(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemBreak(%s) [%s:%d]", id, file, line)); ProcessBreak(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessDevice(CONSENT *c, char *id) -#else -ProcessDevice(c, id) - CONSENT *c; - char *id; -#endif { if (c->device != (char *)0) { free(c->device); @@ -1100,12 +918,7 @@ ProcessDevice(c, id) } void -#if PROTOTYPES DefaultItemDevice(char *id) -#else -DefaultItemDevice(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemDevice(%s) [%s:%d]", id, file, line)); ProcessDevice(parserDefaultTemp, id); @@ -1116,22 +929,13 @@ SUBST *substData = (SUBST *)0; int substTokenCount[255]; int -#if PROTOTYPES SubstTokenCount(char c) -#else -SubstTokenCount(c) - char c; -#endif { return substTokenCount[(unsigned)c]; } void -#if PROTOTYPES ZeroSubstTokenCount(void) -#else -ZeroSubstTokenCount() -#endif { #if HAVE_MEMSET memset((void *)&substTokenCount, 0, sizeof(substTokenCount)); @@ -1142,14 +946,7 @@ ZeroSubstTokenCount() int -#if PROTOTYPES SubstValue(char c, char **s, int *i) -#else -SubstValue(c, s, i) - char c; - char **s; - int *i; -#endif { int retval = 0; CONSENT *pCE; @@ -1198,12 +995,7 @@ SubstValue(c, s, i) } SUBSTTOKEN -#if PROTOTYPES SubstToken(char c) -#else -SubstToken(c) - char c; -#endif { switch (c) { case 'p': @@ -1221,11 +1013,7 @@ SubstToken(c) } void -#if PROTOTYPES InitSubstCallback(void) -#else -InitSubstCallback() -#endif { if (substData == (SUBST *)0) { if ((substData = (SUBST *)calloc(1, sizeof(SUBST))) == (SUBST *)0) @@ -1237,12 +1025,7 @@ InitSubstCallback() } void -#if PROTOTYPES DefaultItemDevicesubst(char *id) -#else -DefaultItemDevicesubst(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemDevicesubst(%s) [%s:%d]", id, file, line)); ProcessSubst(substData, (char **)0, &(parserDefaultTemp->devicesubst), @@ -1250,12 +1033,7 @@ DefaultItemDevicesubst(id) } void -#if PROTOTYPES DefaultItemExecsubst(char *id) -#else -DefaultItemExecsubst(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemExecsubst(%s) [%s:%d]", id, file, line)); ProcessSubst(substData, (char **)0, &(parserDefaultTemp->execsubst), @@ -1263,12 +1041,7 @@ DefaultItemExecsubst(id) } void -#if PROTOTYPES DefaultItemUdssubst(char *id) -#else -DefaultItemUdssubst(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemUdssubst(%s) [%s:%d]", id, file, line)); ProcessSubst(substData, (char **)0, &(parserDefaultTemp->udssubst), @@ -1276,12 +1049,7 @@ DefaultItemUdssubst(id) } void -#if PROTOTYPES DefaultItemInitsubst(char *id) -#else -DefaultItemInitsubst(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemInitsubst(%s) [%s:%d]", id, file, line)); ProcessSubst(substData, (char **)0, &(parserDefaultTemp->initsubst), @@ -1289,14 +1057,7 @@ DefaultItemInitsubst(id) } void -#if PROTOTYPES ProcessUidGid(uid_t * uid, gid_t * gid, char *id) -#else -ProcessUidGid(uid, gid, id) - uid_t *uid; - gid_t *gid; - char *id; -#endif { char *colon = (char *)0; int i; @@ -1360,38 +1121,21 @@ ProcessUidGid(uid, gid, id) } void -#if PROTOTYPES ProcessInitrunas(CONSENT *c, char *id) -#else -ProcessInitrunas(c, id) - CONSENT *c; - char *id; -#endif { CONDDEBUG((1, "ProcessInitrunas(%s) [%s:%d]", id, file, line)); ProcessUidGid(&(c->inituid), &(c->initgid), id); } void -#if PROTOTYPES ProcessExecrunas(CONSENT *c, char *id) -#else -ProcessExecrunas(c, id) - CONSENT *c; - char *id; -#endif { CONDDEBUG((1, "ProcessExecrunas(%s) [%s:%d]", id, file, line)); ProcessUidGid(&(c->execuid), &(c->execgid), id); } void -#if PROTOTYPES DefaultItemInitrunas(char *id) -#else -DefaultItemInitrunas(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemInitrunas(%s) [%s:%d]", id, file, line)); ProcessInitrunas(parserDefaultTemp, id); @@ -1399,13 +1143,7 @@ DefaultItemInitrunas(id) #if HAVE_FREEIPMI void -#if PROTOTYPES ProcessIpmiPrivLevel(CONSENT *c, char *id) -#else -ProcessIpmiPrivLevel(c, id) - CONSENT *c; - char *id; -#endif { if (!strcasecmp("user", id)) c->ipmiprivlevel = IPMIL_USER; @@ -1418,12 +1156,7 @@ ProcessIpmiPrivLevel(c, id) } void -#if PROTOTYPES DefaultItemIpmiPrivLevel(char *id) -#else -DefaultItemIpmiPrivLevel(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemIpmiPrivLevel(%s) [%s:%d]", id, file, line)); ProcessIpmiPrivLevel(parserDefaultTemp, id); @@ -1431,25 +1164,14 @@ DefaultItemIpmiPrivLevel(id) #endif /*freeipmi */ void -#if PROTOTYPES DefaultItemExecrunas(char *id) -#else -DefaultItemExecrunas(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemExecrunas(%s) [%s:%d]", id, file, line)); ProcessExecrunas(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessExec(CONSENT *c, char *id) -#else -ProcessExec(c, id) - CONSENT *c; - char *id; -#endif { if (c->exec != (char *)0) { free(c->exec); @@ -1464,50 +1186,28 @@ ProcessExec(c, id) } void -#if PROTOTYPES DefaultItemExec(char *id) -#else -DefaultItemExec(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemExec(%s) [%s:%d]", id, file, line)); ProcessExec(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessFlow(CONSENT *c, char *id) -#else -ProcessFlow(c, id) - CONSENT *c; - char *id; -#endif { if (isMaster) Error("unimplemented code for `flow' [%s:%d]", file, line); } void -#if PROTOTYPES DefaultItemFlow(char *id) -#else -DefaultItemFlow(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemFlow(%s) [%s:%d]", id, file, line)); ProcessFlow(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessHost(CONSENT *c, char *id) -#else -ProcessHost(c, id) - CONSENT *c; - char *id; -#endif { if (c->host != (char *)0) { free(c->host); @@ -1521,25 +1221,14 @@ ProcessHost(c, id) } void -#if PROTOTYPES DefaultItemHost(char *id) -#else -DefaultItemHost(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemHost(%s) [%s:%d]", id, file, line)); ProcessHost(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessUds(CONSENT *c, char *id) -#else -ProcessUds(c, id) - CONSENT *c; - char *id; -#endif { if (c->uds != (char *)0) { free(c->uds); @@ -1553,12 +1242,7 @@ ProcessUds(c, id) } void -#if PROTOTYPES DefaultItemUds(char *id) -#else -DefaultItemUds(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemUds(%s) [%s:%d]", id, file, line)); ProcessUds(parserDefaultTemp, id); @@ -1566,13 +1250,7 @@ DefaultItemUds(id) #if HAVE_FREEIPMI void -#if PROTOTYPES ProcessIpmiKG(CONSENT *c, char *id) -#else -ProcessIpmiKG(c, id) - CONSENT *c; - char *id; -#endif { char s; char oct = '\000'; @@ -1647,25 +1325,14 @@ ProcessIpmiKG(c, id) } void -#if PROTOTYPES DefaultItemIpmiKG(char *id) -#else -DefaultItemIpmiKG(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemIpmiKG(%s) [%s:%d]", id, file, line)); ProcessIpmiKG(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessUsername(CONSENT *c, char *id) -#else -ProcessUsername(c, id) - CONSENT *c; - char *id; -#endif { if ((id == (char *)0) || (*id == '\000')) { c->username = (char *)0; @@ -1675,25 +1342,14 @@ ProcessUsername(c, id) } void -#if PROTOTYPES DefaultItemUsername(char *id) -#else -DefaultItemUsername(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemUsername(%s) [%s:%d]", id, file, line)); ProcessUsername(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessIpmiCipherSuite(CONSENT *c, char *id) -#else -ProcessIpmiCipherSuite(c, id) - CONSENT *c; - char *id; -#endif { char *p; int i; @@ -1734,12 +1390,7 @@ ProcessIpmiCipherSuite(c, id) } void -#if PROTOTYPES DefaultItemIpmiCipherSuite(char *id) -#else -DefaultItemIpmiCipherSuite(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemIpmiCipherSuite(%s) [%s:%d]", id, file, line)); @@ -1747,13 +1398,7 @@ DefaultItemIpmiCipherSuite(id) } void -#if PROTOTYPES ProcessIpmiWorkaround(CONSENT *c, char *id) -#else -ProcessIpmiWorkaround(c, id) - CONSENT *c; - char *id; -#endif { unsigned int flag; char *token = (char *)0; @@ -1776,58 +1421,58 @@ ProcessIpmiWorkaround(c, id) not = 0; if (!strcmp(token, "default")) flag = IPMICONSOLE_WORKAROUND_DEFAULT; -#if defined(IPMICONSOLE_WORKAROUND_AUTHENTICATION_CAPABILITIES) +# if defined(IPMICONSOLE_WORKAROUND_AUTHENTICATION_CAPABILITIES) else if (!strcmp(token, "auth-capabilites")) flag = IPMICONSOLE_WORKAROUND_AUTHENTICATION_CAPABILITIES; -#endif -#if defined(IPMICONSOLE_WORKAROUND_INTEL_2_0_SESSION) +# endif +# if defined(IPMICONSOLE_WORKAROUND_INTEL_2_0_SESSION) else if (!strcmp(token, "intel-session")) flag = IPMICONSOLE_WORKAROUND_INTEL_2_0_SESSION; -#endif -#if defined(IPMICONSOLE_WORKAROUND_SUPERMICRO_2_0_SESSION) +# endif +# if defined(IPMICONSOLE_WORKAROUND_SUPERMICRO_2_0_SESSION) else if (!strcmp(token, "supermicro-session")) flag = IPMICONSOLE_WORKAROUND_SUPERMICRO_2_0_SESSION; -#endif -#if defined(IPMICONSOLE_WORKAROUND_SUN_2_0_SESSION) +# endif +# if defined(IPMICONSOLE_WORKAROUND_SUN_2_0_SESSION) else if (!strcmp(token, "sun-session")) flag = IPMICONSOLE_WORKAROUND_SUN_2_0_SESSION; -#endif -#if defined(IPMICONSOLE_WORKAROUND_OPEN_SESSION_PRIVILEGE) +# endif +# if defined(IPMICONSOLE_WORKAROUND_OPEN_SESSION_PRIVILEGE) else if (!strcmp(token, "privilege")) flag = IPMICONSOLE_WORKAROUND_OPEN_SESSION_PRIVILEGE; -#endif -#if defined(IPMICONSOLE_WORKAROUND_NON_EMPTY_INTEGRITY_CHECK_VALUE) +# endif +# if defined(IPMICONSOLE_WORKAROUND_NON_EMPTY_INTEGRITY_CHECK_VALUE) else if (!strcmp(token, "integrity")) flag = IPMICONSOLE_WORKAROUND_NON_EMPTY_INTEGRITY_CHECK_VALUE; -#endif -#if defined(IPMICONSOLE_WORKAROUND_NO_CHECKSUM_CHECK) +# endif +# if defined(IPMICONSOLE_WORKAROUND_NO_CHECKSUM_CHECK) else if (!strcmp(token, "checksum")) flag = IPMICONSOLE_WORKAROUND_NO_CHECKSUM_CHECK; -#endif -#if defined(IPMICONSOLE_WORKAROUND_SERIAL_ALERTS_DEFERRED) +# endif +# if defined(IPMICONSOLE_WORKAROUND_SERIAL_ALERTS_DEFERRED) else if (!strcmp(token, "serial-alerts")) flag = IPMICONSOLE_WORKAROUND_SERIAL_ALERTS_DEFERRED; -#endif -#if defined(IPMICONSOLE_WORKAROUND_INCREMENT_SOL_PACKET_SEQUENCE) +# endif +# if defined(IPMICONSOLE_WORKAROUND_INCREMENT_SOL_PACKET_SEQUENCE) else if (!strcmp(token, "packet-sequence")) flag = IPMICONSOLE_WORKAROUND_INCREMENT_SOL_PACKET_SEQUENCE; -#endif -#if defined(IPMICONSOLE_WORKAROUND_IGNORE_SOL_PAYLOAD_SIZE) +# endif +# if defined(IPMICONSOLE_WORKAROUND_IGNORE_SOL_PAYLOAD_SIZE) else if (!strcmp(token, "ignore-payload-size")) flag = IPMICONSOLE_WORKAROUND_IGNORE_SOL_PAYLOAD_SIZE; -#endif -#if defined(IPMICONSOLE_WORKAROUND_IGNORE_SOL_PORT) +# endif +# if defined(IPMICONSOLE_WORKAROUND_IGNORE_SOL_PORT) else if (!strcmp(token, "ignore-port")) flag = IPMICONSOLE_WORKAROUND_IGNORE_SOL_PORT; -#endif -#if defined(IPMICONSOLE_WORKAROUND_SKIP_SOL_ACTIVATION_STATUS) +# endif +# if defined(IPMICONSOLE_WORKAROUND_SKIP_SOL_ACTIVATION_STATUS) else if (!strcmp(token, "activation-status")) flag = IPMICONSOLE_WORKAROUND_SKIP_SOL_ACTIVATION_STATUS; -#endif -#if defined(IPMICONSOLE_WORKAROUND_SKIP_CHANNEL_PAYLOAD_SUPPORT) +# endif +# if defined(IPMICONSOLE_WORKAROUND_SKIP_CHANNEL_PAYLOAD_SUPPORT) else if (!strcmp(token, "channel-payload")) flag = IPMICONSOLE_WORKAROUND_SKIP_CHANNEL_PAYLOAD_SUPPORT; -#endif +# endif else { if (isMaster) Error("invalid ipmiworkaround `%s' [%s:%d]", token, file, @@ -1856,12 +1501,7 @@ ProcessIpmiWorkaround(c, id) } void -#if PROTOTYPES DefaultItemIpmiWorkaround(char *id) -#else -DefaultItemIpmiWorkaround(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemIpmiWorkaround(%s) [%s:%d]", id, file, line)); @@ -1870,13 +1510,7 @@ DefaultItemIpmiWorkaround(id) #endif /*freeipmi */ void -#if PROTOTYPES ProcessInclude(CONSENT *c, char *id) -#else -ProcessInclude(c, id) - CONSENT *c; - char *id; -#endif { CONSENT *inc = (CONSENT *)0; if ((id == (char *)0) || (*id == '\000')) @@ -1891,25 +1525,14 @@ ProcessInclude(c, id) } void -#if PROTOTYPES DefaultItemInclude(char *id) -#else -DefaultItemInclude(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemInclude(%s) [%s:%d]", id, file, line)); ProcessInclude(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessLogfile(CONSENT *c, char *id) -#else -ProcessLogfile(c, id) - CONSENT *c; - char *id; -#endif { if (c->logfile != (char *)0) { free(c->logfile); @@ -1924,13 +1547,7 @@ ProcessLogfile(c, id) } void -#if PROTOTYPES ProcessInitcmd(CONSENT *c, char *id) -#else -ProcessInitcmd(c, id) - CONSENT *c; - char *id; -#endif { if (c->initcmd != (char *)0) { free(c->initcmd); @@ -1945,13 +1562,7 @@ ProcessInitcmd(c, id) } void -#if PROTOTYPES ProcessMOTD(CONSENT *c, char *id) -#else -ProcessMOTD(c, id) - CONSENT *c; - char *id; -#endif { if (c->motd != (char *)0) { free(c->motd); @@ -1966,13 +1577,7 @@ ProcessMOTD(c, id) } void -#if PROTOTYPES ProcessIdlestring(CONSENT *c, char *id) -#else -ProcessIdlestring(c, id) - CONSENT *c; - char *id; -#endif { if (c->idlestring != (char *)0) { free(c->idlestring); @@ -1986,25 +1591,14 @@ ProcessIdlestring(c, id) } void -#if PROTOTYPES DefaultItemLogfile(char *id) -#else -DefaultItemLogfile(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemLogfile(%s) [%s:%d]", id, file, line)); ProcessLogfile(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessLogfilemax(CONSENT *c, char *id) -#else -ProcessLogfilemax(c, id) - CONSENT *c; - char *id; -#endif { char *p; off_t v = 0; @@ -2046,61 +1640,35 @@ ProcessLogfilemax(c, id) } void -#if PROTOTYPES DefaultItemLogfilemax(char *id) -#else -DefaultItemLogfilemax(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemLogfilemax(%s) [%s:%d]", id, file, line)); ProcessLogfilemax(parserDefaultTemp, id); } void -#if PROTOTYPES DefaultItemInitcmd(char *id) -#else -DefaultItemInitcmd(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemInitcmd(%s) [%s:%d]", id, file, line)); ProcessInitcmd(parserDefaultTemp, id); } void -#if PROTOTYPES DefaultItemMOTD(char *id) -#else -DefaultItemMOTD(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemMOTD(%s) [%s:%d]", id, file, line)); ProcessMOTD(parserDefaultTemp, id); } void -#if PROTOTYPES DefaultItemIdlestring(char *id) -#else -DefaultItemIdlestring(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemIdlestring(%s) [%s:%d]", id, file, line)); ProcessIdlestring(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessMaster(CONSENT *c, char *id) -#else -ProcessMaster(c, id) - CONSENT *c; - char *id; -#endif { if (c->master != (char *)0) { free(c->master); @@ -2114,25 +1682,14 @@ ProcessMaster(c, id) } void -#if PROTOTYPES DefaultItemMaster(char *id) -#else -DefaultItemMaster(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemMaster(%s) [%s:%d]", id, file, line)); ProcessMaster(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessOptions(CONSENT *c, char *id) -#else -ProcessOptions(c, id) - CONSENT *c; - char *id; -#endif { char *token = (char *)0; int negative = 0; @@ -2195,25 +1752,14 @@ ProcessOptions(c, id) } void -#if PROTOTYPES DefaultItemOptions(char *id) -#else -DefaultItemOptions(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemOptions(%s) [%s:%d]", id, file, line)); ProcessOptions(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessParity(CONSENT *c, char *id) -#else -ProcessParity(c, id) - CONSENT *c; - char *id; -#endif { if ((id == (char *)0) || (*id == '\000')) { c->parity = (PARITY *)0; @@ -2227,12 +1773,7 @@ ProcessParity(c, id) } void -#if PROTOTYPES DefaultItemParity(char *id) -#else -DefaultItemParity(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemParity(%s) [%s:%d]", id, file, line)); ProcessParity(parserDefaultTemp, id); @@ -2240,13 +1781,7 @@ DefaultItemParity(id) #if HAVE_FREEIPMI void -#if PROTOTYPES ProcessPassword(CONSENT *c, char *id) -#else -ProcessPassword(c, id) - CONSENT *c; - char *id; -#endif { if ((id == (char *)0) || (*id == '\000')) { c->password = (char *)0; @@ -2256,12 +1791,7 @@ ProcessPassword(c, id) } void -#if PROTOTYPES DefaultItemPassword(char *id) -#else -DefaultItemPassword(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemPassword(%s) [%s:%d]", id, file, line)); ProcessPassword(parserDefaultTemp, id); @@ -2269,13 +1799,7 @@ DefaultItemPassword(id) #endif /*freeipmi */ void -#if PROTOTYPES ProcessPort(CONSENT *c, char *id) -#else -ProcessPort(c, id) - CONSENT *c; - char *id; -#endif { char *p; @@ -2306,13 +1830,7 @@ ProcessPort(c, id) } void -#if PROTOTYPES ProcessPortinc(CONSENT *c, char *id) -#else -ProcessPortinc(c, id) - CONSENT *c; - char *id; -#endif { char *p; @@ -2333,13 +1851,7 @@ ProcessPortinc(c, id) } void -#if PROTOTYPES ProcessPortbase(CONSENT *c, char *id) -#else -ProcessPortbase(c, id) - CONSENT *c; - char *id; -#endif { char *p; @@ -2368,49 +1880,28 @@ ProcessPortbase(c, id) } void -#if PROTOTYPES DefaultItemPort(char *id) -#else -DefaultItemPort(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemPort(%s) [%s:%d]", id, file, line)); ProcessPort(parserDefaultTemp, id); } void -#if PROTOTYPES DefaultItemPortbase(char *id) -#else -DefaultItemPortbase(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemPortbase(%s) [%s:%d]", id, file, line)); ProcessPortbase(parserDefaultTemp, id); } void -#if PROTOTYPES DefaultItemPortinc(char *id) -#else -DefaultItemPortinc(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemPortinc(%s) [%s:%d]", id, file, line)); ProcessPortinc(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessInitspinmax(CONSENT *c, char *id) -#else -ProcessInitspinmax(c, id) - CONSENT *c; - char *id; -#endif { char *p; int i; @@ -2440,25 +1931,14 @@ ProcessInitspinmax(c, id) } void -#if PROTOTYPES DefaultItemInitspinmax(char *id) -#else -DefaultItemInitspinmax(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemInitspinmax(%s) [%s:%d]", id, file, line)); ProcessInitspinmax(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessInitspintimer(CONSENT *c, char *id) -#else -ProcessInitspintimer(c, id) - CONSENT *c; - char *id; -#endif { char *p; int i; @@ -2488,25 +1968,14 @@ ProcessInitspintimer(c, id) } void -#if PROTOTYPES DefaultItemInitspintimer(char *id) -#else -DefaultItemInitspintimer(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemInitspintimer(%s) [%s:%d]", id, file, line)); ProcessInitspintimer(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessProtocol(CONSENT *c, char *id) -#else -ProcessProtocol(c, id) - CONSENT *c; - char *id; -#endif { if ((id == (char *)0) || (*id == '\000')) { c->raw = FLAGUNKNOWN; @@ -2526,25 +1995,14 @@ ProcessProtocol(c, id) } void -#if PROTOTYPES DefaultItemProtocol(char *id) -#else -DefaultItemProtocol(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemProtocol(%s) [%s:%d]", id, file, line)); ProcessProtocol(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessReplstring(CONSENT *c, char *id) -#else -ProcessReplstring(c, id) - CONSENT *c; - char *id; -#endif { if (c->replstring != (char *)0) { free(c->replstring); @@ -2558,25 +2016,14 @@ ProcessReplstring(c, id) } void -#if PROTOTYPES DefaultItemReplstring(char *id) -#else -DefaultItemReplstring(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemReplstring(%s) [%s:%d]", id, file, line)); ProcessReplstring(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessTasklist(CONSENT *c, char *id) -#else -ProcessTasklist(c, id) - CONSENT *c; - char *id; -#endif { char *token = (char *)0; char *list = (char *)0; @@ -2611,25 +2058,14 @@ ProcessTasklist(c, id) } void -#if PROTOTYPES DefaultItemTasklist(char *id) -#else -DefaultItemTasklist(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemTasklist(%s) [%s:%d]", id, file, line)); ProcessTasklist(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessBreaklist(CONSENT *c, char *id) -#else -ProcessBreaklist(c, id) - CONSENT *c; - char *id; -#endif { char *token = (char *)0; char *list = (char *)0; @@ -2663,25 +2099,14 @@ ProcessBreaklist(c, id) } void -#if PROTOTYPES DefaultItemBreaklist(char *id) -#else -DefaultItemBreaklist(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemBreaklist(%s) [%s:%d]", id, file, line)); ProcessBreaklist(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessIdletimeout(CONSENT *c, char *id) -#else -ProcessIdletimeout(c, id) - CONSENT *c; - char *id; -#endif { char *p; int factor = 0; @@ -2710,25 +2135,14 @@ ProcessIdletimeout(c, id) } void -#if PROTOTYPES DefaultItemIdletimeout(char *id) -#else -DefaultItemIdletimeout(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemIdletimeout(%s) [%s:%d]", id, file, line)); ProcessIdletimeout(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessRoRw(CONSENTUSERS **ppCU, char *id) -#else -ProcessRoRw(ppCU, id) - CONSENTUSERS **ppCU; - char *id; -#endif { char *token = (char *)0; PARSERGROUP *pg = (PARSERGROUP *)0; @@ -2756,37 +2170,21 @@ ProcessRoRw(ppCU, id) } void -#if PROTOTYPES DefaultItemRo(char *id) -#else -DefaultItemRo(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemRo(%s) [%s:%d]", id, file, line)); ProcessRoRw(&(parserDefaultTemp->ro), id); } void -#if PROTOTYPES DefaultItemRw(char *id) -#else -DefaultItemRw(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemRw(%s) [%s:%d]", id, file, line)); ProcessRoRw(&(parserDefaultTemp->rw), id); } void -#if PROTOTYPES ProcessTimestamp(CONSENT *c, char *id) -#else -ProcessTimestamp(c, id) - CONSENT *c; - char *id; -#endif { time_t tyme; char *p = (char *)0, *n = (char *)0; @@ -2928,25 +2326,14 @@ ProcessTimestamp(c, id) } void -#if PROTOTYPES DefaultItemTimestamp(char *id) -#else -DefaultItemTimestamp(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemTimestamp(%s) [%s:%d]", id, file, line)); ProcessTimestamp(parserDefaultTemp, id); } void -#if PROTOTYPES ProcessType(CONSENT *c, char *id) -#else -ProcessType(c, id) - CONSENT *c; - char *id; -#endif { CONSTYPE t = UNKNOWNTYPE; if ((id == (char *)0) || (*id == '\000')) { @@ -2975,12 +2362,7 @@ ProcessType(c, id) } void -#if PROTOTYPES DefaultItemType(char *id) -#else -DefaultItemType(id) - char *id; -#endif { CONDDEBUG((1, "DefaultItemType(%s) [%s:%d]", id, file, line)); ProcessType(parserDefaultTemp, id); @@ -2992,12 +2374,7 @@ CONSENT **parserConsolesTail = &parserConsoles; CONSENT *parserConsoleTemp = (CONSENT *)0; void -#if PROTOTYPES ConsoleBegin(char *id) -#else -ConsoleBegin(id) - char *id; -#endif { CONSENT *c; @@ -3032,13 +2409,7 @@ ConsoleBegin(id) /* returns 1 if there's an error, otherwise 0 */ int -#if PROTOTYPES CheckSubst(char *label, char *subst) -#else -CheckSubst(label, subst) - char *label; - char *subst; -#endif { int invalid = 0; @@ -3065,11 +2436,7 @@ CheckSubst(label, subst) } void -#if PROTOTYPES ConsoleEnd(void) -#else -ConsoleEnd() -#endif { int invalid = 0; @@ -3204,11 +2571,7 @@ ConsoleEnd() } void -#if PROTOTYPES ConsoleAbort(void) -#else -ConsoleAbort() -#endif { CONDDEBUG((1, "ConsoleAbort() [%s:%d]", file, line)); DestroyParserDefaultOrConsole(parserConsoleTemp, (CONSENT **)0, @@ -3217,13 +2580,7 @@ ConsoleAbort() } void -#if PROTOTYPES SwapStr(char **s1, char **s2) -#else -SwapStr(s1, s2) - char **s1; - char **s2; -#endif { char *s; s = *s1; @@ -3232,13 +2589,7 @@ SwapStr(s1, s2) } void -#if PROTOTYPES ExpandLogfile(CONSENT *c, char *id) -#else -ExpandLogfile(c, id) - CONSENT *c; - char *id; -#endif { char *amp = (char *)0; char *p = (char *)0; @@ -3270,12 +2621,7 @@ ExpandLogfile(c, id) * a new console. */ void -#if PROTOTYPES ConsoleAdd(CONSENT *c) -#else -ConsoleAdd(c) - CONSENT *c; -#endif { CONSENT *pCEmatch = (CONSENT *)0; GRPENT *pGEmatch = (GRPENT *)0, *pGEtmp = (GRPENT *)0; @@ -3692,13 +3038,13 @@ ConsoleAdd(c) if (pCEmatch->ipmikg->used != 0 && c->ipmikg->used == pCEmatch->ipmikg->used) { if ( -#if HAVE_MEMCMP +# if HAVE_MEMCMP memcmp(pCEmatch->ipmikg->string, c->ipmikg, c->ipmikg->used) != 0 -#else +# else bcmp(pCEmatch->ipmikg->string, c->ipmikg, c->ipmikg->used) != 0 -#endif +# endif ) { BuildString((char *)0, pCEmatch->ipmikg); BuildStringN(c->ipmikg->string, @@ -3818,11 +3164,7 @@ ConsoleAdd(c) } void -#if PROTOTYPES ConsoleDestroy(void) -#else -ConsoleDestroy() -#endif { GRPENT **ppGE = (GRPENT **)0; GRPENT *pGEtmp = (GRPENT *)0; @@ -4160,13 +3502,7 @@ ConsoleDestroy() } CONSENT * -#if PROTOTYPES FindConsoleName(CONSENT *c, char *id) -#else -FindConsoleName(c, id) - CONSENT *c; - char *id; -#endif { NAMES *a = (NAMES *)0; for (; c != (CONSENT *)0; c = c->pCEnext) { @@ -4180,12 +3516,7 @@ FindConsoleName(c, id) } void -#if PROTOTYPES ConsoleItemAliases(char *id) -#else -ConsoleItemAliases(id) - char *id; -#endif { char *token = (char *)0; NAMES *name = (NAMES *)0; @@ -4228,48 +3559,28 @@ ConsoleItemAliases(id) } void -#if PROTOTYPES ConsoleItemBaud(char *id) -#else -ConsoleItemBaud(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemBaud(%s) [%s:%d]", id, file, line)); ProcessBaud(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemBreak(char *id) -#else -ConsoleItemBreak(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemBreak(%s) [%s:%d]", id, file, line)); ProcessBreak(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemDevice(char *id) -#else -ConsoleItemDevice(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemDevice(%s) [%s:%d]", id, file, line)); ProcessDevice(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemDevicesubst(char *id) -#else -ConsoleItemDevicesubst(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemDevicesubst(%s) [%s:%d]", id, file, line)); ProcessSubst(substData, (char **)0, &(parserConsoleTemp->devicesubst), @@ -4277,12 +3588,7 @@ ConsoleItemDevicesubst(id) } void -#if PROTOTYPES ConsoleItemExecsubst(char *id) -#else -ConsoleItemExecsubst(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemExecsubst(%s) [%s:%d]", id, file, line)); ProcessSubst(substData, (char **)0, &(parserConsoleTemp->execsubst), @@ -4290,12 +3596,7 @@ ConsoleItemExecsubst(id) } void -#if PROTOTYPES ConsoleItemUdssubst(char *id) -#else -ConsoleItemUdssubst(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemUdssubst(%s) [%s:%d]", id, file, line)); ProcessSubst(substData, (char **)0, &(parserConsoleTemp->udssubst), @@ -4303,12 +3604,7 @@ ConsoleItemUdssubst(id) } void -#if PROTOTYPES ConsoleItemInitsubst(char *id) -#else -ConsoleItemInitsubst(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemInitsubst(%s) [%s:%d]", id, file, line)); ProcessSubst(substData, (char **)0, &(parserConsoleTemp->initsubst), @@ -4316,72 +3612,42 @@ ConsoleItemInitsubst(id) } void -#if PROTOTYPES ConsoleItemInitrunas(char *id) -#else -ConsoleItemInitrunas(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemInitrunas(%s) [%s:%d]", id, file, line)); ProcessInitrunas(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemExecrunas(char *id) -#else -ConsoleItemExecrunas(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemExecrunas(%s) [%s:%d]", id, file, line)); ProcessExecrunas(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemExec(char *id) -#else -ConsoleItemExec(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemExec(%s) [%s:%d]", id, file, line)); ProcessExec(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemFlow(char *id) -#else -ConsoleItemFlow(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemFlow(%s) [%s:%d]", id, file, line)); ProcessFlow(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemHost(char *id) -#else -ConsoleItemHost(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemHost(%s) [%s:%d]", id, file, line)); ProcessHost(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemUds(char *id) -#else -ConsoleItemUds(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemUds(%s) [%s:%d]", id, file, line)); ProcessUds(parserConsoleTemp, id); @@ -4389,36 +3655,21 @@ ConsoleItemUds(id) #if HAVE_FREEIPMI void -#if PROTOTYPES ConsoleItemIpmiKG(char *id) -#else -ConsoleItemIpmiKG(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemIpmiKG(%s) [%s:%d]", id, file, line)); ProcessIpmiKG(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemUsername(char *id) -#else -ConsoleItemUsername(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemUsername(%s) [%s:%d]", id, file, line)); ProcessUsername(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemIpmiCipherSuite(char *id) -#else -ConsoleItemIpmiCipherSuite(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemIpmiCipherSuite(%s) [%s:%d]", id, file, line)); @@ -4426,12 +3677,7 @@ ConsoleItemIpmiCipherSuite(id) } void -#if PROTOTYPES ConsoleItemIpmiWorkaround(char *id) -#else -ConsoleItemIpmiWorkaround(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemIpmiWorkaround(%s) [%s:%d]", id, file, line)); @@ -4440,108 +3686,63 @@ ConsoleItemIpmiWorkaround(id) #endif /*freeipmi */ void -#if PROTOTYPES ConsoleItemInclude(char *id) -#else -ConsoleItemInclude(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemInclude(%s) [%s:%d]", id, file, line)); ProcessInclude(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemLogfile(char *id) -#else -ConsoleItemLogfile(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemLogfile(%s) [%s:%d]", id, file, line)); ProcessLogfile(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemLogfilemax(char *id) -#else -ConsoleItemLogfilemax(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemLogfilemax(%s) [%s:%d]", id, file, line)); ProcessLogfilemax(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemInitcmd(char *id) -#else -ConsoleItemInitcmd(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemInitcmd(%s) [%s:%d]", id, file, line)); ProcessInitcmd(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemMOTD(char *id) -#else -ConsoleItemMOTD(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemMOTD(%s) [%s:%d]", id, file, line)); ProcessMOTD(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemIdlestring(char *id) -#else -ConsoleItemIdlestring(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemIdlestring(%s) [%s:%d]", id, file, line)); ProcessIdlestring(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemMaster(char *id) -#else -ConsoleItemMaster(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemMaster(%s) [%s:%d]", id, file, line)); ProcessMaster(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemOptions(char *id) -#else -ConsoleItemOptions(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemOptions(%s) [%s:%d]", id, file, line)); ProcessOptions(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemParity(char *id) -#else -ConsoleItemParity(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemParity(%s) [%s:%d]", id, file, line)); ProcessParity(parserConsoleTemp, id); @@ -4549,12 +3750,7 @@ ConsoleItemParity(id) #if HAVE_FREEIPMI void -#if PROTOTYPES ConsoleItemPassword(char *id) -#else -ConsoleItemPassword(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemPassword(%s) [%s:%d]", id, file, line)); ProcessPassword(parserConsoleTemp, id); @@ -4562,168 +3758,98 @@ ConsoleItemPassword(id) #endif /*freeipmi */ void -#if PROTOTYPES ConsoleItemPort(char *id) -#else -ConsoleItemPort(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemPort(%s) [%s:%d]", id, file, line)); ProcessPort(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemPortbase(char *id) -#else -ConsoleItemPortbase(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemPortbase(%s) [%s:%d]", id, file, line)); ProcessPortbase(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemPortinc(char *id) -#else -ConsoleItemPortinc(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemPortinc(%s) [%s:%d]", id, file, line)); ProcessPortinc(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemInitspinmax(char *id) -#else -ConsoleItemInitspinmax(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemInitspinmax(%s) [%s:%d]", id, file, line)); ProcessInitspinmax(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemInitspintimer(char *id) -#else -ConsoleItemInitspintimer(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemInitspintimer(%s) [%s:%d]", id, file, line)); ProcessInitspintimer(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemProtocol(char *id) -#else -ConsoleItemProtocol(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemProtocol(%s) [%s:%d]", id, file, line)); ProcessProtocol(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemReplstring(char *id) -#else -ConsoleItemReplstring(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemReplstring(%s) [%s:%d]", id, file, line)); ProcessReplstring(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemTasklist(char *id) -#else -ConsoleItemTasklist(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemTasklist(%s) [%s:%d]", id, file, line)); ProcessTasklist(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemBreaklist(char *id) -#else -ConsoleItemBreaklist(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemBreaklist(%s) [%s:%d]", id, file, line)); ProcessBreaklist(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemIdletimeout(char *id) -#else -ConsoleItemIdletimeout(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemIdletimeout(%s) [%s:%d]", id, file, line)); ProcessIdletimeout(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemRo(char *id) -#else -ConsoleItemRo(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemRo(%s) [%s:%d]", id, file, line)); ProcessRoRw(&(parserConsoleTemp->ro), id); } void -#if PROTOTYPES ConsoleItemRw(char *id) -#else -ConsoleItemRw(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemRw(%s) [%s:%d]", id, file, line)); ProcessRoRw(&(parserConsoleTemp->rw), id); } void -#if PROTOTYPES ConsoleItemTimestamp(char *id) -#else -ConsoleItemTimestamp(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemTimestamp(%s) [%s:%d]", id, file, line)); ProcessTimestamp(parserConsoleTemp, id); } void -#if PROTOTYPES ConsoleItemType(char *id) -#else -ConsoleItemType(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemType(%s) [%s:%d]", id, file, line)); ProcessType(parserConsoleTemp, id); @@ -4743,12 +3869,7 @@ PARSERACCESS **parserAccessesTail = &parserAccesses; PARSERACCESS *parserAccessTemp = (PARSERACCESS *)0; void -#if PROTOTYPES DestroyParserAccess(PARSERACCESS *pa) -#else -DestroyParserAccess(pa) - PARSERACCESS *pa; -#endif { PARSERACCESS **ppa = &parserAccesses; ACCESS *a = (ACCESS *)0; @@ -4790,12 +3911,7 @@ DestroyParserAccess(pa) } PARSERACCESS * -#if PROTOTYPES AccessFind(char *id) -#else -AccessFind(id) - char *id; -#endif { PARSERACCESS *pa; for (pa = parserAccesses; pa != (PARSERACCESS *)0; pa = pa->next) { @@ -4806,13 +3922,7 @@ AccessFind(id) } void -#if PROTOTYPES AccessAddACL(PARSERACCESS *pa, ACCESS *access) -#else -AccessAddACL(pa, access) - PARSERACCESS *pa; - ACCESS *access; -#endif { ACCESS **ppa = (ACCESS **)0; ACCESS *new = (ACCESS *)0; @@ -4839,12 +3949,7 @@ AccessAddACL(pa, access) } void -#if PROTOTYPES AccessBegin(char *id) -#else -AccessBegin(id) - char *id; -#endif { CONDDEBUG((1, "AccessBegin(%s) [%s:%d]", id, file, line)); if (id == (char *)0 || id[0] == '\000') { @@ -4863,11 +3968,7 @@ AccessBegin(id) } void -#if PROTOTYPES AccessEnd(void) -#else -AccessEnd() -#endif { PARSERACCESS *pa = (PARSERACCESS *)0; @@ -4893,11 +3994,7 @@ AccessEnd() } void -#if PROTOTYPES AccessAbort(void) -#else -AccessAbort() -#endif { CONDDEBUG((1, "AccessAbort() [%s:%d]", file, line)); DestroyParserAccess(parserAccessTemp); @@ -4905,11 +4002,7 @@ AccessAbort() } void -#if PROTOTYPES AccessDestroy(void) -#else -AccessDestroy() -#endif { ACCESS *a; PARSERACCESS *p; @@ -4993,36 +4086,21 @@ AccessDestroy() } void -#if PROTOTYPES AccessItemAdmin(char *id) -#else -AccessItemAdmin(id) - char *id; -#endif { CONDDEBUG((1, "AccessItemAdmin(%s) [%s:%d]", id, file, line)); ProcessRoRw(&(parserAccessTemp->admin), id); } void -#if PROTOTYPES AccessItemLimited(char *id) -#else -AccessItemLimited(id) - char *id; -#endif { CONDDEBUG((1, "AccessItemLimited(%s) [%s:%d]", id, file, line)); ProcessRoRw(&(parserAccessTemp->limited), id); } void -#if PROTOTYPES AccessItemInclude(char *id) -#else -AccessItemInclude(id) - char *id; -#endif { char *token = (char *)0; PARSERACCESS *pa = (PARSERACCESS *)0; @@ -5054,13 +4132,7 @@ AccessItemInclude(id) } void -#if PROTOTYPES AccessProcessACL(char trust, char *acl) -#else -AccessProcessACL(trust, acl) - char trust; - char *acl; -#endif { char *token = (char *)0; ACCESS **ppa = (ACCESS **)0; @@ -5170,36 +4242,21 @@ AccessProcessACL(trust, acl) } void -#if PROTOTYPES AccessItemAllowed(char *id) -#else -AccessItemAllowed(id) - char *id; -#endif { CONDDEBUG((1, "AccessItemAllowed(%s) [%s:%d]", id, file, line)); AccessProcessACL('a', id); } void -#if PROTOTYPES AccessItemRejected(char *id) -#else -AccessItemRejected(id) - char *id; -#endif { CONDDEBUG((1, "AccessItemRejected(%s) [%s:%d]", id, file, line)); AccessProcessACL('r', id); } void -#if PROTOTYPES AccessItemTrusted(char *id) -#else -AccessItemTrusted(id) - char *id; -#endif { CONDDEBUG((1, "AccessItemTrusted(%s) [%s:%d]", id, file, line)); AccessProcessACL('t', id); @@ -5209,12 +4266,7 @@ AccessItemTrusted(id) CONFIG *parserConfigTemp = (CONFIG *)0; void -#if PROTOTYPES DestroyConfig(CONFIG *c) -#else -DestroyConfig(c) - CONFIG *c; -#endif { if (c == (CONFIG *)0) return; @@ -5238,12 +4290,7 @@ DestroyConfig(c) } void -#if PROTOTYPES ConfigBegin(char *id) -#else -ConfigBegin(id) - char *id; -#endif { CONDDEBUG((1, "ConfigBegin(%s) [%s:%d]", id, file, line)); if (id == (char *)0 || id[0] == '\000') { @@ -5261,11 +4308,7 @@ ConfigBegin(id) } void -#if PROTOTYPES ConfigEnd(void) -#else -ConfigEnd() -#endif { CONDDEBUG((1, "ConfigEnd() [%s:%d]", file, line)); @@ -5353,11 +4396,7 @@ ConfigEnd() } void -#if PROTOTYPES ConfigAbort(void) -#else -ConfigAbort() -#endif { CONDDEBUG((1, "ConfigAbort() [%s:%d]", file, line)); if (parserConfigTemp == (CONFIG *)0) @@ -5368,11 +4407,7 @@ ConfigAbort() } void -#if PROTOTYPES ConfigDestroy(void) -#else -ConfigDestroy() -#endif { CONDDEBUG((1, "ConfigDestroy() [%s:%d]", file, line)); if (parserConfigTemp == (CONFIG *)0) @@ -5383,12 +4418,7 @@ ConfigDestroy() } void -#if PROTOTYPES ConfigItemDefaultaccess(char *id) -#else -ConfigItemDefaultaccess(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemDefaultaccess(%s) [%s:%d]", id, file, line)); @@ -5410,12 +4440,7 @@ ConfigItemDefaultaccess(id) #if HAVE_FREEIPMI void -#if PROTOTYPES ConsoleItemIpmiPrivLevel(char *id) -#else -ConsoleItemIpmiPrivLevel(id) - char *id; -#endif { CONDDEBUG((1, "ConsoleItemIpmiPrivLevel(%s) [%s:%d]", id, file, line)); ProcessIpmiPrivLevel(parserConsoleTemp, id); @@ -5423,36 +4448,21 @@ ConsoleItemIpmiPrivLevel(id) #endif /*freeipmi */ void -#if PROTOTYPES ConfigItemAutocomplete(char *id) -#else -ConfigItemAutocomplete(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemAutocomplete(%s) [%s:%d]", id, file, line)); ProcessYesNo(id, &(parserConfigTemp->autocomplete)); } void -#if PROTOTYPES ConfigItemDaemonmode(char *id) -#else -ConfigItemDaemonmode(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemDaemonmode(%s) [%s:%d]", id, file, line)); ProcessYesNo(id, &(parserConfigTemp->daemonmode)); } void -#if PROTOTYPES ConfigItemLogfile(char *id) -#else -ConfigItemLogfile(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemLogfile(%s) [%s:%d]", id, file, line)); @@ -5468,12 +4478,7 @@ ConfigItemLogfile(id) } void -#if PROTOTYPES ConfigItemPasswordfile(char *id) -#else -ConfigItemPasswordfile(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemPasswordfile(%s) [%s:%d]", id, file, line)); @@ -5489,12 +4494,7 @@ ConfigItemPasswordfile(id) } void -#if PROTOTYPES ConfigItemUnifiedlog(char *id) -#else -ConfigItemUnifiedlog(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemUnifiedlog(%s) [%s:%d]", id, file, line)); @@ -5511,12 +4511,7 @@ ConfigItemUnifiedlog(id) } void -#if PROTOTYPES ConfigItemPrimaryport(char *id) -#else -ConfigItemPrimaryport(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemPrimaryport(%s) [%s:%d]", id, file, line)); @@ -5532,36 +4527,21 @@ ConfigItemPrimaryport(id) } void -#if PROTOTYPES ConfigItemRedirect(char *id) -#else -ConfigItemRedirect(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemRedirect(%s) [%s:%d]", id, file, line)); ProcessYesNo(id, &(parserConfigTemp->redirect)); } void -#if PROTOTYPES ConfigItemLoghostnames(char *id) -#else -ConfigItemLoghostnames(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemLoghostnames(%s) [%s:%d]", id, file, line)); ProcessYesNo(id, &(parserConfigTemp->loghostnames)); } void -#if PROTOTYPES ConfigItemReinitcheck(char *id) -#else -ConfigItemReinitcheck(id) - char *id; -#endif { char *p; @@ -5587,12 +4567,7 @@ ConfigItemReinitcheck(id) } void -#if PROTOTYPES ConfigItemInitdelay(char *id) -#else -ConfigItemInitdelay(id) - char *id; -#endif { char *p; @@ -5617,12 +4592,7 @@ ConfigItemInitdelay(id) } void -#if PROTOTYPES ConfigItemSecondaryport(char *id) -#else -ConfigItemSecondaryport(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemSecondaryport(%s) [%s:%d]", id, file, line)); @@ -5638,12 +4608,7 @@ ConfigItemSecondaryport(id) } void -#if PROTOTYPES ConfigItemSslcredentials(char *id) -#else -ConfigItemSslcredentials(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemSslcredentials(%s) [%s:%d]", id, file, line)); #if HAVE_OPENSSL @@ -5665,12 +4630,7 @@ ConfigItemSslcredentials(id) } void -#if PROTOTYPES ConfigItemSslcacertificatefile(char *id) -#else -ConfigItemSslcacertificatefile(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemSslcacertificatefile(%s) [%s:%d]", id, file, line)); @@ -5693,12 +4653,7 @@ ConfigItemSslcacertificatefile(id) } void -#if PROTOTYPES ConfigItemSslrequired(char *id) -#else -ConfigItemSslrequired(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemSslrequired(%s) [%s:%d]", id, file, line)); #if HAVE_OPENSSL @@ -5712,12 +4667,7 @@ ConfigItemSslrequired(id) } void -#if PROTOTYPES ConfigItemSslreqclientcert(char *id) -#else -ConfigItemSslreqclientcert(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemSslreqclientcert(%s) [%s:%d]", id, file, line)); @@ -5732,12 +4682,7 @@ ConfigItemSslreqclientcert(id) } void -#if PROTOTYPES ConfigItemSetproctitle(char *id) -#else -ConfigItemSetproctitle(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemSetproctitle(%s) [%s:%d]", id, file, line)); #if HAVE_SETPROCTITLE @@ -5754,12 +4699,7 @@ ConfigItemSetproctitle(id) TASKS *parserTask; void -#if PROTOTYPES TaskBegin(char *id) -#else -TaskBegin(id) - char *id; -#endif { CONDDEBUG((1, "TaskBegin(%s) [%s:%d]", id, file, line)); if (id == (char *)0 || id[0] == '\000' || id[1] != '\000' || @@ -5790,11 +4730,7 @@ TaskBegin(id) } void -#if PROTOTYPES TaskEnd(void) -#else -TaskEnd() -#endif { TASKS *t; TASKS **prev; @@ -5823,11 +4759,7 @@ TaskEnd() } void -#if PROTOTYPES TaskAbort(void) -#else -TaskAbort() -#endif { CONDDEBUG((1, "TaskAbort() [%s:%d]", file, line)); if (parserTask == (TASKS *)0 || parserTask->id == ' ') @@ -5837,11 +4769,7 @@ TaskAbort() } void -#if PROTOTYPES TaskDestroy(void) -#else -TaskDestroy() -#endif { CONDDEBUG((1, "TaskDestroy() [%s:%d]", file, line)); if (parserTask != (TASKS *)0) { @@ -5851,12 +4779,7 @@ TaskDestroy() } void -#if PROTOTYPES TaskItemRunas(char *id) -#else -TaskItemRunas(id) - char *id; -#endif { CONDDEBUG((1, "TaskItemRunas(%s) [%s:%d]", id, file, line)); if (parserTask == (TASKS *)0 || parserTask->id == ' ') @@ -5865,12 +4788,7 @@ TaskItemRunas(id) } void -#if PROTOTYPES TaskItemSubst(char *id) -#else -TaskItemSubst(id) - char *id; -#endif { CONDDEBUG((1, "TaskItemSubst(%s) [%s:%d]", id, file, line)); if (parserTask == (TASKS *)0 || parserTask->id == ' ') @@ -5879,12 +4797,7 @@ TaskItemSubst(id) } void -#if PROTOTYPES TaskItemCmd(char *id) -#else -TaskItemCmd(id) - char *id; -#endif { CONDDEBUG((1, "TaskItemCmd(%s) [%s:%d]", id, file, line)); if (parserTask == (TASKS *)0 || parserTask->id == ' ') @@ -5896,12 +4809,7 @@ TaskItemCmd(id) } void -#if PROTOTYPES TaskItemDescr(char *id) -#else -TaskItemDescr(id) - char *id; -#endif { CONDDEBUG((1, "TaskItemDescr(%s) [%s:%d]", id, file, line)); if (parserTask == (TASKS *)0 || parserTask->id == ' ') @@ -5913,12 +4821,7 @@ TaskItemDescr(id) } void -#if PROTOTYPES TaskItemConfirm(char *id) -#else -TaskItemConfirm(id) - char *id; -#endif { CONDDEBUG((1, "TaskItemConfirm(%s) [%s:%d]", id, file, line)); ProcessYesNo(id, &(parserTask->confirm)); @@ -6090,13 +4993,7 @@ SECTION sections[] = { }; void -#if PROTOTYPES ReadCfg(char *filename, FILE *fp) -#else -ReadCfg(filename, fp) - char *filename; - FILE *fp; -#endif { int i; #if HAVE_DMALLOC && DMALLOC_MARK_READCFG @@ -6151,13 +5048,7 @@ ReadCfg(filename, fp) } void -#if PROTOTYPES ReReadCfg(int fd, int msfd) -#else -ReReadCfg(fd, msfd) - int fd; - int msfd; -#endif { FILE *fpConfig; @@ -6308,7 +5199,11 @@ ReReadCfg(fd, msfd) /* if no one can use us we need to come up with a default */ if (pACList == (ACCESS *)0) +#if USE_IPV6 + SetDefAccess(); +#else SetDefAccess(myAddrs, myHostname); +#endif if (isMaster) { GRPENT *pGE; diff --git a/conserver/readcfg.h b/conserver/readcfg.h index 8394a98..fb8167a 100644 --- a/conserver/readcfg.h +++ b/conserver/readcfg.h @@ -1,5 +1,5 @@ /* - * $Id: readcfg.h,v 5.49 2013/09/23 22:58:21 bryan Exp $ + * $Id: readcfg.h,v 5.50 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -63,12 +63,12 @@ extern SUBST *taskSubst; /* substitution function data for tasks */ extern CONFIG *pConfig; /* settings seen by config parser */ extern SUBST *substData; /* substitution function data */ -extern void ReadCfg PARAMS((char *, FILE *)); -extern void ReReadCfg PARAMS((int, int)); -extern void DestroyBreakList PARAMS((void)); -extern void DestroyTaskList PARAMS((void)); -extern void DestroyUserList PARAMS((void)); -extern void DestroyConfig PARAMS((CONFIG *)); -extern NAMES *FindUserList PARAMS((char *)); -extern NAMES *AddUserList PARAMS((char *)); -extern CONSENT *FindConsoleName PARAMS((CONSENT *, char *)); +extern void ReadCfg(char *, FILE *); +extern void ReReadCfg(int, int); +extern void DestroyBreakList(void); +extern void DestroyTaskList(void); +extern void DestroyUserList(void); +extern void DestroyConfig(CONFIG *); +extern NAMES *FindUserList(char *); +extern NAMES *AddUserList(char *); +extern CONSENT *FindConsoleName(CONSENT *, char *); diff --git a/conserver/version.h b/conserver/version.h index 2c6d595..0e7380b 100644 --- a/conserver/version.h +++ b/conserver/version.h @@ -1,5 +1,5 @@ /* - * $Id: version.h,v 1.79 2014/04/02 04:45:32 bryan Exp $ + * $Id: version.h,v 1.81 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -15,7 +15,7 @@ All rights reserved.\n" #define VERSION_MAJOR 8 -#define VERSION_MINOR 1 -#define VERSION_REV 20 +#define VERSION_MINOR 2 +#define VERSION_REV 0 #define VERSION_TEXT "conserver.com version" #define VERSION_UINT (VERSION_MAJOR * 1000000 + VERSION_MINOR * 1000 + VERSION_REV) diff --git a/console/console.c b/console/console.c index 9e72cf2..12fb641 100644 --- a/console/console.c +++ b/console/console.c @@ -1,5 +1,5 @@ /* - * $Id: console.c,v 5.189 2014/04/02 00:02:47 bryan Exp $ + * $Id: console.c,v 5.190 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -36,12 +36,16 @@ #include #include #if HAVE_OPENSSL -#include -#include -#include +# include +# include +# include #endif #if HAVE_GSSAPI -#include +# include +#endif +#if USE_IPV6 +# include +# include #endif @@ -70,11 +74,7 @@ struct winsize ws; SSL_CTX *ctx = (SSL_CTX *)0; void -#if PROTOTYPES SetupSSL(void) -#else -SetupSSL() -#endif { if (ctx == (SSL_CTX *)0) { char *ciphers; @@ -120,11 +120,11 @@ SetupSSL() } ciphers = "ALL:!LOW:!EXP:!MD5:!aNULL:@STRENGTH"; } else { -#if defined(REQ_SERVER_CERT) +# if defined(REQ_SERVER_CERT) ciphers = "ALL:!LOW:!EXP:!MD5:!aNULL:@STRENGTH"; -#else +# else ciphers = "ALL:!LOW:!EXP:!MD5:@STRENGTH"; -#endif +# endif } SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, SSLVerifyCallback); SSL_CTX_set_options(ctx, @@ -142,12 +142,7 @@ SetupSSL() } void -#if PROTOTYPES AttemptSSL(CONSFILE *pcf) -#else -AttemptSSL(pcf) - CONSFILE *pcf; -#endif { SSL *ssl; @@ -179,12 +174,7 @@ gss_ctx_id_t secctx = GSS_C_NO_CONTEXT; gss_buffer_desc mytok = GSS_C_EMPTY_BUFFER; int -#if PROTOTYPES CanGetGSSContext(const char *servername) -#else -CanGetGSSContext(servername) - const char *servername; -#endif { char namestr[128]; gss_buffer_desc namebuf, dbuf; @@ -220,12 +210,7 @@ CanGetGSSContext(servername) } int -#if PROTOTYPES AttemptGSSAPI(CONSFILE *pcf) -#else -AttemptGSSAPI(pcf) - CONSFILE *pcf; -#endif { OM_uint32 stmaj, stmin; gss_buffer_desc servertok; @@ -257,13 +242,7 @@ AttemptGSSAPI(pcf) /* output a control (or plain) character as a UNIX user would expect it (ksb) */ static void -#if PROTOTYPES PutCtlc(int c, FILE *fp) -#else -PutCtlc(c, fp) - int c; - FILE *fp; -#endif { if (0 != (0200 & c)) { putc('M', fp); @@ -285,12 +264,7 @@ PutCtlc(c, fp) /* output a long message to the user */ static void -#if PROTOTYPES Usage(int wantfull) -#else -Usage(wantfull) - int wantfull; -#endif { static char *full[] = { "7 strip the high bit off all console data", @@ -354,11 +328,7 @@ Usage(wantfull) /* expain who we are and which revision we are (ksb) */ static void -#if PROTOTYPES -Version() -#else -Version() -#endif +Version(void) { int i; static STRING *acA1 = (STRING *)0; @@ -418,12 +388,12 @@ Version() BuildStringChar('0' + DMALLOC_VERSION_MINOR, acA1); BuildStringChar('.', acA1); BuildStringChar('0' + DMALLOC_VERSION_PATCH, acA1); -#if defined(DMALLOC_VERSION_BETA) +# if defined(DMALLOC_VERSION_BETA) if (DMALLOC_VERSION_BETA != 0) { BuildString("-b", acA1); BuildStringChar('0' + DMALLOC_VERSION_BETA, acA1); } -#endif +# endif Msg("dmalloc version: %s", acA1->string); #endif #if HAVE_OPENSSL @@ -441,12 +411,7 @@ Version() * c a plain character */ static int -#if PROTOTYPES ParseChar(char **ppcSrc, char *pcOut) -#else -ParseChar(ppcSrc, pcOut) - char **ppcSrc, *pcOut; -#endif { int cvt, n; char *pcScan = *ppcSrc; @@ -490,11 +455,7 @@ ParseChar(ppcSrc, pcOut) /* */ static void -#if PROTOTYPES -ValidateEsc() -#else -ValidateEsc() -#endif +ValidateEsc(void) { unsigned char c1, c2; @@ -517,12 +478,7 @@ ValidateEsc() /* find the two characters that makeup the users escape sequence (ksb) */ static void -#if PROTOTYPES ParseEsc(char *pcText) -#else -ParseEsc(pcText) - char *pcText; -#endif { char *pcTemp; char c1, c2; @@ -547,16 +503,15 @@ ParseEsc(pcText) * as a side effect we set ThisHost to a short name for this host */ CONSFILE * -#if PROTOTYPES GetPort(char *pcToHost, unsigned short sPort) -#else -GetPort(pcToHost, sPort) - char *pcToHost; - unsigned short sPort; -#endif { int s; -#if USE_UNIX_DOMAIN_SOCKETS +#if USE_IPV6 + int error; + char host[NI_MAXHOST]; + char serv[NI_MAXSERV]; + struct addrinfo *ai, *rp, hints; +#elif USE_UNIX_DOMAIN_SOCKETS struct sockaddr_un port; static STRING *portPath = (STRING *)0; #else @@ -564,13 +519,59 @@ GetPort(pcToHost, sPort) struct sockaddr_in port; #endif -#if HAVE_MEMSET - memset((void *)(&port), '\000', sizeof(port)); +#if USE_IPV6 +# if HAVE_MEMSET + memset(&hints, 0, sizeof(hints)); +# else + bzero(&hints, sizeof(hints)); +# endif #else +# if HAVE_MEMSET + memset((void *)(&port), '\000', sizeof(port)); +# else bzero((char *)(&port), sizeof(port)); +# endif #endif -#if USE_UNIX_DOMAIN_SOCKETS +#if USE_IPV6 + hints.ai_flags = AI_ADDRCONFIG; + hints.ai_socktype = SOCK_STREAM; + snprintf(serv, sizeof(serv), "%hu", sPort); + + error = getaddrinfo(pcToHost, serv, &hints, &ai); + if (error) { + Error("getaddrinfo(%s): %s", pcToHost, gai_strerror(error)); + return (CONSFILE *)0; + } + + rp = ai; + while (rp) { + error = + getnameinfo(rp->ai_addr, rp->ai_addrlen, host, sizeof(host), + serv, sizeof(serv), + NI_NUMERICHOST | NI_NUMERICSERV); + if (error) { + continue; + } + CONDDEBUG((1, "GetPort: hostname=%s, ip=%s, port=%s", pcToHost, + host, serv)); + + /* set up the socket to talk to the server for all consoles + * (it will tell us who to talk to to get a real connection) + */ + s = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); + if (s != -1) { + if (connect(s, rp->ai_addr, rp->ai_addrlen) == 0) + goto success; + close(s); + } + rp = rp->ai_next; + } + Error("Unable to connect to %s:%s", host, serv); + return (CONSFILE *)0; + success: + freeaddrinfo(ai); +#elif USE_UNIX_DOMAIN_SOCKETS if (portPath == (STRING *)0) portPath = AllocString(); BuildStringPrint(portPath, "%s/%hu", config->master, sPort); @@ -663,11 +664,7 @@ static struct termios o_tios; * we really use cbreak at PUCC because we need even parity... */ static void -#if PROTOTYPES -C2Raw() -#else -C2Raw() -#endif +C2Raw(void) { struct termios n_tios; @@ -695,11 +692,7 @@ C2Raw() * put the tty back as it was, however that was */ static void -#if PROTOTYPES -C2Cooked() -#else -C2Cooked() -#endif +C2Cooked(void) { if (!screwy) return; @@ -708,11 +701,7 @@ C2Cooked() } void -#if PROTOTYPES DestroyDataStructures(void) -#else -DestroyDataStructures() -#endif { C2Cooked(); if (cfstdout != (CONSFILE *)0) @@ -721,21 +710,17 @@ DestroyDataStructures() DestroyConfig(optConf); DestroyConfig(config); DestroyTerminal(pTerm); +#if !USE_IPV6 if (myAddrs != (struct in_addr *)0) free(myAddrs); +#endif DestroyStrings(); if (substData != (SUBST *)0) free(substData); } char * -#if PROTOTYPES ReadReply(CONSFILE *fd, FLAG toEOF) -#else -ReadReply(fd, toEOF) - CONSFILE *fd; - FLAG toEOF; -#endif { int nr; static char buf[1024]; @@ -787,11 +772,7 @@ ReadReply(fd, toEOF) } static void -#if PROTOTYPES ReapVirt(void) -#else -ReapVirt() -#endif { pid_t pid; int UWbuf; @@ -832,12 +813,7 @@ static sig_atomic_t fSawReapVirt = 0; static #endif RETSIGTYPE -#if PROTOTYPES FlagReapVirt(int sig) -#else -FlagReapVirt(sig) - int sig; -#endif { fSawReapVirt = 1; #if !HAVE_SIGACTION @@ -847,11 +823,7 @@ FlagReapVirt(sig) /* invoke the execcmd command */ void -#if PROTOTYPES ExecCmd(void) -#else -ExecCmd() -#endif { int i; pid_t iNewGrp; @@ -929,15 +901,15 @@ ExecCmd() close(1); close(0); -# if HAVE_SETSID +#if HAVE_SETSID iNewGrp = setsid(); if (-1 == iNewGrp) { Error("ExecCmd(): setsid(): %s", strerror(errno)); iNewGrp = thepid; } -# else +#else iNewGrp = thepid; -# endif +#endif if (dup(pout[0]) != 0 || dup(pin[1]) != 1) { Error("ExecCmd(): fd sync error"); @@ -957,12 +929,7 @@ ExecCmd() } void -#if PROTOTYPES GetUserInput(STRING *str) -#else -GetUserInput(str) - STRING *str; -#endif { char c; @@ -1008,12 +975,7 @@ GetUserInput(str) } void -#if PROTOTYPES DoExec(CONSFILE *pcf) -#else -DoExec(pcf) - CONSFILE *pcf; -#endif { showExecData = 1; FileWrite(cfstdout, FLAGFALSE, "exec: ", 6); @@ -1063,13 +1025,7 @@ DoExec(pcf) } void -#if PROTOTYPES ExpandString(char *str, CONSFILE *c) -#else -ExpandString(str, c) - char *str; - CONSFILE *c; -#endif { char s; short backslash = 0; @@ -1159,15 +1115,7 @@ ExpandString(str, c) } void -#if PROTOTYPES PrintSubst(CONSFILE *pcf, char *pcMach, char *string, char *subst) -#else -PrintSubst(pcf, pcMach, string, subst) - CONSFILE *pcf; - char *pcMach; - char *string; - char *subst; -#endif { if (string == (char *)0) return; @@ -1186,13 +1134,7 @@ PrintSubst(pcf, pcMach, string, subst) } void -#if PROTOTYPES Interact(CONSFILE *pcf, char *pcMach) -#else -Interact(pcf, pcMach) - CONSFILE *pcf; - char *pcMach; -#endif { int i; int nc; @@ -1415,14 +1357,8 @@ Interact(pcf, pcMach) /* interact with a group server (ksb) */ void -#if PROTOTYPES CallUp(CONSFILE *pcf, char *pcMaster, char *pcMach, char *pcHow, char *result) -#else -CallUp(pcf, pcMaster, pcMach, pcHow, result) - CONSFILE *pcf; - char *pcMaster, *pcMach, *pcHow, *result; -#endif { int fIn = '-'; char *r = (char *)0; @@ -1606,14 +1542,7 @@ char *cmdarg = (char *)0; * and ask the machine master at pop.stat for more group leaders */ int -#if PROTOTYPES DoCmds(char *master, char *pports, int cmdi) -#else -DoCmds(master, pports, cmdi) - char *master; - char *pports; - int cmdi; -#endif { CONSFILE *pcf; char *t; @@ -1657,7 +1586,9 @@ DoCmds(master, pports, cmdi) #endif if (*ports == '\000') { -#if USE_UNIX_DOMAIN_SOCKETS +#if USE_IPV6 + port = bindPort; +#elif USE_UNIX_DOMAIN_SOCKETS port = 0; #else port = htons(bindPort); @@ -1666,7 +1597,9 @@ DoCmds(master, pports, cmdi) Error("invalid port spec for %s: `%s'", serverName, ports); continue; } else { -#if USE_UNIX_DOMAIN_SOCKETS +#if USE_IPV6 + port = (short)atoi(ports); +#elif USE_UNIX_DOMAIN_SOCKETS port = (short)atoi(ports); #else port = htons((short)atoi(ports)); @@ -1933,13 +1866,7 @@ DoCmds(master, pports, cmdi) * exit happy or sad */ int -#if PROTOTYPES main(int argc, char **argv) -#else -main(argc, argv) - int argc; - char **argv; -#endif { char *pcCmd; struct passwd *pwdMe = (struct passwd *)0; @@ -2230,8 +2157,9 @@ main(argc, argv) Version(); Bye(EX_OK); } - +#if !USE_IPV6 ProbeInterfaces(INADDR_ANY); +#endif if (readSystemConf) ReadConf(CLIENTCONFIGFILE, FLAGFALSE); @@ -2485,11 +2413,11 @@ main(argc, argv) #if defined(TIOCGWINSZ) if (interact == FLAGTRUE) { int fd; -#if HAVE_MEMSET +# if HAVE_MEMSET memset((void *)(&ws), '\000', sizeof(ws)); -#else +# else bzero((char *)(&ws), sizeof(ws)); -#endif +# endif if ((fd = open("/dev/tty", O_RDONLY)) != -1) { ioctl(fd, TIOCGWINSZ, &ws); } diff --git a/console/console.man b/console/console.man index 7cbf4d6..afeea6c 100644 --- a/console/console.man +++ b/console/console.man @@ -1,5 +1,5 @@ .\" $Id: console.man,v 1.65 2013/09/25 22:10:30 bryan Exp $ -.TH CONSOLE 1 "2013/09/25" "conserver-8.1.20" "conserver" +.TH CONSOLE 1 "2013/09/25" "conserver-8.2.0" "conserver" .SH NAME console \- console server client program .SH SYNOPSIS diff --git a/console/getpassword.c b/console/getpassword.c index 14f4bf0..e54e4f0 100644 --- a/console/getpassword.c +++ b/console/getpassword.c @@ -1,5 +1,5 @@ /* - * $Id: getpassword.c,v 1.8 2003/11/20 13:56:41 bryan Exp $ + * $Id: getpassword.c,v 1.9 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -31,12 +31,7 @@ static STRING *pass = (STRING *)0; * we really use cbreak at PUCC because we need even parity... */ static void -#if PROTOTYPES C2Raw(int fd) -#else -C2Raw(fd) - int fd; -#endif { struct termios n_tios; @@ -64,12 +59,7 @@ C2Raw(fd) * put the tty back as it was, however that was */ static void -#if PROTOTYPES C2Normal(int fd) -#else -C2Normal(fd) - int fd; -#endif { if (!screwy) return; @@ -78,12 +68,7 @@ C2Normal(fd) } char * -#if PROTOTYPES GetPassword(char *prompt) -#else -GetPassword(prompt) - char *prompt; -#endif { int fd; int nc; @@ -140,11 +125,7 @@ GetPassword(prompt) } void -#if PROTOTYPES ClearPassword(void) -#else -ClearPassword() -#endif { if (pass == (STRING *)0 || pass->allocated == 0) return; diff --git a/console/getpassword.h b/console/getpassword.h index 53ea564..e08773f 100644 --- a/console/getpassword.h +++ b/console/getpassword.h @@ -1,10 +1,10 @@ /* - * $Id: getpassword.h,v 1.3 2003/09/11 09:10:58 bryan Exp $ + * $Id: getpassword.h,v 1.4 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * * Maintainer/Enhancer: Bryan Stansell (bryan@conserver.com) */ -extern char *GetPassword PARAMS((char *)); -extern void *ClearPassword PARAMS((void)); +extern char *GetPassword(char *); +extern void *ClearPassword(void); diff --git a/console/readconf.c b/console/readconf.c index 10bcf10..e83f203 100644 --- a/console/readconf.c +++ b/console/readconf.c @@ -1,5 +1,5 @@ /* - * $Id: readconf.c,v 5.7 2013/09/18 14:31:39 bryan Exp $ + * $Id: readconf.c,v 5.8 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -19,12 +19,7 @@ TERM *parserTermDefault = (TERM *)0; TERM *pTerm = (TERM *)0; void -#if PROTOTYPES DestroyConfig(CONFIG *c) -#else -DestroyConfig(c) - CONFIG *c; -#endif { if (c == (CONFIG *)0) return; @@ -48,12 +43,7 @@ DestroyConfig(c) } void -#if PROTOTYPES ApplyConfigDefault(CONFIG *c) -#else -ApplyConfigDefault(c) - CONFIG *c; -#endif { if (parserConfigDefault == (CONFIG *)0) return; @@ -121,12 +111,7 @@ ApplyConfigDefault(c) } void -#if PROTOTYPES ConfigBegin(char *id) -#else -ConfigBegin(id) - char *id; -#endif { CONDDEBUG((1, "ConfigBegin(%s) [%s:%d]", id, file, line)); if (id == (char *)0 || id[0] == '\000') { @@ -144,11 +129,7 @@ ConfigBegin(id) } void -#if PROTOTYPES ConfigEnd(void) -#else -ConfigEnd() -#endif { CONDDEBUG((1, "ConfigEnd() [%s:%d]", file, line)); @@ -170,11 +151,7 @@ ConfigEnd() } void -#if PROTOTYPES ConfigAbort(void) -#else -ConfigAbort() -#endif { CONDDEBUG((1, "ConfigAbort() [%s:%d]", file, line)); if (parserConfigTemp == (CONFIG *)0) @@ -185,11 +162,7 @@ ConfigAbort() } void -#if PROTOTYPES ConfigDestroy(void) -#else -ConfigDestroy() -#endif { CONDDEBUG((1, "ConfigDestroy() [%s:%d]", file, line)); @@ -206,12 +179,7 @@ ConfigDestroy() } void -#if PROTOTYPES DestroyTerminal(TERM *t) -#else -DestroyTerminal(t) - TERM *t; -#endif { if (t == (TERM *)0) return; @@ -227,12 +195,7 @@ DestroyTerminal(t) } void -#if PROTOTYPES ApplyTermDefault(TERM *t) -#else -ApplyTermDefault(t) - TERM *t; -#endif { if (parserTermDefault == (TERM *)0) return; @@ -266,12 +229,7 @@ ApplyTermDefault(t) } void -#if PROTOTYPES TerminalBegin(char *id) -#else -TerminalBegin(id) - char *id; -#endif { CONDDEBUG((1, "TerminalBegin(%s) [%s:%d]", id, file, line)); if (id == (char *)0 || id[0] == '\000') { @@ -289,11 +247,7 @@ TerminalBegin(id) } void -#if PROTOTYPES TerminalEnd(void) -#else -TerminalEnd() -#endif { static char *term = (char *)0; @@ -323,11 +277,7 @@ TerminalEnd() } void -#if PROTOTYPES TerminalAbort(void) -#else -TerminalAbort() -#endif { CONDDEBUG((1, "TerminalAbort() [%s:%d]", file, line)); if (parserTermTemp == (TERM *)0) @@ -338,11 +288,7 @@ TerminalAbort() } void -#if PROTOTYPES TerminalDestroy(void) -#else -TerminalDestroy() -#endif { CONDDEBUG((1, "TerminalDestroy() [%s:%d]", file, line)); @@ -359,13 +305,7 @@ TerminalDestroy() } void -#if PROTOTYPES ProcessYesNo(char *id, FLAG *flag) -#else -ProcessYesNo(id, flag) - char *id; - FLAG *flag; -#endif { if (id == (char *)0 || id[0] == '\000') *flag = FLAGFALSE; @@ -378,12 +318,7 @@ ProcessYesNo(id, flag) } void -#if PROTOTYPES ConfigItemEscape(char *id) -#else -ConfigItemEscape(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemEscape(%s) [%s:%d]", id, file, line)); @@ -399,12 +334,7 @@ ConfigItemEscape(id) } void -#if PROTOTYPES ConfigItemMaster(char *id) -#else -ConfigItemMaster(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemMaster(%s) [%s:%d]", id, file, line)); @@ -420,12 +350,7 @@ ConfigItemMaster(id) } void -#if PROTOTYPES ConfigItemPlayback(char *id) -#else -ConfigItemPlayback(id) - char *id; -#endif { int i; @@ -449,12 +374,7 @@ ConfigItemPlayback(id) } void -#if PROTOTYPES ConfigItemPort(char *id) -#else -ConfigItemPort(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemPort(%s) [%s:%d]", id, file, line)); @@ -470,12 +390,7 @@ ConfigItemPort(id) } void -#if PROTOTYPES ConfigItemReplay(char *id) -#else -ConfigItemReplay(id) - char *id; -#endif { int i; @@ -499,12 +414,7 @@ ConfigItemReplay(id) } void -#if PROTOTYPES ConfigItemSslcredentials(char *id) -#else -ConfigItemSslcredentials(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemSslcredentials(%s) [%s:%d]", id, file, line)); #if HAVE_OPENSSL @@ -525,12 +435,7 @@ ConfigItemSslcredentials(id) } void -#if PROTOTYPES ConfigItemSslcacertificatefile(char *id) -#else -ConfigItemSslcacertificatefile(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemSslcacertificatefile(%s) [%s:%d]", id, file, line)); @@ -552,12 +457,7 @@ ConfigItemSslcacertificatefile(id) } void -#if PROTOTYPES ConfigItemSslcacertificatepath(char *id) -#else -ConfigItemSslcacertificatepath(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemSslcacertificatepath(%s) [%s:%d]", id, file, line)); @@ -579,12 +479,7 @@ ConfigItemSslcacertificatepath(id) } void -#if PROTOTYPES ConfigItemSslrequired(char *id) -#else -ConfigItemSslrequired(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemSslrequired(%s) [%s:%d]", id, file, line)); #if HAVE_OPENSSL @@ -597,12 +492,7 @@ ConfigItemSslrequired(id) } void -#if PROTOTYPES ConfigItemSslenabled(char *id) -#else -ConfigItemSslenabled(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemSslenabled(%s) [%s:%d]", id, file, line)); #if HAVE_OPENSSL @@ -614,24 +504,14 @@ ConfigItemSslenabled(id) } void -#if PROTOTYPES ConfigItemStriphigh(char *id) -#else -ConfigItemStriphigh(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemStriphigh(%s) [%s:%d]", id, file, line)); ProcessYesNo(id, &(parserConfigTemp->striphigh)); } void -#if PROTOTYPES ConfigItemUsername(char *id) -#else -ConfigItemUsername(id) - char *id; -#endif { CONDDEBUG((1, "ConfigItemUsername(%s) [%s:%d]", id, file, line)); @@ -649,12 +529,7 @@ ConfigItemUsername(id) SUBST *substData = (SUBST *)0; SUBSTTOKEN -#if PROTOTYPES SubstToken(char c) -#else -SubstToken(c) - char c; -#endif { switch (c) { case 'u': @@ -666,14 +541,7 @@ SubstToken(c) } int -#if PROTOTYPES SubstValue(char c, char **s, int *i) -#else -SubstValue(c, s, i) - char c; - char **s; - int *i; -#endif { int retval = 0; @@ -696,11 +564,7 @@ SubstValue(c, s, i) } void -#if PROTOTYPES InitSubstCallback(void) -#else -InitSubstCallback() -#endif { if (substData == (SUBST *)0) { if ((substData = (SUBST *)calloc(1, sizeof(SUBST))) == (SUBST *)0) @@ -712,12 +576,7 @@ InitSubstCallback() void -#if PROTOTYPES TerminalItemAttach(char *id) -#else -TerminalItemAttach(id) - char *id; -#endif { CONDDEBUG((1, "TerminalItemAttach(%s) [%s:%d]", id, file, line)); @@ -733,12 +592,7 @@ TerminalItemAttach(id) } void -#if PROTOTYPES TerminalItemAttachsubst(char *id) -#else -TerminalItemAttachsubst(id) - char *id; -#endif { CONDDEBUG((1, "TerminalItemAttachsubst(%s) [%s:%d]", id, file, line)); ProcessSubst(substData, (char **)0, &(parserTermTemp->attachsubst), @@ -746,12 +600,7 @@ TerminalItemAttachsubst(id) } void -#if PROTOTYPES TerminalItemDetach(char *id) -#else -TerminalItemDetach(id) - char *id; -#endif { CONDDEBUG((1, "TerminalItemDetach(%s) [%s:%d]", id, file, line)); @@ -767,12 +616,7 @@ TerminalItemDetach(id) } void -#if PROTOTYPES TerminalItemDetachsubst(char *id) -#else -TerminalItemDetachsubst(id) - char *id; -#endif { CONDDEBUG((1, "TerminalItemDetachsubst(%s) [%s:%d]", id, file, line)); ProcessSubst(substData, (char **)0, &(parserTermTemp->detachsubst), @@ -812,13 +656,7 @@ SECTION sections[] = { }; void -#if PROTOTYPES ReadConf(char *filename, FLAG verbose) -#else -ReadConf(filename, verbose) - char *filename; - FLAG verbose; -#endif { FILE *fp; diff --git a/console/readconf.h b/console/readconf.h index 47b6231..ddc4d9b 100644 --- a/console/readconf.h +++ b/console/readconf.h @@ -1,5 +1,5 @@ /* - * $Id: readconf.h,v 5.6 2013/09/18 14:31:39 bryan Exp $ + * $Id: readconf.h,v 5.7 2014/04/20 06:45:07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -37,6 +37,6 @@ extern CONFIG *pConfig; extern TERM *pTerm; extern SUBST *substData; -extern void ReadConf PARAMS((char *, FLAG)); -extern void DestroyConfig PARAMS((CONFIG *)); -extern void DestroyTerminal PARAMS((TERM *)); +extern void ReadConf(char *, FLAG); +extern void DestroyConfig(CONFIG *); +extern void DestroyTerminal(TERM *); diff --git a/contrib/redhat-rpm/conserver.spec b/contrib/redhat-rpm/conserver.spec index 8ff5273..1ac9731 100644 --- a/contrib/redhat-rpm/conserver.spec +++ b/contrib/redhat-rpm/conserver.spec @@ -4,7 +4,7 @@ # %define pkg conserver -%define ver 8.1.20 +%define ver 8.2.0 # define the name of the machine on which the main conserver # daemon will be running if you don't want to use the default diff --git a/contrib/solaris-package/pkginfo b/contrib/solaris-package/pkginfo index 9a2f79d..8ccacbd 100644 --- a/contrib/solaris-package/pkginfo +++ b/contrib/solaris-package/pkginfo @@ -1,7 +1,7 @@ PKG="conserver" NAME="Console server and client" CATEGORY="system" -VERSION="8.1.20" +VERSION="8.2.0" DESC="Console server and client" CLASSES=none ARCH=sparc