summaryrefslogtreecommitdiffstats
path: root/usr.bin/locale
diff options
context:
space:
mode:
authorphantom <phantom@FreeBSD.org>2003-06-25 23:05:11 +0000
committerphantom <phantom@FreeBSD.org>2003-06-25 23:05:11 +0000
commit3a0952afbd82dda0c03d4f658194fd1503720a44 (patch)
treec684057a98949a7c28c9b874c69366f41eb14cf7 /usr.bin/locale
parent445694f17f3a6b2909ca0f9fdd8b2d91663feae3 (diff)
downloadFreeBSD-src-3a0952afbd82dda0c03d4f658194fd1503720a44.zip
FreeBSD-src-3a0952afbd82dda0c03d4f658194fd1503720a44.tar.gz
locale.c:
Use newly added __detect_path_locale() helper to lookup _PathLocale value. It adds boundary checking for PATH_LOCALE environment variable value and check for super-user fallback. Makefile: Add lib/libc/locale to compiler's include path (for setlocale.h)
Diffstat (limited to 'usr.bin/locale')
-rw-r--r--usr.bin/locale/Makefile1
-rw-r--r--usr.bin/locale/locale.c12
2 files changed, 6 insertions, 7 deletions
diff --git a/usr.bin/locale/Makefile b/usr.bin/locale/Makefile
index 539fc1f..d7f67e1 100644
--- a/usr.bin/locale/Makefile
+++ b/usr.bin/locale/Makefile
@@ -1,6 +1,7 @@
# $FreeBSD$
PROG = locale
+CFLAGS += -I${.CURDIR}/../../lib/libc/locale
WARNS ?= 1
.include <bsd.prog.mk>
diff --git a/usr.bin/locale/locale.c b/usr.bin/locale/locale.c
index 3a53ff8..c7ebdeb 100644
--- a/usr.bin/locale/locale.c
+++ b/usr.bin/locale/locale.c
@@ -40,12 +40,12 @@
#include <err.h>
#include <locale.h>
#include <langinfo.h>
-#include <paths.h> /* for _PATH_LOCALE */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stringlist.h>
#include <unistd.h>
+#include "setlocale.h"
/* Local prototypes */
void init_locales_list(void);
@@ -320,7 +320,6 @@ init_locales_list(void)
{
DIR *dirp;
struct dirent *dp;
- const char *dirname;
/* why call this function twice ? */
if (locales != NULL)
@@ -332,14 +331,13 @@ init_locales_list(void)
err(1, "could not allocate memory");
/* get actual locales directory name */
- dirname = getenv("PATH_LOCALE");
- if (dirname == NULL)
- dirname = _PATH_LOCALE;
+ if (__detect_path_locale() != 0)
+ err(1, "unable to find locales storage");
/* open locales directory */
- dirp = opendir(dirname);
+ dirp = opendir(_PathLocale);
if (dirp == NULL)
- err(1, "could not open directory '%s'", dirname);
+ err(1, "could not open directory '%s'", _PathLocale);
/* scan directory and store its contents except "." and ".." */
while ((dp = readdir(dirp)) != NULL) {
OpenPOWER on IntegriCloud