xhost.patch revision 851
546N/A--- xhost.c Mon Jul 10 19:53:04 2006
546N/A+++ filemerge.out Wed Jan 23 14:22:49 2008
546N/A@@ -124,6 +124,11 @@
546N/A #endif
546N/A #endif
546N/A
546N/A+/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
546N/A+#include <locale.h> /* setlocale() */
546N/A+#include <libintl.h> /* gettext(), textdomain(), etc. */
546N/A+#include <stdlib.h> /* getenv() */
546N/A+
546N/A static int change_host(Display *dpy, char *name, Bool add);
546N/A static char *get_hostname(XHostAddress *ha);
546N/A static int local_xerror(Display *dpy, XErrorEvent *rep);
546N/A@@ -193,10 +198,24 @@
546N/A char *cp;
546N/A #endif
546N/A
546N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
546N/A+ char *domaindir;
546N/A+ setlocale(LC_ALL,"");
546N/A+ textdomain("xhost");
546N/A+
546N/A+ /* mainly for debugging */
546N/A+ if((domaindir=getenv("TEXTDOMAINDIR")) == NULL) {
546N/A+ domaindir = "/usr/share/locale"; /*XLOCALEDIR;*/
546N/A+ }
546N/A+ bindtextdomain("xhost",domaindir);
546N/A+
546N/A+
546N/A ProgramName = argv[0];
546N/A
546N/A if ((dpy = XOpenDisplay(NULL)) == NULL) {
546N/A- fprintf(stderr, "%s: unable to open display \"%s\"\n",
546N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
546N/A+ fprintf(stderr,
546N/A+ gettext("%s: unable to open display \"%s\"\n"),
546N/A ProgramName, XDisplayName (NULL));
546N/A exit(1);
546N/A }
546N/A@@ -211,9 +230,11 @@
546N/A sethostent(1); /* don't close the data base each time */
546N/A list = XListHosts(dpy, &nhosts, &enabled);
546N/A if (enabled)
546N/A- printf ("access control enabled, only authorized clients can connect\n");
546N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
546N/A+ printf (gettext("access control enabled, only authorized clients can connect\n"));
546N/A else
546N/A- printf ("access control disabled, clients can connect from any host\n");
546N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
546N/A+ printf (gettext("access control disabled, clients can connect from any host\n"));
546N/A
546N/A if (nhosts != 0) {
546N/A for (i = 0; i < nhosts; i++ ) {
546N/A@@ -242,16 +263,18 @@
546N/A printf("SI:");
546N/A break;
546N/A default:
546N/A- printf("<unknown family type %d>:", list[i].family);
546N/A+ printf(gettext("<unknown family type %d>:"), list[i].family);
546N/A break;
546N/A }
546N/A printf ("%s", hostname);
546N/A } else {
546N/A- printf ("<unknown address in family %d>",
546N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
546N/A+ printf (gettext("<unknown address in family %d>"),
546N/A list[i].family);
546N/A }
546N/A if (nameserver_timedout) {
546N/A- printf("\t(no nameserver response within %d seconds)\n",
546N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
546N/A+ printf(gettext("\t(no nameserver response within %d seconds)\n"),
546N/A NAMESERVER_TIMEOUT);
546N/A nameserver_timedout = 0;
546N/A } else
546N/A@@ -264,7 +287,8 @@
546N/A }
546N/A
546N/A if (argc == 2 && !strcmp(argv[1], "-help")) {
546N/A- fprintf(stderr, "usage: %s [[+-]hostname ...]\n", argv[0]);
546N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
546N/A+ fprintf(stderr, gettext("usage: %s [[+-]hostname ...]\n"), argv[0]);
546N/A exit(1);
546N/A }
546N/A
546N/A@@ -273,12 +297,14 @@
546N/A if (*arg == '-') {
546N/A
546N/A if (!argv[i][1] && ((i+1) == argc)) {
546N/A- printf ("access control enabled, only authorized clients can connect\n");
546N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
546N/A+ printf (gettext("access control enabled, only authorized clients can connect\n"));
546N/A XEnableAccessControl(dpy);
546N/A } else {
546N/A arg = argv[i][1]? &argv[i][1] : argv[++i];
546N/A if (!change_host (dpy, arg, False)) {
546N/A- fprintf (stderr, "%s: bad hostname \"%s\"\n",
546N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
546N/A+ fprintf (stderr, gettext("%s: bad hostname \"%s\"\n"),
546N/A ProgramName, arg);
546N/A nfailed++;
546N/A }
546N/A@@ -285,7 +311,8 @@
546N/A }
546N/A } else {
546N/A if (*arg == '+' && !argv[i][1] && ((i+1) == argc)) {
546N/A- printf ("access control disabled, clients can connect from any host\n");
546N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
546N/A+ printf (gettext("access control disabled, clients can connect from any host\n"));
546N/A XDisableAccessControl(dpy);
546N/A } else {
546N/A if (*arg == '+') {
546N/A@@ -292,7 +319,8 @@
546N/A arg = argv[i][1]? &argv[i][1] : argv[++i];
546N/A }
546N/A if (!change_host (dpy, arg, True)) {
546N/A- fprintf (stderr, "%s: bad hostname \"%s\"\n",
546N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
546N/A+ fprintf (stderr, gettext("%s: bad hostname \"%s\"\n"),
546N/A ProgramName, arg);
546N/A nfailed++;
546N/A }
546N/A@@ -324,6 +352,7 @@
546N/A krb5_data kbuf;
546N/A #endif
546N/A #ifdef NEEDSOCKETS
546N/A+#ifndef AMTCPCONN
546N/A static struct in_addr addr; /* so we can point at it */
546N/A #if defined(IPv6) && defined(AF_INET6)
546N/A static struct in6_addr addr6; /* so we can point at it */
546N/A@@ -330,7 +359,10 @@
546N/A #else
546N/A struct hostent *hp;
546N/A #endif
546N/A+#else
546N/A+ static ipaddr_t addr;
546N/A #endif
546N/A+#endif
546N/A char *cp;
546N/A #ifdef DNETCONN
546N/A struct dn_naddr *dnaddrp;
546N/A@@ -337,12 +369,14 @@
546N/A struct nodeent *np;
546N/A static struct dn_naddr dnaddr;
546N/A #endif /* DNETCONN */
546N/A- static char *add_msg = "being added to access control list";
546N/A- static char *remove_msg = "being removed from access control list";
546N/A+ const char *add_msg = gettext("being added to access control list");
546N/A+ const char *remove_msg = gettext("being removed from access control list");
546N/A
546N/A namelen = strlen(name);
546N/A if ((lname = (char *)malloc(namelen+1)) == NULL) {
546N/A- fprintf (stderr, "%s: malloc bombed in change_host\n", ProgramName);
546N/A+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
546N/A+ fprintf (stderr, gettext("%s: malloc bombed in change_host\n"),
546N/A+ ProgramName);
546N/A exit (1);
546N/A }
546N/A for (i = 0; i < namelen; i++) {
546N/A@@ -350,12 +384,12 @@
546N/A }
lname[namelen] = '\0';
if (!strncmp("inet:", lname, 5)) {
-#if defined(TCPCONN) || defined(STREAMSCONN)
+#if defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN)
family = FamilyInternet;
name += 5;
#else
- fprintf (stderr, "%s: not compiled for TCP/IP\n", ProgramName);
- free(lname);
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: not compiled for TCP/IP\n"), ProgramName);
return 0;
#endif
}
@@ -365,8 +399,8 @@
family = FamilyInternet6;
name += 6;
#else
- fprintf (stderr, "%s: not compiled for IPv6\n", ProgramName);
- free(lname);
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: not compiled for IPv6\n"), ProgramName);
return 0;
#endif
}
@@ -378,8 +412,8 @@
family = FamilyInternet6;
name += 7;
#else
- fprintf (stderr, "%s: not compiled for IPv6\n", ProgramName);
- free(lname);
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: not compiled for IPv6\n"), ProgramName);
return 0;
#endif
}
@@ -389,8 +423,8 @@
family = FamilyDECnet;
name += 5;
#else
- fprintf (stderr, "%s: not compiled for DECnet\n", ProgramName);
- free(lname);
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: not compiled for DECnet\n"), ProgramName);
return 0;
#endif
}
@@ -399,8 +433,8 @@
family = FamilyNetname;
name += 4;
#else
- fprintf (stderr, "%s: not compiled for Secure RPC\n", ProgramName);
- free(lname);
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: not compiled for Secure RPC\n"), ProgramName);
return 0;
#endif
}
@@ -409,8 +443,8 @@
family = FamilyKrb5Principal;
name +=4;
#else
- fprintf (stderr, "%s: not compiled for Kerberos 5\n", ProgramName);
- free(lname);
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: not compiled for Kerberos 5\n"), ProgramName);
return 0;
#endif
}
@@ -422,11 +456,21 @@
name += 3;
}
if (family == FamilyWild && (cp = strchr(lname, ':'))) {
- *cp = '\0';
- fprintf (stderr, "%s: unknown address family \"%s\"\n",
- ProgramName, lname);
- free(lname);
- return 0;
+#ifdef IPv6
+ /*
+ * Check to see if inet_pton() can grok it as an IPv6 address
+ */
+ if (inet_pton(AF_INET6, lname, &addr6.s6_addr) == 1) {
+ family = FamilyInternet6;
+ } else
+#endif
+ {
+ *cp = '\0';
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: unknown address family \"%s\"\n"),
+ ProgramName, lname);
+ return 0;
+ }
}
free(lname);
@@ -436,8 +480,8 @@
cp = strchr(name, ':');
if (cp == NULL || cp == name) {
- fprintf(stderr,
- "%s: type must be specified for server interpreted family \"%s\"\n",
+ fprintf(stderr, gettext(
+ "%s: type must be specified for server interpreted family \"%s\"\n"),
ProgramName, name);
return 0;
}
@@ -471,7 +515,8 @@
dnaddr = *dnaddrp;
} else {
if ((np = getnodebyname (name)) == NULL) {
- fprintf (stderr, "%s: unable to get node name for \"%s::\"\n",
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf (stderr, gettext("%s: unable to get node name for \"%s::\"\n"),
ProgramName, name);
return 0;
}
@@ -497,7 +542,8 @@
retval = krb5_parse_name(name, &princ);
if (retval) {
krb5_init_ets(); /* init krb errs for error_message() */
- fprintf(stderr, "%s: cannot parse Kerberos name: %s\n",
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf(stderr, gettext("%s: cannot parse Kerberos name: %s\n"),
ProgramName, error_message(retval));
return 0;
}
@@ -523,7 +569,7 @@
XAddHost(dpy, &ha);
else
XRemoveHost(dpy, &ha);
- printf( "non-network local connections %s\n", add ? add_msg : remove_msg);
+ printf( gettext("non-network local connections %s\n"), add ? add_msg : remove_msg);
return 1;
}
/*
@@ -542,12 +588,14 @@
*cp = '\0';
pwd = getpwnam(name);
if (!pwd) {
- fprintf(stderr, "no such user \"%s\"\n", name);
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf(stderr, gettext("no such user \"%s\"\n"), name);
return 0;
}
getdomainname(domainname, sizeof(domainname));
if (!user2netname(username, pwd->pw_uid, domainname)) {
- fprintf(stderr, "failed to get netname for \"%s\"\n", name);
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
+ fprintf(stderr, gettext("failed to get netname for \"%s\"\n"), name);
return 0;
}
netname = username;
@@ -570,8 +618,13 @@
/*
* First see if inet_addr() can grok the name; if so, then use it.
*/
+#ifndef AMTCPCONN
if (((family == FamilyWild) || (family == FamilyInternet)) &&
((addr.s_addr = inet_addr(name)) != -1)) {
+#else
+ if (((family == FamilyWild) || (family == FamilyInternet)) &&
+ ((addr = inet_addr(name)) != -1)) {
+#endif
ha.family = FamilyInternet;
ha.length = 4; /* but for Cray would be sizeof(addr.s_addr) */
ha.address = (char *)&addr; /* but for Cray would be &addr.s_addr */
@@ -654,8 +707,11 @@
familyMsg = "inet ";
}
- fprintf(stderr, "%s: unable to get %saddress for \"%s\"\n",
- ProgramName, familyMsg, name);
+ /* L10N_Comments - Parts composed to make full error string
+ 'unable to get' ['inet'|'inetv6'|''] 'address for' <address> */
+ fprintf (stderr, "%s: %s %s%s \"%s\"\n", ProgramName,
+ gettext("unable to get"), familyMsg, gettext("address for"),
+ name);
}
freeaddrinfo(addresses);
return 1;
@@ -715,7 +771,7 @@
static char *
get_hostname(XHostAddress *ha)
{
-#if (defined(TCPCONN) || defined(STREAMSCONN)) && \
+#if (defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN)) && \
(!defined(IPv6) || !defined(AF_INET6))
static struct hostent *hp = NULL;
#endif
@@ -733,7 +789,7 @@
struct sigaction sa;
#endif
-#if defined(TCPCONN) || defined(STREAMSCONN)
+#if defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN)
#if defined(IPv6) && defined(AF_INET6)
if ((ha->family == FamilyInternet) || (ha->family == FamilyInternet6)) {
struct sockaddr_storage saddr;
@@ -823,7 +879,11 @@
alarm(0);
if (hp)
return (hp->h_name);
+#ifndef AMTCPCONN
else return (inet_ntoa(*((struct in_addr *)(ha->address))));
+#else
+ else return (inet_ntoa(*((ipaddr_t *)(ha->address))));
+#endif
}
#endif /* IPv6 */
#endif
@@ -933,14 +993,16 @@
local_xerror(Display *dpy, XErrorEvent *rep)
{
if ((rep->error_code == BadAccess) && (rep->request_code == X_ChangeHosts)) {
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
fprintf (stderr,
- "%s: must be on local machine to add or remove hosts.\n",
+ gettext("%s: must be on local machine to add or remove hosts.\n"),
ProgramName);
return 1;
} else if ((rep->error_code == BadAccess) &&
(rep->request_code == X_SetAccessControl)) {
+ /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
fprintf (stderr,
- "%s: must be on local machine to enable or disable access control.\n",
+ gettext("%s: must be on local machine to enable or disable access control.\n"),
ProgramName);
return 1;
} else if ((rep->error_code == BadValue) &&