diff options
author | sayama <none@none> | 2006-08-14 21:05:32 -0700 |
---|---|---|
committer | sayama <none@none> | 2006-08-14 21:05:32 -0700 |
commit | c8d284976ee7a60fd288bb6667ddb74331be96e9 (patch) | |
tree | 56e9e2eb2fff8aaaa74b8919aeab665ee2152df3 /usr/src | |
parent | cea92495d0c426c5ef0d8c45bfee626731af3b3a (diff) | |
download | illumos-gate-c8d284976ee7a60fd288bb6667ddb74331be96e9.tar.gz |
6208005 /usr/bin/ppriv -v -l outputs wrong strings if locale is UTF-8.
6450300 ppriv -lv should output English description if the privilege name is missing from L10n file.
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/ptools/ppriv/ppriv.c | 6 | ||||
-rw-r--r-- | usr/src/lib/libc/port/gen/priv_str_xlate.c | 58 |
2 files changed, 38 insertions, 26 deletions
diff --git a/usr/src/cmd/ptools/ppriv/ppriv.c b/usr/src/cmd/ptools/ppriv/ppriv.c index 21d25b4b9f..61af0efdc9 100644 --- a/usr/src/cmd/ptools/ppriv/ppriv.c +++ b/usr/src/cmd/ptools/ppriv/ppriv.c @@ -596,8 +596,10 @@ dopriv(const char *p) char *p, *q; if (text == NULL) return (1); - for (p = text; q = strchr(p, '\n'); p = q + 1) - (void) printf("\t%.*s", (int)(q - p + 1), p); + for (p = text; q = strchr(p, '\n'); p = q + 1) { + *q = '\0'; + (void) printf("\t%s\n", p); + } free(text); } return (0); diff --git a/usr/src/lib/libc/port/gen/priv_str_xlate.c b/usr/src/lib/libc/port/gen/priv_str_xlate.c index 4fa3e86f9d..36f7a7d7e5 100644 --- a/usr/src/lib/libc/port/gen/priv_str_xlate.c +++ b/usr/src/lib/libc/port/gen/priv_str_xlate.c @@ -341,34 +341,14 @@ priv_set_to_str(const priv_set_t *pset, char separator, int flag) return (__priv_set_to_str(NULL, pset, separator, flag)); } -/* - * priv_gettext() is defined to return a string that - * the caller must deallocate with free(3C). Grr... - */ -char * -priv_gettext(const char *priv) +static char * +do_priv_gettext(const char *priv, const char *file) { - FILE *namefp = NULL; char buf[8*1024]; boolean_t inentry = B_FALSE; - char file[MAXPATHLEN]; - const char *loc; - - /* Not a valid privilege */ - if (priv_getbyname(priv) < 0) - return (NULL); - - if ((loc = setlocale(LC_MESSAGES, NULL)) == NULL) - loc = "C"; - - if (snprintf(file, sizeof (file), - _DFLT_LOC_PATH "%s/LC_MESSAGES/priv_names", loc) < sizeof (file)) - namefp = fopen(file, "rF"); - - /* If the path is too long or can't be opened, punt to default */ - if (namefp == NULL) - namefp = fopen("/etc/security/priv_names", "rF"); + FILE *namefp; + namefp = fopen(file, "rF"); if (namefp == NULL) return (NULL); @@ -442,3 +422,33 @@ out: (void) fclose(namefp); return (NULL); } + +/* + * priv_gettext() is defined to return a string that + * the caller must deallocate with free(3C). Grr... + */ +char * +priv_gettext(const char *priv) +{ + char file[MAXPATHLEN]; + const char *loc; + char *ret; + + /* Not a valid privilege */ + if (priv_getbyname(priv) < 0) + return (NULL); + + if ((loc = setlocale(LC_MESSAGES, NULL)) == NULL) + loc = "C"; + + if (snprintf(file, sizeof (file), + _DFLT_LOC_PATH "%s/LC_MESSAGES/priv_names", loc) < sizeof (file)) { + ret = do_priv_gettext(priv, (const char *)file); + if (ret != NULL) + return (ret); + } + + /* If the path is too long or can't be opened, punt to default */ + ret = do_priv_gettext(priv, "/etc/security/priv_names"); + return (ret); +} |