297
297
buf[buf_len-1] = '\0';
308
#ifndef NO_XLOCALEDIR
312
dir = getenv("XLOCALELIBDIR");
317
* Only use the user-supplied path if the process isn't priviledged.
319
if (getuid() == geteuid() && getgid() == getegid()) {
320
#if defined(HASSETUGID)
322
#elif defined(HASGETRESUID)
324
uid_t ruid, euid, suid;
325
gid_t rgid, egid, sgid;
326
if ((getresuid(&ruid, &euid, &suid) == 0) &&
327
(getresgid(&rgid, &egid, &sgid) == 0))
328
priv = (euid != suid) || (egid != sgid);
332
* If there are saved ID's the process might still be priviledged
333
* even though the above test succeeded. If issetugid() and
334
* getresgid() aren't available, test this by trying to set
337
* Note: this only protects setuid-root clients. It doesn't
338
* protect other setuid or any setgid clients. If this tradeoff
339
* isn't acceptable, set DisableXLocaleDirEnv to YES in host.def.
341
unsigned int oldeuid;
343
if (seteuid(0) != 0) {
356
strncpy(p, dir, buf_len);
358
p[len++] = LC_PATHDELIM;
363
#endif /* NO_XLOCALEDIR */
367
strncpy(p, XLOCALELIBDIR, buf_len - len);
369
strncpy(p,__XOS2RedirRoot(XLOCALELIBDIR), buf_len - len);
371
buf[buf_len-1] = '\0';
300
374
/* Mapping direction */
302
376
LtoR, /* Map first field to second field */
642
716
Xfree(target_name);
721
_XlcLocaleLibDirName(dir_name, dir_len, lc_name)
726
char dir[PATH_MAX], buf[PATH_MAX], *name = NULL;
728
char *args[NUM_LOCALEDIR];
729
static char locale_alias[] = LOCALE_ALIAS;
730
char *target_name = (char*)0;
731
char *target_dir = (char*)0;
732
char *nlc_name = NULL;
734
xlocalelibdir (dir, PATH_MAX);
735
n = _XlcParsePath(dir, args, 256);
736
for (i = 0; i < n; ++i) {
738
if ((2 + (args[i] ? strlen(args[i]) : 0) +
739
strlen(locale_alias)) < PATH_MAX) {
740
sprintf (buf, "%s/%s", args[i], locale_alias);
741
name = resolve_name(lc_name, buf, LtoR);
744
nlc_name = normalize_lcname(lc_name);
746
name = resolve_name (nlc_name, buf, LtoR);
750
/* If name is not an alias, use lc_name for locale.dir search */
754
/* look at locale.dir */
756
target_dir = args[i];
758
/* something wrong */
763
if ((1 + (target_dir ? strlen (target_dir) : 0) +
764
strlen("locale.dir")) < PATH_MAX) {
765
sprintf(buf, "%s/locale.dir", target_dir);
766
target_name = resolve_name(name, buf, RtoL);
770
if (target_name != NULL) {
772
if ((p = strstr(target_name, "/XLC_LOCALE"))) {
781
if (nlc_name) Xfree(nlc_name);
783
if (target_name == NULL) {
784
/* vendor locale name == Xlocale name, no expansion of alias */
785
target_dir = args[0];
786
target_name = lc_name;
788
/* snprintf(dir_name, dir_len, "%s/%", target_dir, target_name); */
789
strncpy(dir_name, target_dir, dir_len - 1);
790
if (strlen(target_dir) >= dir_len - 1) {
791
dir_name[dir_len - 1] = '\0';
793
strcat(dir_name, "/");
794
strncat(dir_name, target_name, dir_len - strlen(dir_name) - 1);
795
if (strlen(target_name) >= dir_len - strlen(dir_name) - 1)
796
dir_name[dir_len - 1] = '\0';
798
if (target_name != lc_name)