diff options
Diffstat (limited to 'contrib/amd/libamu')
-rw-r--r-- | contrib/amd/libamu/.cvsignore | 1 | ||||
-rw-r--r-- | contrib/amd/libamu/amu.h | 4 | ||||
-rw-r--r-- | contrib/amd/libamu/hasmntopt.c | 4 | ||||
-rw-r--r-- | contrib/amd/libamu/misc_rpc.c | 13 | ||||
-rw-r--r-- | contrib/amd/libamu/mtab.c | 26 | ||||
-rw-r--r-- | contrib/amd/libamu/nfs_prot_xdr.c | 4 | ||||
-rw-r--r-- | contrib/amd/libamu/strerror.c | 68 | ||||
-rw-r--r-- | contrib/amd/libamu/util.c | 4 | ||||
-rw-r--r-- | contrib/amd/libamu/wire.c | 68 | ||||
-rw-r--r-- | contrib/amd/libamu/xdr_func.c | 108 | ||||
-rw-r--r-- | contrib/amd/libamu/xutil.c | 70 |
11 files changed, 182 insertions, 188 deletions
diff --git a/contrib/amd/libamu/.cvsignore b/contrib/amd/libamu/.cvsignore new file mode 100644 index 0000000..70845e0 --- /dev/null +++ b/contrib/amd/libamu/.cvsignore @@ -0,0 +1 @@ +Makefile.in diff --git a/contrib/amd/libamu/amu.h b/contrib/amd/libamu/amu.h index 3769652..e6532fa 100644 --- a/contrib/amd/libamu/amu.h +++ b/contrib/amd/libamu/amu.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2001 Erez Zadok + * Copyright (c) 1997-2003 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: amu.h,v 1.3.2.1 2001/01/10 03:23:38 ezk Exp $ + * $Id: amu.h,v 1.3.2.3 2002/12/27 22:45:11 ezk Exp $ * */ diff --git a/contrib/amd/libamu/hasmntopt.c b/contrib/amd/libamu/hasmntopt.c index 9e76752..843ef2f 100644 --- a/contrib/amd/libamu/hasmntopt.c +++ b/contrib/amd/libamu/hasmntopt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2001 Erez Zadok + * Copyright (c) 1997-2003 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -38,7 +38,7 @@ n * modification, are permitted provided that the following conditions * * %W% (Berkeley) %G% * - * $Id: hasmntopt.c,v 1.3.2.1 2001/01/10 03:23:39 ezk Exp $ + * $Id: hasmntopt.c,v 1.3.2.3 2002/12/27 22:45:11 ezk Exp $ * */ diff --git a/contrib/amd/libamu/misc_rpc.c b/contrib/amd/libamu/misc_rpc.c index 616ceed..ae413c3 100644 --- a/contrib/amd/libamu/misc_rpc.c +++ b/contrib/amd/libamu/misc_rpc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2001 Erez Zadok + * Copyright (c) 1997-2003 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: misc_rpc.c,v 1.4.2.1 2001/01/10 03:23:39 ezk Exp $ + * $Id: misc_rpc.c,v 1.4.2.5 2002/12/29 00:46:43 ib42 Exp $ * */ @@ -127,6 +127,13 @@ make_rpc_packet(char *buf, int buflen, u_long proc, struct rpc_msg *mp, voidp ar { XDR msg_xdr; int len; + /* + * Never cast pointers between different integer types, it breaks badly + * on big-endian platforms if those types have different sizes. + * + * Cast to a local variable instead, and use that variable's address. + */ + enum_t local_proc = (enum_t) proc; xdrmem_create(&msg_xdr, buf, buflen, XDR_ENCODE); @@ -139,7 +146,7 @@ make_rpc_packet(char *buf, int buflen, u_long proc, struct rpc_msg *mp, voidp ar /* * Called procedure number */ - if (!xdr_enum(&msg_xdr, (enum_t *) & proc)) + if (!xdr_enum(&msg_xdr, &local_proc)) return -EIO; /* diff --git a/contrib/amd/libamu/mtab.c b/contrib/amd/libamu/mtab.c index 1fb3a33..eab87b3 100644 --- a/contrib/amd/libamu/mtab.c +++ b/contrib/amd/libamu/mtab.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2001 Erez Zadok + * Copyright (c) 1997-2003 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: mtab.c,v 1.3.2.3 2001/04/14 21:08:25 ezk Exp $ + * $Id: mtab.c,v 1.3.2.7 2002/12/27 22:45:12 ezk Exp $ * */ @@ -60,11 +60,11 @@ mnt_free(mntent_t *mp) XFREE(mp->mnt_type); XFREE(mp->mnt_opts); -#ifdef HAVE_FIELD_MNTENT_T_MNT_TIME -# ifdef HAVE_FIELD_MNTENT_T_MNT_TIME_STRING +#ifdef HAVE_MNTENT_T_MNT_TIME +# ifdef HAVE_MNTENT_T_MNT_TIME_STRING XFREE(mp->mnt_time); -# endif /* HAVE_FIELD_MNTENT_T_MNT_TIME_STRING */ -#endif /* HAVE_FIELD_MNTENT_T_MNT_TIME */ +# endif /* HAVE_MNTENT_T_MNT_TIME_STRING */ +#endif /* HAVE_MNTENT_T_MNT_TIME */ XFREE(mp); } @@ -154,22 +154,24 @@ hasmntval(mntent_t *mnt, char *opt) if (eq) { /* and had an = after it */ char *endptr = NULL; - long int i = strtol(eq,&endptr,0); /* hex and octal allowed ;-) */ + long int i = strtol(eq, &endptr, 0); /* hex and octal allowed ;-) */ - if ( (! endptr) || /* endptr == NULL means all chars valid */ + if (!endptr || /* * endptr set means strtol saw a non-digit. If the * non-digit is a comma, it's probably the start of the next * option. If the comma is the first char though, complain about * it (foo=,bar is made noticeable by this). + * + * Similar reasoning for '\0' instead of comma, it's the end + * of the string. */ - ((endptr == strchr(eq, ',')) && (endptr != eq)) - ) + (endptr != eq && (*endptr == ',' || *endptr == '\0'))) return((int) i); - /* whatever was after = wasn't a number */ + /* whatever was after the '=' sign wasn't a number */ plog(XLOG_MAP, "invalid numeric option in \"%s\": \"%s\"", opt, str); } else { - /* No argument to option (= was missing) */ + /* No argument to option ('=' sign was missing) */ plog(XLOG_MAP, "numeric option to \"%s\" missing", opt); } } diff --git a/contrib/amd/libamu/nfs_prot_xdr.c b/contrib/amd/libamu/nfs_prot_xdr.c index c126471..9a3ff9a 100644 --- a/contrib/amd/libamu/nfs_prot_xdr.c +++ b/contrib/amd/libamu/nfs_prot_xdr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2001 Erez Zadok + * Copyright (c) 1997-2003 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: nfs_prot_xdr.c,v 1.3.2.1 2001/01/10 03:23:40 ezk Exp $ + * $Id: nfs_prot_xdr.c,v 1.3.2.3 2002/12/27 22:45:12 ezk Exp $ * */ diff --git a/contrib/amd/libamu/strerror.c b/contrib/amd/libamu/strerror.c new file mode 100644 index 0000000..7c230bc --- /dev/null +++ b/contrib/amd/libamu/strerror.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2002-2003 Ion Badulescu + * Copyright (c) 1997-2003 Erez Zadok + * Copyright (c) 1990 Jan-Simon Pendry + * Copyright (c) 1990 Imperial College of Science, Technology & Medicine + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry at Imperial College, London. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgment: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * + * $Id: strerror.c,v 1.2.2.2 2002/12/27 22:45:13 ezk Exp $ + * + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ +#include <am_defs.h> +#include <amu.h> + + +/* + * Convert errno to a string + */ +char * +strerror(int errnum) +{ +#ifdef HAVE_EXTERN_SYS_ERRLIST + if (errnum < 0 || errnum >= (sizeof(sys_errlist) >> 2)) { + static char errstr[30]; + sprintf(errstr, "Unknown error #%d", errnum); + return errstr; + } + return sys_errlist[error]; +#else /* not HAVE_EXTERN_SYS_ERRLIST */ + return "unknown (strerror not available)"; +#endif /* not HAVE_EXTERN_SYS_ERRLIST */ +} diff --git a/contrib/amd/libamu/util.c b/contrib/amd/libamu/util.c index ff84997..e9b83ed 100644 --- a/contrib/amd/libamu/util.c +++ b/contrib/amd/libamu/util.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2001 Erez Zadok + * Copyright (c) 1997-2003 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: util.c,v 1.3.2.1 2001/01/10 03:23:41 ezk Exp $ + * $Id: util.c,v 1.3.2.3 2002/12/27 22:45:13 ezk Exp $ * */ diff --git a/contrib/amd/libamu/wire.c b/contrib/amd/libamu/wire.c index 25a4427..649b336 100644 --- a/contrib/amd/libamu/wire.c +++ b/contrib/amd/libamu/wire.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2001 Erez Zadok + * Copyright (c) 1997-2003 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: wire.c,v 1.8.2.5 2001/01/10 03:23:41 ezk Exp $ + * $Id: wire.c,v 1.8.2.9 2002/12/27 22:45:13 ezk Exp $ * */ @@ -304,9 +304,51 @@ is_network_member(const char *net) { addrlist *al; - for (al = localnets; al; al = al->ip_next) - if (STREQ(net, al->ip_net_name) || STREQ(net, al->ip_net_num)) - return TRUE; + /* + * If the network name string does not contain a '/', use old behavior. + * If it does contain a '/' then interpret the string as a network/netmask + * pair. If "netmask" doesn't exist, use the interface's own netmask. + * Also support fully explicit netmasks such as 255.255.255.0 as well as + * bit-length netmask such as /24 (hex formats such 0xffffff00 work too). + */ + if (strchr(net, '/') == NULL) { + for (al = localnets; al; al = al->ip_next) + if (STREQ(net, al->ip_net_name) || STREQ(net, al->ip_net_num)) + return TRUE; + } else { + char *netstr = strdup(net), *maskstr; + u_long netnum, masknum = 0; + maskstr = strchr(netstr, '/'); + maskstr++; + maskstr[-1] = '\0'; /* null terminate netstr */ + if (*maskstr == '\0') /* if empty string, make it NULL */ + maskstr = NULL; + /* check if netmask uses a dotted-quad or bit-length, or not defined at all */ + if (maskstr) { + if (strchr(maskstr, '.')) { + masknum = inet_addr(maskstr); + if (masknum < 0) /* can be invalid (-1) or all-1s */ + masknum = 0xffffffff; + } else if (NSTRCEQ(maskstr, "0x", 2)) { + masknum = strtoul(maskstr, NULL, 16); + } else { + int bits = atoi(maskstr); + if (bits < 0) + bits = 0; + if (bits > 32) + bits = 32; + masknum = 0xffffffff << (32-bits); + } + } + netnum = inet_addr(netstr); /* not checking return value, b/c -1 (0xffffffff) is valid */ + XFREE(netstr); /* netstr not needed any longer */ + + /* now check against each local interface */ + for (al = localnets; al; al = al->ip_next) { + if ((al->ip_addr & (maskstr ? masknum : al->ip_mask)) == netnum) + return TRUE; + } + } return FALSE; } @@ -318,22 +360,22 @@ getwire(char **name1, char **number1) { addrlist *al = NULL, *tail = NULL; struct ifaddrs *ifaddrs, *ifap; -#ifndef HAVE_FIELD_STRUCT_IFADDRS_IFA_NEXT +#ifndef HAVE_STRUCT_IFADDRS_IFA_NEXT int count = 0, i; -#endif /* not HAVE_FIELD_STRUCT_IFADDRS_IFA_NEXT */ +#endif /* not HAVE_STRUCT_IFADDRS_IFA_NEXT */ ifaddrs = NULL; -#ifdef HAVE_FIELD_STRUCT_IFADDRS_IFA_NEXT +#ifdef HAVE_STRUCT_IFADDRS_IFA_NEXT if (getifaddrs(&ifaddrs) < 0) goto out; for (ifap = ifaddrs; ifap != NULL; ifap = ifap->ifa_next) { -#else /* not HAVE_FIELD_STRUCT_IFADDRS_IFA_NEXT */ +#else /* not HAVE_STRUCT_IFADDRS_IFA_NEXT */ if (getifaddrs(&ifaddrs, &count) < 0) goto out; for (i = 0,ifap = ifaddrs; i < count; ifap++, i++) { -#endif /* HAVE_FIELD_STRUCT_IFADDRS_IFA_NEXT */ +#endif /* HAVE_STRUCT_IFADDRS_IFA_NEXT */ if (!ifap || !ifap->ifa_addr || ifap->ifa_addr->sa_family != AF_INET) continue; @@ -377,11 +419,11 @@ out: #else /* not HAVE_GETIFADDRS */ -#if defined(HAVE_FIELD_STRUCT_IFREQ_IFR_ADDR) && defined(HAVE_FIELD_STRUCT_SOCKADDR_SA_LEN) +#if defined(HAVE_STRUCT_IFREQ_IFR_ADDR) && defined(HAVE_STRUCT_SOCKADDR_SA_LEN) # define SIZE(ifr) (MAX((ifr)->ifr_addr.sa_len, sizeof((ifr)->ifr_addr)) + sizeof(ifr->ifr_name)) -#else /* not defined(HAVE_FIELD_STRUCT_IFREQ_IFR_ADDR) && defined(HAVE_FIELD_STRUCT_SOCKADDR_SA_LEN) */ +#else /* not defined(HAVE_STRUCT_IFREQ_IFR_ADDR) && defined(HAVE_STRUCT_SOCKADDR_SA_LEN) */ # define SIZE(ifr) sizeof(struct ifreq) -#endif /* not defined(HAVE_FIELD_STRUCT_IFREQ_IFR_ADDR) && defined(HAVE_FIELD_STRUCT_SOCKADDR_SA_LEN) */ +#endif /* not defined(HAVE_STRUCT_IFREQ_IFR_ADDR) && defined(HAVE_STRUCT_SOCKADDR_SA_LEN) */ #define clist (ifc.ifc_ifcu.ifcu_req) #define count (ifc.ifc_len/sizeof(struct ifreq)) diff --git a/contrib/amd/libamu/xdr_func.c b/contrib/amd/libamu/xdr_func.c index 1e8085d..eed657c 100644 --- a/contrib/amd/libamu/xdr_func.c +++ b/contrib/amd/libamu/xdr_func.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2001 Erez Zadok + * Copyright (c) 1997-2003 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: xdr_func.c,v 1.4.2.4 2001/02/02 18:28:27 ezk Exp $ + * $Id: xdr_func.c,v 1.4.2.7 2002/12/27 22:45:14 ezk Exp $ * */ @@ -55,17 +55,6 @@ /* * MACROS: */ -#ifdef HAVE_FS_AUTOFS -# ifndef A_MAXNAME -# define A_MAXNAME 255 -# endif /* not A_MAXNAME */ -# ifndef A_MAXOPTS -# define A_MAXOPTS 255 -# endif /* not A_MAXOPTS */ -# ifndef A_MAXPATH -# define A_MAXPATH 1024 -# endif /* not A_MAXPATH */ -#endif /* HAVE_FS_AUTOFS */ /* forward definitions, are they needed? */ extern bool_t xdr_exportnode(XDR *xdrs, exportnode *objp); @@ -1053,96 +1042,3 @@ xdr_writeargs(XDR *xdrs, nfswriteargs *objp) return (TRUE); } #endif /* not HAVE_XDR_WRITEARGS */ - - -/* - * AUTOFS XDR FUNCTIONS: - */ -#ifdef HAVE_FS_AUTOFS -# ifndef HAVE_XDR_MNTREQUEST -bool_t -xdr_mntrequest(XDR *xdrs, mntrequest *objp) -{ -#ifdef DEBUG - amuDebug(D_XDRTRACE) - plog(XLOG_DEBUG, "xdr_mntrequest:"); -#endif /* DEBUG */ - - if (!xdr_string(xdrs, &objp->name, A_MAXNAME)) - return (FALSE); - - if (!xdr_string(xdrs, &objp->map, A_MAXNAME)) - return (FALSE); - - if (!xdr_string(xdrs, &objp->opts, A_MAXOPTS)) - return (FALSE); - - if (!xdr_string(xdrs, &objp->path, A_MAXPATH)) - return (FALSE); - - return (TRUE); -} -# endif /* not HAVE_XDR_MNTREQUEST */ - - -# ifndef HAVE_XDR_MNTRES -bool_t -xdr_mntres(XDR *xdrs, mntres *objp) -{ -#ifdef DEBUG - amuDebug(D_XDRTRACE) - plog(XLOG_DEBUG, "xdr_mntres:"); -#endif /* DEBUG */ - - if (!xdr_int(xdrs, &objp->status)) - return (FALSE); - - return (TRUE); -} -# endif /* not HAVE_XDR_MNTRES */ - - -# ifndef HAVE_XDR_UMNTREQUEST -bool_t -xdr_umntrequest(XDR *xdrs, umntrequest *objp) -{ -#ifdef DEBUG - amuDebug(D_XDRTRACE) - plog(XLOG_DEBUG, "xdr_umntrequest:"); -#endif /* DEBUG */ - - if (!xdr_int(xdrs, &objp->isdirect)) - return (FALSE); - - if (!xdr_u_int(xdrs, (u_int *) &objp->devid)) - return (FALSE); - -#ifdef HAVE_FIELD_UMNTREQUEST_RDEVID - if (!xdr_u_long(xdrs, &objp->rdevid)) - return (FALSE); -#endif /* HAVE_FIELD_UMNTREQUEST_RDEVID */ - - if (!xdr_pointer(xdrs, (char **) &objp->next, sizeof(umntrequest), (XDRPROC_T_TYPE) xdr_umntrequest)) - return (FALSE); - - return (TRUE); -} -# endif /* not HAVE_XDR_UMNTREQUEST */ - - -# ifndef HAVE_XDR_UMNTRES -bool_t -xdr_umntres(XDR *xdrs, umntres *objp) -{ -#ifdef DEBUG - amuDebug(D_XDRTRACE) - plog(XLOG_DEBUG, "xdr_mntres:"); -#endif /* DEBUG */ - - if (!xdr_int(xdrs, &objp->status)) - return (FALSE); - - return (TRUE); -} -# endif /* not HAVE_XDR_UMNTRES */ -#endif /* HAVE_FS_AUTOFS */ diff --git a/contrib/amd/libamu/xutil.c b/contrib/amd/libamu/xutil.c index 998d0d8..ca571b6 100644 --- a/contrib/amd/libamu/xutil.c +++ b/contrib/amd/libamu/xutil.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2001 Erez Zadok + * Copyright (c) 1997-2003 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: xutil.c,v 1.11.2.6 2001/01/10 03:23:41 ezk Exp $ + * $Id: xutil.c,v 1.11.2.12 2003/04/04 15:53:35 ezk Exp $ * */ @@ -80,11 +80,10 @@ static int orig_mem_bytes; #endif /* DEBUG_MEM */ /* forward definitions */ +/* for GCC format string auditing */ static void real_plog(int lvl, const char *fmt, va_list vargs) __attribute__((__format__(__printf__, 2, 0))); -/* for GCC format string auditing */ -static const char *expand_error(const char *f, char *e, int maxlen) - __attribute__((__format_arg__(1))); + #ifdef DEBUG /* @@ -292,15 +291,6 @@ checkup_mem(void) static const char * expand_error(const char *f, char *e, int maxlen) { -#ifndef HAVE_STRERROR - /* - * XXX: we are assuming that if a system doesn't has strerror, - * then it has sys_nerr. If this assumption turns out to be wrong on - * some systems, we'll have to write a separate test to detect if - * a system has sys_nerr. -Erez - */ - extern int sys_nerr; -#endif /* not HAVE_STRERROR */ const char *p; char *q; int error = errno; @@ -308,23 +298,7 @@ expand_error(const char *f, char *e, int maxlen) for (p = f, q = e; (*q = *p) && len < maxlen; len++, q++, p++) { if (p[0] == '%' && p[1] == 'm') { - const char *errstr; -#ifdef HAVE_STRERROR - if (error < 0) -#else /* not HAVE_STRERROR */ - if (error < 0 || error >= sys_nerr) -#endif /* not HAVE_STRERROR */ - errstr = NULL; - else -#ifdef HAVE_STRERROR - errstr = strerror(error); -#else /* not HAVE_STRERROR */ - errstr = sys_errlist[error]; -#endif /* not HAVE_STRERROR */ - if (errstr) - strcpy(q, errstr); - else - sprintf(q, "Error %d", error); + strcpy(q, strerror(error)); len += strlen(q) - 1; q += strlen(q) - 1; p++; @@ -851,7 +825,11 @@ switch_to_logfile(char *logfile, int old_umask) (void) fclose(logfp); logfp = new_logfp; - plog(XLOG_INFO, "switched to logfile \"%s\"", logfile); + if (logfile) + plog(XLOG_INFO, "switched to logfile \"%s\"", logfile); + else + plog(XLOG_INFO, "no logfile defined; using stderr"); + return 0; } @@ -923,24 +901,14 @@ amu_release_controlling_tty(void) #endif /* TIOCNOTTY */ int tempfd; -#ifdef HAVE_SETSID - /* XXX: one day maybe use vhangup(2) */ - if (setsid() < 0) { - plog(XLOG_WARNING, "Could not release controlling tty using setsid(): %m"); - } else { - plog(XLOG_INFO, "released controlling tty using setsid()"); - return; - } -#endif /* HAVE_SETSID */ - /* * In daemon mode, leaving open file descriptors to terminals or pipes * can be a really bad idea. * Case in point: the redhat startup script calls us through their 'initlog' - * program, which exits as soon as the original amd process exits. If, at some - * point, a misbehaved library function decides to print something to the screen, - * we get a SIGPIPE and die. - * More precisely: NIS libc functions will attempt to print to stderr + * program, which exits as soon as the original amd process exits. If, + * at some point, a misbehaved library function decides to print something + * to the screen, we get a SIGPIPE and die. + * And guess what: NIS glibc functions will attempt to print to stderr * "YPBINDPROC_DOMAIN: Domain not bound" if ypbind is running but can't find * a ypserver. * @@ -955,6 +923,16 @@ amu_release_controlling_tty(void) fflush(stderr); close(2); dup2(tempfd, 2); close(tempfd); +#ifdef HAVE_SETSID + /* XXX: one day maybe use vhangup(2) */ + if (setsid() < 0) { + plog(XLOG_WARNING, "Could not release controlling tty using setsid(): %m"); + } else { + plog(XLOG_INFO, "released controlling tty using setsid()"); + return; + } +#endif /* HAVE_SETSID */ + #ifdef TIOCNOTTY fd = open("/dev/tty", O_RDWR); if (fd < 0) { |