Importing bin/domainname utility
Change-Id: Iaf2067296195d2d55b93d00ac593b431572ca4cd
This commit is contained in:
parent
ea69bfc71d
commit
989398b447
6 changed files with 171 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
|
6
bin/domainname/Makefile
Normal file
6
bin/domainname/Makefile
Normal file
|
@ -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 <bsd.prog.mk>
|
65
bin/domainname/domainname.1
Normal file
65
bin/domainname/domainname.1
Normal file
|
@ -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 .
|
95
bin/domainname/domainname.c
Normal file
95
bin/domainname/domainname.c
Normal file
|
@ -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 <sys/cdefs.h>
|
||||
#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 <sys/param.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
__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);
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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 \
|
||||
|
|
Loading…
Reference in a new issue