From 7b1360495da7bd7306ddeea3a9ddb95a483233ae Mon Sep 17 00:00:00 2001 From: ache Date: Mon, 7 Apr 1997 08:54:38 +0000 Subject: Restore PATH_LOCALE functionality using issetugid() call now --- lib/libc/locale/rune.3 | 2 +- lib/libc/locale/setlocale.3 | 2 +- lib/libc/locale/setlocale.c | 19 +++++++++++++++---- lib/libc/locale/setlocale.h | 1 + lib/libc/locale/setrunelocale.c | 16 ++++++++++++++-- 5 files changed, 32 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/libc/locale/rune.3 b/lib/libc/locale/rune.3 index cab767d..d36dd3a 100644 --- a/lib/libc/locale/rune.3 +++ b/lib/libc/locale/rune.3 @@ -233,7 +233,7 @@ function returns the number of bytes needed to store as a multibyte string. .Sh FILES .Bl -tag -width /usr/share/locale/locale/LC_CTYPE -compact -.\" .It Pa $PATH_LOCALE/ Ns Em locale Ns /LC_CTYPE +.It Pa $PATH_LOCALE/ Ns Em locale Ns /LC_CTYPE .It Pa /usr/share/locale/ Ns Em locale Ns /LC_CTYPE binary LC_CTYPE file for the locale .Em locale . diff --git a/lib/libc/locale/setlocale.3 b/lib/libc/locale/setlocale.3 index 695112d..18ee80b 100644 --- a/lib/libc/locale/setlocale.3 +++ b/lib/libc/locale/setlocale.3 @@ -271,7 +271,7 @@ or .Fn localeconv . .Sh FILES .Bl -tag -width /usr/share/locale/locale/category -compact -.\" .It Pa $PATH_LOCALE/ Ns Em locale/category +.It Pa $PATH_LOCALE/ Ns Em locale/category .It Pa /usr/share/locale/ Ns Em locale/category locale file for the locale .Em locale diff --git a/lib/libc/locale/setlocale.c b/lib/libc/locale/setlocale.c index 58de9ea..4b7a1b1 100644 --- a/lib/libc/locale/setlocale.c +++ b/lib/libc/locale/setlocale.c @@ -33,12 +33,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: setlocale.c,v 1.20 1997/02/22 14:59:56 peter Exp $ */ #ifdef LIBC_RCS static const char rcsid[] = - "$Id$"; + "$Id: setlocale.c,v 1.20 1997/02/22 14:59:56 peter Exp $"; #endif #if defined(LIBC_SCCS) && !defined(lint) @@ -222,8 +222,19 @@ loadlocale(category) char *new = new_categories[category]; char *old = current_categories[category]; - if (!_PathLocale) - _PathLocale = _PATH_LOCALE; + if (_PathLocale == NULL) { + char *p = getenv("PATH_LOCALE"); + + if (p != NULL && !issetugid()) { + if (strlen(p) + 1/*"/"*/ + ENCODING_LEN + + 1/*"/"*/ + CATEGORY_LEN >= PATH_MAX) + return (NULL); + _PathLocale = strdup(p); + if (_PathLocale == NULL) + return (NULL); + } else + _PathLocale = _PATH_LOCALE; + } if (strcmp(new, old) == 0) return (old); diff --git a/lib/libc/locale/setlocale.h b/lib/libc/locale/setlocale.h index 262b9c0..f3b2a22 100644 --- a/lib/libc/locale/setlocale.h +++ b/lib/libc/locale/setlocale.h @@ -27,6 +27,7 @@ */ #define ENCODING_LEN 31 +#define CATEGORY_LEN 11 extern char *_PathLocale; diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c index d422e39..d44f8e2 100644 --- a/lib/libc/locale/setrunelocale.c +++ b/lib/libc/locale/setrunelocale.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "setlocale.h" extern int _none_init __P((_RuneLocale *)); @@ -82,8 +83,19 @@ _xpg4_setrunelocale(encoding) return(0); } - if (!_PathLocale) - _PathLocale = _PATH_LOCALE; + if (_PathLocale == NULL) { + char *p = getenv("PATH_LOCALE"); + + if (p != NULL && !issetugid()) { + if (strlen(p) + 1/*"/"*/ + ENCODING_LEN + + 1/*"/"*/ + CATEGORY_LEN >= PATH_MAX) + return(EFAULT); + _PathLocale = strdup(p); + if (_PathLocale == NULL) + return (errno); + } else + _PathLocale = _PATH_LOCALE; + } /* Range checking not needed, encoding length already checked above */ (void) strcpy(name, _PathLocale); (void) strcat(name, "/"); -- cgit v1.1