summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <Alan.Coopersmith@sun.com>2004-03-17 17:39:37 +0000
committerAlan Coopersmith <Alan.Coopersmith@sun.com>2004-03-17 17:39:37 +0000
commitced64662c41b885fa778caef5fbeded0b9f4d810 (patch)
tree88d02daa5440873a4b472831b8c66b3b5da96376
parent6580d9e718777974a14bf617cec0d7c0dd6d7908 (diff)
second public review. (Alan Coopersmith)
-rw-r--r--xhost.c128
-rw-r--r--xhost.man59
2 files changed, 147 insertions, 40 deletions
diff --git a/xhost.c b/xhost.c
index ced2494..43babdc 100644
--- a/xhost.c
+++ b/xhost.c
@@ -1,29 +1,38 @@
/* $Xorg: xhost.c,v 1.4 2001/02/09 02:05:46 xorgcvs Exp $ */
+/* $XdotOrg: xc/programs/xhost/xhost.c,v 1.1.4.2.6.1.2.1 2004/03/13 18:48:40 alanc Exp $ */
/*
Copyright 1985, 1986, 1987, 1998 The Open Group
+Copyright 2004 Sun Microsystems, Inc.
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
+All rights reserved.
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-Except as contained in this notice, the name of The Open Group shall
-not be used in advertising or otherwise to promote the sale, use or
-other dealings in this Software without prior written authorization
-from The Open Group.
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+X Window System is a trademark of The Open Group.
*/
/* $XFree86: xc/programs/xhost/xhost.c,v 3.26 2003/07/27 14:05:45 herrb Exp $ */
@@ -221,6 +230,12 @@ main(int argc, char *argv[])
case FamilyLocalHost:
printf("LOCAL:");
break;
+ case FamilyServerInterpreted:
+ printf("SI:");
+ break;
+ default:
+ printf("<unknown family type %d>:", list[i].family);
+ break;
}
printf ("%s", hostname);
} else {
@@ -349,6 +364,19 @@ change_host(Display *dpy, char *name, Bool add)
return 0;
#endif
}
+#ifdef ACCEPT_INETV6 /* Allow inetv6 as an alias for inet6 for compatibility
+ with original X11 over IPv6 draft. */
+ else if (!strncmp("inetv6:", lname, 7)) {
+#if (defined(TCPCONN) || defined(STREAMSCONN)) && \
+ defined(IPv6) && defined(AF_INET6)
+ family = FamilyInternet6;
+ name += 7;
+#else
+ fprintf (stderr, "%s: not compiled for IPv6\n", ProgramName);
+ return 0;
+#endif
+ }
+#endif /* ACCEPT_INETV6 */
else if (!strncmp("dnet:", lname, 5)) {
#ifdef DNETCONN
family = FamilyDECnet;
@@ -379,6 +407,10 @@ change_host(Display *dpy, char *name, Bool add)
else if (!strncmp("local:", lname, 6)) {
family = FamilyLocalHost;
}
+ else if (!strncmp("si:", lname, 3)) {
+ family = FamilyServerInterpreted;
+ name += 3;
+ }
if (family == FamilyWild && (cp = strchr(lname, ':'))) {
*cp = '\0';
fprintf (stderr, "%s: unknown address family \"%s\"\n",
@@ -387,10 +419,42 @@ change_host(Display *dpy, char *name, Bool add)
}
free(lname);
+ if (family == FamilyServerInterpreted) {
+ XServerInterpretedAddress siaddr;
+ int namelen;
+
+ cp = strchr(name, ':');
+ if (cp == NULL || cp == name) {
+ fprintf(stderr,
+ "%s: type must be specified for server interpreted family \"%s\"\n",
+ ProgramName, name);
+ return 0;
+ }
+ ha.family = FamilyServerInterpreted;
+ ha.address = (char *) &siaddr;
+ namelen = strlen(name);
+ siaddr.type = malloc(namelen);
+ if (siaddr.type == NULL) {
+ return 0;
+ }
+ memcpy(siaddr.type, name, namelen);
+ siaddr.typelength = cp - name;
+ siaddr.type[siaddr.typelength] = '\0';
+ siaddr.value = siaddr.type + siaddr.typelength + 1;
+ siaddr.valuelength = namelen - (siaddr.typelength + 1);
+ if (add)
+ XAddHost(dpy, &ha);
+ else
+ XRemoveHost(dpy, &ha);
+ free(siaddr.type);
+ printf( "%s %s\n", name, add ? add_msg : remove_msg);
+ return 1;
+ }
+
#ifdef DNETCONN
- if (family == FamilyDECnet ||
+ if (family == FamilyDECnet || ((family == FamilyWild) &&
(cp = strchr(name, ':')) && (*(cp + 1) == ':') &&
- !(*cp = '\0')) {
+ !(*cp = '\0'))) {
ha.family = FamilyDECnet;
if (dnaddrp = dnet_addr(name)) {
dnaddr = *dnaddrp;
@@ -815,6 +879,34 @@ get_hostname(XHostAddress *ha)
if (ha->family == FamilyLocalHost) {
return "";
}
+ if (ha->family == FamilyServerInterpreted) {
+ XServerInterpretedAddress *sip;
+ static char *addressString;
+ static size_t addressStringSize;
+ size_t neededSize;
+
+ sip = (XServerInterpretedAddress *) ha->address;
+ neededSize = sip->typelength + sip->valuelength + 2;
+
+ if (addressStringSize < neededSize) {
+ if (addressString != NULL) {
+ free(addressString);
+ }
+ addressStringSize = neededSize;
+ addressString = malloc(addressStringSize);
+ }
+ if (addressString != NULL) {
+ char *cp = addressString;
+
+ memcpy(cp, sip->type, sip->typelength);
+ cp += sip->typelength;
+ *cp++ = ':';
+ memcpy(cp, sip->value, sip->valuelength);
+ cp += sip->valuelength;
+ *cp = '\0';
+ }
+ return addressString;
+ }
return (NULL);
}
diff --git a/xhost.man b/xhost.man
index 5b8cb8c..8d02fec 100644
--- a/xhost.man
+++ b/xhost.man
@@ -1,27 +1,35 @@
.\" $Xorg: xhost.man,v 1.4 2001/02/09 02:05:46 xorgcvs Exp $
+.\" $XdotOrg: xc/programs/xhost/xhost.man,v 1.1.4.2.6.1.2.1 2004/03/13 18:48:40 alanc Exp $
+.\"
.\" Copyright 1988, 1998 The Open Group
+.\" Copyright 2004 Sun Microsystems, Inc.
.\"
-.\" Permission to use, copy, modify, distribute, and sell this software and its
-.\" documentation for any purpose is hereby granted without fee, provided that
-.\" the above copyright notice appear in all copies and that both that
-.\" copyright notice and this permission notice appear in supporting
-.\" documentation.
-.\"
-.\" The above copyright notice and this permission notice shall be included
-.\" in all copies or substantial portions of the Software.
+.\" Permission is hereby granted, free of charge, to any person obtaining a
+.\" copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, and/or sell copies of the Software, and to permit persons
+.\" to whom the Software is furnished to do so, provided that the above
+.\" copyright notice(s) and this permission notice appear in all copies of
+.\" the Software and that both the above copyright notice(s) and this
+.\" permission notice appear in supporting documentation.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
-.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-.\" OTHER DEALINGS IN THE SOFTWARE.
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+.\" OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+.\" HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+.\" INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+.\" FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+.\" NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+.\" WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.\" Except as contained in this notice, the name of The Open Group shall
-.\" not be used in advertising or otherwise to promote the sale, use or
-.\" other dealings in this Software without prior written authorization
-.\" from The Open Group.
+.\" Except as contained in this notice, the name of a copyright holder
+.\" shall not be used in advertising or otherwise to promote the sale, use
+.\" or other dealings in this Software without prior written authorization
+.\" of the copyright holder.
+.\"
+.\" X Window System is a trademark of The Open Group.
.\"
.\" $XFree86: xc/programs/xhost/xhost.man,v 1.8tsi Exp $
.\"
@@ -91,6 +99,7 @@ dnet DECnet host
nis Secure RPC network name
krb Kerberos V5 principal
local contains only one name, the empty string
+si Server Interpreted
.fi
.PP
The family is case insensitive.
@@ -106,6 +115,11 @@ names that contain an at-sign (@) are assumed to be in the nis family.
Otherwise they are assumed to be Internet addresses. If compiled to support
IPv6, then all IPv4 and IPv6 addresses returned by getaddrinfo(3) are added to
the access list in the appropriate inet or inet6 family.
+.PP
+Server interpreted addresses consist of a case-sensitive type tag and a
+string representing a given value, separated by a colon. For example,
+"si:hostname:almas" is a server interpreted address of type \fIhostname\fP,
+with a value of \fIalmas\fP.
.SH DIAGNOSTICS
For each name added to the access control list,
a line of the form "\fIname\fP being added to access control list"
@@ -116,7 +130,7 @@ is printed.
.SH FILES
/etc/X*.hosts
.SH "SEE ALSO"
-X(__miscmansuffix__), Xsecurity(__miscmansuffix__), Xserver(1), xdm(1), getaddrinfo(3)
+X(__miscmansuffix__), Xsecurity(__miscmansuffix__), Xserver(1), xdm(1), xauth(1), getaddrinfo(3)
.SH ENVIRONMENT
.TP 8
.B DISPLAY
@@ -130,10 +144,11 @@ to remove the machine named
.I ``display''
from the access list).
.PP
-The X server stores network addresses, not host names. This is not
-really a bug. If somehow you change a host's network address while
-the server is still running, \fIxhost\fP must be used to add the new
-address and/or remove the old address.
+The X server stores network addresses, not host names, unless you use
+the server-interpreted hostname type address. If somehow you change a
+host's network address while the server is still running, and you are
+using a network-address based form of authentication, \fIxhost\fP must
+be used to add the new address and/or remove the old address.
.SH AUTHORS
Bob Scheifler, MIT Laboratory for Computer Science,
.br