From 989398b4476c53703138eedf6b7ac07cbab28f55 Mon Sep 17 00:00:00 2001 From: Kaustubh Kelkar Date: Sat, 11 Jul 2015 17:53:22 -0500 Subject: [PATCH] Importing bin/domainname utility Change-Id: Iaf2067296195d2d55b93d00ac593b431572ca4cd --- bin/Makefile | 2 +- bin/domainname/Makefile | 6 +++ bin/domainname/domainname.1 | 65 +++++++++++++++++++++++++ bin/domainname/domainname.c | 95 +++++++++++++++++++++++++++++++++++++ distrib/sets/lists/minix/mi | 2 + lib/libc/gen/Makefile.inc | 4 +- 6 files changed, 171 insertions(+), 3 deletions(-) create mode 100644 bin/domainname/Makefile create mode 100644 bin/domainname/domainname.1 create mode 100644 bin/domainname/domainname.c diff --git a/bin/Makefile b/bin/Makefile index 183971f56..4c55e024d 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -1,7 +1,7 @@ # $NetBSD: Makefile,v 1.22 2007/12/31 15:31:24 ad Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 -SUBDIR= cat chmod cp date dd df echo ed expr hostname \ +SUBDIR= cat chmod cp date dd df domainname echo ed expr hostname \ kill ksh ln ls mkdir mv pax pwd rm rmdir sh \ sleep stty sync test diff --git a/bin/domainname/Makefile b/bin/domainname/Makefile new file mode 100644 index 000000000..5e0164f31 --- /dev/null +++ b/bin/domainname/Makefile @@ -0,0 +1,6 @@ +# $NetBSD: Makefile,v 1.6 1997/07/20 22:36:50 christos Exp $ +# @(#)Makefile 8.1 (Berkeley) 5/31/93 + +PROG= domainname + +.include diff --git a/bin/domainname/domainname.1 b/bin/domainname/domainname.1 new file mode 100644 index 000000000..c52159dfa --- /dev/null +++ b/bin/domainname/domainname.1 @@ -0,0 +1,65 @@ +.\" $NetBSD: domainname.1,v 1.15 2004/06/15 14:08:33 jmmv Exp $ +.\" +.\" Copyright (c) 1983, 1988, 1990, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" 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. 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. +.\" +.\" @(#)hostname.1 8.1 (Berkeley) 5/31/93 +.\" +.Dd May 31, 1993 +.Dt DOMAINNAME 1 +.Os +.Sh NAME +.Nm domainname +.Nd set or print YP domain of current host system +.Sh SYNOPSIS +.Nm +.Op Ar name-of-domain +.Sh DESCRIPTION +.Nm +prints the +.Tn YP +domain name of the current host. +The super-user can set the domain name by supplying an argument; +this is usually done in the network initialization script +.Pa /etc/rc.d/network , +normally run at boot +time. +.Sh SEE ALSO +.Xr hostname 1 , +.Xr getdomainname 3 , +.Xr setdomainname 3 +.Sh HISTORY +The +.Nm +utility is derived from the +.Nm hostname +utility, which appeared in +.Bx 4.2 . +The +.Nm +utility appeared in +.Nx 0.8 . diff --git a/bin/domainname/domainname.c b/bin/domainname/domainname.c new file mode 100644 index 000000000..b06cbdf2d --- /dev/null +++ b/bin/domainname/domainname.c @@ -0,0 +1,95 @@ +/* $NetBSD: domainname.c,v 1.15 2011/08/29 14:51:18 joerg Exp $ */ + +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * 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. 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. + */ + +#include +#ifndef lint +__COPYRIGHT("@(#) Copyright (c) 1988, 1993\ + The Regents of the University of California. All rights reserved."); +#endif /* not lint */ + +#ifndef lint +#if 0 +static char sccsid[] = "@(#)hostname.c 8.1 (Berkeley) 5/31/93"; +#else +__RCSID("$NetBSD: domainname.c,v 1.15 2011/08/29 14:51:18 joerg Exp $"); +#endif +#endif /* not lint */ + +#include + +#include +#include +#include +#include +#include + +__dead static void usage(void); + +int +main(int argc, char *argv[]) +{ + int ch; + char domainname[MAXHOSTNAMELEN]; + + setprogname(argv[0]); + + while ((ch = getopt(argc, argv, "")) != -1) { + switch (ch) { + case '?': + default: + usage(); + /* NOTREACHED */ + } + } + argc -= optind; + argv += optind; + + if (argc > 1) + usage(); + + if (*argv) { + if (setdomainname(*argv, strlen(*argv))) + err(1, "setdomainname"); + } else { + if (getdomainname(domainname, sizeof(domainname))) + err(1, "getdomainname"); + (void)printf("%s\n", domainname); + } + exit(EXIT_SUCCESS); + /* NOTREACHED */ +} + +static void +usage(void) +{ + (void)fprintf(stderr, "usage: %s [name-of-domain]\n", getprogname()); + exit(EXIT_FAILURE); +} diff --git a/distrib/sets/lists/minix/mi b/distrib/sets/lists/minix/mi index 45b63a498..88071c186 100644 --- a/distrib/sets/lists/minix/mi +++ b/distrib/sets/lists/minix/mi @@ -19,6 +19,7 @@ ./bin/date minix-sys ./bin/dd minix-sys ./bin/df minix-sys +./bin/domainname minix-sys ./bin/echo minix-sys ./bin/ed minix-sys ./bin/expr minix-sys @@ -2367,6 +2368,7 @@ ./usr/man/man1/dhrystone.1 minix-sys ./usr/man/man1/diff.1 minix-sys ./usr/man/man1/dirname.1 minix-sys +./usr/man/man1/domainname.1 minix-sys ./usr/man/man1/dosdir.1 minix-sys ./usr/man/man1/dosread.1 minix-sys ./usr/man/man1/doswrite.1 minix-sys diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index e3af4ce3a..7ea07c63d 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -17,7 +17,7 @@ SRCS+= dhcp_gettag.c dhcp_settag.c fsversion.c gcov.c gcov_flush.c itoa.c \ .if defined(__MINIX) # Unsupported by Minix. # closefrom.c confstr.c extattr.c getdevmajor.c \ -# pthread_atfork.c setdomainname.c \ +# pthread_atfork.c \ # sysctlbyname.c sysctlgetmibinfo.c sysctlnametomib.c # wait3.c @@ -46,7 +46,7 @@ SRCS+= _errno.c alarm.c alphasort.c arc4random.c assert.c basename.c clock.c \ posix_spawn_fileactions.c posix_spawnp.c \ psignal.c \ ptree.c pwcache.c pw_scan.c raise.c randomid.c rb.c readdir.c \ - rewinddir.c scandir.c seekdir.c \ + rewinddir.c scandir.c seekdir.c setdomainname.c \ sethostname.c setjmperr.c setmode.c setproctitle.c setprogname.c \ shquote.c shquotev.c sighold.c sigignore.c siginterrupt.c \ siglist.c signal.c signame.c sigrelse.c \