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