xref: /onnv-gate/usr/src/lib/gss_mechs/mech_krb5/mech/util_localhost.c (revision 5053:532e59d6bffd)
10Sstevel@tonic-gate /*
2*5053Sgtb  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
30Sstevel@tonic-gate  * Use is subject to license terms.
40Sstevel@tonic-gate  */
50Sstevel@tonic-gate 
60Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
70Sstevel@tonic-gate 
80Sstevel@tonic-gate /*
90Sstevel@tonic-gate  * Copyright 1993 by OpenVision Technologies, Inc.
10*5053Sgtb  *
110Sstevel@tonic-gate  * Permission to use, copy, modify, distribute, and sell this software
120Sstevel@tonic-gate  * and its documentation for any purpose is hereby granted without fee,
130Sstevel@tonic-gate  * provided that the above copyright notice appears in all copies and
140Sstevel@tonic-gate  * that both that copyright notice and this permission notice appear in
150Sstevel@tonic-gate  * supporting documentation, and that the name of OpenVision not be used
160Sstevel@tonic-gate  * in advertising or publicity pertaining to distribution of the software
170Sstevel@tonic-gate  * without specific, written prior permission. OpenVision makes no
180Sstevel@tonic-gate  * representations about the suitability of this software for any
190Sstevel@tonic-gate  * purpose.  It is provided "as is" without express or implied warranty.
20*5053Sgtb  *
210Sstevel@tonic-gate  * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
220Sstevel@tonic-gate  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
230Sstevel@tonic-gate  * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
240Sstevel@tonic-gate  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
250Sstevel@tonic-gate  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
260Sstevel@tonic-gate  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
270Sstevel@tonic-gate  * PERFORMANCE OF THIS SOFTWARE.
280Sstevel@tonic-gate  */
290Sstevel@tonic-gate 
300Sstevel@tonic-gate /*
31*5053Sgtb  * $Id: util_localhost.c 7797 1996-04-12 00:40:24Z marc $
320Sstevel@tonic-gate  */
330Sstevel@tonic-gate 
340Sstevel@tonic-gate /* This file could be OS specific */
350Sstevel@tonic-gate 
36*5053Sgtb #include <sys/param.h>
370Sstevel@tonic-gate 
38*5053Sgtb #include "gssapiP_generic.h"
39*5053Sgtb #include <strings.h> /* SUNW15resync */
40*5053Sgtb #include <unistd.h>  /* SUNW15resync */
410Sstevel@tonic-gate 
420Sstevel@tonic-gate #ifndef MAXHOSTNAMELEN
430Sstevel@tonic-gate #define MAXHOSTNAMELEN 64
440Sstevel@tonic-gate #endif
450Sstevel@tonic-gate 
g_local_host_name()460Sstevel@tonic-gate char *g_local_host_name()
470Sstevel@tonic-gate {
480Sstevel@tonic-gate      char buf[MAXHOSTNAMELEN+1], *ptr;
490Sstevel@tonic-gate 
500Sstevel@tonic-gate      if (gethostname(buf, sizeof(buf)) < 0)
510Sstevel@tonic-gate 	  return 0;
520Sstevel@tonic-gate 
530Sstevel@tonic-gate      buf[sizeof(buf)-1] = '\0';
540Sstevel@tonic-gate 
550Sstevel@tonic-gate      if (! (ptr = xmalloc(strlen(buf) + 1)))
560Sstevel@tonic-gate 	  return 0;
570Sstevel@tonic-gate 
580Sstevel@tonic-gate      return strcpy(ptr, buf);
590Sstevel@tonic-gate }
60