Re: [PATCH] Prefer getenv("HOME") to find the UNIX home directory

Поиск
Список
Период
Сортировка
От Anders Kaseorg
Тема Re: [PATCH] Prefer getenv("HOME") to find the UNIX home directory
Дата
Msg-id d452fd57-8c34-0a94-79c1-4498eb4ffbdc@mit.edu
обсуждение исходный текст
Ответ на Re: [PATCH] Prefer getenv("HOME") to find the UNIX home directory  (Daniel Gustafsson <daniel@yesql.se>)
Ответы Re: [PATCH] Prefer getenv("HOME") to find the UNIX home directory  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On 10/20/21 04:55, Daniel Gustafsson wrote:
> Is the proposed change portable across all linux/unix systems we support?
> Reading aobut indicates that it's likely to be, but neither NetBSD nor FreeBSD
> have the upthread referenced wording in their manpages.

Since the proposed change falls back to the old behavior if HOME is 
unset or empty, I assume this is a question about convention and not 
literally about whether it will work on these systems. I don’t find it 
surprising that this convention isn’t explicitly called out in every 
system’s manpage for the wrong function, but it still applies to these 
systems.

POSIX specifies that the shell uses the HOME environment variable for 
‘cd’ with no arguments and for the expansion of ~. This implies by 
reference that this behavior is required of wordexp() as well.

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/cd.html
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_01
https://pubs.opengroup.org/onlinepubs/9699919799/functions/wordexp.html

libc’s glob() and wordexp() respect HOME in glibc, musl, NetBSD, and 
FreeBSD.

https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/glob.c;hb=glibc-2.34#l622
https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/wordexp.c;hb=glibc-2.34#l293

https://git.musl-libc.org/cgit/musl/tree/src/regex/glob.c?h=v1.2.2#n203
https://git.musl-libc.org/cgit/musl/tree/src/misc/wordexp.c?h=v1.2.2#n111

https://github.com/NetBSD/src/blob/netbsd-9/lib/libc/gen/glob.c#L424
https://github.com/NetBSD/src/blob/netbsd-9/lib/libc/gen/wordexp.c#L129-L150
https://github.com/NetBSD/src/blob/netbsd-9/bin/sh/expand.c#L434-L441

https://github.com/freebsd/freebsd-src/blob/release/13.0.0/lib/libc/gen/glob.c#L457
https://github.com/freebsd/freebsd-src/blob/release/13.0.0/lib/libc/gen/wordexp.c#L171-L190
https://github.com/freebsd/freebsd-src/blob/release/13.0.0/bin/sh/expand.c#L396

(Today I learned that musl and BSD libc literally spawn a shell process 
to handle wordexp(). Wow.)

Anders



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Mark Dilger
Дата:
Сообщение: Re: Extending amcheck to check toast size and compression
Следующее
От: Jeff Davis
Дата:
Сообщение: Re: Delegating superuser tasks to new security roles (Was: Granting control of SUSET gucs to non-superusers)