Return to BSD News archive
Newsgroups: comp.unix.bsd Path: sserve!manuel.anu.edu.au!munnari.oz.au!uunet!ornl!rsg1.er.usgs.gov!darwin.sura.net!wupost!gumby!destroyer!cs.ubc.ca!unixg.ubc.ca!kakwa.ucs.ualberta.ca!alberta!cpsc.ucalgary.ca!xenlink!newt.cuc.ab.ca!deraadt From: deraadt@newt.cuc.ab.ca (Theo de Raadt) Subject: 386BSD: PATCH to add domainname(1) Message-ID: <DERAADT.92Nov19025510@newt.newt.cuc.ab.ca> Sender: news@newt.cuc.ab.ca Nntp-Posting-Host: newt Organization: little lizard city Date: Thu, 19 Nov 1992 09:55:10 GMT Lines: 453 Here's support for the domainname system calls and programs. This patch is required for the YP client stuff that I will be shipping in probably two weeks (beta). I'm implimenting my YP stuff on a network of Sun's. I'd like to have a few beta testers who have different YP master/server machines, ie. SGI, Ultrix, HP. Hopefully I can get people who know a bit of RPC programming. Drop me a note. I've sent a copy of this to <terry@cs.weber.edu> as well for inclusion into the patchkit. Could someone ensure that William Jolitz gets a copy of this so that it will be in the next release whenever that is due? Thanks. <tdr. #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: Makefile Makefile.inc.diffs README domainname.1 # domainname.c getdomainname.2 kernel-patches # Wrapped by deraadt@newt.cuc.ab.ca on Thu Nov 19 02:53:38 1992 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(80 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' X# @(#)Makefile 5.3 (Berkeley) 5/11/90 X XPROG= domainname X X.include <bsd.prog.mk> END_OF_FILE if test 80 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'Makefile.inc.diffs' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile.inc.diffs'\" else echo shar: Extracting \"'Makefile.inc.diffs'\" \(1626 characters\) sed "s/^X//" >'Makefile.inc.diffs' <<'END_OF_FILE' X*** /gecko.userb/usr/src/lib/libc/sys/Makefile.inc Tue Nov 17 04:33:13 1992 X--- /usr/src/lib/libc/sys/Makefile.inc Sat Oct 31 14:47:08 1992 X*************** X*** 27,33 **** X setrlimit.o setsid.o setsockopt.o settimeofday.o setuid.o \ X shutdown.o sigaction.o sigstack.o socket.o socketpair.o stat.o \ X statfs.o swapon.o symlink.o sync.o truncate.o umask.o unlink.o \ X! unmount.o utimes.o vadvise.o wait4.o write.o writev.o X X PSEUDO= _exit.o _getlogin.o X X--- 27,34 ---- X setrlimit.o setsid.o setsockopt.o settimeofday.o setuid.o \ X shutdown.o sigaction.o sigstack.o socket.o socketpair.o stat.o \ X statfs.o swapon.o symlink.o sync.o truncate.o umask.o unlink.o \ X! unmount.o utimes.o vadvise.o wait4.o write.o writev.o getdomainname.o \ X! setdomainname.o X X PSEUDO= _exit.o _getlogin.o X X*************** X*** 80,86 **** X shutdown.0 sigaction.0 sigprocmask.0 sigreturn.0 sigstack.0 \ X sigsuspend.0 socket.0 socketpair.0 stat.0 statfs.0 swapon.0 \ X symlink.0 sync.0 syscall.0 truncate.0 umask.0 unlink.0 utimes.0 \ X! vfork.0 wait.0 write.0 X X MLINKS+=brk.2 sbrk.2 X MLINKS+=dup.2 dup2.2 X--- 81,87 ---- X shutdown.0 sigaction.0 sigprocmask.0 sigreturn.0 sigstack.0 \ X sigsuspend.0 socket.0 socketpair.0 stat.0 statfs.0 swapon.0 \ X symlink.0 sync.0 syscall.0 truncate.0 umask.0 unlink.0 utimes.0 \ X! vfork.0 wait.0 write.0 getdomainname.0 X X MLINKS+=brk.2 sbrk.2 X MLINKS+=dup.2 dup2.2 X*************** X*** 110,112 **** X--- 111,114 ---- X MLINKS+=truncate.2 ftruncate.2 X MLINKS+=wait.2 wait3.2 wait.2 wait4.2 wait.2 waitpid.2 X MLINKS+=write.2 writev.2 X+ MLINKS+=getdomainname.2 setdomainname.2 END_OF_FILE if test 1626 -ne `wc -c <'Makefile.inc.diffs'`; then echo shar: \"'Makefile.inc.diffs'\" unpacked with wrong size! fi # end of 'Makefile.inc.diffs' fi if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(328 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' XMakefile.inc.diffs diffs /usr/src/lib/libc/sys/Makefile.inc XMakefile new /usr/src/bin/domainname/Makefile Xdomainname.1 new /usr/src/bin/domainname/domainname.1 Xdomainname.c new /usr/src/bin/domainname/domainname.c Xgetdomainname.2 new /usr/src/lib/libc/sys/getdomainname.2 Xkernel-patches apply to /usr/src/sys.386bsd/kern/* END_OF_FILE if test 328 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'domainname.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'domainname.1'\" else echo shar: Extracting \"'domainname.1'\" \(2515 characters\) sed "s/^X//" >'domainname.1' <<'END_OF_FILE' X.\" Copyright (c) 1983, 1988, 1990 The Regents of the University of California. X.\" All rights reserved. X.\" X.\" Redistribution and use in source and binary forms, with or without X.\" modification, are permitted provided that the following conditions X.\" are met: X.\" 1. Redistributions of source code must retain the above copyright X.\" notice, this list of conditions and the following disclaimer. X.\" 2. Redistributions in binary form must reproduce the above copyright X.\" notice, this list of conditions and the following disclaimer in the X.\" documentation and/or other materials provided with the distribution. X.\" 3. All advertising materials mentioning features or use of this software X.\" must display the following acknowledgement: X.\" This product includes software developed by the University of X.\" California, Berkeley and its contributors. X.\" 4. Neither the name of the University nor the names of its contributors X.\" may be used to endorse or promote products derived from this software X.\" without specific prior written permission. X.\" X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X.\" SUCH DAMAGE. X.\" X.\" @(#)domainname.1 6.8 (Berkeley) 7/27/91 X.\" X.Dd July 27, 1991 X.Dt DOMAINNAME 1 X.Os BSD 4.2 X.Sh NAME X.Nm domainname X.Nd set or print name of current host system X.Sh SYNOPSIS X.Nm domainname X.Op Fl s X.Op Ar nameofhost X.Sh DESCRIPTION X.Nm Hostname Xprints the name of the current host. The super-user can Xset the domainname by supplying an argument; this is usually done in the Xnetwork initialization script X.Pa /etc/netstart , Xnormally run at boot Xtime. X.Pp XOptions: X.Bl -tag -width flag X.It Fl s XTrims off any domain information from the printed Xname. X.El X.Sh SEE ALSO X.Xr getdomainname 2 X.Sh HISTORY XThe X.Nm domainname Xcommand appeared in X.Bx 4.2 . END_OF_FILE if test 2515 -ne `wc -c <'domainname.1'`; then echo shar: \"'domainname.1'\" unpacked with wrong size! fi # end of 'domainname.1' fi if test -f 'domainname.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'domainname.c'\" else echo shar: Extracting \"'domainname.c'\" \(496 characters\) sed "s/^X//" >'domainname.c' <<'END_OF_FILE' X#include <sys/types.h> X#include <sys/param.h> X#include <netdb.h> X#include <stdio.h> X#include <errno.h> X Xmain(argc, argv) Xchar **argv; X{ X char dom[MAXHOSTNAMELEN]; X X if( argc>2 ) { X fprintf(stderr, "usage: domainname [name]\n"); X exit(1); X } X if( argc==2 ) { X if( setdomainname(argv[1], strlen(argv[1])+1) == -1) { X perror("setdomainname"); X exit(1); X } X exit(0); X } X if( getdomainname(dom, sizeof dom) == -1) { X perror("getdomainname"); X exit(1); X } X printf("%s\n", dom); X exit(0); X} X END_OF_FILE if test 496 -ne `wc -c <'domainname.c'`; then echo shar: \"'domainname.c'\" unpacked with wrong size! fi # end of 'domainname.c' fi if test -f 'getdomainname.2' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getdomainname.2'\" else echo shar: Extracting \"'getdomainname.2'\" \(3295 characters\) sed "s/^X//" >'getdomainname.2' <<'END_OF_FILE' X.\" Copyright (c) 1983, 1991 The Regents of the University of California. X.\" All rights reserved. X.\" X.\" Redistribution and use in source and binary forms, with or without X.\" modification, are permitted provided that the following conditions X.\" are met: X.\" 1. Redistributions of source code must retain the above copyright X.\" notice, this list of conditions and the following disclaimer. X.\" 2. Redistributions in binary form must reproduce the above copyright X.\" notice, this list of conditions and the following disclaimer in the X.\" documentation and/or other materials provided with the distribution. X.\" 3. All advertising materials mentioning features or use of this software X.\" must display the following acknowledgement: X.\" This product includes software developed by the University of X.\" California, Berkeley and its contributors. X.\" 4. Neither the name of the University nor the names of its contributors X.\" may be used to endorse or promote products derived from this software X.\" without specific prior written permission. X.\" X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X.\" SUCH DAMAGE. X.\" X.\" @(#)getdomainname.2 6.7 (Berkeley) 3/10/91 X.\" X.Dd March 10, 1991 X.Dt GETDOMAINNAME 2 X.Os BSD 4.2 X.Sh NAME X.Nm getdomainname , X.Nm setdomainname X.Nd get/set name of current host X.Sh SYNOPSIS X.Fd #include <unistd.h> X.Ft int X.Fn getdomainname "char *name" "int namelen" X.Ft int X.Fn setdomainname "const char *name" "int namelen" X.Sh DESCRIPTION X.Fn Getdomainname Xreturns the standard host name for the current processor, as Xpreviously set by X.Fn setdomainname . XThe parameter X.Fa namelen Xspecifies the size of the X.Fa name Xarray. The returned name is null-terminated unless insufficient Xspace is provided. X.Pp X.Fn Setdomainname Xsets the name of the host machine to be X.Fa name , Xwhich has length X.Fa namelen . XThis call is restricted to the super-user and Xis normally used only when the system is bootstrapped. X.Sh RETURN VALUES XIf the call succeeds a value of 0 is returned. If the call Xfails, a value of -1 is returned and an error code is Xplaced in the global location X.Va errno . X.Sh ERRORS XThe following errors may be returned by these calls: X.Bl -tag -width Er X.It Bq Er EFAULT XThe X.Fa name Xor X.Fa namelen Xparameter gave an Xinvalid address. X.It Bq Er EPERM XThe caller tried to set the domainname and was not the super-user. X.El X.Sh SEE ALSO X.Xr gethostid 2 X.Sh BUGS XHost names are limited to X.Dv MAXHOSTNAMELEN X(from X.Ao Pa sys/param.h Ac ) Xcharacters, currently 64. X.Sh HISTORY XThe X.Nm Xfunction call appeared in X.Bx 4.2 . END_OF_FILE if test 3295 -ne `wc -c <'getdomainname.2'`; then echo shar: \"'getdomainname.2'\" unpacked with wrong size! fi # end of 'getdomainname.2' fi if test -f 'kernel-patches' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'kernel-patches'\" else echo shar: Extracting \"'kernel-patches'\" \(2593 characters\) sed "s/^X//" >'kernel-patches' <<'END_OF_FILE' X*** /gecko.userb/usr/src/sys.386bsd/kern/init_sysent.c Tue Nov 17 04:30:48 1992 X--- /usr/src/sys.386bsd/kern/init_sysent.c Sun Oct 18 19:38:48 1992 X*************** X*** 158,163 **** X--- 158,165 ---- X int getfh(); X #else X #endif X+ int getdomainname(); X+ int setdomainname(); X #ifdef SYSVSHM X int shmsys(); X #else X*************** X*** 400,407 **** X 0, nosys, /* 160 = nosys */ X 0, nosys, /* 161 = nosys */ X #endif X! 0, nosys, /* 162 = nosys */ X! 0, nosys, /* 163 = nosys */ X 0, nosys, /* 164 = nosys */ X 0, nosys, /* 165 = nosys */ X 0, nosys, /* 166 = nosys */ X--- 402,409 ---- X 0, nosys, /* 160 = nosys */ X 0, nosys, /* 161 = nosys */ X #endif X! 2, getdomainname, /* 162 = getdomainname */ X! 2, setdomainname, /* 163 = setdomainname */ X 0, nosys, /* 164 = nosys */ X 0, nosys, /* 165 = nosys */ X 0, nosys, /* 166 = nosys */ X*** /gecko.userb/usr/src/sys.386bsd/kern/kern_xxx.c Tue Nov 17 04:30:51 1992 X--- /usr/src/sys.386bsd/kern/kern_xxx.c Sun Oct 18 19:44:23 1992 X*************** X*** 103,108 **** X--- 103,143 ---- X } X X /* ARGSUSED */ X+ getdomainname(p, uap, retval) X+ struct proc *p; X+ struct args { X+ char *domainname; X+ u_int len; X+ } *uap; X+ int *retval; X+ { X+ if (uap->len > domainnamelen + 1) X+ uap->len = domainnamelen + 1; X+ return (copyout((caddr_t)domainname, (caddr_t)uap->domainname, uap->len)); X+ } X+ X+ /* ARGSUSED */ X+ setdomainname(p, uap, retval) X+ struct proc *p; X+ struct args { X+ char *domainname; X+ u_int len; X+ } *uap; X+ int *retval; X+ { X+ int error; X+ X+ if (error = suser(p->p_ucred, &p->p_acflag)) X+ return (error); X+ if (uap->len > sizeof (domainname) - 1) X+ return EINVAL; X+ domainnamelen = uap->len; X+ error = copyin((caddr_t)uap->domainname, domainname, uap->len); X+ domainname[domainnamelen] = 0; X+ return (error); X+ } X+ X+ /* ARGSUSED */ X reboot(p, uap, retval) X struct proc *p; X struct args { X*** /gecko.userb/usr/src/sys.386bsd/kern/syscalls.c Tue Nov 17 04:30:53 1992 X--- /usr/src/sys.386bsd/kern/syscalls.c Sun Oct 18 19:35:11 1992 X*************** X*** 193,200 **** X "#160", /* 160 = nosys */ X "#161", /* 161 = nosys */ X #endif X! "#162", /* 162 = nosys */ X! "#163", /* 163 = nosys */ X "#164", /* 164 = nosys */ X "#165", /* 165 = nosys */ X "#166", /* 166 = nosys */ X--- 193,200 ---- X "#160", /* 160 = nosys */ X "#161", /* 161 = nosys */ X #endif X! "getdomainname", /* 162 = getdomainname */ X! "setdomainname", /* 163 = setdomainname */ X "#164", /* 164 = nosys */ X "#165", /* 165 = nosys */ X "#166", /* 166 = nosys */ END_OF_FILE if test 2593 -ne `wc -c <'kernel-patches'`; then echo shar: \"'kernel-patches'\" unpacked with wrong size! fi # end of 'kernel-patches' fi echo shar: End of shell archive. exit 0 -- This space not left unintentionally unblank. deraadt@newt.cuc.ab.ca