summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/ptools/ppriv/ppriv.c6
-rw-r--r--usr/src/lib/libc/port/gen/priv_str_xlate.c58
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);
+}