open-src/app/xhost/xhost.patch
author X gate hg captive account <xhg@xserver.us.oracle.com>
Wed Aug 19 13:48:41 2015 -0700 (2015-08-19)
changeset 1484 bc8922b8e1d2
parent 1276 52f85727ce94
permissions -rw-r--r--
Added tag s11u3_30 for changeset 221e9d9cc9cb
Alan@1276
     1
diff --git a/xhost.c b/xhost.c
Alan@1370
     2
index a67d136..f43b267 100644
Alan@1276
     3
--- a/xhost.c
Alan@1276
     4
+++ b/xhost.c
Alan@1370
     5
@@ -119,6 +119,11 @@ extern int getdomainname(char *name, size_t len);
Jay@294
     6
 #endif
Jay@294
     7
 #endif
Jay@294
     8
 
Jay@294
     9
+/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
    10
+#include <locale.h>	/* setlocale()  */
Jay@294
    11
+#include <libintl.h>	/* gettext(), textdomain(), etc. */
Jay@294
    12
+#include <stdlib.h>	/* getenv() */
Jay@294
    13
+
Jay@294
    14
 static int change_host(Display *dpy, char *name, Bool add);
Alan@1276
    15
 static const char *get_hostname(XHostAddress *ha);
Jay@294
    16
 static int local_xerror(Display *dpy, XErrorEvent *rep);
Alan@1370
    17
@@ -171,15 +176,30 @@ main(int argc, char *argv[])
Alan@1370
    18
     Bool enabled = False;
Alan@1370
    19
     Display *dpy;
Jay@294
    20
  
Jay@294
    21
+    /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
    22
+    char *domaindir;
Jay@294
    23
+    setlocale(LC_ALL,"");
Jay@294
    24
+    textdomain("xhost");
Jay@294
    25
+    
Jay@294
    26
+    /* mainly for debugging */
Jay@294
    27
+    if((domaindir=getenv("TEXTDOMAINDIR")) == NULL) {
Alan@851
    28
+	domaindir = "/usr/share/locale"; /*XLOCALEDIR;*/
Jay@294
    29
+    }
Jay@294
    30
+    bindtextdomain("xhost",domaindir);
Jay@294
    31
+
Jay@294
    32
+
Jay@294
    33
     ProgramName = argv[0];
Jay@294
    34
 
Alan@1276
    35
     if (argc == 2 && !strcmp(argv[1], "-help")) {
Alan@1276
    36
-	fprintf(stderr, "usage: %s [[+-]hostname ...]\n", argv[0]);
Alan@1276
    37
+	/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Alan@1276
    38
+	fprintf(stderr, gettext("usage: %s [[+-]hostname ...]\n"), argv[0]);
Alan@1276
    39
 	exit(1);
Alan@1276
    40
     }
Alan@1276
    41
 
Jay@294
    42
     if ((dpy = XOpenDisplay(NULL)) == NULL) {
Jay@294
    43
-	fprintf(stderr, "%s:  unable to open display \"%s\"\n",
Jay@294
    44
+	/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
    45
+	fprintf(stderr,
Jay@294
    46
+		gettext("%s:  unable to open display \"%s\"\n"),
Jay@294
    47
 		ProgramName, XDisplayName (NULL));
Jay@294
    48
 	exit(1);
Jay@294
    49
     }
Alan@1370
    50
@@ -191,9 +211,11 @@ main(int argc, char *argv[])
Jay@294
    51
 	sethostent(1);		/* don't close the data base each time */
Jay@294
    52
 	list = XListHosts(dpy, &nhosts, &enabled);
Jay@294
    53
 	if (enabled)
Jay@294
    54
-	    printf ("access control enabled, only authorized clients can connect\n");
Jay@294
    55
+	    /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
    56
+	    printf (gettext("access control enabled, only authorized clients can connect\n"));
Jay@294
    57
 	else
Jay@294
    58
-	    printf ("access control disabled, clients can connect from any host\n");
Jay@294
    59
+	    /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
    60
+	    printf (gettext("access control disabled, clients can connect from any host\n"));
Jay@294
    61
 
Jay@294
    62
 	if (nhosts != 0) {
Jay@294
    63
 	    for (i = 0; i < nhosts; i++ )  {
Alan@1370
    64
@@ -222,16 +244,18 @@ main(int argc, char *argv[])
Jay@294
    65
 			printf("SI:");
Jay@294
    66
 			break;
Jay@294
    67
 		    default:
Jay@294
    68
-			printf("<unknown family type %d>:", list[i].family);
Jay@294
    69
+			printf(gettext("<unknown family type %d>:"), list[i].family);
Jay@294
    70
 			break;
Jay@294
    71
 		    }
Jay@294
    72
 		    printf ("%s", hostname);
Jay@294
    73
 		} else {
Jay@294
    74
-		    printf ("<unknown address in family %d>",
Jay@294
    75
+		    /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
    76
+		    printf (gettext("<unknown address in family %d>"),
Jay@294
    77
 			    list[i].family);
Jay@294
    78
 		}
Jay@294
    79
 		if (nameserver_timedout) {
Jay@294
    80
-		    printf("\t(no nameserver response within %d seconds)\n",
Jay@294
    81
+		    /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
    82
+		    printf(gettext("\t(no nameserver response within %d seconds)\n"),
Jay@294
    83
 			   NAMESERVER_TIMEOUT);
Jay@294
    84
 		    nameserver_timedout = 0;
Jay@294
    85
 		} else
Alan@1370
    86
@@ -248,26 +272,30 @@ main(int argc, char *argv[])
Jay@294
    87
 	if (*arg == '-') {
Jay@294
    88
 	    
Jay@294
    89
 	    if (!argv[i][1] && ((i+1) == argc)) {
Jay@294
    90
-		printf ("access control enabled, only authorized clients can connect\n");
Jay@294
    91
+		/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
    92
+		printf (gettext("access control enabled, only authorized clients can connect\n"));
Jay@294
    93
 		XEnableAccessControl(dpy);
Jay@294
    94
 	    } else {
Jay@294
    95
 		arg = argv[i][1]? &argv[i][1] : argv[++i];
Jay@294
    96
 		if (!change_host (dpy, arg, False)) {
Jay@294
    97
-		    fprintf (stderr, "%s:  bad hostname \"%s\"\n",
Jay@294
    98
+		    /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
    99
+		    fprintf (stderr, gettext("%s:  bad hostname \"%s\"\n"),
Jay@294
   100
 			     ProgramName, arg);
Jay@294
   101
 		    nfailed++;
Jay@294
   102
 		}
Jay@294
   103
 	    }
Jay@294
   104
 	} else {
Jay@294
   105
 	    if (*arg == '+' && !argv[i][1] && ((i+1) == argc)) {
Jay@294
   106
-		printf ("access control disabled, clients can connect from any host\n");
Jay@294
   107
+		/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
   108
+		printf (gettext("access control disabled, clients can connect from any host\n"));
Jay@294
   109
 		XDisableAccessControl(dpy);
Jay@294
   110
 	    } else {
Jay@294
   111
 		if (*arg == '+') {
Jay@294
   112
 		    arg = argv[i][1]? &argv[i][1] : argv[++i];
Jay@294
   113
 		}
Jay@294
   114
 		if (!change_host (dpy, arg, True)) {
Jay@294
   115
-		    fprintf (stderr, "%s:  bad hostname \"%s\"\n",
Jay@294
   116
+		    /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
   117
+		    fprintf (stderr, gettext("%s:  bad hostname \"%s\"\n"),
Jay@294
   118
 			     ProgramName, arg);
Jay@294
   119
 		    nfailed++;
Jay@294
   120
 		}
Alan@1370
   121
@@ -308,12 +336,14 @@ change_host(Display *dpy, char *name, Bool add)
Alan@1370
   122
 #endif
Alan@1370
   123
 #endif
Alan@1370
   124
     char *cp;
Alan@1276
   125
-    static const char *add_msg = "being added to access control list";
Alan@1276
   126
-    static const char *remove_msg = "being removed from access control list";
Jay@294
   127
+    const char *add_msg = gettext("being added to access control list");
Jay@294
   128
+    const char *remove_msg = gettext("being removed from access control list");
Jay@294
   129
 
Jay@294
   130
     namelen = strlen(name);
Jay@294
   131
     if ((lname = (char *)malloc(namelen+1)) == NULL) {
Jay@294
   132
-	fprintf (stderr, "%s: malloc bombed in change_host\n", ProgramName);
Jay@294
   133
+	/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
   134
+	fprintf (stderr, gettext("%s: malloc bombed in change_host\n"),
Jay@294
   135
+		 ProgramName);
Jay@294
   136
 	exit (1);
Jay@294
   137
     }
Jay@294
   138
     for (i = 0; i < namelen; i++) {
Alan@1370
   139
@@ -325,8 +355,8 @@ change_host(Display *dpy, char *name, Bool add)
Jay@294
   140
 	family = FamilyInternet;
Jay@294
   141
 	name += 5;
Jay@294
   142
 #else
Jay@294
   143
-	fprintf (stderr, "%s: not compiled for TCP/IP\n", ProgramName);
Jay@294
   144
-	free(lname);
Jay@294
   145
+	/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
   146
+	fprintf (stderr, gettext("%s: not compiled for TCP/IP\n"), ProgramName);
Jay@294
   147
 	return 0;
Jay@294
   148
 #endif
Jay@294
   149
     }
Alan@1370
   150
@@ -335,8 +365,8 @@ change_host(Display *dpy, char *name, Bool add)
Jay@294
   151
 	family = FamilyInternet6;
Jay@294
   152
 	name += 6;
Jay@294
   153
 #else
Jay@294
   154
-	fprintf (stderr, "%s: not compiled for IPv6\n", ProgramName);
Jay@294
   155
-	free(lname);
Jay@294
   156
+	/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
   157
+	fprintf (stderr, gettext("%s: not compiled for IPv6\n"), ProgramName);
Jay@294
   158
 	return 0;
Jay@294
   159
 #endif
Jay@294
   160
     }
Alan@1370
   161
@@ -347,15 +377,15 @@ change_host(Display *dpy, char *name, Bool add)
Jay@294
   162
 	family = FamilyInternet6;
Jay@294
   163
 	name += 7;
Jay@294
   164
 #else
Jay@294
   165
-	fprintf (stderr, "%s: not compiled for IPv6\n", ProgramName);
Jay@294
   166
-	free(lname);
Jay@294
   167
+	/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
   168
+	fprintf (stderr, gettext("%s: not compiled for IPv6\n"), ProgramName);
Jay@294
   169
 	return 0;
Jay@294
   170
 #endif
Jay@294
   171
     }
Alan@1370
   172
 #endif /* ACCEPT_INETV6 */
Alan@1370
   173
     else if (!strncmp("dnet:", lname, 5)) {
Jay@294
   174
-	fprintf (stderr, "%s: not compiled for DECnet\n", ProgramName);
Jay@294
   175
-	free(lname);
Jay@294
   176
+	/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
   177
+	fprintf (stderr, gettext("%s: not compiled for DECnet\n"), ProgramName);
Jay@294
   178
 	return 0;
Jay@294
   179
     }
Alan@1370
   180
     else if (!strncmp("nis:", lname, 4)) {
Alan@1370
   181
@@ -363,8 +393,8 @@ change_host(Display *dpy, char *name, Bool add)
Jay@294
   182
 	family = FamilyNetname;
Jay@294
   183
 	name += 4;
Jay@294
   184
 #else
Jay@294
   185
-	fprintf (stderr, "%s: not compiled for Secure RPC\n", ProgramName);
Jay@294
   186
-	free(lname);
Jay@294
   187
+	/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
   188
+	fprintf (stderr, gettext("%s: not compiled for Secure RPC\n"), ProgramName);
Jay@294
   189
 	return 0;
Jay@294
   190
 #endif
Jay@294
   191
     }
Alan@1370
   192
@@ -373,8 +403,8 @@ change_host(Display *dpy, char *name, Bool add)
Jay@294
   193
 	family = FamilyKrb5Principal;
Jay@294
   194
 	name +=4;
Jay@294
   195
 #else
Jay@294
   196
-	fprintf (stderr, "%s: not compiled for Kerberos 5\n", ProgramName);
Jay@294
   197
-	free(lname);
Jay@294
   198
+	/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
   199
+	fprintf (stderr, gettext("%s: not compiled for Kerberos 5\n"), ProgramName);
Jay@294
   200
 	return 0;
Jay@294
   201
 #endif
Jay@294
   202
     }
Alan@1370
   203
@@ -386,11 +416,21 @@ change_host(Display *dpy, char *name, Bool add)
Jay@294
   204
 	name += 3;
Jay@294
   205
     }
Jay@294
   206
     if (family == FamilyWild && (cp = strchr(lname, ':'))) {
Jay@294
   207
-	*cp = '\0';
Jay@294
   208
-	fprintf (stderr, "%s: unknown address family \"%s\"\n",
Jay@294
   209
-		 ProgramName, lname);
Jay@294
   210
-	free(lname);
Jay@294
   211
-	return 0;
Jay@294
   212
+#ifdef IPv6
Jay@294
   213
+	/*
Jay@294
   214
+	 * Check to see if inet_pton() can grok it as an IPv6 address
Jay@294
   215
+	 */
Jay@294
   216
+	if (inet_pton(AF_INET6, lname, &addr6.s6_addr) == 1) {
Jay@294
   217
+	    family = FamilyInternet6;
Jay@294
   218
+	} else
Jay@294
   219
+#endif
Jay@294
   220
+	{
Jay@294
   221
+	    *cp = '\0';
Jay@294
   222
+	    /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
   223
+	    fprintf (stderr, gettext("%s: unknown address family \"%s\"\n"),
Jay@294
   224
+		     ProgramName, lname);
Jay@294
   225
+	    return 0;
Jay@294
   226
+	}
Jay@294
   227
     }
Jay@294
   228
     free(lname);
Jay@294
   229
 
Alan@1370
   230
@@ -400,8 +440,8 @@ change_host(Display *dpy, char *name, Bool add)
Jay@294
   231
 
Jay@294
   232
 	cp = strchr(name, ':');
Jay@294
   233
 	if (cp == NULL || cp == name) {
Jay@294
   234
-	    fprintf(stderr, 
Jay@294
   235
-	   "%s: type must be specified for server interpreted family \"%s\"\n",
Jay@294
   236
+	    fprintf(stderr, gettext(
Jay@294
   237
+	  "%s: type must be specified for server interpreted family \"%s\"\n"),
Jay@294
   238
 	      ProgramName, name);
Jay@294
   239
 	    return 0;
Jay@294
   240
 	}
Alan@1370
   241
@@ -429,7 +469,8 @@ change_host(Display *dpy, char *name, Bool add)
Jay@294
   242
 	retval = krb5_parse_name(name, &princ);
Jay@294
   243
 	if (retval) {
Jay@294
   244
 	    krb5_init_ets();	/* init krb errs for error_message() */
Jay@294
   245
-	    fprintf(stderr, "%s: cannot parse Kerberos name: %s\n",
Jay@294
   246
+	    /* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
   247
+	    fprintf(stderr, gettext("%s: cannot parse Kerberos name: %s\n"),
Jay@294
   248
 		    ProgramName, error_message(retval));
Jay@294
   249
 	    return 0;
Jay@294
   250
 	}
Alan@1370
   251
@@ -456,7 +497,7 @@ change_host(Display *dpy, char *name, Bool add)
Jay@294
   252
 	    XAddHost(dpy, &ha);
Jay@294
   253
 	else
Jay@294
   254
 	    XRemoveHost(dpy, &ha);
Jay@294
   255
-	printf( "non-network local connections %s\n", add ? add_msg : remove_msg);
Jay@294
   256
+	printf( gettext("non-network local connections %s\n"), add ? add_msg : remove_msg);
Jay@294
   257
 	return 1;
Jay@294
   258
     }
Jay@294
   259
     /*
Alan@1370
   260
@@ -475,12 +516,14 @@ change_host(Display *dpy, char *name, Bool add)
Jay@294
   261
 	    *cp = '\0';
Jay@294
   262
 	    pwd = getpwnam(name);
Jay@294
   263
 	    if (!pwd) {
Jay@294
   264
-		fprintf(stderr, "no such user \"%s\"\n", name);
Jay@294
   265
+		/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
   266
+		fprintf(stderr, gettext("no such user \"%s\"\n"), name);
Jay@294
   267
 		return 0;
Jay@294
   268
 	    }
Jay@294
   269
 	    getdomainname(domainname, sizeof(domainname));
Jay@294
   270
 	    if (!user2netname(username, pwd->pw_uid, domainname)) {
Jay@294
   271
-		fprintf(stderr, "failed to get netname for \"%s\"\n", name);
Jay@294
   272
+		/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
   273
+		fprintf(stderr, gettext("failed to get netname for \"%s\"\n"), name);
Jay@294
   274
 		return 0;
Jay@294
   275
 	    }
Jay@294
   276
 	    netname = username;
Alan@1370
   277
@@ -587,8 +630,11 @@ change_host(Display *dpy, char *name, Bool add)
Jay@294
   278
 		familyMsg = "inet ";
Jay@294
   279
 	    }
Jay@294
   280
 
Jay@294
   281
-	    fprintf(stderr, "%s: unable to get %saddress for \"%s\"\n",
Jay@294
   282
-		ProgramName, familyMsg, name);
Jay@294
   283
+	    /* L10N_Comments - Parts composed to make full error string
Jay@294
   284
+	       'unable to get' ['inet'|'inetv6'|''] 'address for' <address> */
Jay@294
   285
+	    fprintf (stderr, "%s:  %s %s%s \"%s\"\n", ProgramName, 
Jay@294
   286
+	      gettext("unable to get"), familyMsg, gettext("address for"), 
Jay@294
   287
+	      name);
Jay@294
   288
 	}
Jay@294
   289
 	freeaddrinfo(addresses);
Jay@294
   290
 	return 1;
Alan@1370
   291
@@ -824,14 +870,16 @@ static int
Jay@294
   292
 local_xerror(Display *dpy, XErrorEvent *rep)
Jay@294
   293
 {
Jay@294
   294
     if ((rep->error_code == BadAccess) && (rep->request_code == X_ChangeHosts)) {
Jay@294
   295
+	/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
   296
 	fprintf (stderr, 
Jay@294
   297
-		 "%s:  must be on local machine to add or remove hosts.\n",
Jay@294
   298
+		 gettext("%s:  must be on local machine to add or remove hosts.\n"),
Jay@294
   299
 		 ProgramName);
Jay@294
   300
 	return 1;
Jay@294
   301
     } else if ((rep->error_code == BadAccess) && 
Jay@294
   302
 	       (rep->request_code == X_SetAccessControl)) {
Jay@294
   303
+	/* Internationalize messages for bug 4256527... S Swales 5/25/00 */
Jay@294
   304
 	fprintf (stderr, 
Jay@294
   305
-	"%s:  must be on local machine to enable or disable access control.\n",
Jay@294
   306
+		 gettext("%s:  must be on local machine to enable or disable access control.\n"),
Jay@294
   307
 		 ProgramName);
Jay@294
   308
 	return 1;
Jay@294
   309
     } else if ((rep->error_code == BadValue) &&