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)
This commit is contained in:
Alexey Zelkin 2003-06-25 23:05:11 +00:00
parent 3305fa5359
commit 48f12e5860
2 changed files with 6 additions and 7 deletions

View File

@ -1,6 +1,7 @@
# $FreeBSD$
PROG = locale
CFLAGS += -I${.CURDIR}/../../lib/libc/locale
WARNS ?= 1
.include <bsd.prog.mk>

View File

@ -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) {