diff options
Diffstat (limited to 'usr/src/lib/libnsl/netselect/netselect.c')
| -rw-r--r-- | usr/src/lib/libnsl/netselect/netselect.c | 27 | 
1 files changed, 20 insertions, 7 deletions
| diff --git a/usr/src/lib/libnsl/netselect/netselect.c b/usr/src/lib/libnsl/netselect/netselect.c index 7225fa86a6..461840b695 100644 --- a/usr/src/lib/libnsl/netselect/netselect.c +++ b/usr/src/lib/libnsl/netselect/netselect.c @@ -22,6 +22,7 @@  /*   * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.   * Use is subject to license terms. + * Copyright 2015 Joyent, Inc.   */  /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/ @@ -32,8 +33,6 @@   * under license from the Regents of the University of California.   */ -#pragma ident	"%Z%%M%	%I%	%E% SMI" -  #include "mt.h"  #include "../rpc/rpc_mt.h"		/* for MT declarations only */  #include <rpc/types.h> @@ -45,6 +44,7 @@  #include <malloc.h>  #include <libintl.h>  #include <syslog.h> +#include <zone.h>  #include "netcspace.h"  #define	FAILURE  (unsigned)(-1) @@ -265,13 +265,22 @@ freenetconfigent(struct netconfig *netp)  static struct netconfig **  getnetlist(void)  { -	char line[BUFSIZ];	/* holds each line of NETCONFIG */ -	FILE *fp;		/* file stream for NETCONFIG */ +	FILE *fp = NULL;	/* file stream for NETCONFIG */  	struct netconfig **listpp; /* the beginning of the netconfig list */  	struct netconfig **tpp;	/* used to traverse the netconfig list */  	int count;		/* the number of entries in file */ +	char nc_path[MAXPATHLEN]; +	const char *zroot = zone_get_nroot(); +	char line[BUFSIZ];	/* holds each line of NETCONFIG */ + +	/* +	 * If we are running in a branded zone, ensure we use the "/native" +	 * prefix when opening the netconfig file: +	 */ +	(void) snprintf(nc_path, sizeof (nc_path), "%s%s", zroot != NULL ? +	    zroot : "", NETCONFIG); -	if ((fp = fopen(NETCONFIG, "rF")) == NULL) { +	if ((fp = fopen(nc_path, "rF")) == NULL) {  		nc_error = NC_OPENFAIL;  		return (NULL);  	} @@ -286,13 +295,16 @@ getnetlist(void)  	if (count == 0) {  		nc_error = NC_NOTFOUND; -		(void) fclose(fp); +		if (fp != NULL) +			(void) fclose(fp);  		return (NULL);  	} +  	if ((listpp = malloc((count + 1) *  	    sizeof (struct netconfig *))) == NULL) {  		nc_error = NC_NOMEM; -		(void) fclose(fp); +		if (fp != NULL) +			(void) fclose(fp);  		return (NULL);  	} @@ -311,6 +323,7 @@ getnetlist(void)  	if (nc_error != NC_NOMOREENTRIES) /* Something is screwed up */  		netlist_free(&listpp); +  	return (listpp);  } | 
