]> git.ipfire.org Git - thirdparty/asterisk.git/commit
asterisk.c: Use the euid's home directory to read/write cli history
authorGeorge Joseph <gjoseph@sangoma.com>
Fri, 15 Sep 2023 17:19:18 +0000 (11:19 -0600)
committerAsterisk Development Team <asteriskteam@digium.com>
Fri, 12 Jan 2024 18:32:12 +0000 (18:32 +0000)
commitfe1bca6a726c1964dac260a0a81ac7f9fe1932d5
tree87e7d8450087c47ca06ed890947cda8fa1084063
parentaadf9d920aac593e9972dd1b5013094843c98402
asterisk.c: Use the euid's home directory to read/write cli history

The CLI .asterisk_history file is read from/written to the directory
specified by the HOME environment variable. If the root user starts
asterisk with the -U/-G options, or with runuser/rungroup set in
asterisk.conf, the asterisk process is started as root but then it
calls setuid/setgid to set the new user/group. This does NOT reset
the HOME environment variable to the new user's home directory
though so it's still left as "/root". In this case, the new user
will almost certainly NOT have access to read from or write to the
history file.

* Added function process_histfile() which calls
  getpwuid(geteuid()) and uses pw->dir as the home directory
  instead of the HOME environment variable.
* ast_el_read_default_histfile() and ast_el_write_default_histfile()
  have been modified to use the new process_histfile()
  function.

Resolves: #337
(cherry picked from commit fc516f5781bbf14ba3c4d3f27d614d6ca564a6cd)
main/asterisk.c