diff options
Diffstat (limited to 'bin/named/unix')
| -rw-r--r-- | bin/named/unix/include/named/os.h | 7 | ||||
| -rw-r--r-- | bin/named/unix/os.c | 37 |
2 files changed, 38 insertions, 6 deletions
diff --git a/bin/named/unix/include/named/os.h b/bin/named/unix/include/named/os.h index c979e53871d7..b0ac1d568ce2 100644 --- a/bin/named/unix/include/named/os.h +++ b/bin/named/unix/include/named/os.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007-2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007-2009, 2016 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,8 +15,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: os.h,v 1.31 2009/08/05 23:47:43 tbox Exp $ */ - #ifndef NS_OS_H #define NS_OS_H 1 @@ -72,4 +70,7 @@ ns_os_tzset(void); void ns_os_started(void); +char * +ns_os_uname(void); + #endif /* NS_OS_H */ diff --git a/bin/named/unix/os.c b/bin/named/unix/os.c index 18e8c3910373..953bbdd163b4 100644 --- a/bin/named/unix/os.c +++ b/bin/named/unix/os.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011, 2013, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2011, 2013, 2014, 2016 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,8 +15,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: os.c,v 1.107 2011/03/02 00:02:54 marka Exp $ */ - /*! \file */ #include <config.h> @@ -24,6 +22,9 @@ #include <sys/types.h> /* dev_t FreeBSD 2.1 */ #include <sys/stat.h> +#ifdef HAVE_UNAME +#include <sys/utsname.h> +#endif #include <ctype.h> #include <errno.h> @@ -966,3 +967,33 @@ ns_os_tzset(void) { tzset(); #endif } + +static char unamebuf[BUFSIZ]; +static char *unamep = NULL; + +static void +getuname(void) { +#ifdef HAVE_UNAME + struct utsname uts; + + memset(&uts, 0, sizeof(uts)); + if (uname(&uts) < 0) { + strcpy(unamebuf, "unknown architecture"); + return; + } + + snprintf(unamebuf, sizeof(unamebuf), + "%s %s %s %s", + uts.sysname, uts.machine, uts.release, uts.version); +#else + strcpy(unamebuf, "unknown architecture"); +#endif + unamep = unamebuf; +} + +char * +ns_os_uname(void) { + if (unamep == NULL) + getuname(); + return (unamep); +} |
