priv_str_xlate.c (7257d1b4) priv_str_xlate.c (b599bd93)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 10 unchanged lines hidden (view full) ---

19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 10 unchanged lines hidden (view full) ---

19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#pragma ident "%Z%%M% %I% %E% SMI"
28
29/*
30 * priv_str_xlate.c - Privilege translation routines.
31 */
32
33#pragma weak _priv_str_to_set = priv_str_to_set
34#pragma weak _priv_set_to_str = priv_set_to_str
35#pragma weak _priv_gettext = priv_gettext
36

--- 390 unchanged lines hidden (view full) ---

427/*
428 * priv_gettext() is defined to return a string that
429 * the caller must deallocate with free(3C). Grr...
430 */
431char *
432priv_gettext(const char *priv)
433{
434 char file[MAXPATHLEN];
27/*
28 * priv_str_xlate.c - Privilege translation routines.
29 */
30
31#pragma weak _priv_str_to_set = priv_str_to_set
32#pragma weak _priv_set_to_str = priv_set_to_str
33#pragma weak _priv_gettext = priv_gettext
34

--- 390 unchanged lines hidden (view full) ---

425/*
426 * priv_gettext() is defined to return a string that
427 * the caller must deallocate with free(3C). Grr...
428 */
429char *
430priv_gettext(const char *priv)
431{
432 char file[MAXPATHLEN];
433 locale_t curloc;
435 const char *loc;
436 char *ret;
437
438 /* Not a valid privilege */
439 if (priv_getbyname(priv) < 0)
440 return (NULL);
441
434 const char *loc;
435 char *ret;
436
437 /* Not a valid privilege */
438 if (priv_getbyname(priv) < 0)
439 return (NULL);
440
442 if ((loc = setlocale(LC_MESSAGES, NULL)) == NULL)
443 loc = "C";
441 curloc = uselocale(NULL);
442 loc = current_locale(curloc, LC_MESSAGES);
444
445 if (snprintf(file, sizeof (file),
446 _DFLT_LOC_PATH "%s/LC_MESSAGES/priv_names", loc) < sizeof (file)) {
447 ret = do_priv_gettext(priv, (const char *)file);
448 if (ret != NULL)
449 return (ret);
450 }
451
452 /* If the path is too long or can't be opened, punt to default */
453 ret = do_priv_gettext(priv, "/etc/security/priv_names");
454 return (ret);
455}
443
444 if (snprintf(file, sizeof (file),
445 _DFLT_LOC_PATH "%s/LC_MESSAGES/priv_names", loc) < sizeof (file)) {
446 ret = do_priv_gettext(priv, (const char *)file);
447 if (ret != NULL)
448 return (ret);
449 }
450
451 /* If the path is too long or can't be opened, punt to default */
452 ret = do_priv_gettext(priv, "/etc/security/priv_names");
453 return (ret);
454}