summaryrefslogtreecommitdiffstats
path: root/lib/libc/locale
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1997-04-07 08:54:38 +0000
committerache <ache@FreeBSD.org>1997-04-07 08:54:38 +0000
commit7b1360495da7bd7306ddeea3a9ddb95a483233ae (patch)
tree8ba3017cb8ed5f902d750c3aa3a11f5ca86a887f /lib/libc/locale
parent42b08e73160ea8e6dc0d62f41a73acb091c3cc39 (diff)
downloadFreeBSD-src-7b1360495da7bd7306ddeea3a9ddb95a483233ae.zip
FreeBSD-src-7b1360495da7bd7306ddeea3a9ddb95a483233ae.tar.gz
Restore PATH_LOCALE functionality using issetugid() call now
Diffstat (limited to 'lib/libc/locale')
-rw-r--r--lib/libc/locale/rune.32
-rw-r--r--lib/libc/locale/setlocale.32
-rw-r--r--lib/libc/locale/setlocale.c19
-rw-r--r--lib/libc/locale/setlocale.h1
-rw-r--r--lib/libc/locale/setrunelocale.c16
5 files changed, 32 insertions, 8 deletions
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 <string.h>
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
#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, "/");
OpenPOWER on IntegriCloud