Home | History | Annotate | Line # | Download | only in mtree
getid.c revision 1.2
      1  1.2  lukem /*	$NetBSD: getid.c,v 1.2 2002/01/29 00:29:32 lukem Exp $	*/
      2  1.1  lukem /*	from: NetBSD: getpwent.c,v 1.48 2000/10/03 03:22:26 enami Exp */
      3  1.1  lukem /*	from: NetBSD: getgrent.c,v 1.41 2002/01/12 23:51:30 lukem Exp */
      4  1.1  lukem 
      5  1.1  lukem /*
      6  1.1  lukem  * Copyright (c) 1987, 1988, 1989, 1993, 1994, 1995
      7  1.1  lukem  *	The Regents of the University of California.  All rights reserved.
      8  1.1  lukem  *
      9  1.1  lukem  * Redistribution and use in source and binary forms, with or without
     10  1.1  lukem  * modification, are permitted provided that the following conditions
     11  1.1  lukem  * are met:
     12  1.1  lukem  * 1. Redistributions of source code must retain the above copyright
     13  1.1  lukem  *    notice, this list of conditions and the following disclaimer.
     14  1.1  lukem  * 2. Redistributions in binary form must reproduce the above copyright
     15  1.1  lukem  *    notice, this list of conditions and the following disclaimer in the
     16  1.1  lukem  *    documentation and/or other materials provided with the distribution.
     17  1.1  lukem  * 3. All advertising materials mentioning features or use of this software
     18  1.1  lukem  *    must display the following acknowledgement:
     19  1.1  lukem  *	This product includes software developed by the University of
     20  1.1  lukem  *	California, Berkeley and its contributors.
     21  1.1  lukem  * 4. Neither the name of the University nor the names of its contributors
     22  1.1  lukem  *    may be used to endorse or promote products derived from this software
     23  1.1  lukem  *    without specific prior written permission.
     24  1.1  lukem  *
     25  1.1  lukem  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     26  1.1  lukem  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     27  1.1  lukem  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     28  1.1  lukem  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     29  1.1  lukem  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     30  1.1  lukem  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     31  1.1  lukem  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     32  1.1  lukem  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     33  1.1  lukem  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     34  1.1  lukem  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     35  1.1  lukem  * SUCH DAMAGE.
     36  1.1  lukem  */
     37  1.1  lukem 
     38  1.1  lukem /*-
     39  1.1  lukem  * Copyright (c) 2002 The NetBSD Foundation, Inc.
     40  1.1  lukem  * All rights reserved.
     41  1.1  lukem  *
     42  1.1  lukem  * This code is derived from software contributed to The NetBSD Foundation
     43  1.1  lukem  * by Luke Mewburn of Wasabi Systems.
     44  1.1  lukem  *
     45  1.1  lukem  * Redistribution and use in source and binary forms, with or without
     46  1.1  lukem  * modification, are permitted provided that the following conditions
     47  1.1  lukem  * are met:
     48  1.1  lukem  * 1. Redistributions of source code must retain the above copyright
     49  1.1  lukem  *    notice, this list of conditions and the following disclaimer.
     50  1.1  lukem  * 2. Redistributions in binary form must reproduce the above copyright
     51  1.1  lukem  *    notice, this list of conditions and the following disclaimer in the
     52  1.1  lukem  *    documentation and/or other materials provided with the distribution.
     53  1.1  lukem  * 3. All advertising materials mentioning features or use of this software
     54  1.1  lukem  *    must display the following acknowledgement:
     55  1.1  lukem  *        This product includes software developed by the NetBSD
     56  1.1  lukem  *        Foundation, Inc. and its contributors.
     57  1.1  lukem  * 4. Neither the name of The NetBSD Foundation nor the names of its
     58  1.1  lukem  *    contributors may be used to endorse or promote products derived
     59  1.1  lukem  *    from this software without specific prior written permission.
     60  1.1  lukem  *
     61  1.1  lukem  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     62  1.1  lukem  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     63  1.1  lukem  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     64  1.1  lukem  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     65  1.1  lukem  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     66  1.1  lukem  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     67  1.1  lukem  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     68  1.1  lukem  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     69  1.1  lukem  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     70  1.1  lukem  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     71  1.1  lukem  * POSSIBILITY OF SUCH DAMAGE.
     72  1.1  lukem  */
     73  1.1  lukem 
     74  1.1  lukem #include <sys/param.h>
     75  1.1  lukem 
     76  1.1  lukem #include <grp.h>
     77  1.1  lukem #include <limits.h>
     78  1.1  lukem #include <pwd.h>
     79  1.1  lukem #include <stdlib.h>
     80  1.1  lukem #include <stdio.h>
     81  1.1  lukem #include <string.h>
     82  1.1  lukem #include <time.h>
     83  1.1  lukem #include <unistd.h>
     84  1.1  lukem 
     85  1.1  lukem #include "mtree.h"
     86  1.1  lukem 
     87  1.1  lukem static	struct group *	gi_getgrnam(const char *);
     88  1.1  lukem static	struct group *	gi_getgrgid(gid_t);
     89  1.1  lukem static	int		gi_setgroupent(int);
     90  1.1  lukem static	void		gi_endgrent(void);
     91  1.1  lukem static	int		grstart(void);
     92  1.1  lukem static	int		grscan(int, gid_t, const char *);
     93  1.1  lukem static	int		grmatchline(int, gid_t, const char *);
     94  1.1  lukem 
     95  1.1  lukem static	struct passwd *	gi_getpwnam(const char *);
     96  1.1  lukem static	struct passwd *	gi_getpwuid(uid_t);
     97  1.1  lukem static	int		gi_setpassent(int);
     98  1.1  lukem static	void		gi_endpwent(void);
     99  1.1  lukem static	int		pwstart(void);
    100  1.1  lukem static	int		pwscan(int, uid_t, const char *);
    101  1.1  lukem static	int		pwmatchline(int, uid_t, const char *);
    102  1.1  lukem 
    103  1.1  lukem #define	MAXGRP		200
    104  1.1  lukem #define	MAXLINELENGTH	1024
    105  1.1  lukem 
    106  1.1  lukem static	FILE		*_gr_fp;
    107  1.1  lukem static	struct group	_gr_group;
    108  1.1  lukem static	int		_gr_stayopen;
    109  1.1  lukem static	int		_gr_filesdone;
    110  1.1  lukem static	FILE		*_pw_fp;
    111  1.1  lukem static	struct passwd	_pw_passwd;	/* password structure */
    112  1.1  lukem static	int		_pw_stayopen;	/* keep fd's open */
    113  1.1  lukem static	int		_pw_filesdone;
    114  1.1  lukem 
    115  1.2  lukem static	char		grfile[MAXPATHLEN];
    116  1.2  lukem static	char		pwfile[MAXPATHLEN];
    117  1.1  lukem 
    118  1.1  lukem static	char		*members[MAXGRP];
    119  1.1  lukem static	char		grline[MAXLINELENGTH];
    120  1.1  lukem static	char		pwline[MAXLINELENGTH];
    121  1.1  lukem 
    122  1.1  lukem int
    123  1.1  lukem setup_getid(const char *dir)
    124  1.1  lukem {
    125  1.1  lukem 	if (dir == NULL)
    126  1.1  lukem 		return (0);
    127  1.1  lukem 
    128  1.1  lukem 				/* close existing databases */
    129  1.1  lukem 	gi_endgrent();
    130  1.1  lukem 	gi_endpwent();
    131  1.1  lukem 
    132  1.1  lukem 				/* build paths to new databases */
    133  1.1  lukem 	snprintf(grfile, sizeof(grfile), "%s/group", dir);
    134  1.1  lukem 	snprintf(pwfile, sizeof(pwfile), "%s/master.passwd", dir);
    135  1.1  lukem 
    136  1.1  lukem 				/* try to open new databases */
    137  1.1  lukem 	if (!grstart() || !pwstart())
    138  1.1  lukem 		return (0);
    139  1.1  lukem 
    140  1.1  lukem 				/* switch pwcache(3) lookup functions */
    141  1.1  lukem 	if (pwcache_groupdb(gi_setgroupent, gi_endgrent,
    142  1.1  lukem 			    gi_getgrnam, gi_getgrgid) == -1
    143  1.1  lukem 	    || pwcache_userdb(gi_setpassent, gi_endpwent,
    144  1.1  lukem 			    gi_getpwnam, gi_getpwuid) == -1)
    145  1.1  lukem 		return (0);
    146  1.1  lukem 
    147  1.1  lukem 	return (1);
    148  1.1  lukem }
    149  1.1  lukem 
    150  1.1  lukem 
    151  1.1  lukem /*
    152  1.1  lukem  * group lookup functions
    153  1.1  lukem  */
    154  1.1  lukem 
    155  1.1  lukem static struct group *
    156  1.1  lukem gi_getgrnam(const char *name)
    157  1.1  lukem {
    158  1.1  lukem 	int rval;
    159  1.1  lukem 
    160  1.1  lukem 	if (!grstart())
    161  1.1  lukem 		return NULL;
    162  1.1  lukem 	rval = grscan(1, 0, name);
    163  1.1  lukem 	if (!_gr_stayopen)
    164  1.1  lukem 		endgrent();
    165  1.1  lukem 	return (rval) ? &_gr_group : NULL;
    166  1.1  lukem }
    167  1.1  lukem 
    168  1.1  lukem static struct group *
    169  1.1  lukem gi_getgrgid(gid_t gid)
    170  1.1  lukem {
    171  1.1  lukem 	int rval;
    172  1.1  lukem 
    173  1.1  lukem 	if (!grstart())
    174  1.1  lukem 		return NULL;
    175  1.1  lukem 	rval = grscan(1, gid, NULL);
    176  1.1  lukem 	if (!_gr_stayopen)
    177  1.1  lukem 		endgrent();
    178  1.1  lukem 	return (rval) ? &_gr_group : NULL;
    179  1.1  lukem }
    180  1.1  lukem 
    181  1.1  lukem static int
    182  1.1  lukem gi_setgroupent(int stayopen)
    183  1.1  lukem {
    184  1.1  lukem 
    185  1.1  lukem 	if (!grstart())
    186  1.1  lukem 		return 0;
    187  1.1  lukem 	_gr_stayopen = stayopen;
    188  1.1  lukem 	return 1;
    189  1.1  lukem }
    190  1.1  lukem 
    191  1.1  lukem static void
    192  1.1  lukem gi_endgrent(void)
    193  1.1  lukem {
    194  1.1  lukem 
    195  1.1  lukem 	_gr_filesdone = 0;
    196  1.1  lukem 	if (_gr_fp) {
    197  1.1  lukem 		(void)fclose(_gr_fp);
    198  1.1  lukem 		_gr_fp = NULL;
    199  1.1  lukem 	}
    200  1.1  lukem }
    201  1.1  lukem 
    202  1.1  lukem static int
    203  1.1  lukem grstart(void)
    204  1.1  lukem {
    205  1.1  lukem 
    206  1.1  lukem 	_gr_filesdone = 0;
    207  1.1  lukem 	if (_gr_fp) {
    208  1.1  lukem 		rewind(_gr_fp);
    209  1.1  lukem 		return 1;
    210  1.1  lukem 	}
    211  1.2  lukem 	if (grfile[0] == '\0')			/* sanity check */
    212  1.2  lukem 		return 0;
    213  1.1  lukem 	return (_gr_fp = fopen(grfile, "r")) ? 1 : 0;
    214  1.1  lukem }
    215  1.1  lukem 
    216  1.1  lukem 
    217  1.1  lukem static int
    218  1.1  lukem grscan(int search, gid_t gid, const char *name)
    219  1.1  lukem {
    220  1.1  lukem 
    221  1.1  lukem 	if (_gr_filesdone)
    222  1.1  lukem 		return 0;
    223  1.1  lukem 	for (;;) {
    224  1.1  lukem 		if (!fgets(grline, sizeof(grline), _gr_fp)) {
    225  1.1  lukem 			if (!search)
    226  1.1  lukem 				_gr_filesdone = 1;
    227  1.1  lukem 			return 0;
    228  1.1  lukem 		}
    229  1.1  lukem 		/* skip lines that are too big */
    230  1.1  lukem 		if (!strchr(grline, '\n')) {
    231  1.1  lukem 			int ch;
    232  1.1  lukem 
    233  1.1  lukem 			while ((ch = getc(_gr_fp)) != '\n' && ch != EOF)
    234  1.1  lukem 				;
    235  1.1  lukem 			continue;
    236  1.1  lukem 		}
    237  1.1  lukem 		if (grmatchline(search, gid, name))
    238  1.1  lukem 			return 1;
    239  1.1  lukem 	}
    240  1.1  lukem 	/* NOTREACHED */
    241  1.1  lukem }
    242  1.1  lukem 
    243  1.1  lukem static int
    244  1.1  lukem grmatchline(int search, gid_t gid, const char *name)
    245  1.1  lukem {
    246  1.1  lukem 	unsigned long	id;
    247  1.1  lukem 	char		**m;
    248  1.1  lukem 	char		*cp, *bp, *ep;
    249  1.1  lukem 
    250  1.1  lukem 	/* name may be NULL if search is nonzero */
    251  1.1  lukem 
    252  1.1  lukem 	bp = grline;
    253  1.1  lukem 	memset(&_gr_group, 0, sizeof(_gr_group));
    254  1.1  lukem 	_gr_group.gr_name = strsep(&bp, ":\n");
    255  1.1  lukem 	if (search && name && strcmp(_gr_group.gr_name, name))
    256  1.1  lukem 		return 0;
    257  1.1  lukem 	_gr_group.gr_passwd = strsep(&bp, ":\n");
    258  1.1  lukem 	if (!(cp = strsep(&bp, ":\n")))
    259  1.1  lukem 		return 0;
    260  1.1  lukem 	id = strtoul(cp, &ep, 10);
    261  1.1  lukem 	if (id > GID_MAX || *ep != '\0')
    262  1.1  lukem 		return 0;
    263  1.1  lukem 	_gr_group.gr_gid = (gid_t)id;
    264  1.1  lukem 	if (search && name == NULL && _gr_group.gr_gid != gid)
    265  1.1  lukem 		return 0;
    266  1.1  lukem 	cp = NULL;
    267  1.1  lukem 	if (bp == NULL)
    268  1.1  lukem 		return 0;
    269  1.1  lukem 	for (_gr_group.gr_mem = m = members;; bp++) {
    270  1.1  lukem 		if (m == &members[MAXGRP - 1])
    271  1.1  lukem 			break;
    272  1.1  lukem 		if (*bp == ',') {
    273  1.1  lukem 			if (cp) {
    274  1.1  lukem 				*bp = '\0';
    275  1.1  lukem 				*m++ = cp;
    276  1.1  lukem 				cp = NULL;
    277  1.1  lukem 			}
    278  1.1  lukem 		} else if (*bp == '\0' || *bp == '\n' || *bp == ' ') {
    279  1.1  lukem 			if (cp) {
    280  1.1  lukem 				*bp = '\0';
    281  1.1  lukem 				*m++ = cp;
    282  1.1  lukem 			}
    283  1.1  lukem 			break;
    284  1.1  lukem 		} else if (cp == NULL)
    285  1.1  lukem 			cp = bp;
    286  1.1  lukem 	}
    287  1.1  lukem 	*m = NULL;
    288  1.1  lukem 	return 1;
    289  1.1  lukem }
    290  1.1  lukem 
    291  1.1  lukem 
    292  1.1  lukem /*
    293  1.1  lukem  * user lookup functions
    294  1.1  lukem  */
    295  1.1  lukem 
    296  1.1  lukem static struct passwd *
    297  1.1  lukem gi_getpwnam(const char *name)
    298  1.1  lukem {
    299  1.1  lukem 	int rval;
    300  1.1  lukem 
    301  1.1  lukem 	if (!pwstart())
    302  1.1  lukem 		return NULL;
    303  1.1  lukem 	rval = pwscan(1, 0, name);
    304  1.1  lukem 	if (!_pw_stayopen)
    305  1.1  lukem 		endpwent();
    306  1.1  lukem 	return (rval) ? &_pw_passwd : NULL;
    307  1.1  lukem }
    308  1.1  lukem 
    309  1.1  lukem static struct passwd *
    310  1.1  lukem gi_getpwuid(uid_t uid)
    311  1.1  lukem {
    312  1.1  lukem 	int rval;
    313  1.1  lukem 
    314  1.1  lukem 	if (!pwstart())
    315  1.1  lukem 		return NULL;
    316  1.1  lukem 	rval = pwscan(1, uid, NULL);
    317  1.1  lukem 	if (!_pw_stayopen)
    318  1.1  lukem 		endpwent();
    319  1.1  lukem 	return (rval) ? &_pw_passwd : NULL;
    320  1.1  lukem }
    321  1.1  lukem 
    322  1.1  lukem static int
    323  1.1  lukem gi_setpassent(int stayopen)
    324  1.1  lukem {
    325  1.1  lukem 
    326  1.1  lukem 	if (!pwstart())
    327  1.1  lukem 		return 0;
    328  1.1  lukem 	_pw_stayopen = stayopen;
    329  1.1  lukem 	return 1;
    330  1.1  lukem }
    331  1.1  lukem 
    332  1.1  lukem static void
    333  1.1  lukem gi_endpwent(void)
    334  1.1  lukem {
    335  1.1  lukem 
    336  1.1  lukem 	_pw_filesdone = 0;
    337  1.1  lukem 	if (_pw_fp) {
    338  1.1  lukem 		(void)fclose(_pw_fp);
    339  1.1  lukem 		_pw_fp = NULL;
    340  1.1  lukem 	}
    341  1.1  lukem }
    342  1.1  lukem 
    343  1.1  lukem static int
    344  1.1  lukem pwstart(void)
    345  1.1  lukem {
    346  1.1  lukem 
    347  1.1  lukem 	_pw_filesdone = 0;
    348  1.1  lukem 	if (_pw_fp) {
    349  1.1  lukem 		rewind(_pw_fp);
    350  1.1  lukem 		return 1;
    351  1.1  lukem 	}
    352  1.2  lukem 	if (pwfile[0] == '\0')			/* sanity check */
    353  1.2  lukem 		return 0;
    354  1.1  lukem 	return (_pw_fp = fopen(pwfile, "r")) ? 1 : 0;
    355  1.1  lukem }
    356  1.1  lukem 
    357  1.1  lukem 
    358  1.1  lukem static int
    359  1.1  lukem pwscan(int search, uid_t uid, const char *name)
    360  1.1  lukem {
    361  1.1  lukem 
    362  1.1  lukem 	if (_pw_filesdone)
    363  1.1  lukem 		return 0;
    364  1.1  lukem 	for (;;) {
    365  1.1  lukem 		if (!fgets(pwline, sizeof(pwline), _pw_fp)) {
    366  1.1  lukem 			if (!search)
    367  1.1  lukem 				_pw_filesdone = 1;
    368  1.1  lukem 			return 0;
    369  1.1  lukem 		}
    370  1.1  lukem 		/* skip lines that are too big */
    371  1.1  lukem 		if (!strchr(pwline, '\n')) {
    372  1.1  lukem 			int ch;
    373  1.1  lukem 
    374  1.1  lukem 			while ((ch = getc(_pw_fp)) != '\n' && ch != EOF)
    375  1.1  lukem 				;
    376  1.1  lukem 			continue;
    377  1.1  lukem 		}
    378  1.1  lukem 		if (pwmatchline(search, uid, name))
    379  1.1  lukem 			return 1;
    380  1.1  lukem 	}
    381  1.1  lukem 	/* NOTREACHED */
    382  1.1  lukem }
    383  1.1  lukem 
    384  1.1  lukem static int
    385  1.1  lukem pwmatchline(int search, uid_t uid, const char *name)
    386  1.1  lukem {
    387  1.1  lukem 	unsigned long	id;
    388  1.1  lukem 	char		*cp, *bp, *ep;
    389  1.1  lukem 
    390  1.1  lukem 	/* name may be NULL if search is nonzero */
    391  1.1  lukem 
    392  1.1  lukem 	bp = pwline;
    393  1.1  lukem 	memset(&_pw_passwd, 0, sizeof(_pw_passwd));
    394  1.1  lukem 	_pw_passwd.pw_name = strsep(&bp, ":\n");		/* name */
    395  1.1  lukem 	if (search && name && strcmp(_pw_passwd.pw_name, name))
    396  1.1  lukem 		return 0;
    397  1.1  lukem 
    398  1.1  lukem 	_pw_passwd.pw_passwd = strsep(&bp, ":\n");		/* passwd */
    399  1.1  lukem 
    400  1.1  lukem 	if (!(cp = strsep(&bp, ":\n")))				/* uid */
    401  1.1  lukem 		return 0;
    402  1.1  lukem 	id = strtoul(cp, &ep, 10);
    403  1.1  lukem 	if (id > UID_MAX || *ep != '\0')
    404  1.1  lukem 		return 0;
    405  1.1  lukem 	_pw_passwd.pw_uid = (uid_t)id;
    406  1.1  lukem 	if (search && name == NULL && _pw_passwd.pw_uid != uid)
    407  1.1  lukem 		return 0;
    408  1.1  lukem 
    409  1.1  lukem 	if (!(cp = strsep(&bp, ":\n")))				/* gid */
    410  1.1  lukem 		return 0;
    411  1.1  lukem 	id = strtoul(cp, &ep, 10);
    412  1.1  lukem 	if (id > GID_MAX || *ep != '\0')
    413  1.1  lukem 		return 0;
    414  1.1  lukem 	_pw_passwd.pw_gid = (gid_t)id;
    415  1.1  lukem 
    416  1.1  lukem 	if (!(ep = strsep(&bp, ":")))				/* class */
    417  1.1  lukem 		return 0;
    418  1.1  lukem 	if (!(ep = strsep(&bp, ":")))				/* change */
    419  1.1  lukem 		return 0;
    420  1.1  lukem 	if (!(ep = strsep(&bp, ":")))				/* expire */
    421  1.1  lukem 		return 0;
    422  1.1  lukem 
    423  1.1  lukem 	if (!(_pw_passwd.pw_gecos = strsep(&bp, ":\n")))	/* gecos */
    424  1.1  lukem 		return 0;
    425  1.1  lukem 	if (!(_pw_passwd.pw_dir = strsep(&bp, ":\n")))		/* directory */
    426  1.1  lukem 		return 0;
    427  1.1  lukem 	if (!(_pw_passwd.pw_shell = strsep(&bp, ":\n")))	/* shell */
    428  1.1  lukem 		return 0;
    429  1.1  lukem 
    430  1.1  lukem 	if (strchr(bp, ':') != NULL)
    431  1.1  lukem 		return 0;
    432  1.1  lukem 
    433  1.1  lukem 	return 1;
    434  1.1  lukem }
    435  1.1  lukem 
    436