mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-05-23 00:31:29 +02:00
52193: handle UTF8-encoded USERNAME and therefore home directory in zcompile
Includes one unposted thinko fix ztrdup -> dupstring
This commit is contained in:
parent
1b8446e1cd
commit
29644f12e7
5 changed files with 20 additions and 7 deletions
|
@ -1,3 +1,10 @@
|
|||
2023-10-01 Bart Schaefer <schaefer@zsh.org>
|
||||
|
||||
* 52193: Src/init.c, Src/params.c, Src/utils.c: metafy USERNAME
|
||||
(mostly for Cygwin compatibilty with UTF8 encodings)
|
||||
|
||||
* 52193: Src/parse.c: unmetafy file paths in zcompile
|
||||
|
||||
2023-09-27 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
|
||||
|
||||
* 52188: Test/D04parameter.ztst: skip tests that fail if
|
||||
|
|
|
@ -1212,8 +1212,8 @@ setupvals(char *cmd, char *runscript, char *zsh_name)
|
|||
#ifdef USE_GETPWUID
|
||||
if ((pswd = getpwuid(cached_uid))) {
|
||||
if (EMULATION(EMULATE_ZSH))
|
||||
home = metafy(pswd->pw_dir, -1, META_DUP);
|
||||
cached_username = ztrdup(pswd->pw_name);
|
||||
home = ztrdup_metafy(pswd->pw_dir);
|
||||
cached_username = ztrdup_metafy(pswd->pw_name);
|
||||
}
|
||||
else
|
||||
#endif /* USE_GETPWUID */
|
||||
|
|
|
@ -4561,7 +4561,7 @@ usernamesetfn(UNUSED(Param pm), char *x)
|
|||
zwarn("failed to change user ID: %e", errno);
|
||||
else {
|
||||
zsfree(cached_username);
|
||||
cached_username = ztrdup(pswd->pw_name);
|
||||
cached_username = ztrdup_metafy(pswd->pw_name);
|
||||
cached_uid = pswd->pw_uid;
|
||||
}
|
||||
}
|
||||
|
|
12
Src/parse.c
12
Src/parse.c
|
@ -3217,12 +3217,14 @@ bin_zcompile(char *nam, char **args, Options ops, UNUSED(int func))
|
|||
|
||||
if (!args[1] && !(OPT_ISSET(ops,'c') || OPT_ISSET(ops,'a'))) {
|
||||
queue_signals();
|
||||
ret = build_dump(nam, dyncat(*args, FD_EXT), args, OPT_ISSET(ops,'U'),
|
||||
dump = unmetafy(dyncat(*args, FD_EXT), NULL);
|
||||
ret = build_dump(nam, dump, args, OPT_ISSET(ops,'U'),
|
||||
map, flags);
|
||||
unqueue_signals();
|
||||
return ret;
|
||||
}
|
||||
dump = (strsfx(FD_EXT, *args) ? *args : dyncat(*args, FD_EXT));
|
||||
dump = (strsfx(FD_EXT, *args) ? dupstring(*args) : dyncat(*args, FD_EXT));
|
||||
unmetafy(dump, NULL);
|
||||
|
||||
queue_signals();
|
||||
ret = ((OPT_ISSET(ops,'c') || OPT_ISSET(ops,'a')) ?
|
||||
|
@ -3400,6 +3402,7 @@ build_dump(char *nam, char *dump, char **files, int ali, int map, int flags)
|
|||
|
||||
for (hlen = FD_PRELEN, tlen = 0; *files; files++) {
|
||||
struct stat st;
|
||||
char *fnam;
|
||||
|
||||
if (check_cond(*files, "k")) {
|
||||
flags = (flags & ~(FDHF_KSHLOAD | FDHF_ZSHLOAD)) | FDHF_KSHLOAD;
|
||||
|
@ -3408,7 +3411,8 @@ build_dump(char *nam, char *dump, char **files, int ali, int map, int flags)
|
|||
flags = (flags & ~(FDHF_KSHLOAD | FDHF_ZSHLOAD)) | FDHF_ZSHLOAD;
|
||||
continue;
|
||||
}
|
||||
if ((fd = open(*files, O_RDONLY)) < 0 ||
|
||||
fnam = unmeta(*files);
|
||||
if ((fd = open(fnam, O_RDONLY)) < 0 ||
|
||||
fstat(fd, &st) != 0 || !S_ISREG(st.st_mode) ||
|
||||
(flen = lseek(fd, 0, 2)) == -1) {
|
||||
if (fd >= 0)
|
||||
|
@ -3417,8 +3421,10 @@ build_dump(char *nam, char *dump, char **files, int ali, int map, int flags)
|
|||
zwarnnam(nam, "can't open file: %s", *files);
|
||||
noaliases = ona;
|
||||
unlink(dump);
|
||||
zsfree(fnam);
|
||||
return 1;
|
||||
}
|
||||
zsfree(fnam);
|
||||
file = (char *) zalloc(flen + 1);
|
||||
file[flen] = '\0';
|
||||
lseek(fd, 0, 0);
|
||||
|
|
|
@ -1069,7 +1069,7 @@ get_username(void)
|
|||
cached_uid = current_uid;
|
||||
zsfree(cached_username);
|
||||
if ((pswd = getpwuid(current_uid)))
|
||||
cached_username = ztrdup(pswd->pw_name);
|
||||
cached_username = ztrdup_metafy(pswd->pw_name);
|
||||
else
|
||||
cached_username = ztrdup("");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue