[PATCH] Prefer getenv("HOME") to find the UNIX home directory
В списке pgsql-hackers по дате отправления:
| От | Anders Kaseorg |
|---|---|
| Тема | [PATCH] Prefer getenv("HOME") to find the UNIX home directory |
| Дата | |
| Msg-id | 1634252654444.90107@mit.edu обсуждение |
| Ответы |
Re: [PATCH] Prefer getenv("HOME") to find the UNIX home directory
Re: Is my home $HOME or is it getpwent()->pw_dir ? |
| Список | pgsql-hackers |
According to getpwnam(3):
An application that wants to determine its user's home directory
should inspect the value of HOME (rather than the value
getpwuid(getuid())->pw_dir) since this allows the user to modify
their notion of "the home directory" during a login session.
This is important for systems where many users share the same UID, and for test systems that change HOME to avoid
interferencewith the user’s real home directory. It matches what most applications do, as well as what glibc does for
glob("~",GLOB_TILDE, …) and wordexp("~", …).
There was some previous discussion of this in 2016, where although there were some questions about the use case, there
seemedto be general support for the concept:
https://www.postgresql.org/message-id/flat/CAEH6cQqbdbXoUHJBbX9ixwfjFFsUC-a8hFntKcci%3DdiWgBb3fQ%40mail.gmail.com
Regardless of whether one thinks modifying HOME is a good idea, if we happen to find ourselves in that case, we should
respectthe modified HOME, so that when the user creates (say) a ~/.pgpass file, we’ll look for it at the same place the
user’seditor created it. getenv() also skips the overhead of reading /etc/passwd as an added bonus.
The way I ran into this issue myself was in a test suite that runs on GitHub Actions, which automatically sets
HOME=/github/home.
Anders
В списке pgsql-hackers по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера