New version, derived from hostname(1), with a corrected man page.
This commit is contained in:
parent
ea92d19cb0
commit
5b20b0d3c6
@ -1,5 +1,5 @@
|
||||
# from: @(#)Makefile 5.3 (Berkeley) 5/11/90
|
||||
# $Id: Makefile,v 1.2 1993/08/01 05:47:39 mycroft Exp $
|
||||
# from: @(#)Makefile 8.1 (Berkeley) 5/31/93
|
||||
# $Id: Makefile,v 1.3 1994/09/22 09:42:45 mycroft Exp $
|
||||
|
||||
PROG= domainname
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" Copyright (c) 1983, 1988, 1990 The Regents of the University of California.
|
||||
.\" All rights reserved.
|
||||
.\" 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
|
||||
@ -29,22 +29,22 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" from: @(#)domainname.1 6.8 (Berkeley) 7/27/91
|
||||
.\" $Id: domainname.1,v 1.3 1993/09/10 01:24:45 jtc Exp $
|
||||
.\" from: @(#)hostname.1 8.1 (Berkeley) 5/31/93
|
||||
.\" $Id: domainname.1,v 1.4 1994/09/22 09:42:47 mycroft Exp $
|
||||
.\"
|
||||
.Dd July 27, 1991
|
||||
.Dd May 31, 1993
|
||||
.Dt DOMAINNAME 1
|
||||
.Os BSD 4.2
|
||||
.Sh NAME
|
||||
.Nm domainname
|
||||
.Nd set or print the name of the current domain
|
||||
.Nd set or print YP domain of current host system
|
||||
.Sh SYNOPSIS
|
||||
.Nm domainname
|
||||
.Op Ar name-of-domain
|
||||
.Sh DESCRIPTION
|
||||
.Nm Domainname
|
||||
prints the domain name of the current host. The super-user can
|
||||
set the domain name by supplying an argument; this is usually done in the
|
||||
prints the YP domain name of the current host. The super-user can
|
||||
set the domainname by supplying an argument; this is usually done in the
|
||||
network initialization script
|
||||
.Pa /etc/netstart ,
|
||||
normally run at boot
|
||||
@ -52,9 +52,11 @@ time.
|
||||
.Sh SEE ALSO
|
||||
.Xr hostname 1 ,
|
||||
.Xr getdomainname 2 ,
|
||||
.Xr setdomainname 2
|
||||
.Xr setdomainname 2
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm domainname
|
||||
command appeared in
|
||||
command is derived from the
|
||||
.Nm hostname
|
||||
command, which appeared in
|
||||
.Bx 4.2 .
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca>
|
||||
* All rights reserved.
|
||||
* 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
|
||||
@ -10,15 +10,19 @@
|
||||
* 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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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 AUTHOR ``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 AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* 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
|
||||
@ -28,47 +32,61 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: domainname.c,v 1.4 1994/02/23 02:48:29 cgd Exp $";
|
||||
static char copyright[] =
|
||||
"@(#) Copyright (c) 1988, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)hostname.c 8.1 (Berkeley) 5/31/93";*/
|
||||
static char *rcsid = "$Id: domainname.c,v 1.5 1994/09/22 09:42:49 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
static void usage __P((void));
|
||||
void usage __P((void));
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
char *argv[];
|
||||
{
|
||||
char dom[MAXHOSTNAMELEN];
|
||||
int ch;
|
||||
char domainname[MAXHOSTNAMELEN];
|
||||
|
||||
if( argc>2 ) {
|
||||
usage ();
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
if( argc==2 ) {
|
||||
if( setdomainname(argv[1], strlen(argv[1])+1) == -1) {
|
||||
perror("setdomainname");
|
||||
exit(1);
|
||||
while ((ch = getopt(argc, argv, "s")) != -1)
|
||||
switch (ch) {
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc > 1)
|
||||
usage();
|
||||
|
||||
if (*argv) {
|
||||
if (setdomainname(*argv, strlen(*argv)))
|
||||
err(1, "setdomainname");
|
||||
} else {
|
||||
if( getdomainname(dom, sizeof(dom)) == -1) {
|
||||
perror("getdomainname");
|
||||
exit(1);
|
||||
}
|
||||
printf("%s\n", dom);
|
||||
if (getdomainname(domainname, sizeof(domainname)))
|
||||
err(1, "getdomainname");
|
||||
(void)printf("%s\n", domainname);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static void
|
||||
usage ()
|
||||
void
|
||||
usage()
|
||||
{
|
||||
(void)fprintf(stderr, "usage: domainname [name-of-domain]\n");
|
||||
|
||||
(void)fprintf(stderr, "usage: domainname [domainname]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user